Stoploss following SMA50 line

 

I'm using the following code to track the SMA50 line:


double SMA50;

SMA50=iMA(NULL,0,50,0,MODE_SMA,PRICE_CLOSE,0);

Print(SMA50);


How can I modify an order so that it remains 20 pips below the SMA50 line?

 
if((Bid-SMA50)/Point<20) OrderModify(....);
 
Roger:
if((Bid-SMA50)/Point<20) OrderModify(....);

I decided instead of modifying the order over time I simply added a while loop, so while the price is below the SMA50 line it will run another function to check if two consecutive bars have formed below the line. If this happens it performs an OrderClose

Reason: