OPEN-SOURCE SCRIPT
Telah dikemas kini

Accurate Swing Trading System - Strategy

788
//version=5
strategy("Accurate Swing Trading System - Strategy", overlay=true)

// Inputs
no = input.int(3, title="Swing")
Barcolor = input.bool(true, title="Barcolor")
Bgcolor = input.bool(false, title="Bgcolor")

// Logic
res = ta.highest(high, no)
sup = ta.lowest(low, no)
avd = close > res[1] ? 1 : close < sup[1] ? -1 : 0
avn = ta.valuewhen(avd != 0, avd, 0)
tsl = avn == 1 ? sup : res

Buy = ta.crossover(close, tsl)
Sell = ta.crossunder(close, tsl)

// Plotting
plotshape(Buy, title="BUY", style=shape.labelup, location=location.belowbar, color=color.green, text="BUY", textcolor=color.black)
plotshape(Sell, title="SELL", style=shape.labeldown, location=location.abovebar, color=color.red, text="SELL", textcolor=color.black)

colr = close >= tsl ? color.green : close <= tsl ? color.red : na
plot(tsl, color=colr, linewidth=3, title="TSL")
barcolor(Barcolor ? colr : na)
bgcolor(Bgcolor ? colr : na)

// Alerts
alertcondition(Buy, title="Buy Signal", message="Buy")
alertcondition(Sell, title="Sell Signal", message="Sell")

// Strategy Orders
if Buy
strategy.entry("Buy", strategy.long)
if Sell
strategy.close("Buy")
Nota Keluaran
//version=5
strategy("Accurate Swing Trading System - Strategy", overlay=true)

// Inputs
no = input.int(3, title="Swing")
Barcolor = input.bool(true, title="Barcolor")
Bgcolor = input.bool(false, title="Bgcolor")

// Logic
res = ta.highest(high, no)
sup = ta.lowest(low, no)
avd = close > res[1] ? 1 : close < sup[1] ? -1 : 0
avn = ta.valuewhen(avd != 0, avd, 0)
tsl = avn == 1 ? sup : res

Buy = ta.crossover(close, tsl)
Sell = ta.crossunder(close, tsl)

// Plotting
plotshape(Buy, title="BUY", style=shape.labelup, location=location.belowbar, color=color.green, text="BUY", textcolor=color.black)
plotshape(Sell, title="SELL", style=shape.labeldown, location=location.abovebar, color=color.red, text="SELL", textcolor=color.black)

colr = close >= tsl ? color.green : close <= tsl ? color.red : na
plot(tsl, color=colr, linewidth=3, title="TSL")
barcolor(Barcolor ? colr : na)
bgcolor(Bgcolor ? colr : na)

// Alerts
alertcondition(Buy, title="Buy Signal", message="Buy")
alertcondition(Sell, title="Sell Signal", message="Sell")

// Strategy Orders
if Buy
strategy.close("Sell") // Close short if open
strategy.entry("Buy", strategy.long)

if Sell
strategy.close("Buy") // Close long if open
strategy.entry("Sell", strategy.short)

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.