Hi all I am developing an EA in MQL5. I am having issue in removing TakeProfit of open position. I am using following method.
CTrade trade;
trade.PositionModify(symbol, 0.0, 0.0);
I am getting [invalid stop] error.
Please help.
Hi all I am developing an EA in MQL5. I am having issue in removing TakeProfit of open position. I am using following method.
CTrade trade;
trade.PositionModify(symbol, 0.0, 0.0);
I am getting [invalid stop] error.
Please help.
Provide more information.
Why you send sl and tp of you do t want to use it?
Thanks all of you for the reply… I just want to remove TakeProfit and StopLoss on my open positions using MQL5… please guide my how can I do this…
#include <Trade\Trade.mqh>
#define Ask SymbolInfoDouble(_Symbol, SYMBOL_ASK)
#define Bid SymbolInfoDouble(_Symbol, SYMBOL_BID)
void OnTick()
{
static CTrade Trade;
const double SLTP = MathMax(SymbolInfoInteger(_Symbol, SYMBOL_TRADE_STOPS_LEVEL), 100) * _Point;
if (Trade.PositionOpen(_Symbol, ORDER_TYPE_BUY, 1, Ask, Bid - SLTP, Bid + SLTP))
Trade.PositionModify(_Symbol, 0, 0);
ExpertRemove();
}
#include <mt4orders.mqh>
void OnStart()
{
for (int i=OrdersTotal()-1; i>=0; i--)
if (OrderSelect(i,SELECT_BY_POS) && (OrderType()<=OP_SELL))
OrderModify(OrderTicket(),OrderOpenPrice(),0,0,0);
}