maybe this will help. EA opens the maximum number of trades entered in total ("OnlyOne"), or the maximum number of trades entered in direction ("OneDir").
enum onoff {Ano=1,Ne=0}; extern onoff OnlyOne=Ano;//Pouze jeden obchod celkem extern onoff OneDir=Ano;//Pouze jeden obchod ve smeru extern int MaxTrades=1;//Max obchodu
<Screenshot deleted>
<Screenshot deleted>
Please do not show screenshots of code.
Copy and paste the code correctly, using the code button.
}} return(TotalTradesInTrend+OrdersTotal());
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.02.15
PositionClose is not working - MQL5 programming forum 2020.02.21
MagicNumber: "Magic" Identifier of the Order - MQL4 Articles 24 July 2006
Orders, Positions and Deals in MetaTrader 5 - MQL5 Articles 1 February 2011
maybe this will help. EA opens the maximum number of trades entered in total ("OnlyOne"), or the maximum number of trades entered in direction ("OneDir").
<Screenshot deleted>
Hi there...
Please reshare your code?
I have figured it out.
Thanks though...
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Good day,
I am trying to write a code that counts the number of trades that have been opened in a new trend. That is, if there is a trend (e.g. MA1 > MA2) the EA opens trades until the set number is reached, and then it stops and waits until there is a new trend. Then it starts counting again from 0.
I have written the code below. It is in 2 parts.
Part 1 - checks that MA has crossed recently, and it is therefore a new trend.
Part 2 - starts counting trades as soon as it is a new trend.
The code works to a certain extent - it counts trades that have been opened since the new trend - usually up to 2 or 3, but then it just stops counting and then continues opening more trades.
Please let me know what my mistake is.
NB: I am a beginner and wrote this by researching a lot, so any pointers would be greatly appreciated.