Your topic has been moved to the section: MQL4 and MetaTrader 4
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
MaxOpenOrders = 0;
Move this line to OnInit so it executes only once.
Yashar Seyyedin #: Move this line to OnInit so it executes only once.
Actually he needs to move it outside of any function scope (so it will be global variable).
If he'll move it to OnInit(), the above variable will only reside within OnInit() scope.
But you can also just change it to a static variable.
Simply change code to-
static int MaxOpenOrders = 0;
AMI289 #: Simply change code to-
static int MaxOpenOrders = 0;
That will not work on a symbol (chart) change; EAs are not reloaded.
Resetting static: Problem in detecting a new Bar - MQL5 programming forum #5.3 (2020)
Thx a lot for your help guys
I moved it to a global variable and it works perfectly.
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,
Trying to find the highest amount of open orders but but this code gives the same amount for TotalOpenOrders and MaxOpenOrders.
Thx a lot.
Amir