https://www.tradingview.com/script/aJDdjBh6-Trend-Strength-Gauge/
Hi can anyone help convert this TradingView to thinkorswim indicator code below:
// @VanHe1sing
//@version=5
indicator("Trend Strength Gauge", 'HSMA',overlay = true)
length = input(20, "HSMA Length")
// Hma
wma = ta.wma(close, length)
wma1 = ta.wma(close, length)
a = 3 * wma - 2 * wma1
// Sma
a1 = ta.sma(close, length)
// Extract the difference (HMA - SMA)
diff = a - a1
// Table Function
printTable(txt, col, row, color, txt1, col1, row1, color1) => var table t = table.new(position.bottom_center, 60, 3),
table.cell(t, col, row, txt, bgcolor = color),
table.cell(t, col1, row1, txt1, bgcolor = color1, text_color = color.white)
// Normalize
x = diff
len = 100
xMax = ta.highest(x, len)
xMin = ta.lowest(x, len)
range_ = xMax - xMin
y = x / range_
// Convertation searies float to searies int with round()
g = math.round(y*40)
// Plot
color1 = color.from_gradient(g, -2, 2, color.white, color.teal)
p1 = plot(a, 'HEMA', color1, 2)
p2 = plot(a1, 'SMA', color1, 2)
fill(p1, p2, color = color1)
// Convertation negative values to positive
g := g < 0 ? g *- 1 : g
// Plot trend strength gauge
if barstate.islast
for i = 1 to 40
color_ = math.round(y*40) < 0 ? color.white : color.teal
color = color.from_gradient(i, 1, 50, color.rgb(0, 137, 123, 100), color_)
printTable("", i, 1, color, "V", g, 1, color.rgb(255, 255, 255, 100))