How can I close a position after 3 bars have happened?

 

hi guys.


Can you please tell me how can I close a opened order after 3 bars have happened?


I want to stables a time based close for my orders.



thanks

 
nirvaman:

hi guys.


Can you please tell me how can I close a opened order after 3 bars have happened?


I want to stables a time based close for my orders.



thanks

Happened to be working on this same problem.

//3 candles each candle being 5 minutes in the 5-minute time frame

if(TimeCurrent()-OrderOpenTime()>=900)

{

OrderClose(ticket,Lots,MarketInfo(Symbol(),MODE_BID),3,GreenYellow);

}

There could be several other ways.