my condition1,2,3 are same level,but metaeditor recognized as condition1,(2,3 are same level )are same level.
Please tell me how to solve this problem?
I wrote about this in a topic that terminal developers read
Форум по трейдингу, автоматическим торговым системам и тестированию торговых стратегий
Новая версия платформы MetaTrader 5 build 4755: общие улучшения
Vladislav Boyko, 2025.04.09 17:43
Questionable styling from the built-in styler
A bug (or feature) was found by @c327515.
Link to his topic
if(PositionsTotal()>0) { // deal pos } else if(OrdersTotal()>0) { // deal order } else { // deal buy or sell }
the compiler sees the second "if" as nested within the "else" of the first condition. If your intention is to have all three conditions on the same level, the preferred approach is to use the "else if" keyword combination. That way, it's clear that the second condition is tied to the first "if", and the third condition is an "else" case.
Try this version instead:
if(PositionsTotal() > 0) { // deal with position } else if(OrdersTotal() > 0) { // deal with order } else { // deal buy or sell }
The issue is due to the way the compiler interprets the nesting of your "if" statements when you structure them like this. In your code, using
the compiler sees the second "if" as nested within the "else" of the first condition. If your intention is to have all three conditions on the same level, the preferred approach is to use the "else if" keyword combination. That way, it's clear that the second condition is tied to the first "if", and the third condition is an "else" case.
Try this version instead:
no ,i write in 1 rows, but the MetaEditor format 2 rows,see 1# reply video or try do it
You're right. I misunderstood you. I tried and the same problem happens if I pick code style is MetaQuotes.
Fortunately, I don't prefer MetaQuotes code style and usually using Google style. This problem doesn't occur in Google code style (and some others as I tried). You can consider to use this option as a workaround.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
my condition1,2,3 are same level,but metaeditor recognized as condition1,(2,3 are same level )are same level.
Please tell me how to solve this problem?