OPEN-SOURCE SCRIPT

SuperTrend+TrailingStop+ChandelierExit/Stop [OmniFlamo]

77

Overview

This indicator combines four well-known trailing-stop methodologies into a single, switchable tool: SuperTrend, Trailing Stop, Chandelier Exit, and Chandelier Stop. Instead of publishing four separate scripts, this lets traders compare and switch between stop-calculation styles on the same chart using one input.

How it works

An ATR value is calculated using a selectable smoothing method (RMA/SMA/EMA/WMA/VWMA/DEMA/VAR), then multiplied by a user-defined factor.
Depending on the selected mode, the ATR offset is applied to a different price reference (hl2, high/low, or close), producing an upper (short) stop and a lower (long) stop.

SuperTrend hl2 ± ATR
TrailingStop high/low ± ATR
ChandelierExit close ± ATR (usePeriod → N close max/min)
ChandelierStop low/high ± ATR (usePeriod →
classic Chandelier: lowest(low,N)+ATR/highest(high,N)−ATR

A ratchet mechanism only lets the long stop rise and the short stop fall while the trend persists, which is the same logic used in classic SuperTrend implementations — this prevents the stop from moving against the trade.
A direction flag flips from long to short (or vice versa) only when price closes beyond the opposite stop line, and the active stop line is plotted accordingly.

How to use it

Select the calculation mode (SuperTrend, TrailingStop, ChandelierExit, ChandelierStop) that matches your trading style.
Adjust ATR length and multiplier to control stop sensitivity — larger multipliers give wider stops and fewer whipsaws, smaller multipliers react faster but generate more signals.
Optional: enable "Show ATR Upper And Lower" to visualize the raw bands before the ratchet/direction logic is applied.
Alerts are provided for stop-line crossovers/crossunders and trend-direction changes, so this can be used for manual trade management or as a building block for automated alert workflows.

Notes & disclaimer

The stop line does not repaint once a bar closes; values shown on the currently forming bar are provisional until close.
This is a trend-following stop/exit tool, not a standalone entry signal generator — it works best combined with your own trend or momentum confirmation.
For sale/manual traders only — this publication does not constitute financial advice. Past performance of any stop-loss method does not guarantee future results. Always backtest and risk-manage independently before live use.

=====================================

概述

本指标将四种经典的移动止损/离场算法整合为一个可切换的工具:SuperTrend、Trailing Stop(跟踪止损)、Chandelier Exit(吊灯离场)与 Chandelier Stop(吊灯止损)。无需分别发布四个脚本,交易者可以在同一图表上通过一个输入项对比、切换不同的止损计算方式。

计算原理

使用可选的均线平滑方式(RMA/SMA/EMA/WMA/VWMA/DEMA/VAR)计算 ATR,并乘以用户自定义的倍数。
根据所选模式,ATR 偏移量会应用到不同的价格基准(hl2、最高/最低价或收盘价),从而得到上方(空头)止损线与下方(多头)止损线。

SuperTrend hl2 ± ATR
TrailingStop high/low ± ATR
ChandelierExit close ± ATR (usePeriod → N close max/min)
ChandelierStop low/high ± ATR (usePeriod →
classic Chandelier: lowest(low,N)+ATR/highest(high,N)−ATR

采用"棘轮"机制:趋势持续期间,多头止损只上移、空头止损只下移,这与经典 SuperTrend 的处理逻辑一致,避免止损线逆势移动。
仅当收盘价突破对侧止损线时,方向标志才会由多转空或由空转多,并绘制对应的当前止损线。

使用方法

根据自己的交易风格选择计算模式(SuperTrend、TrailingStop、ChandelierExit、ChandelierStop)。
调整 ATR 周期与倍数以控制止损的灵敏度——倍数越大,止损越宽、被震荡打止损的概率越低;倍数越小,反应越快但信号也越多。
可选开启"Show ATR Upper And Lower"以查看棘轮/方向逻辑处理前的原始通道。
内置止损线上穿/下穿及趋势方向变化的提醒(alert),可用于人工交易管理,也可作为自动化提醒流程的基础模块。

说明与免责声明

K线收盘后止损线不会重绘;当前未收盘K线上显示的数值为临时值,收盘后才会确定。
本指标是趋势跟踪型止损/离场工具,而非独立的入场信号生成器,建议配合自己的趋势或动量确认方法一同使用。
本发布内容不构成任何财务建议。任何止损方法的历史表现均不保证未来结果,实盘使用前请务必自行回测并做好风险管理。

Exención de responsabilidad

La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.