-
if(Volume[0]<=1)
For a new bar test, Bars is unreliable (a refresh/reconnect can change number of bars on chart), volume is unreliable (miss ticks), Price is unreliable (duplicate prices and The == operand. - MQL4 programming forum.) Always use time.
New candle - MQL4 programming forum #3 (2014)I disagree with making a new bar function, because it can only be called once per tick. A variable can be tested multiple times.
Running EA once at the start of each bar - MQL4 programming forum (2011) Your code closebuy3=false; closesell3=false; if(BuysTotal()>step) { closebuy3=true; } if(SellsTotal()>step) { closesell3=true; }
Simplified closebuy3 = BuysTotal()>step; closesell3=SellsTotal()>step;
-
int start()
You should stop using the old event handlers and IndicatorCounted() and start using new event handlers.
Event Handling Functions - MQL4 Reference
How to do your lookbacks correctly - MQL4 programming forum #9-14 & #19 (2016) - GoldenDiamonds: I created a close code that works properly
No idea what you mean by “close code”. If it works properly, what's the problem?
- GoldenDiamonds: In which part of the code of buying positions do I make a mistake?
Use the debugger or print out your variables, including _LastError and prices and find out why. Do you really expect us to debug your code for you?
Code debugging - Developing programs - MetaEditor Help
Error Handling and Logging in MQL5 - MQL5 Articles (2015)
Tracing, Debugging and Structural Analysis of Source Code - MQL5 Articles (2011)
Introduction to MQL5: How to write simple Expert Advisor and Custom Indicator - MQL5 Articles (2010) -
closePostion(Magic1 && closebuy3); closePostion(Magic2 && closesell3);
Always post all relevant code (using Code button) or attach the file. We can't know what closePostion uses.
How To Ask Questions The Smart Way. (2004)
Be precise and informative about your problemAny non-zero is true, so you are passing true && closexxx3 which equals closexxx3. Does closePostion really take an boolean? Do you actually mean:
if(closebuy3) closePostion(Magic1); if(closesell3) closePostion(Magic2);
- No need for two magic numbers as you can get the direction from the order itself.
Magic number only allows an EA to identify its trades from all others. Using OrdersTotal/OrdersHistoryTotal (MT4) or PositionsTotal (MT5), directly and/or no Magic number/symbol filtering on your OrderSelect / Position select loop means your code is incompatible with every EA (including itself on other charts and manual trading.)
Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 programming forum (2013)
PositionClose is not working - MQL5 programming forum (2020.02.21)
MagicNumber: "Magic" Identifier of the Order - MQL4 Articles (2006)
Orders, Positions and Deals in MetaTrader 5 - MQL5 Articles 2011You need one Magic Number for each symbol/timeframe/strategy. Trade current timeframe, one strategy, and filter by symbol requires one MN.
-
For a new bar test, Bars is unreliable (a refresh/reconnect can change number of bars on chart), volume is unreliable (miss ticks), Price is unreliable (duplicate prices and The == operand. - MQL4 programming forum.) Always use time.
New candle - MQL4 programming forum #3 (2014)I disagree with making a new bar function, because it can only be called once per tick. A variable can be tested multiple times.
Running EA once at the start of each bar - MQL4 programming forum (2011) Your code Simplified -
You should stop using the old event handlers and IndicatorCounted() and start using new event handlers.
Event Handling Functions - MQL4 Reference
How to do your lookbacks correctly - MQL4 programming forum #9-14 & #19 (2016) -
No idea what you mean by “close code”. If it works properly, what's the problem?
-
Use the debugger or print out your variables, including _LastError and prices and find out why. Do you really expect us to debug your code for you?
Code debugging - Developing programs - MetaEditor Help
Error Handling and Logging in MQL5 - MQL5 Articles (2015)
Tracing, Debugging and Structural Analysis of Source Code - MQL5 Articles (2011)
Introduction to MQL5: How to write simple Expert Advisor and Custom Indicator - MQL5 Articles (2010) -
Always post all relevant code (using Code button) or attach the file. We can't know what closePostion uses.
How To Ask Questions The Smart Way. (2004)
Be precise and informative about your problemAny non-zero is true, so you are passing true && closexxx3 which equals closexxx3. Does closePostion really take an boolean? Do you actually mean:
- No need for two magic numbers as you can get the direction from the order itself.
Hello dear master
The problem was that I had created a function close position
And I wanted this function to be activated for the same position whenever there are more than 13 buy or sell positions.
This function was activated in the sell positions properly and after opening the 13th sell position
But it did not work properly on buy positions and did not count buy positions
But this command solved the problem
if(closebuy3) closePostion(Magic1); if(closesell3) closePostion(Magic2);
The links you put help a lot
Thankful.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
And in the first position, the close code purchase is activated and starts working
In which part of the code of buying positions do I make a mistake?
please guide