Either set the expiration paramater in the OrderSend() function or go through the Orders, check OrderOpenTime() agains CurTime() or Time[0] and call OrderClose() in your code if the time is more than what you intend.
Markus
Markus
Does this code, mean that this long position will be close after 2700 seconds?
ticket=OrderSend(Symbol(),OP_BUY,Lots,Open[0],3,Ask-TakeLoss*Point,Ask+TakeProfit*Point, "blabla",16384,CurTime()+2700,Green);
because it seems that it doesn't work :(
ticket=OrderSend(Symbol(),OP_BUY,Lots,Open[0],3,Ask-TakeLoss*Point,Ask+TakeProfit*Point, "blabla",16384,CurTime()+2700,Green);
because it seems that it doesn't work :(
I just read the OrderSend() docs again. It's an expiration for orders that doesn't get filled. So it won't affect open orders. With that I guess your expert will have to loop through the open orders and check the difference between CurTime() and OrderOpen() time via program and OrderClose() them if their time is up.
Markus
Markus
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I would like to place a time based stop to exit my position, how can i do?
Example :
If the position is open since more than 10 bars, then close the position.
How can i code that?