Regime exit
Exit signal: marks bars where the current regime's stop, trailing, profit-target or RSI rule is met.
RegimeExit is the exit half of a regime logic. Each bar it reads the regime label and applies that regime's exit rules to a position entered at the entry_price input: a stop below entry set in ATR units, a profit target a fixed multiple of ATR percent above entry, and, depending on the regime, a trailing stop off the trailing_max input, an RSI overbought check, or a failed-breakout check. It returns True on each bar a rule is met and nothing otherwise, and it has no parameters: its multiples are fixed in code.
How to read it
- Markers sit on the candles where an exit fires; the indicator draws no line on the price or in its own pane.
- The rules change with the regime label, so the same bar can exit in a choppy regime and hold in a trending one.
- In choppy regimes the exit also fires on any loss past 1.5% from entry.
- A run of markers is normal: the rule stays true on every bar its condition holds, not only the first.
What it outputs
- Exit
- True on each bar where the current regime's exit rule is met; nothing on other bars.
When it fires
Fires on each bar an exit rule holds: close under the ATR stop or trailing level, close above the profit target, RSI past the regime's overbought line, or in consolidation a close 0.3% under maxs. It means close the open position. Repeat markers mean the rule still holds, not new exits.
Pitfalls
- Nothing fired at defaults: regime, entry_price, atr_pct and trailing_max have no default, and the indicator returns nothing while any is missing, so zero markers says nothing about the exit rules.
- Exits compare the bar's close only, so a wick through the stop or target that closes back inside draws nothing.
- A regime label the code does not name, such as a typo or a new label, silently gets the NORMAL rules.