Pine Script (TradingView)
Este e um exemplo de Pine Script do TradingView para este indicador. Cole no Pine Editor do TradingView, adicione ao grafico e ajuste os parametros para seu mercado e timeframe.
//@version=6
indicator("Ultimate Oscillator", overlay=false)
short = input.int(7, "Short Period")
mid = input.int(14, "Mid Period")
long = input.int(28, "Long Period")
bp = close - math.min(low, close[1])
tr = math.max(high, close[1]) - math.min(low, close[1])
avg7 = math.sum(bp, short) / math.sum(tr, short)
avg14 = math.sum(bp, mid) / math.sum(tr, mid)
avg28 = math.sum(bp, long) / math.sum(tr, long)
uo = 100 * (4 * avg7 + 2 * avg14 + avg28) / 7
longSignal = ta.crossover(uo, 30)
shortSignal = ta.crossunder(uo, 70)
plotshape(longSignal, style=shape.triangleup, location=location.bottom, color=color.green, size=size.small)
plotshape(shortSignal, style=shape.triangledown, location=location.top, color=color.red, size=size.small)
hline(70, "Overbought", color=color.red, linestyle=hline.style_dashed)
hline(50, "Mid", color=color.gray, linestyle=hline.style_dotted)
hline(30, "Oversold", color=color.green, linestyle=hline.style_dashed)
plot(uo, "Ultimate Oscillator", color=color.purple)