OPEN-SOURCE SCRIPT
HARRISH DADE

//version=5
strategy("Nifty 15m ORB + 20 EMA + Volume - Signals Fixed", overlay=true,
initial_capital=100000, default_qty_type=strategy.percent_of_equity, default_qty_value=25,
process_orders_on_close=true)
// 15-minute timeframe check
if timeframe.period != "15"
runtime.error("Use this strategy on 15 minute timeframe only")
// ORB 9:15–9:30 High/Low
var float orbHigh = na
var float orbLow = na
newDay = ta.change(time("D")) != 0
if newDay
orbHigh := na
orbLow := na
sessStart = 0915
sessEnd = 0930
hhmm = hour * 100 + minute
inORB = hhmm >= sessStart and hhmm < sessEnd
if inORB
orbHigh := na(orbHigh) ? high : math.max(orbHigh, high)
orbLow := na(orbLow) ? low : math.min(orbLow, low)
// Plot ORB levels
plot(orbHigh, "ORB High", color=color.new(color.green, 0), linewidth=2)
plot(orbLow, "ORB Low", color=color.new(color.red, 0), linewidth=2)
// Trend filter - 20 EMA
emaLen = input.int(20, "EMA Length", minval=1)
ema20 = ta.ema(close, emaLen)
upTrend = close > ema20
dnTrend = close < ema20
plot(ema20, "EMA 20", color=color.orange, linewidth=2)
// Volume filter - Adaptive
volLen = input.int(20, "Volume MA Length", minval=1)
avgVol = ta.sma(volume, volLen)
volMult = input.float(1.5, "Volume Multiplier", step=0.1)
enoughVol = volume >= (avgVol * volMult)
// ORB complete check
orbLocked = not na(orbHigh) and not na(orbLow) and not inORB
// Entry conditions (for strategy)
longCond = orbLocked and ta.crossover(close, orbHigh) and upTrend and enoughVol
shortCond = orbLocked and ta.crossunder(close, orbLow) and dnTrend and enoughVol
// Risk Management
targetPts = input.float(40.0, "Target Points", step=1.0)
slPts = input.float(25.0, "Stoploss Points", step=1.0)
// STRATEGY ENTRIES
if longCond and strategy.position_size == 0
strategy.entry("LONG", strategy.long)
if shortCond and strategy.position_size == 0
strategy.entry("SHORT", strategy.short)
// STRATEGY EXITS
if strategy.position_size > 0
strategy.exit("LONG EXIT", from_entry="LONG",
limit=strategy.position_avg_price + targetPts,
stop=strategy.position_avg_price - slPts)
if strategy.position_size < 0
strategy.exit("SHORT EXIT", from_entry="SHORT",
limit=strategy.position_avg_price - targetPts,
stop=strategy.position_avg_price + slPts)
// **FIXED BUY/SELL SIGNALS** - No barstate.isconfirmed, direct conditions
plotshape(longCond, title="BUY", style=shape.triangleup, location=location.belowbar,
color=color.new(color.lime, 0), size=size.large, text="BUY", textcolor=color.white)
plotshape(shortCond, title="SELL", style=shape.triangledown, location=location.abovebar,
color=color.new(color.red, 0), size=size.large, text="SELL", textcolor=color.white)
// Debug table - shows if conditions met
if barstate.islast
var table debugTable = table.new(position.top_right, 2, 6, bgcolor=color.white, border_width=1)
table.cell(debugTable, 0, 0, "Condition", text_color=color.black, bgcolor=color.gray)
table.cell(debugTable, 1, 0, "Status", text_color=color.black, bgcolor=color.gray)
table.cell(debugTable, 0, 1, "ORB Locked", text_color=color.black)
table.cell(debugTable, 1, 1, str.tostring(orbLocked), text_color=orbLocked ? color.green : color.red)
table.cell(debugTable, 0, 2, "UpTrend", text_color=color.black)
table.cell(debugTable, 1, 2, str.tostring(upTrend), text_color=upTrend ? color.green : color.red)
table.cell(debugTable, 0, 3, "Enough Vol", text_color=color.black)
table.cell(debugTable, 1, 3, str.tostring(enoughVol), text_color=enoughVol ? color.green : color.red)
strategy("Nifty 15m ORB + 20 EMA + Volume - Signals Fixed", overlay=true,
initial_capital=100000, default_qty_type=strategy.percent_of_equity, default_qty_value=25,
process_orders_on_close=true)
// 15-minute timeframe check
if timeframe.period != "15"
runtime.error("Use this strategy on 15 minute timeframe only")
// ORB 9:15–9:30 High/Low
var float orbHigh = na
var float orbLow = na
newDay = ta.change(time("D")) != 0
if newDay
orbHigh := na
orbLow := na
sessStart = 0915
sessEnd = 0930
hhmm = hour * 100 + minute
inORB = hhmm >= sessStart and hhmm < sessEnd
if inORB
orbHigh := na(orbHigh) ? high : math.max(orbHigh, high)
orbLow := na(orbLow) ? low : math.min(orbLow, low)
// Plot ORB levels
plot(orbHigh, "ORB High", color=color.new(color.green, 0), linewidth=2)
plot(orbLow, "ORB Low", color=color.new(color.red, 0), linewidth=2)
// Trend filter - 20 EMA
emaLen = input.int(20, "EMA Length", minval=1)
ema20 = ta.ema(close, emaLen)
upTrend = close > ema20
dnTrend = close < ema20
plot(ema20, "EMA 20", color=color.orange, linewidth=2)
// Volume filter - Adaptive
volLen = input.int(20, "Volume MA Length", minval=1)
avgVol = ta.sma(volume, volLen)
volMult = input.float(1.5, "Volume Multiplier", step=0.1)
enoughVol = volume >= (avgVol * volMult)
// ORB complete check
orbLocked = not na(orbHigh) and not na(orbLow) and not inORB
// Entry conditions (for strategy)
longCond = orbLocked and ta.crossover(close, orbHigh) and upTrend and enoughVol
shortCond = orbLocked and ta.crossunder(close, orbLow) and dnTrend and enoughVol
// Risk Management
targetPts = input.float(40.0, "Target Points", step=1.0)
slPts = input.float(25.0, "Stoploss Points", step=1.0)
// STRATEGY ENTRIES
if longCond and strategy.position_size == 0
strategy.entry("LONG", strategy.long)
if shortCond and strategy.position_size == 0
strategy.entry("SHORT", strategy.short)
// STRATEGY EXITS
if strategy.position_size > 0
strategy.exit("LONG EXIT", from_entry="LONG",
limit=strategy.position_avg_price + targetPts,
stop=strategy.position_avg_price - slPts)
if strategy.position_size < 0
strategy.exit("SHORT EXIT", from_entry="SHORT",
limit=strategy.position_avg_price - targetPts,
stop=strategy.position_avg_price + slPts)
// **FIXED BUY/SELL SIGNALS** - No barstate.isconfirmed, direct conditions
plotshape(longCond, title="BUY", style=shape.triangleup, location=location.belowbar,
color=color.new(color.lime, 0), size=size.large, text="BUY", textcolor=color.white)
plotshape(shortCond, title="SELL", style=shape.triangledown, location=location.abovebar,
color=color.new(color.red, 0), size=size.large, text="SELL", textcolor=color.white)
// Debug table - shows if conditions met
if barstate.islast
var table debugTable = table.new(position.top_right, 2, 6, bgcolor=color.white, border_width=1)
table.cell(debugTable, 0, 0, "Condition", text_color=color.black, bgcolor=color.gray)
table.cell(debugTable, 1, 0, "Status", text_color=color.black, bgcolor=color.gray)
table.cell(debugTable, 0, 1, "ORB Locked", text_color=color.black)
table.cell(debugTable, 1, 1, str.tostring(orbLocked), text_color=orbLocked ? color.green : color.red)
table.cell(debugTable, 0, 2, "UpTrend", text_color=color.black)
table.cell(debugTable, 1, 2, str.tostring(upTrend), text_color=upTrend ? color.green : color.red)
table.cell(debugTable, 0, 3, "Enough Vol", text_color=color.black)
table.cell(debugTable, 1, 3, str.tostring(enoughVol), text_color=enoughVol ? color.green : color.red)
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.