Circuit Breaker EA Code?

 

I want to be prepared for when the SH*T hits the FOREX fan.

I have been running a bunch of EA's for a few months now. They have been behaving beautifully but they are only prepared for normal, stable market conditions. Thet are opening and closing trades all the time but at any given moment I usually have 5 or 10 open trades.

I have searched all the usual places and haven't found any solutions.

Basically, if I was watching my bots open and close trades they started behaving VERY differently, I would probably close all trades until further notice.

Any code out there to handle this?

Thanks in advance ...

Danny

 

Your ea should go in emergency mode.

Not opening any more positions, and trailing off all that are still opened.

 
xazarlx20:

I want to be prepared for when the SH*T hits the FOREX fan.

I have been running a bunch of EA's for a few months now. They have been behaving beautifully but they are only prepared for normal, stable market conditions. Thet are opening and closing trades all the time but at any given moment I usually have 5 or 10 open trades.

I have searched all the usual places and haven't found any solutions.

Basically, if I was watching my bots open and close trades they started behaving VERY differently, I would probably close all trades until further notice.

Any code out there to handle this?

Thanks in advance ...

Danny

My suggestion is using pending orders to control your EAs using the mobile app

First, all your EAs must watch for a Global Variable used a "circuit breaker". TRUE for active trading, FALSE for stop trading.

Second. an EA will watch for specific pending orders:

  • if a manual pending order of 111 lots is placed, the circuit breaker GV switches to TRUE
  • if a manual pending order of 999 lots is placed, the circuit breaker GV switches to FALSE
  • if a manual pending order of 200 lots is placed, all the market orders will be closed.
  • if a manual pending order of 300 lots is placed, all the market orders will be closed and pending orders deleted.

Of course, after finding a pending order of the above list, the EA will delete the order right after executing the programmed task.

 
I have thought a lot of the circuit breaker analogy for EA strategies.  I abhor traditional stop losses submitted through a broker.  My belief is that an EA should be coded smart enough to know when to get out of a trade without relying on a fixed SL or TP order with the broker.  The way some more complex circuit breakers work is they have an instantaneous trip and a time delay trip.  For example (I caution that I am just pulling these numbers out of the air), lets say I have a 10 amp circuit breaker.  I may set my instantaneous trip at 18 amps.  Not that I want to run 18 amps through the breaker continuously but I don't want any small variations to trip the circuit breaker.  This way, the breaker protects the circuit from huge spikes but will not trip randomly due to small fluctuations.  Then the long term time delay trip would be set closer to the breaker's actual 10 amp rating, say 10.1 amps.  So if there is sustained current through the breaker of 10.1 amps for 60 seconds, it will trip.  I think this should apply to EA's.  Way too many times I 've had a stop loss in and price spikes and triggers the stop loss just before the currency pair moves in my favor.  One of the strategies I have used is to take derivatives (rate of change) and even second derivatives (rate of change of rate of change) of Force Index (which looks at price and volume, the only non-lagging indicators). I can't claim to have mastered this or have a magical formula but this is something I plan on working on more in the future.  I do have one EA actively trading that has this coded into it.  Another alternative to address your concern is hedging, if it fits into your trading strategy.  Since currency is traded in pairs, unlike the stock market, it can't all go to sh*t, something has to go in the right direction.  For example if you are concerned about USD, you could be long EUR/USD and long USD/CAD, if one USD goes to shi*t, one of your pairs is going to offset it correctly.  If you time your exits right, you could even turn it into a big win.