Moderator warning: AI-generated comment
I’m currently experimenting with dynamic stop losses for automated trading systems.
Fixed SLs feel too rigid for changing market conditions, so I’d like to hear how others approach adaptive risk management in their EAs.
ATR trailing? Swing highs/lows? Volatility regimes? Time-based adjustments?
What have give you the best results?
What I generally use as a dynamic exit is really nothing clever. Let's say that I'm using 2 moving averages (MA's) applied to the main price chart, and an oscillator in the chart subwindow, for entries. For a buy, price must be above the fast MA, the fast MA must be above the slow MA, the fast MA must show a 2-bar slope up, and the oscillator must be above a midpoint level. In this scenario, I find that price and the fast MA are the fastest (least lagging) components of the strategy. So as that is the case, price and the fast MA are determining the immediate directional bias of price, and the slow MA and the oscillator are additional filters.
With some minimal critical thinking involved, I deduce that filtering exits is nonsensical because exiting is inherently noncommittal─more like an escape. Therefore, I use the immediate sell conditions (price must be below the fast MA) without the filters applied to exit longs─invert for shorts. The simple underlying premise is the fact that price and the fast MA are accurately calling immediate directional bias for entries, so they must be able to accurately call the same for exits. In fact, I find that having exits that are faster than entries is a feature of almost every single-position trading strategy.
Of course, further refinement is likely required in the form of trading time filters, position sizing, etc., but that is outside of the scope of this thread.
I like to work with a percentage-based SL, which is calculated on the current price of the traded instrument.
I also implement ATR-based or sometimes depending on the strategy an opposite signal for a SL.
Control your risk.
Risk depends on your initial stop loss, lot size, and the value of the symbol. It does not depend on margin or leverage. No SL means you have infinite risk (on leveraged symbols). Never risk more than a small percentage of your trading funds, certainly less than 2% per trade, 6% account total.
-
You place the stop where it needs to be — where the reason for the trade is no longer valid. E.g., trading a support bounce, the stop goes below the support. Then you compute your lot size.
-
AccountBalance * percent/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerLot + CommissionPerLot) (Note OOP-OSL includes the spread, and DeltaPerLot is usually around $10/PIP, but it takes account of the exchange rates of the pair vs. your account currency.)
-
Do NOT use TickValue by itself - DeltaPerLot and verify that MODE_TICKVALUE is returning a value in your deposit currency, as promised by the documentation, or whether it is returning a value in the instrument's base currency.
MODE_TICKVALUE is not reliable on non-fx instruments with many brokers - MQL4 programming forum (2017)
Is there an universal solution for Tick value? - Currency Pairs - General - MQL5 programming forum (2018)
Lot value calculation off by a factor of 100 - MQL5 programming forum (2019) -
You must normalize lots properly and check against min and max.
-
You must also check Free Margin to avoid stop out
-
For MT5, see 'Money Fixed Risk' - MQL5 Code Base (2017)
Most pairs are worth about $10 per PIP. A $5 risk with a (very small) 5 PIP SL is $5/$10/5 or 0.1 Lots maximum.
Moderator warning: AI-generated comment
How do you deal with the market structure part?
How can you identify that the price is in a trend or sideways?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I’m currently experimenting with dynamic stop losses for automated trading systems.
Fixed SLs feel too rigid for changing market conditions, so I’d like to hear how others approach adaptive risk management in their EAs.
ATR trailing? Swing highs/lows? Volatility regimes? Time-based adjustments?
What have give you the best results?