OPEN-SOURCE SCRIPT
Swing & Short Term

//version=6
indicator("Swing & Short Term", overlay=true)
// Input
len = input.int(14, "Williams %R Length")
// Multi-timeframe Williams %R
wprDay = request.security(syminfo.tickerid, "D", ta.wpr(len))
wprWeek = request.security(syminfo.tickerid, "W", ta.wpr(len))
wpr1H = request.security(syminfo.tickerid, "60", ta.wpr(len))
// Conditions
buyCond = (wprDay > -30 and wprWeek > -30 and wpr1H > -30)
sellCond = (wprDay < -40 and wprWeek < -40 and wpr1H < -40)
// Track last signal
var int lastSignal = 0 // 0 = none, 1 = buy, -1 = sell
buySignal = buyCond and lastSignal != 1
sellSignal = sellCond and lastSignal != -1
if buySignal
lastSignal := 1
if sellSignal
lastSignal := -1
// Plot signals
plotshape(buySignal, title="Buy", location=location.belowbar,
style=shape.triangleup, color=color.green, size=size.small, text="BUY")
plotshape(sellSignal, title="Sell", location=location.abovebar,
style=shape.triangledown, color=color.red, size=size.small, text="SELL")
// Alerts
alertcondition(buySignal, title="Buy Alert", message="BUY: D/W/1H W%R > -30")
alertcondition(sellSignal, title="Sell Alert", message="SELL: D/W/1H W%R < -40")
// Reference lines
hline(-30, "Overbought", color=color.red)
hline(-40, "Sell Threshold", color=color.gray)
indicator("Swing & Short Term", overlay=true)
// Input
len = input.int(14, "Williams %R Length")
// Multi-timeframe Williams %R
wprDay = request.security(syminfo.tickerid, "D", ta.wpr(len))
wprWeek = request.security(syminfo.tickerid, "W", ta.wpr(len))
wpr1H = request.security(syminfo.tickerid, "60", ta.wpr(len))
// Conditions
buyCond = (wprDay > -30 and wprWeek > -30 and wpr1H > -30)
sellCond = (wprDay < -40 and wprWeek < -40 and wpr1H < -40)
// Track last signal
var int lastSignal = 0 // 0 = none, 1 = buy, -1 = sell
buySignal = buyCond and lastSignal != 1
sellSignal = sellCond and lastSignal != -1
if buySignal
lastSignal := 1
if sellSignal
lastSignal := -1
// Plot signals
plotshape(buySignal, title="Buy", location=location.belowbar,
style=shape.triangleup, color=color.green, size=size.small, text="BUY")
plotshape(sellSignal, title="Sell", location=location.abovebar,
style=shape.triangledown, color=color.red, size=size.small, text="SELL")
// Alerts
alertcondition(buySignal, title="Buy Alert", message="BUY: D/W/1H W%R > -30")
alertcondition(sellSignal, title="Sell Alert", message="SELL: D/W/1H W%R < -40")
// Reference lines
hline(-30, "Overbought", color=color.red)
hline(-40, "Sell Threshold", color=color.gray)
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.