bool CanTrade = false; int OHTotal = OrdersHistoryTotal(); for (int hi = 0; hi < OHTotal; hi ++) { bool hasclosedtrade = OrderSelect(hi, SELECT_BY_POS, MODE_HISTORY); if(hasclosedtrade && OrderCloseTime() < Time[0] && OrderMagicNumber() == MagicNumber) { CanTrade = true; } }
MagicNumber is an undeclared variable in your code above. What are you initializing this variable as?
OrderMagicNumber() == MagicNumber
Thank you.
execute a new entry only if there has not been closed order on the current bar
- www.mql5.com
Hi guys, need some help here. I made an momentum based EA (nothing exciting, I know...
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 guys,
need some help here.
I made an momentum based EA (nothing exciting, I know). When take profit has occurred, The EA is supposed to wait for a fresh bar to enter the next trade. So here is my code at the begining of the start()
bool CanTrade = True;
int OHTotal = OrdersHistoryTotal();
for (int hi = 0; hi < OHTotal; hi ++) {
bool hasclosedtrade = OrderSelect(hi, SELECT_BY_POS, MODE_HISTORY);
if(hasclosedtrade && OrderCloseTime() >= Time[0] && OrderMagicNumber() == MagicNumber) {
CanTrade = False;
}
return 0;
}
It does not work. What have I done wrong?