How to set an order Buy/Sell stop??

 

Hi all,

after writing my first indicator now I'm trying to code me first EA!!

I have this problem:

Once I obtain a buy or sell signal from an indicator I wanna place a buy or sell stop order at 5 pips + spread from the high or low of the bar of the signal...if an other signal occurred I have to change the old order with the new high or low price....is it still possible to delete the order after x bar without the breakout of the price??

Also I wanna only 1 position open and if I use OrdersTotal() it returns both open position that pending orders...how can I know only if I'm not in the market???

Thanks

Maury

Reason: