for ( int TrC = OrdersTotal() - 1; TrC >= 0; TrC -- )
{
if ( !OrderSelect( TrC, SELECT_BY_POS,MODE_TRADES ) ) { Print( "OrderSelect Error #:", GetLastError()); continue; }
if ( OrderSymbol() != symb || OrderMagicNumber() != mgn ) continue; //symb is desired symbol and mgn is desired magic number for filtering opened orders
if ( OrderType() != OP_BUY && OrderType() != OP_SELL ) continue; //selectonly buy or sell order
SL=0;TP=0; //defined as doubke type data in global variable
if ( OrderProfit()> 0 )
if ( trailslpoint > 0 ) //int trailspoint ( no. of point used for trailing
{
SL=ntrailsl(Symbol(),OrderType(), OrderStopLoss(), OrderOpenPrice() ,trailslpoint, PERIOD_CURRENT); //it returns the stoploss price to modify by trailing it is userdefined function for buy or sell type position
}
if (SL==OrderStopLoss() ) continue;
if ( OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0)==true ) Print("Modified by "+strategy_code); // CE10089 (" ","Error in modofying SL for trailing of ticket#"+(string)OrderTicket()+" Error#"+(string)GetLastError()," ") ;
}
the problem is that it is working only with opened order of buy type, not sell
I my point of view it must work in both buy and sell type of orders
Can anybody help me with this.
Thanks in advance.