Resetting Consecutive Losses Block
-
I am trying to build an EA that monitors consecutive losses (e.g., 3 losses in a row) and automatically closes all open and pending orders when this condition is met. However, I am encountering an issue: when I attach the EA to a chart, it immediately closes all newly placed orders, as it mistakenly considers prior losses in the order history.
I want the EA to start counting consecutive losses from the moment it is attached to the chart, without taking into account previous trades. Once the condition is met and EA executes the closing procedure, the loss count should be reset to zero again.
Here is the ea link: https://fxdreema.com/shared/dNfp0dRle
-
You will need variables to do that. Are you familiar with variables?
-
Like this: https://fxdreema.com/shared/pnTRM5TZb
-
did I make it right?
-
You will need to use the 'on trade' tab instead. Like this:
https://fxdreema.com/shared/E3s30T1xc
Then you will have to reset the variable somewhere else in your structure in order to count from 0 again.
-
The problem sounds like you're pulling trade history data without filtering it by the time the EA was attached. You need to add a variable that stores the EA's activation time. Then, only count losses that occurred after that time.
-
@l-andorrà In that case, do I need to use the "Check Consecutive Lossess" block on Tick tab?
-
@kvng-kr I don't want to add more variables to it. I simply want the EA to reset back to zero after 3 or more consecutive losses, regardless of whether those losses come from historical trades or current running trades. That's all.
-
@pressium No, it is not necessary.
-
@l-andorrà So far I did this: https://fxdreema.com/shared/hLpkXEI8b
please check it and write me whether i did it right or wrong.
Again the goal is to count consecutive losses (for example: 3 losses), and then close open trades, delete pending orders and reset the counter back to zero.
-
did I make it right?
-
This structure will count correctly the number of consecutive losses, but will not stop new trades to be open. You need to use the 'turn on' and turn off' blocks as I suggested.
-
@l-andorrà I want the ea to count number of consecutive losses from the time it was attached to the chart and when it gets 3 or more losses according to input info, it will close all the running and pending orders and reset the loss count back to zero.
-
Then you need this structure instead:
https://fxdreema.com/shared/2LdYd0PI
However, that will not stop opening new trades. You will still need to apply those 'turn ON/OFF' blocks I suggested. -
To fix this, add a variable to record the timestamp or trade count when the EA is attached. Only evaluate trades after this point to ignore prior losses. Reset the counter after closing all orders to start fresh.