OPEN-SOURCE SCRIPT
๐โ ๏ธ Aggressive + Confirmed Long Strategy (v2)

//version=5
strategy("๐โ ๏ธ Aggressive + Confirmed Long Strategy (v2)",
overlay=true,
pyramiding=0,
initial_capital=10000,
default_qty_type=strategy.percent_of_equity,
default_qty_value=10, // % of equity per trade
commission_type=strategy.commission.percent,
commission_value=0.05)
// ========= Inputs =========
lenRSI = input.int(14, "RSI Length")
lenSMA1 = input.int(20, "SMA 20")
lenSMA2 = input.int(50, "SMA 50")
lenBB = input.int(20, "Bollinger Length")
multBB = input.float(2, "Bollinger Multiplier", step=0.1)
volLen = input.int(20, "Volume MA Length")
smaBuffP = input.float(1.0, "Margin above SMA50 (%)", step=0.1)
confirmOnClose = input.bool(true, "Confirm signals only after candle close")
useEarly = input.bool(true, "Allow Early entries")
// Risk
atrLen = input.int(14, "ATR Length", minval=1)
slATR = input.float(2.0, "Stop = ATR *", step=0.1)
tpRR = input.float(2.0, "Take-Profit RR (TP = SL * RR)", step=0.1)
useTrail = input.bool(false, "Use Trailing Stop instead of fixed SL/TP")
trailATR = input.float(2.5, "Trailing Stop = ATR *", step=0.1)
moveToBE = input.bool(true, "Move SL to breakeven at 1R TP")
// ========= Indicators =========
// MAs
sma20 = ta.sma(close, lenSMA1)
sma50 = ta.sma(close, lenSMA2)
// RSI
rsi = ta.rsi(close, lenRSI)
rsiEarly = rsi > 45 and rsi < 55
rsiStrong = rsi > 55
// MACD
[macdLine, signalLine, _hist] = ta.macd(close, 12, 26, 9)
macdCross = ta.crossover(macdLine, signalLine)
macdEarly = macdCross and macdLine < 0
macdStrong = macdCross and macdLine > 0
// Bollinger
[bbBasis, bbUpper, bbLower] = ta.bb(close, lenBB, multBB)
bollBreakout = close > bbUpper
// Candle & Volume
bullishCandle = close > open
volCondition = volume > ta.sma(volume, volLen)
// Price vs MAs
smaCondition = close > sma20 and close > sma50 and close > sma50 * (1 + smaBuffP/100.0)
// Confirm-on-close helper
useSignal(cond) =>
confirmOnClose ? (cond and barstate.isconfirmed) : cond
// Entries
confirmedEntry = useSignal(rsiStrong and macdStrong and bollBreakout and bullishCandle and volCondition and smaCondition)
earlyEntry = useSignal(rsiEarly and macdEarly and close > sma20 and bullishCandle) and not confirmedEntry
longSignal = confirmedEntry or (useEarly and earlyEntry)
// ========= Risk Mgmt =========
atr = ta.atr(atrLen)
slPrice = close - atr * slATR
tpPrice = close + (close - slPrice) * tpRR
trailPts = atr * trailATR
// ========= Orders =========
if strategy.position_size == 0 and longSignal
strategy.entry("Long", strategy.long)
if strategy.position_size > 0
if useTrail
// Trailing Stop
strategy.exit("Exit", "Long", trail_points=trailPts, trail_offset=trailPts)
else
// Normal SL/TP
strategy.exit("Exit", "Long", stop=slPrice, limit=tpPrice)
// Move SL to breakeven when TP1 hit
if moveToBE and high >= tpPrice
strategy.exit("BE", "Long", stop=strategy.position_avg_price)
// ========= Plots =========
plot(sma20, title="SMA 20", color=color.orange, linewidth=2)
plot(sma50, title="SMA 50", color=color.new(color.blue, 0), linewidth=2)
plot(bbUpper, title="BB Upper", color=color.new(color.fuchsia, 0))
plot(bbBasis, title="BB Basis", color=color.new(color.gray, 50))
plot(bbLower, title="BB Lower", color=color.new(color.fuchsia, 0))
plotshape(confirmedEntry, title="๐ Confirmed", location=location.belowbar,
color=color.green, style=shape.labelup, text="๐", size=size.tiny)
plotshape(earlyEntry, title="โ ๏ธ Early", location=location.belowbar,
color=color.orange, style=shape.labelup, text="โ ๏ธ", size=size.tiny)
// ========= Alerts =========
alertcondition(confirmedEntry, title="๐ Confirmed Entry", message="๐ {{ticker}} confirmed entry on {{interval}}")
alertcondition(earlyEntry, title="โ ๏ธ Early Entry", message="โ ๏ธ {{ticker}} early entry on {{interval}}")
strategy("๐โ ๏ธ Aggressive + Confirmed Long Strategy (v2)",
overlay=true,
pyramiding=0,
initial_capital=10000,
default_qty_type=strategy.percent_of_equity,
default_qty_value=10, // % of equity per trade
commission_type=strategy.commission.percent,
commission_value=0.05)
// ========= Inputs =========
lenRSI = input.int(14, "RSI Length")
lenSMA1 = input.int(20, "SMA 20")
lenSMA2 = input.int(50, "SMA 50")
lenBB = input.int(20, "Bollinger Length")
multBB = input.float(2, "Bollinger Multiplier", step=0.1)
volLen = input.int(20, "Volume MA Length")
smaBuffP = input.float(1.0, "Margin above SMA50 (%)", step=0.1)
confirmOnClose = input.bool(true, "Confirm signals only after candle close")
useEarly = input.bool(true, "Allow Early entries")
// Risk
atrLen = input.int(14, "ATR Length", minval=1)
slATR = input.float(2.0, "Stop = ATR *", step=0.1)
tpRR = input.float(2.0, "Take-Profit RR (TP = SL * RR)", step=0.1)
useTrail = input.bool(false, "Use Trailing Stop instead of fixed SL/TP")
trailATR = input.float(2.5, "Trailing Stop = ATR *", step=0.1)
moveToBE = input.bool(true, "Move SL to breakeven at 1R TP")
// ========= Indicators =========
// MAs
sma20 = ta.sma(close, lenSMA1)
sma50 = ta.sma(close, lenSMA2)
// RSI
rsi = ta.rsi(close, lenRSI)
rsiEarly = rsi > 45 and rsi < 55
rsiStrong = rsi > 55
// MACD
[macdLine, signalLine, _hist] = ta.macd(close, 12, 26, 9)
macdCross = ta.crossover(macdLine, signalLine)
macdEarly = macdCross and macdLine < 0
macdStrong = macdCross and macdLine > 0
// Bollinger
[bbBasis, bbUpper, bbLower] = ta.bb(close, lenBB, multBB)
bollBreakout = close > bbUpper
// Candle & Volume
bullishCandle = close > open
volCondition = volume > ta.sma(volume, volLen)
// Price vs MAs
smaCondition = close > sma20 and close > sma50 and close > sma50 * (1 + smaBuffP/100.0)
// Confirm-on-close helper
useSignal(cond) =>
confirmOnClose ? (cond and barstate.isconfirmed) : cond
// Entries
confirmedEntry = useSignal(rsiStrong and macdStrong and bollBreakout and bullishCandle and volCondition and smaCondition)
earlyEntry = useSignal(rsiEarly and macdEarly and close > sma20 and bullishCandle) and not confirmedEntry
longSignal = confirmedEntry or (useEarly and earlyEntry)
// ========= Risk Mgmt =========
atr = ta.atr(atrLen)
slPrice = close - atr * slATR
tpPrice = close + (close - slPrice) * tpRR
trailPts = atr * trailATR
// ========= Orders =========
if strategy.position_size == 0 and longSignal
strategy.entry("Long", strategy.long)
if strategy.position_size > 0
if useTrail
// Trailing Stop
strategy.exit("Exit", "Long", trail_points=trailPts, trail_offset=trailPts)
else
// Normal SL/TP
strategy.exit("Exit", "Long", stop=slPrice, limit=tpPrice)
// Move SL to breakeven when TP1 hit
if moveToBE and high >= tpPrice
strategy.exit("BE", "Long", stop=strategy.position_avg_price)
// ========= Plots =========
plot(sma20, title="SMA 20", color=color.orange, linewidth=2)
plot(sma50, title="SMA 50", color=color.new(color.blue, 0), linewidth=2)
plot(bbUpper, title="BB Upper", color=color.new(color.fuchsia, 0))
plot(bbBasis, title="BB Basis", color=color.new(color.gray, 50))
plot(bbLower, title="BB Lower", color=color.new(color.fuchsia, 0))
plotshape(confirmedEntry, title="๐ Confirmed", location=location.belowbar,
color=color.green, style=shape.labelup, text="๐", size=size.tiny)
plotshape(earlyEntry, title="โ ๏ธ Early", location=location.belowbar,
color=color.orange, style=shape.labelup, text="โ ๏ธ", size=size.tiny)
// ========= Alerts =========
alertcondition(confirmedEntry, title="๐ Confirmed Entry", message="๐ {{ticker}} confirmed entry on {{interval}}")
alertcondition(earlyEntry, title="โ ๏ธ Early Entry", message="โ ๏ธ {{ticker}} early entry on {{interval}}")
์คํ ์์ค ์คํฌ๋ฆฝํธ
์ง์ ํ ํธ๋ ์ด๋ฉ๋ทฐ ์ ์ ์ ๋ฐ๋ผ ์ด ์คํฌ๋ฆฝํธ ์์ฑ์๋ ํธ๋ ์ด๋๊ฐ ๊ธฐ๋ฅ์ ๊ฒํ ํ๊ณ ๊ฒ์ฆํ ์ ์๋๋ก ์คํ์์ค๋ก ๊ณต๊ฐํ์ต๋๋ค. ์์ฑ์์๊ฒ ์ฐฌ์ฌ๋ฅผ ๋ณด๋ ๋๋ค! ๋ฌด๋ฃ๋ก ์ฌ์ฉํ ์ ์์ง๋ง ์ฝ๋๋ฅผ ๋ค์ ๊ฒ์ํ ๊ฒฝ์ฐ ํ์ฐ์ค ๋ฃฐ์ด ์ ์ฉ๋๋ค๋ ์ ์ ๊ธฐ์ตํ์ธ์.
๋ฉด์ฑ ์ฌํญ
์ด ์ ๋ณด์ ๊ฒ์๋ฌผ์ TradingView์์ ์ ๊ณตํ๊ฑฐ๋ ๋ณด์ฆํ๋ ๊ธ์ต, ํฌ์, ๊ฑฐ๋ ๋๋ ๊ธฐํ ์ ํ์ ์กฐ์ธ์ด๋ ๊ถ๊ณ ์ฌํญ์ ์๋ฏธํ๊ฑฐ๋ ๊ตฌ์ฑํ์ง ์์ต๋๋ค. ์์ธํ ๋ด์ฉ์ ์ด์ฉ ์ฝ๊ด์ ์ฐธ๊ณ ํ์ธ์.
์คํ ์์ค ์คํฌ๋ฆฝํธ
์ง์ ํ ํธ๋ ์ด๋ฉ๋ทฐ ์ ์ ์ ๋ฐ๋ผ ์ด ์คํฌ๋ฆฝํธ ์์ฑ์๋ ํธ๋ ์ด๋๊ฐ ๊ธฐ๋ฅ์ ๊ฒํ ํ๊ณ ๊ฒ์ฆํ ์ ์๋๋ก ์คํ์์ค๋ก ๊ณต๊ฐํ์ต๋๋ค. ์์ฑ์์๊ฒ ์ฐฌ์ฌ๋ฅผ ๋ณด๋ ๋๋ค! ๋ฌด๋ฃ๋ก ์ฌ์ฉํ ์ ์์ง๋ง ์ฝ๋๋ฅผ ๋ค์ ๊ฒ์ํ ๊ฒฝ์ฐ ํ์ฐ์ค ๋ฃฐ์ด ์ ์ฉ๋๋ค๋ ์ ์ ๊ธฐ์ตํ์ธ์.
๋ฉด์ฑ ์ฌํญ
์ด ์ ๋ณด์ ๊ฒ์๋ฌผ์ TradingView์์ ์ ๊ณตํ๊ฑฐ๋ ๋ณด์ฆํ๋ ๊ธ์ต, ํฌ์, ๊ฑฐ๋ ๋๋ ๊ธฐํ ์ ํ์ ์กฐ์ธ์ด๋ ๊ถ๊ณ ์ฌํญ์ ์๋ฏธํ๊ฑฐ๋ ๊ตฌ์ฑํ์ง ์์ต๋๋ค. ์์ธํ ๋ด์ฉ์ ์ด์ฉ ์ฝ๊ด์ ์ฐธ๊ณ ํ์ธ์.