Check for consecutive losses for a pair within last 15 seconds
-
I would like to add a safety net to my EA by building in logic that checks for consecutive opening/closing of trades within a specified times. This is to ensure that once the EA is on a live account, if issues arise that weren't apparent during testing, I can put a block to either delay the trading by x amount of time or terminate the EA.
I know how to do the latter, delaying additional trades and terminating the EA, what I can't figure out is how to check for consecutive opening and closing of trades within a short span of time (2 mins).
I tried using the Check age block, but that doesn't seem to be working right.
https://fxdreema.com/shared/6viqlj7Zd
Any and all help would be greatly appreciated.
-

something about this seems like the wicked smaht way to do it. Just turn off the buy and sell blocks. Because it leaves the EA running instead of terminating, you could also program in something to turn them back on later.
-
@TipsyWisdom the issue with this is that I'm okay if the losses occur naturally over time, even if they are consecutive. What I'm really trying to figure out is how to identify consecutive opens and closes within a short time frame. I've had this happen a few times when I missed something in my logic/blocks with how the trades open based on specific signals, and then immediately close because they're triggered by my blocks triggering closing of trades. This is why I want to build in safeguards to terminate the EA in such circumstances.
Any thoughts on how to add the time component to your solution?
-
- NEVER EVER use once per day unless its acting as a function of...drawing lines, running custom code.
- Limit it by using the block "once per bar," and then inside that block, change the time to how many bars (candles) you would want it to work. I.e. If I have a strat I expect that could potentially trade once per hour with profit, I'll change it to H1.
- Placement of that block, right above your buy now and sell now blocks...nowhere else.
-
@darekl You should use a 'For each trade' block on top of your structure for that 'check age' block to work properly.