How to delete pending orders which are more than 2 days old ?
There has been a thread about this already, use the search at the top right of the page.
For example: https://www.mql5.com/en/forum/138402
Yes, I search but did not manage to find anything close to what I am looking for.
If I use something like,
TimeDay(TimeCurrent) - TimeDay(OrderOpenTime) >=2
it will work for say, 5 April - 3 April >=2,
but what about, 1 May - 29 April ??
And there are also Sats and Suns which should not be counted as they are non-trading days.
Any ideas ?
As an idea I have this (test it before use):
if (iBarShift(Symbol(), PERIOD_D1, OrderOpenTime(), false) >= 2)
And there are also Sats and Suns which should not be counted as they are non-trading days.
Any ideas ?
Hi everyone,
I am writing a code that loops through all orders, and to check that if is a pending order is placed more than 2 days before, the pending order will be deleted.
e.g Pending orders placed on 3 April (or earlier) will be deleted if today is 5 April.
Pending orders placed on 4 April will not be deleted until 6 April arrives.
I think we have to use functions like "OrderOpenTime" and somehow compare it with today's date, but am not exactly sure how to code it.
Anyone can show me the way ?
Thank you,
Hip