OPEN-SOURCE SCRIPT

Swing & Short Term

84
//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)


면책사항

해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.