Dynamic stop loss
A stop level a multiple of ATR beyond support in an up-trend, or beyond resistance in a down-trend.
DynamicStopLoss sets a stop level from four other indicators: support, resistance, ATR and a trend reading, scaled by a multiplier. If the trend input is above zero it returns support minus multiplier times ATR; otherwise it returns resistance plus multiplier times ATR. It recomputes that level on every bar and holds the last value while any input is still blank; the price input is only checked for a value and never enters the arithmetic.
How to read it
- Read the line as a stop level: up-trend stops sit below support, down-trend stops above resistance.
- A sudden jump means the trend input changed sign, which switches the reference from support to resistance on that bar.
- On the default chart every input reads the close, so the line runs at about minus half the price and moves opposite to it.
- It holds its last level through any bar where an input is blank, so a flat stretch can mean missing data, not a steady stop.
What it outputs
- Stop level
- Support minus multiplier times ATR in an up-trend, resistance plus multiplier times ATR in a down-trend.
Settings
- multiplier
- How many ATRs the stop sits beyond support or resistance. Raising it moves the stop further out, so it is hit less often; lowering it pulls the stop in toward the level, so it is hit more often. Negative values put the stop on the wrong side.
Pitfalls
- Default-chart output is not a stop: every input reads the close, so wire ATR, support, resistance and trend to real indicators before reading the level.
- The level is not a ratchet: it is recomputed from current inputs each bar, so it can loosen as well as tighten as support, resistance or ATR move.
- The price input is only checked for a value and never enters the formula; a trend reading of exactly zero counts as a down-trend.