OPEN-SOURCE SCRIPT

Swing & Short Term

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


إخلاء المسؤولية

لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.