1Copy the scriptPress Copy script above, or the copy button on the code below.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.
Source Code
55 lines of Pine Script v6 from tv-scripts/tvt-ma-crossover-stop.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.
TVT MA Crossover with Stop Loss calculates an ATR-based trailing stop line derived from the highest high minus a multiplied ATR value over a configurable lookback period. Green and red background shading highlights trend bias, while shapes indicate crossover signals and trailing stop breaches. Customizable parameters include moving average lengths, MA calculation type, ATR length, and multiplier.
Fast and slow moving average crossovers
ATR-based trailing stop calculation
Selectable EMA or SMA calculation mode
Visual crossover signals and background trend shading
Alert triggers for crossovers and trailing stop hits
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Source
source
close
src
Use EMA over SMA?
bool
true
use_ema
Fast MA Length
int
50
fast_len
Slow MA Length
int
200
slow_len
ATR Length
int
14
atr_len
ATR Multiplier
float
2.5
atr_mult
HHV Period
int
10
hhv_len
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.
This indicator plots standard Bollinger Bands and three configurable moving averages directly on the price chart. Users can toggle the Bollinger Bands, adjust their length and multiplier, and choose between exponential or simple moving averages for fast, slow,
This indicator plots three exponential moving averages and ATR volatility envelopes on the price chart. It compares the fast and slow EMAs to shade a trend ribbon and marks confirmed upward and downward crossovers with triangle labels. Settings change the thre
This indicator modifies standard Bollinger Bands to measure directional trend force based on line alignment. It calculates a simple moving average basis along with upper and lower volatility bands. When all three lines move upward or downward simultaneously, i
This indicator overlays trend-following Supertrend bands on the price chart using Average True Range calculations. It plots trailing stop lines, highlights active trend directions, and prints buy or sell shape labels when price closes across band thresholds. I
This indicator calculates Kaufman's Adaptive Moving Average (KAMA) on a chosen price source and determines trend direction based on the slope across a configurable lookback window. Signals can be filtered by short-term volatility expansion using ATR comparison
The Adaptive Price Zone indicator calculates volatility bands around a double-smoothed exponential moving average baseline directly on the price chart. It calculates internal smoothing factors using the square root of the user-specified period, double-smoothin