Erratic behavior, Breakeven and Trail Stop
-
I have set my EA to store the ATR value in PIPS at the time of trade entry, this is correct and works, I have incorporated in the chart the values to be updated and it works. ATRX is the TakeProfit of the first order and (ATRX_BP) in the image data ATR BUY PRINCIPAL is the value for my Breakeven and to initiate the Trail Stop.
The values are correct and update correctly so far so good.

The strange thing is that when I use the variable ATRX_BP in breakeven and Trail Stop (both) it behaves erratically, sometimes it moves when it should and sometimes not, the strange thing is that the variable values are correct in all the EA works correctly except for the behavior of Breakeven and TrailStop that is erratic. Sometimes it works, sometimes it doesn't

Things I have done:1- Implemented the variables in MT4
2- Chart tick by tick with quality data
3- Connect the trail stop and breakeven blocks to eleven per trade
4- I used price fraction and pips in the configuration
5- For each operation I store the variable for later use in Break Even and Trail Stop and it updates correctly to the values in the image I have shown initially. So the data stored in the variable is correct and is maintained.
6- After eleven per trade I tried with eleven per tick, this one is higher level and is not connected to any other block.If someone can "shed light" to understand what the problem could be it would be of great help, I have come this far and it is the only point that fails in this implementation. I don't understand why if the values are correct it doesn't behave as expected. Regardless of what approach you propose I will implement it to get the Breakeven and Trail Stop to working. Thank you very much
-
Add a shared link so what is happening can be looked at. Attached is how I get the ATR pips, this does work in breakeven/trail blocks, hope this helps.: https://fxdreema.com/shared/7e69K3wjd
-
@jstap In fact it is from you where I understood the concept of ATR to PIPS but my problem is not there, as this is achieved, as you see in the image ATR BUY PRINCIPAL which is the variable ATR_BP is correctly stored and the value is correct, the Take profit of each order is set perfectly in ATR PIPS Base, this makes everything perfect. My thought is: If everything is correct regarding the TP Pips in the image (ATRX) and the values (ATRX_BP) are the same (as shown in the image), why it does not work correctly in BreakEven and TrailStop?


-
From the look of your pictures, it looks like it would work, but is hard to tell without a shared link.
-
@jstap Yes sorry, I was preparing it, I have reduced it because of the big project. Before the Pass would be the conditions and from there is what you do. Thank you very much. https://fxdreema.com/shared/noGjUsOKb
-
Without a no trade block it was placing hundreds of trades, I am not sure what is happening with trail, but if you change the trail to a fixed 10 pips, it trails as expected:

-
@jstap Yes, in pips it works perfectly I have tested it, but with the current implementation is erratic, the strange thing is that the values are maintained perfectly, but does not apply them that way, the trail sometimes works sometimes not, the breakeven sometimes works and sometimes not, and there is nothing to interfere with it, both breakeven and takeprofit have higher level.
I give you an example, in this operation the take profit is perfect based on the ATRX values, the takeprofit always sets it correctly.

The first order closes with TakeProfit, the price moves to BreakEven, but the trail does not move when it should.

The strange thing is that sometimes the BreakEven moves correctly and sometimes it does not, and also the Trail Stop moves sometimes and sometimes it does not...
I have a version exactly like this one but only with fixed pips, no variables, only fixed pips and it works perfectly.
It doesn't make sense, I know, I don't know how I could change the approach, focus it to make this work. I appreciate the time you are giving me.
-
I have never used trail by price level, only ever used with pips.
-
Finally I got it and it works perfectly, the problem was two areas, apparently the variables have to be set to double not int.
The other problem was a detail that I missed, in the conversion NormalizeDouble(ATRX_BP,2) I had not modified ATRX by the correct variable for each module which is ATRX_BP ATRX_BP2 etc... now it seems to work correctly.

I have to do more tests but it looks promising.
This has allowed me to dive in and understand the potential of variables and changes everything :). Thank you very much for your time.
-
Your welcome