if (GetTotalOpenTrades() < MaxTrades) { //Buys } else if (GetTotalOpenTrades() < MaxTrades) { //Sells }
The else will never be executed.
The else will never be executed.
so it is just a bracket issue?
No it is a logic error. When in doubt, think!
so it is just a bracket issue?
Do you remember this post in your earlier topic?
You wrote the code so you should know what it is supposed to do.
When it doesn't execute as you expect, check your code carefully.
As I said before...
Then, as a coder you should be asking yourself "Why doesn't it print the error??"
The obvious answer is because there was no error!
If there was no error, then it can only be because there was no attempt to close any trade (or because a trade was closed).
What are the possible reasons for there being no attempt to close any trade?
Only possible answers.......
There was not a trade open with the symbol.
The OrderSelect() failed.
The function was not called.
Add prints in your code to find the correct answer.
Did you check all the above?
if (GetTotalOpenTrades() < MaxTrades) { // } else if (GetTotalOpenTrades() < MaxTrades) { //No code within these braces will be executed! }
I have removed the actual code from the above and an error is obvious.
You have already had this same mistake pointed out to you!
I am not going to waste any more time trying to help you as you ignore the advice and just repeat the same errors.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Not sure what the problem is hoping another set of eyes will help. Thanks