I am trying to figure out how to stop my EA from trading if there was a trade in lets say last 5 bars. It should be relatively simple but I cant get it done.
I came up with this code, where LastTradeBar is extern int and I set it to ie. 5.
bool LastTrade=False;
for (int i1 = 0; i1 < OrdersHistoryTotal(); i1 ++)
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.
Hi fellow coders,
I am trying to figure out how to stop my EA from trading if there was a trade in lets say last 5 bars. It should be relatively simple but I cant get it done.
I came up with this code, where LastTradeBar is extern int and I set it to ie. 5.
bool LastTrade=False;
for (int i1 = 0; i1 < OrdersHistoryTotal(); i1 ++)
{
OrderSelect(i1, SELECT_BY_POS, MODE_HISTORY);
if(OrderType() <= OP_SELL && OrderSymbol() == Symbol() && iBarShift(NULL,0,OrderCloseTime())<LastTradeBar)
{
LastTrade = True;
}
}However, when I add LastTrade=False into my entry conditions it never trades. It seems that it is always true, but why???
Thank you.
-Rookie_FaW