return(PositionTotal++);
Why the ++ ?
- 2020.07.05
- www.mql5.com
Why the ++ ?
Hi thanks Vladimir Karputov for your code ,but the problems of return(true/false), if position equals to my MagicNumber is that ..... What if am making an EA based on averaging strategy which have lots of open positions at the same time!! How can I stop another position being opened if condition s are still true? Your code is quite useful for one position at a time but what if there are more than one and all have the same MagicNumber?
Thanks for your time!@Vladimir Stashkevich@VLADIMIR KLEVKO@Vladimir Kalashnikov
Hi thanks Vladimir Karputov for your code ,but the problems of return(true/false), if position equals to my MagicNumber is that ..... What if am making an EA based on averaging strategy which have lots of open positions at the same time!! How can I stop another position being opened if condition s are still true? Your code is quite useful for one position at a time but what if there are more than one and all have the same MagicNumber?
Thanks for your time! @Vladimir Stashkevich @VLADIMIR KLEVKO @Vladimir Kalashnikov
Sorry, I did not understand your question.
Sorry, I did not understand your question.
Hi , what I actually meant is that what if Positions to be opened are two at the same TIME ? ... and not one. How can it be possible in your code to limit only two positions at the same time ? I say this because my EA opens a second position when the first position is in loss by x amount of pips. I could easily limit this using PositionsTotal() function for MQl5 but that will make my EA not trade well while other positions are opened manually or with other EAs
Thanks for your time...
@nicholish en @William Roeder @Keith Watford @vladimir9010 @Vladimir Kazennov @Vladimir Kalashnikov @VLADIMIR KLEVKO- www.mql5.com
@William Roeder @vladimir250273@VLADISLAV BUTOV@Vladimir@Ahmet Metin Yilmaz@Stanislav Ivanov@Keith Watford@nicholish en @Marco Y Anja VlaskampHello guys sorry for taking your time ,but I have this big problem since I started making EAs.......! Why didnt Metatrader Create a predefined Function that could calculate PositionsTotal based on EAs Magic Number!! This could save newbies like I when starting programming journey as there is no great use of having only one EA running to avoid interruption in the PositionsTotal function.
So I tried all my best, remember am newbie in MQL5 .... to create my own PositionTotal() function but the problem comes when I close the position it doesn't decrement ,though I was looking on a way to do that ! So iam asking for your help Senior MQl5 Programmers .... Thanks
Hi there, try this:
int OrdersCount=0; for(int i=PositionsTotal()-1;i>=0;i--){ ulong iTicket=PositionGetTicket(i); if(PositionSelectByTicket(iTicket)&& PositionGetString(POSITION_SYMBOL)==_Symbol){ // <-- Here your MN condition. OrdersCount++; } }
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
@William Roeder @vladimir250273@VLADISLAV BUTOV@Vladimir@Ahmet Metin Yilmaz@Stanislav Ivanov@Keith Watford@nicholish en @Marco Y Anja VlaskampHello guys sorry for taking your time ,but I have this big problem since I started making EAs.......! Why didnt Metatrader Create a predefined Function that could calculate PositionsTotal based on EAs Magic Number!! This could save newbies like I when starting programming journey as there is no great use of having only one EA running to avoid interruption in the PositionsTotal function.
So I tried all my best, remember am newbie in MQL5 .... to create my own PositionTotal() function but the problem comes when I close the position it doesn't decrement ,though I was looking on a way to do that ! So iam asking for your help Senior MQl5 Programmers .... Thanks