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
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