Pending order Stop Loss changes when it fills
-
https://fxdreema.com/shared/Kb8Lkt7B
I think that's the best I can do to cut it down. 21 blocks. Just group 1 and 2, and just how to create pending orders and then storing the variables. Thoughts? I can't see anything wrong...but I'm still a newb.
-
@MTAB Based on the selected blocks, I see no issue there. I recommend testing those blocks only on the tester and use a 'comment' block to visualize the value of all those variables used. If everything works fine, then the problem is somewhere else
-
When I say reduce the number of blocks, I mean so when you test only 1 thing happens, so you can visibly watch what happens, then adjusting is easy because you know any problems. Then do it again until you can add it all together: https://fxdreema.com/shared/habkZ1EQb
-
Thanks @l-andorrà and @jstap i really appreciate the help. One problem is that things work fine when testing. It’s during forward testing that things don’t match up. Again, everything works as it should until the second order actually fills, which is when the SL seems to change. Maybe I’ll just try to rebuild those blocks and see if that works. Thanks again you two!
-
It normally works the same for me, I will run for a week, then backtest over the same dates to see if there is any difference.
-
Lo he probado y veo que funsiona bastante bien, este proyecto esta muy interesante para aprender algo nuevo, pero realmente tampoco logro identificar donde esta el error es intrigante
-
Another piece of information for what it's worth. I tried to change the SL for group 1 manually, and it caused MT4 to also change the SL for group 2 to that same value at the same time. There is clearly some kind of link between group 1 and group 2 in the code, and there is nothing in my project that should cause group 1 to match anything in group 2. AH!
-
I have never seen this happen, put a few blocks together and show to admin, he can then see what's happening
-
@fxDreema , any ideas from these blocks why the SLs of the trades are linked?
-
Because they are all placed at the same time with an ATR SL?
-
@MTAB What do you exactly mean by 'linked'?
-
@jstap maybe? That might explain why they initially have the same stop loss, but wouldn’t explain why manually changing the stop loss of one on MT4 would immediately change the stop loss of the other to match. It also doesn’t explain why they have the correct (different) stop loss while the orders are pending, but then when they fill (at different prices) they suddenly match.
Also, the ATR stop loss is based on price as well (I believe) so price dictates the SL, and the EA is supposed to be coded such that if the trigger prices of each pending order is the same, there should only be one pending order.
-
@l-andorrà manually changing the stop loss of one on MT4 would immediately change the stop loss of the other to match. They are always the same even if I make the code change the SL of one immediately after the second trade fills (days after the first trade has filled) it will modify the first trades SL to match.
-
Yes to ATR, but if at the same time it will match. It will have something to do with the on trade blocks, switch some off then back on until you find the cause, and then the problem can be resolved
-
@jstap that’s good advice thanks! The only thing is that they are pending orders set to fill at different prices. Their SLs are different and correct when they are pending (I checked on MT4). When the first order fills it has the correct SL, and the second order that is still pending has the correct SL. It’s only when the second order fills, that now both the first order (filled and in the market days before) and the second order are filled (at a different price) that the first and second orders SLs match. Anything that ever happens to any blocks are always limited to their particular group number so they shouldn’t overlap at all ever. Frustrating.
-
When it fills it becomes a trade, so on trade blocks are activated
-
@jstap i really appreciate all the time you have spent trying to help me with this. That makes sense, and just to be clear, the on trade blocks are also set up to operate on their respective group, and all they do is update the group variables when the pending order is created. I later tried to fix the problem by changing the variables again once the trade filled, but that didn’t solve the problem.
-
On trade will only affect group 2, is it affecting group 1 as well?
-
according to the blocks, no. According to what is happening on MT4 in live trading, yes. That's the mystery. There is NOTHING that should connect group 1 and 2. Yet it does.
https://fxdreema.com/shared/uzMWwiEbe
The variables that include 21H are group 1, and the variables that include 52H are group 2. If it isn't a bug then I have no idea what could be happening...unless the "Reference Price" being the "Current market price" is what is linking them, but I only added that after to see if that would still affect the trade.
-
On MT4 live you can get the magic used to place by hovering your mouse over it.