![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
thank CB, i should have noticed that, so the error was right in the end (130).
Is it working then?
CB
Hey CB, It is running the trades but I haven't done the detailed going through the trades to see if logic is followed up correctly (it seems to be at first glance). So this is the time I say a massive 'THANK YOU!!!!' :-)
It is still quite a way to go before the strategy is running profitably, as the code is just a way to automate the trades, I need to do a bit of work at my end to refine the strategy itself. Looks like all this effort paid off, but I am still super puzzled with coding. I'm gonna start making little codes on my own to display comments on my charts, and mess about with those, to help me learn functions and other things you used. I super appreciate your help with this CB, and your patience as I kept asking the same thing and making the same mistakes over and over. Thank you!
That will be easy.
Set yourself a parameter which is the max number of open orders. Extern it if you require to change frequently.
Then implement by changing only the fnOrderDuplicate() function - you should not have to change the start() function. That will help maintain the existing architecture of the application.
CB
Hey CB, i spent like 2 hours now trying to do what you asked in the above post, looked at other codes, documentation, and no progress (i just don't know what to do). Man, i keep getting stuck like this, it's so annoying, even with the simplest things! there must be a way to learn easier than how im going at the moment, as i feel i'm not having any progress in learning, you guys are kindly writing all the code for me
hey CB, any help on the above point, how to fix the code to do a multiple trades in 1 direction?
Just change: if (iDuplicateOrders == 0) to: if (iDuplicateOrders <= iMaxDuplicateOrders)
CB
Hey CB, thank you for this. With this option I can not regulate how many open orders are allowed in 1 direction (lets say i make extern iMaxDuplicateOrders = 4;) the ea will run 4 shorts, and not distribute the parameter evenly (eg: 2 shorts max, 2 longs max). Shall I give a go making a duplicate of bool fnOrderDuplicate (eg: bool fnOrderDuplicateBuys, and bool fnOrderDuplicateSells) and then referring to each one respectively in bool fnShouldWeTrade. In my mind this could work, what do you reckon?
Hey CB, thank you for this. With this option I can not regulate how many open orders are allowed in 1 direction (lets say i make extern iMaxDuplicateOrders = 4;) the ea will run 4 shorts, and not distribute the parameter evenly (eg: 2 shorts max, 2 longs max). Shall I give a go making a duplicate of bool fnOrderDuplicate (eg: bool fnOrderDuplicateBuys, and bool fnOrderDuplicateSells) and then referring to each one respectively in bool fnShouldWeTrade. In my mind this could work, what do you reckon?
Setting iMaxDuplicateOrders = 4 will mean that the maximum will be 4 orders in each direction, as we check the direction before incrementing the counter.
Credit where credit's due. The reverse is due in this instance. Apologies - I was already disappointed that you didn't make the amendment yourself. ALL that needed to be done was to change the limit from a single order to a variable.
It is clear from the annotations that you are simply re-creating the code in prose without really understanding the logic.
CB