After a bit of adjustment, I did get the code to work, per original requirements. Thanks for the Forum input. The final working code included a sleep function to get the delay to work properly - I am sure that it is not the "cleanest" code, but it delivers what I am looking for, so I am at least happy with that :
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
After a bit of adjustment, I did get the code to work, per original requirements. Thanks for the Forum input. The final working code included a sleep function to get the delay to work properly - I am sure that it is not the "cleanest" code, but it delivers what I am looking for, so I am at least happy with that :
bool trade_closed_less_than_1_hour_ago=false;
for(int x=OrdersHistoryTotal()-1;x>=0;x--)
{
OrderSelect(x,SELECT_BY_POS,MODE_HISTORY);
if(OrderSymbol()==Symbol() && (TimeCurrent()-OrderCloseTime())<3600 && OrderMagicNumber()==39379)
{
//if the OrderSelect() function above is TRUE, define the trade entry filter here - include the Sleep(3600000) function;
trade_closed_less_than_1_hour_ago=true;
break;
//Probably no need to continue with loop once a trade is found that was closed less than 1 hour ago
//sleep is in milliseconds to ensure the required minimum of 1 hour delay since last closed trade
}
}
if(trade_closed_less_than_1_hour_ago==false)
{
//Code to open new order or whatever
}
Play video
For large amounts of code, attach it.