OPEN-SOURCE SCRIPT
aurora

//version=6
strategy("AURORA PRIME — MAX CAGR v3",
overlay=true,
initial_capital=100000,
pyramiding=2,
process_orders_on_close=true)
//----------------------------------------------------
// INPUTS
//----------------------------------------------------
baseRisk = input.float(0.6, "Base Risk %", step=0.1)
expRisk = input.float(0.9, "Expansion Risk %", step=0.1)
atrLen = input.int(14, "ATR Length")
stopATRmult = input.float(1.5, "Stop ATR Mult")
trailATRmult = input.float(2.0, "Trail ATR Mult")
adxLen = input.int(14, "ADX Length")
adxThresh = input.float(22, "ADX Trend Threshold")
volMult = input.float(1.5, "Volume Expansion Mult")
//----------------------------------------------------
// CORE INDICATORS
//----------------------------------------------------
atr = ta.atr(atrLen)
ema200 = ta.ema(close, 200)
// --- Manual ADX Calculation ---
upMove = high - high[1]
downMove = low[1] - low
plusDM = (upMove > downMove and upMove > 0) ? upMove : 0
minusDM = (downMove > upMove and downMove > 0) ? downMove : 0
trur = ta.rma(ta.tr(true), adxLen)
plusDI = 100 * ta.rma(plusDM, adxLen) / trur
minusDI = 100 * ta.rma(minusDM, adxLen) / trur
dx = 100 * math.abs(plusDI - minusDI) / (plusDI + minusDI)
adx = ta.rma(dx, adxLen)
volPower = volume / ta.sma(volume, 20)
volExpansion = volPower > volMult
trendRegime = adx > adxThresh
expansionRegime = trendRegime and volExpansion
// Structure bias (HTF)
htfClose = request.security(syminfo.tickerid, "60", close)
htfEMA = request.security(syminfo.tickerid, "60", ta.ema(close, 50))
bullBias = htfClose > htfEMA
bearBias = htfClose < htfEMA
//----------------------------------------------------
// ENTRY LOGIC
//----------------------------------------------------
longSignal = bullBias and trendRegime and close > ema200
shortSignal = bearBias and trendRegime and close < ema200
//----------------------------------------------------
// RISK ENGINE
//----------------------------------------------------
riskPct = expansionRegime ? expRisk : baseRisk
riskCash = strategy.equity * riskPct * 0.01
stopDist = atr * stopATRmult
qty = stopDist > 0 ? riskCash / stopDist : 0
//----------------------------------------------------
// EXECUTION
//----------------------------------------------------
longSL = close - stopDist
shortSL = close + stopDist
// 2R partial
longTP1 = close + stopDist * 2
shortTP1 = close - stopDist * 2
// ATR trail
trailLong = atr * trailATRmult
trailShort = atr * trailATRmult
if longSignal and strategy.position_size <= 0
strategy.entry("AURORA", strategy.long, qty)
strategy.exit("TP1", "AURORA", qty_percent=50, limit=longTP1)
strategy.exit("Trail", "AURORA", stop=longSL, trail_points=trailLong)
if shortSignal and strategy.position_size >= 0
strategy.entry("AURORA", strategy.short, qty)
strategy.exit("TP1", "AURORA", qty_percent=50, limit=shortTP1)
strategy.exit("Trail", "AURORA", stop=shortSL, trail_points=trailShort)
// Pyramiding logic
inLong = strategy.position_size > 0
inShort = strategy.position_size < 0
entryPrice = strategy.position_avg_price
unrealRLong = inLong ? (close - entryPrice) / stopDist : 0
unrealRShort = inShort ? (entryPrice - close) / stopDist : 0
if inLong and unrealRLong >= 1 and expansionRegime
strategy.entry("AURORA-ADD", strategy.long, qty)
if inShort and unrealRShort >= 1 and expansionRegime
strategy.entry("AURORA-ADD", strategy.short, qty)
plot(ema200, color=color.orange)
strategy("AURORA PRIME — MAX CAGR v3",
overlay=true,
initial_capital=100000,
pyramiding=2,
process_orders_on_close=true)
//----------------------------------------------------
// INPUTS
//----------------------------------------------------
baseRisk = input.float(0.6, "Base Risk %", step=0.1)
expRisk = input.float(0.9, "Expansion Risk %", step=0.1)
atrLen = input.int(14, "ATR Length")
stopATRmult = input.float(1.5, "Stop ATR Mult")
trailATRmult = input.float(2.0, "Trail ATR Mult")
adxLen = input.int(14, "ADX Length")
adxThresh = input.float(22, "ADX Trend Threshold")
volMult = input.float(1.5, "Volume Expansion Mult")
//----------------------------------------------------
// CORE INDICATORS
//----------------------------------------------------
atr = ta.atr(atrLen)
ema200 = ta.ema(close, 200)
// --- Manual ADX Calculation ---
upMove = high - high[1]
downMove = low[1] - low
plusDM = (upMove > downMove and upMove > 0) ? upMove : 0
minusDM = (downMove > upMove and downMove > 0) ? downMove : 0
trur = ta.rma(ta.tr(true), adxLen)
plusDI = 100 * ta.rma(plusDM, adxLen) / trur
minusDI = 100 * ta.rma(minusDM, adxLen) / trur
dx = 100 * math.abs(plusDI - minusDI) / (plusDI + minusDI)
adx = ta.rma(dx, adxLen)
volPower = volume / ta.sma(volume, 20)
volExpansion = volPower > volMult
trendRegime = adx > adxThresh
expansionRegime = trendRegime and volExpansion
// Structure bias (HTF)
htfClose = request.security(syminfo.tickerid, "60", close)
htfEMA = request.security(syminfo.tickerid, "60", ta.ema(close, 50))
bullBias = htfClose > htfEMA
bearBias = htfClose < htfEMA
//----------------------------------------------------
// ENTRY LOGIC
//----------------------------------------------------
longSignal = bullBias and trendRegime and close > ema200
shortSignal = bearBias and trendRegime and close < ema200
//----------------------------------------------------
// RISK ENGINE
//----------------------------------------------------
riskPct = expansionRegime ? expRisk : baseRisk
riskCash = strategy.equity * riskPct * 0.01
stopDist = atr * stopATRmult
qty = stopDist > 0 ? riskCash / stopDist : 0
//----------------------------------------------------
// EXECUTION
//----------------------------------------------------
longSL = close - stopDist
shortSL = close + stopDist
// 2R partial
longTP1 = close + stopDist * 2
shortTP1 = close - stopDist * 2
// ATR trail
trailLong = atr * trailATRmult
trailShort = atr * trailATRmult
if longSignal and strategy.position_size <= 0
strategy.entry("AURORA", strategy.long, qty)
strategy.exit("TP1", "AURORA", qty_percent=50, limit=longTP1)
strategy.exit("Trail", "AURORA", stop=longSL, trail_points=trailLong)
if shortSignal and strategy.position_size >= 0
strategy.entry("AURORA", strategy.short, qty)
strategy.exit("TP1", "AURORA", qty_percent=50, limit=shortTP1)
strategy.exit("Trail", "AURORA", stop=shortSL, trail_points=trailShort)
// Pyramiding logic
inLong = strategy.position_size > 0
inShort = strategy.position_size < 0
entryPrice = strategy.position_avg_price
unrealRLong = inLong ? (close - entryPrice) / stopDist : 0
unrealRShort = inShort ? (entryPrice - close) / stopDist : 0
if inLong and unrealRLong >= 1 and expansionRegime
strategy.entry("AURORA-ADD", strategy.long, qty)
if inShort and unrealRShort >= 1 and expansionRegime
strategy.entry("AURORA-ADD", strategy.short, qty)
plot(ema200, color=color.orange)
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.