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
70 lines of Pine Script v5 from 3 and 5 EMA__UTBot_S-WA.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.
3 and 5 EMA__UTBot_S-WA.pine
//@version=5
indicator("Combined 3EMA and UT Bot Alerts with 5 EMA Trend alart", shorttitle="3/5EMA_UTBot_TS-WA", overlay=true)
// Inputs for EMAs
EMA1 = input.int(50, minval=1, title="EMA1")
EMA2 = input.int(100, minval=1, title="EMA2")
EMA3 = input.int(200, minval=1, title="EMA3")
EMA4 = input.int(5, minval=1, title="EMA4")
// Plot EMAs
plot(ta.ema(close, EMA1), color=color.red, linewidth=2)
plot(ta.ema(close, EMA2), color=color.yellow, linewidth=2)
plot(ta.ema(close, EMA3), color=color.purple, linewidth=2)
plot(ta.ema(close, EMA4), color=color.blue, linewidth=2)
// Inputs for UT Bot Alerts
a = input.int(1, title="Key Value (sensitivity)")
c = input.int(10, title="ATR Period")
h = input.bool(false, title="Signals from Heikin Ashi Candles")
xATR = ta.atr(c)
nLoss = a * xATR
src = h ? request.security(syminfo.tickerid, timeframe.period, close, lookahead=barmerge.lookahead_off) : close
var float xATRTrailingStop = na
if na(xATRTrailingStop[1])
xATRTrailingStop := src
else
if src > xATRTrailingStop[1] and src[1] > xATRTrailingStop[1]
xATRTrailingStop := math.max(xATRTrailingStop[1], src - nLoss)
else if src < xATRTrailingStop[1] and src[1] < xATRTrailingStop[1]
xATRTrailingStop := math.min(xATRTrailingStop[1], src + nLoss)
else
xATRTrailingStop := src > xATRTrailingStop[1] ? src - nLoss : src + nLoss
var int pos = na
if na(pos[1])
pos := na
else
if src[1] < xATRTrailingStop[1] and src > xATRTrailingStop[1]
pos := 1
else if src[1] > xATRTrailingStop[1] and src < xATRTrailingStop[1]
pos := -1
else
pos := pos[1]
xcolor = pos == -1 ? color.red : pos == 1 ? color.green : color.blue
ema_1 = ta.ema(src, 1)
above = ta.crossover(ema_1, xATRTrailingStop)
below = ta.crossover(xATRTrailingStop, ema_1)
buy = src > xATRTrailingStop and above
sell = src < xATRTrailingStop and below
barbuy = src > xATRTrailingStop
barsell = src < xATRTrailingStop
plotshape(buy, title="Buy", text='Buy', style=shape.labelup, location=location.belowbar, color=color.green, textcolor=color.white, size=size.tiny)
plotshape(sell, title="Sell", text='Sell', style=shape.labeldown, location=location.abovebar, color=color.red, textcolor=color.white, size=size.tiny)
barcolor(barbuy ? color.green : na)
barcolor(barsell ? color.red : na)
alertcondition(buy, title="UT Long", message="UT Long")
alertcondition(sell, title="UT Short", message="UT Short")
// Additional alert for "red signal"
alertcondition(barsell, title="Red Signal Alert", message="Red Signal: Consider Selling")
Overview
Combined 3EMA and UT Bot Alerts with 5 EMA Trend Alert computes an ATR-based trailing stop using sensitivity and period settings. The trailing stop updates based on price action and Heikin Ashi candles if enabled. Signals trigger on crossovers between a 1-period EMA and the trailing stop, producing buy and sell labels, bar color changes, and alerts. Main settings adjust EMA lengths, ATR period, and Heikin Ashi usage. It draws solely on the price chart with no separate pane.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
EMA1
int
50
EMA1
EMA2
int
100
EMA2
EMA3
int
200
EMA3
EMA4
int
5
EMA4
Key Value (sensitivity)
int
1
a
ATR Period
int
10
c
Signals from Heikin Ashi Candles
bool
false
h
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 four customizable moving averages directly on the main price chart using default lengths of 3, 8, 21, and 50 periods. It fills the space between adjacent averages in green or maroon depending on trend alignment. Additionally, it computes B
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