jon:
Need some idea (MT5):
How to allow opening of a new order only after the last order has be opened for at least more than one day?
1) Create global variable(or static) like bool new_trade=false;
2) Select last order
3) Chek current time-time of order. If it is more than 24*60*60 new_trade=true; else new_trade=false;
Do you also want to check a closed order ? If so
datetime lastOrderClose = 0;
for(int iPos=OrdersHistoryTotal()-1; iPos >= 0; iPos--)
if ( OrderSelect(iPos, SELECT_BY_POS, MODE_HISTORY) // Only orders w/
&& OrderMagicNumber() == Magic.Number // my magic number
&& OrderSymbol() == Symbol() // and my pair.
&& OrderCloseTime() > lastOrderClose)
lastOrderClose = OrderCloseTime();
if (TimeCurrent()-lastOrderClose > 24*60*60)
new_trade = true;
else new_trade = false;
for(int iPos=OrdersHistoryTotal()-1; iPos >= 0; iPos--)
if ( OrderSelect(iPos, SELECT_BY_POS, MODE_HISTORY) // Only orders w/
&& OrderMagicNumber() == Magic.Number // my magic number
&& OrderSymbol() == Symbol() // and my pair.
&& OrderCloseTime() > lastOrderClose)
lastOrderClose = OrderCloseTime();
if (TimeCurrent()-lastOrderClose > 24*60*60)
new_trade = true;
else new_trade = false;
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
Need some idea (MT5):
How to allow opening of a new order only after the last order has be opened for at least more than one day?