Hello,
So I have this trailing stop function, and it is supposed to put the trailing stop equal to a particular moving average's level if the unrealized profit is up to a certain level (10 pips) and then put the trailing stop at the level of another (tighter) moving average line if the unrealized profit reaches past that level.
The problem is that my trailing stop function works for stage one, but NEVER reaches stage two (when unrealized profits are greater than 10 pips). I was wondering if someone here could shed some light on this.
Thank you,
Ravi
So I have this trailing stop function, and it is supposed to put the trailing stop equal to a particular moving average's level if the unrealized profit is up to a certain level (10 pips) and then put the trailing stop at the level of another (tighter) moving average line if the unrealized profit reaches past that level.
The problem is that my trailing stop function works for stage one, but NEVER reaches stage two (when unrealized profits are greater than 10 pips). I was wondering if someone here could shed some light on this.
Thank you,
Ravi
Inserted Code
void trail_stop() { switch(OrderType()) { case OP_BUY: { if(Bid - OrderOpenPrice() < 10) { Print("buy < 10"); if(iMA(Symbol(), 0, lma, 0, 1, 0, 1) > OrderStopLoss()) OrderModify(OrderTicket(), OrderOpenPrice(), iMA(Symbol(), 0, lma, 0, 1, 0, 1), 0, 0, Blue); return(0); } else if(Bid - OrderOpenPrice() < 20) { Print("buy < 20"); if(iMA(Symbol(), 0, mma, 0, 1, 0, 1) > OrderStopLoss()) OrderModify(OrderTicket(), OrderOpenPrice(), iMA(Symbol(), 0, mma, 0, 1, 0, 1), 0, 0, Green); return(0); } else { Print("buy else"); if(iMA(Symbol(), 0, sma, 0, 1, 0, 1) > OrderStopLoss()) OrderModify(OrderTicket(), OrderOpenPrice(), iMA(Symbol(), 0, sma, 0, 1, 0, 1), 0, 0, Yellow); return(0); } } case OP_SELL: { if(OrderOpenPrice() - Ask < 10) { Print("sell < 10"); if(iMA(Symbol(), 0, lma, 0, 1, 0, 1) < OrderStopLoss()) OrderModify(OrderTicket(), OrderOpenPrice(), iMA(Symbol(), 0, lma, 0, 1, 0, 1), 0, 0, Red); return(0); } else if(OrderOpenPrice() - Ask < 20) { Print("sell < 20"); if(iMA(Symbol(), 0, mma, 0, 1, 0, 1) < OrderStopLoss()) OrderModify(OrderTicket(), OrderOpenPrice(), iMA(Symbol(), 0, mma, 0, 1, 0, 1), 0, 0, Orange); return(0); } else { Print("sell else"); if(iMA(Symbol(), 0, sma, 0, 1, 0, 1) < OrderStopLoss()) OrderModify(OrderTicket(), OrderOpenPrice(), iMA(Symbol(), 0, sma, 0, 1, 0, 1), 0, 0, White); return(0); } } } }