OPEN-SOURCE SCRIPT

Taka Swing Didi Index

124
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at mozilla.org/MPL/2.0/
// © Ltardi

//version=6

// Didi Index script may be freely distributed under the MIT license.
indicator('Taka Swing Didi Index')

curtaLength = input(title = 'Curta (Short) Length', defval = 3)
mediaLength = input(title = 'Media (Medium) Length', defval = 8)
longaLength = input(title = 'Longa (Long) Length', defval = 50)
src = input(title = 'Source', defval = close)
applyFilling = input(title = 'Apply Ribbon Filling ?', defval = true)
highlightCrossovers = input(title = 'Highlight Crossovers ?', defval = true)

media = ta.sma(src, mediaLength)
curta = ta.sma(src, curtaLength) / media
longa = ta.sma(src, longaLength) / media

curtaPlot = plot(curta, title = 'Curta', color = color.rgb(9, 192, 233))
plot(1, title = 'Media', color = color.rgb(230, 124, 11))
longaPlot = plot(longa, title = 'Longa', color = color.rgb(14, 8, 8))

color_1 = color.new(color.white, 100)
fillColor = applyFilling ? curta > longa ? #30e5ef : color.rgb(0, 0, 0) : color_1
fill(curtaPlot, longaPlot, color = fillColor)

avg_1 = math.avg(longa, longa[1])
plotshape(ta.crossover(curta, longa) and highlightCrossovers ? avg_1 : na, title = 'Crossover', location = location.absolute, style = shape.circle, size = size.tiny, color = color.rgb(81, 195, 79))
avg_2 = math.avg(longa, longa[1])
plotshape(ta.crossunder(curta, longa) and highlightCrossovers ? avg_2 : na, title = 'Crossunder', location = location.absolute, style = shape.circle, size = size.tiny, color = color.rgb(255, 76, 76))

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.