RAQ

How to Delay a Close Buy and Close Sell

Q:


I would like to delay a close buy and close sell a certain number of bars from the open of the trade. Is there an easy way to do this in VTS?


A:


Yes.


Yes, in the Function Toolbox, under Trade, use the function fnGetOrderInfo. Set the InfoType to INFO_OPEN_BARS


 



 




This will tell you the number of bars the trade has been open, You can use this info in your close trade logic.


NOTE: This will return a double value. If you use it for comparison, for example GREATER_THAN, use decimal point if the logical condition. MQL can act weird about comparing integers and numbers with decimals.


This is the correct way to create the logical condition (note the 3.0, not 3)



 


 


 



To get notified about the latest questions and answers, follow us!