Hello good day
this my first time of posting here, have seen how this forum has been of great help to solve code issues and am hoping i will find a solution to mine
am working on a function but am having some issue below is my function and what it does is that if a orders is opened the function opens a pending order and if that pending order got triggered 2 pending orders will be placed and if that 2 pending orders triggered 3 pending orders will be placed and it goes on like that, the function works fine as have explained if no stop loss is used but when stop loss is used it does not work perfectly it only opens 5 or 6 pending orders max, but i want it to continue in that sequence manner, i tried every thing i could
Please note i limit my pending orders in the Ontick Function to avoid multiples pending orders
thanks
Hi, if the issue when using a stoploss means that some pending order are not created, I think you may need reading the "Journal" log for the Strategy Tester or the "Expert" log if the EA was online attached to a chart. My guess is that you would find an MQL4 error in the log indicating error such as 130 or 136. See error list below: https://book.mql4.com/appendix/errors
If I'm guessing you find 130, then it use to happen in MQL4 when we calculate prices. There is a number of maximum decimal places for the Symbol (i.e. MarketInfo(Symbol(), MODE_DIGITS) ...) and also the broker may required prices rounded to a given tick size that your calculated stoploss (and price) need to match. That is, you need to rounded your stoploss calculation to the closest tick based on the tick size, and round it to the maximum decimals of the Symbol.
But before going into the burden of suggestion in your code, let's check if the log shows any of those error messages.

- book.mql4.com
Hi, if the issue when using a stoploss means that some pending order are not created, I think you may need reading the "Journal" log for the Strategy Tester or the "Expert" log if the EA was online attached to a chart. My guess is that you would find an MQL4 error in the log indicating error such as 130 or 136. See error list below: https://book.mql4.com/appendix/errors
If I'm guessing you find 130, then it use to happen in MQL4 when we calculate prices. There is a number of maximum decimal places for the Symbol (i.e. MarketInfo(Symbol(), MODE_DIGITS) ...) and also the broker may required prices rounded to a given tick size that your calculated stoploss (and price) need to match. That is, you need to rounded your stoploss calculation to the closest tick based on the tick size, and round it to the maximum decimals of the Symbol.
But before going into the burden of suggestion in your code, let's check if the log shows any of those error messages.Hi
Hi, thanks for the reply
i tried that just now but i see no error in the log the pending orders created are just limited to 5 with no error before or after
thanks
Hi, thanks for the reply
i tried that just now but i see no error in the log the pending orders created are just limited to 5 with no error before or after
thanks
Hi, what I would suggest is to add a few sentences after each "OrderSend" command. In the Journal/Expert log you should at least find the output from the Print command. If no error then it should print "0" (zero). If nothing is printed then I was wrong about my hint that was the stoploss validation ... but at least you may drill-down adding some additional "Print" to track where your EA stopped following your logic.
The code should look like this ... I hope I didn't add a syntax error :-)
if(Use_Pend_Sl==true) { SellLimit=OrderSend(NULL,OP_SELLLIMIT,LotSize,SellL,Slippage,Ask+25*UsePoint,Ask-30*UsePoint,EA_Comment,Magic_Number_1,0,Yellow); int justChecking = GetLastError(); Print("Use_Pend_Sl=true's return code was ...", justChecking); }
Hi, what I would suggest is to add a few sentences after each "OrderSend" command. In the Journal/Expert log you should at least find the output from the Print command. If no error then it should print "0" (zero). If nothing is printed then I was wrong about my hint that was the stoploss validation ... but at least you may drill-down adding some additional "Print" to track where your EA stopped following your logic.
The code should look like this ... I hope I didn't add a syntax error :-)
Thanks i appreciate you sir,
i got 0 (Zero) as the return code when i applied the lines above,
am thinking i need a counter that increases only per trade picked, and reset back only when OrdersTotal()==0
i.e counter should be 5 if i have 5 opened trades and should remain at 5 if 1 or more trades are closed,
let say i have 10 opened orders counter should read 10 and if 5 were closed counter should remain at 10 and if 2 more trades were opened counter should be at 12 (despite total orders are 7) and reset back to 0 (zero) when i have no opened orders
i tried defining that as well but its not stable
thanks
Thanks i appreciate you sir,
i got 0 (Zero) as the return code when i applied the lines above,
am thinking i need a counter that increases only per trade picked, and reset back only when OrdersTotal()==0
i.e counter should be 5 if i have 5 opened trades and should remain at 5 if 1 or more trades are closed,
let say i have 10 opened orders counter should read 10 and if 5 were closed counter should remain at 10 and if 2 more trades were opened counter should be at 12 (despite total orders are 7) and reset back to 0 (zero) when i have no opened orders
i tried defining that as well but its not stable
thanks
Great news: Getting 0 (Zero) as the return code makes life easier. You are now in control, and as you said perhaps managing that counter would help you. It's always about an ongoing learning and you would be creating a sort of common tested routines that makes it easier to go for more complex scenarios. Good luck my friend.
Great news: Getting 0 (Zero) as the return code makes life easier. You are now in control, and as you said perhaps managing that counter would help you. It's always about an ongoing learning and you would be creating a sort of common tested routines that makes it easier to go for more complex scenarios. Good luck my friend.
Thanks
i dont know if you could help me check it out as well
https://www.mql5.com/en/forum/352457

- 2020.10.01
- www.mql5.com

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello good day
this my first time of posting here, have seen how this forum has been of great help to solve code issues and am hoping i will find a solution to mine
am working on a function but am having some issue below is my function and what it does is that if a orders is opened the function opens a pending order and if that pending order got triggered 2 pending orders will be placed and if that 2 pending orders triggered 3 pending orders will be placed and it goes on like that, the function works fine as have explained if no stop loss is used but when stop loss is used it does not work perfectly it only opens 5 or 6 pending orders max, but i want it to continue in that sequence manner, i tried every thing i could
Please note i limit my pending orders in the Ontick Function to avoid multiples pending orders
thanks