Your topic has been moved to the section: Expert Advisors and Automated Trading
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
Ignore this question. I figured out the EA is using pending orders, which changes the logic.
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 all,
I'm trying to detect the last profit/loss in the transaction history (which I think I've got right), but something unexpected is happening, hopefully someone will have an idea.
Here's the snippet:
I've tried using the debugger to step through the code to figure out what is happening, but I'm not making much headway. Setting the var = 1 when a trade loses works perfectly. Conversely, when a trade ends in profit, the var = 0, which is fine, BUT, that line is being hit at unexpected times and I cannot figure out why. Probably something fundamental I'm missing in the way orders/deals/history/etc are processed.
All I'm trying to do basically is set a variable to be used in subsequent buy/sell trades when a trade ends in a loss.
Any guidance would be appreciated.
Thanks
Update: changed initial condition to TRADE_TRANSACTION_DEAL_ADD... I must have fiddled before posting this question.