OPEN-SOURCE SCRIPT

Price-Aligned Trend Indicator

259
//version=6
indicator("Price-Aligned Trend Indicator", overlay=true)

// Input parameters
t3Length1 = input.int(5, "Fast T3 Length")
t3Length2 = input.int(13, "Medium T3 Length")
t3Length3 = input.int(34, "Slow T3 Length")

// T3 Moving Average Function
t3(src, len) =>
e1 = ta.ema(src, len)
e2 = ta.ema(e1, len)
e3 = ta.ema(e2, len)
e4 = ta.ema(e3, len)
(e1 + 2 * e2 + 2 * e3 + e4) / 6

// Moving averages
maFast = t3(close, t3Length1)
maMedium = t3(close, t3Length2)
maSlow = t3(close, t3Length3)

// Conditions for trends
bullish = maFast > maMedium and maMedium > maSlow
bearish = maFast < maMedium and maMedium < maSlow

// Trend clouds
pFast = plot(maFast, color=bullish ? color.new(color.green, 0) : bearish ? color.new(color.red, 0) : color.new(color.gray, 0), linewidth=2)
pMedium = plot(maMedium, color=bullish ? color.new(color.green, 30) : bearish ? color.new(color.red, 30) : color.new(color.gray, 30), linewidth=2)
pSlow = plot(maSlow, color=bullish ? color.new(color.green, 60) : bearish ? color.new(color.red, 60) : color.new(color.gray, 60), linewidth=2)
fill(pFast, pMedium, color=bullish ? color.new(color.green, 80) : bearish ? color.new(color.red, 80) : color.new(color.gray, 90))

// Breakout/Breakdown Labels
if ta.crossover(maFast, maMedium) and bullish
label.new(x=bar_index, y=close, text="BREAKOUT", style=label.style_label_up, color=color.green, textcolor=color.white)
if ta.crossunder(maFast, maMedium) and bearish
label.new(x=bar_index, y=close, text="BREAKDOWN", style=label.style_label_down, color=color.red, textcolor=color.white)

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.