How do I delete a pending order?
How do I delete an order after it has been open for 5 candles.
A.
In the VTS Functions Toolbox, under Trade->MQL, use the MQL function “OrderDelete” to delete a pending order.
To delete after 5 bars, save the MQL variable “Bars” into a new Variable (one that you drag and drop).
The MQL builtin variable “Bars” is a running count of each bar on a chart, where the latest forming bar is the highest number (like 344). The bar on the chart before it (to the left) would be bar # 342.
Suppose you name your variable “mybars”. The key is to only set “mybars” once, at the same time that you create the pending order. Then create logic that states:
if: Bars is greater or equal to mybars + 5
then: delete the pending order
How do I delete a pending order?
How do I delete an order after it has been open for 5 candles.
A.
In the VTS Functions Toolbox, under Trade->MQL, use the MQL function “OrderDelete” to delete a pending order.
To delete after 5 bars, save the MQL variable “Bars” into a new Variable (one that you drag and drop).
The MQL builtin variable “Bars” is a running count of each bar on a chart, where the latest forming bar is the highest number (like 344). The bar on the chart before it (to the left) would be bar # 342.
Suppose you name your variable “mybars”. The key is to only set “mybars” once, at the same time that you create the pending order. Then create logic that states:
if: Bars is greater or equal to mybars + 5
then: delete the pending order