OPEN-SOURCE SCRIPT

KANG NUR

Od zrtreder
//version=5
strategy("BB Breakout with MA 100 Strategy", overlay=true)

// Parameter Bollinger Bands
length = input(20, title="BB Length")
stdDev = input(2.0, title="BB Standard Deviation")

// Hitung Bollinger Bands
basis = ta.sma(close, length)
dev = stdDev * ta.stdev(close, length)
upperBB = basis + dev
lowerBB = basis - dev

// Hitung Moving Average 100
ma100 = ta.sma(close, 100)

// Logika untuk sinyal beli dan jual
longCondition = close > upperBB and close[1] <= upperBB[1]
shortCondition = close < lowerBB and close[1] >= lowerBB[1]

// Menentukan ukuran posisi (jumlah lot)
size = strategy.equity / close // Menentukan ukuran posisi berdasarkan ekuitas saat ini

// Eksekusi order
if (longCondition)
strategy.entry("Long", strategy.long, qty=size)

if (shortCondition)
strategy.entry("Short", strategy.short, qty=size)

// Menutup posisi ketika kondisi terbalik
if (longCondition and strategy.position_size < 0)
strategy.close("Short")

if (shortCondition and strategy.position_size > 0)
strategy.close("Long")

// Plotting
plot(upperBB, color=color.red, title="Upper BB")
plot(lowerBB, color=color.green, title="Lower BB")
plot(basis, color=color.blue, title="Basis BB")
plot(ma100, color=color.orange, title="MA 100")

// Menambahkan informasi ke grafik
bgcolor(longCondition ? color.new(color.green, 90) : na, title="Buy Signal Background")
bgcolor(shortCondition ? color.new(color.red, 90) : na, title="Sell Signal Background")
Bands and Channels

Skrypt open-source

W prawdziwym duchu TradingView autor tego skryptu opublikował go jako open source, aby inwestorzy mogli go zrozumieć i zweryfikować. Pozdrowienia dla autora! Możesz go używać bezpłatnie, ale ponowne użycie tego kodu w publikacji podlega Zasadom Regulaminu. Możesz go oznaczyć jako ulubione, aby użyć go na wykresie.

Chcesz użyć tego skryptu na wykresie?

Wyłączenie odpowiedzialności