本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=6
indicator("Sniper Akshita Pro - Dual Entry", overlay=true,
max_boxes_count=20, max_lines_count=100, max_labels_count=100)
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// INPUTS
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
groupRange = "01. Opening Range"
rangeSession = input.session("0330-0430", "Opening 1H Range", group=groupRange)
sessionTZ = input.string("Asia/Kolkata", "Timezone", group=groupRange)
groupSetup = "02. 5M Setup"
atrLen = input.int(14, "ATR Length", group=groupSetup)
dispATR = input.float(0.60, "Displacement Body ATR", step=0.05, group=groupSetup)
bodyPctMin = input.float(0.60, "Minimum Body %", step=0.05, group=groupSetup)
mssLookback = input.int(5, "MSS Lookback", minval=2, group=groupSetup)
confirmBars = input.int(12, "Bars After 2nd Sweep", minval=1, group=groupSetup)
groupFVG = "03. Primary FVG"
fvgScanBars = input.int(3, "FVG Scan Bars", minval=1, maxval=8, group=groupFVG)
minFvgATR = input.float(0.05, "Minimum FVG ATR", step=0.01, group=groupFVG)
groupDelta = "04. Delta"
deltaLen5 = input.int(20, "5M Delta Average", group=groupDelta)
deltaMult5 = input.float(1.00, "5M Delta Strength", step=0.10, group=groupDelta)
deltaLen1 = input.int(20, "1M Delta Average", group=groupDelta)
deltaMult1 = input.float(0.80, "1M Delta Strength", step=0.10, group=groupDelta)
groupVisual = "05. Display"
showRange = input.bool(true, "Opening Range", group=groupVisual)
showSweeps = input.bool(true, "Fakeout", group=groupVisual)
showBreakout = input.bool(true, "Breakout", group=groupVisual)
showFVG = input.bool(true, "Primary FVG", group=groupVisual)
show1M = input.bool(true, "1M Entry", group=groupVisual)
show5M = input.bool(true, "5M Entry", group=groupVisual)
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 5 MINUTE ENGINE
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
f_engine5m() =>
atr = ta.atr(atrLen)
candleRange = math.max(high - low, syminfo.mintick)
body = math.abs(close - open)
bodyPct = body / candleRange
pressure = ((close - low) - (high - close)) / candleRange
delta = volume * pressure
deltaAvg = ta.sma(math.abs(delta), deltaLen5)
bullDelta = delta > 0 and math.abs(delta) >= deltaAvg * deltaMult5
bearDelta = delta < 0 and math.abs(delta) >= deltaAvg * deltaMult5
inRange = not na(time(timeframe.period, rangeSession, sessionTZ))
startRange = inRange and not inRange[1]
var float rHigh = na
var float rLow = na
var bool highSwept = false
var bool lowSwept = false
var int candidateDir = 0
var int secondSweepBar = na
var int direction = 0
var int confirmationBar = na
var int setupID = 0
var float candidateTop = na
var float candidateBottom = na
var float candidateMid = na
var float primaryTop = na
var float primaryBottom = na
var bool primaryReady = false
var bool used5 = false
if startRange
rHigh := high
rLow := low
highSwept := false
lowSwept := false
candidateDir := 0
secondSweepBar := na
direction := 0
confirmationBar := na
candidateTop := na
candidateBottom := na
candidateMid := na
primaryTop := na
primaryBottom := na
primaryReady := false
used5 := false
else if inRange
rHigh := math.max(nz(rHigh, high), high)
rLow := math.min(nz(rLow, low), low)
rangeReady = not inRange and not na(rHigh) and not na(rLow)
highSweep = rangeReady and high > rHigh and close < rHigh
lowSweep = rangeReady and low < rLow and close > rLow
oldHigh = highSwept
oldLow = lowSwept
// High swept first, then low swept = possible LONG reversal
if lowSweep and oldHigh
candidateDir := 1
secondSweepBar := bar_index
// Low swept first, then high swept = possible SHORT reversal
if highSweep and oldLow
candidateDir := -1
secondSweepBar := bar_index
if highSweep
highSwept := true
if lowSweep
lowSwept := true
bullDisp =
close > open and
body >= atr * dispATR and
bodyPct >= bodyPctMin
bearDisp =
close < open and
body >= atr * dispATR and
bodyPct >= bodyPctMin
priorHigh = ta.highest(high[1], mssLookback)
priorLow = ta.lowest(low[1], mssLookback)
bullMSS = close > priorHigh
bearMSS = close < priorLow
barsAfterSweep = not na(secondSweepBar) ? bar_index - secondSweepBar : 9999
validWindow =
barsAfterSweep >= 0 and
barsAfterSweep <= confirmBars
bullConfirm =
candidateDir == 1 and
validWindow and
bullDisp and
bullMSS and
bullDelta
bearConfirm =
candidateDir == -1 and
validWindow and
bearDisp and
bearMSS and
bearDelta
if bullConfirm
direction := 1
confirmationBar := bar_index
setupID += 1
candidateTop := na
candidateBottom := na
candidateMid := na
primaryTop := na
primaryBottom := na
primaryReady := false
used5 := false
if bearConfirm
direction := -1
confirmationBar := bar_index
setupID += 1
candidateTop := na
candidateBottom := na
candidateMid := na
primaryTop := na
primaryBottom := na
primaryReady := false
used5 := false
bullGap = low - high[2]
bearGap = low[2] - high
bullFVG =
low > high[2] and
bullGap >= atr * minFvgATR
bearFVG =
high < low[2] and
bearGap >= atr * minFvgATR
scanning =
not na(confirmationBar) and
bar_index >= confirmationBar and
bar_index - confirmationBar <= fvgScanBars
// Bullish move: choose deepest/lower valid FVG
if scanning and direction == 1 and bullFVG
tempBottom = high[2]
tempTop = low
tempMid = (tempTop + tempBottom) / 2
if na(candidateMid) or tempMid < candidateMid
candidateTop := tempTop
candidateBottom := tempBottom
candidateMid := tempMid
// Bearish move: choose highest valid FVG
if scanning and direction == -1 and bearFVG
tempTop = low[2]
tempBottom = high
tempMid = (tempTop + tempBottom) / 2
if na(candidateMid) or tempMid > candidateMid
candidateTop := tempTop
candidateBottom := tempBottom
candidateMid := tempMid
lockPrimary =
not na(confirmationBar) and
bar_index - confirmationBar >= fvgScanBars and
not primaryReady
if lockPrimary and not na(candidateMid)
primaryTop := candidateTop
primaryBottom := candidateBottom
primaryReady := true
primaryMid =
primaryReady ?
(primaryTop + primaryBottom) / 2 :
na
bullRetest =
primaryReady and
direction == 1 and
low <= primaryTop and
high >= primaryBottom
bearRetest =
primaryReady and
direction == -1 and
high >= primaryBottom and
low <= primaryTop
buy5 =
not used5 and
bullRetest and
close > primaryMid and
close > open and
bullDelta
sell5 =
not used5 and
bearRetest and
close < primaryMid and
close < open and
bearDelta
if buy5 or sell5
used5 := true
[
rHigh,
rLow,
highSweep,
lowSweep,
bullConfirm,
bearConfirm,
direction,
primaryTop,
primaryBottom,
primaryReady,
setupID,
buy5,
sell5
]
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// GET 5M DATA
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
[
rangeHigh5,
rangeLow5,
highSweepRaw,
lowSweepRaw,
bullBreakRaw,
bearBreakRaw,
direction5,
fvgTop5,
fvgBottom5,
fvgReady5,
setupID5,
buy5Raw,
sell5Raw
] = request.security(
syminfo.tickerid,
"5",
f_engine5m(),
gaps=barmerge.gaps_off,
lookahead=barmerge.lookahead_off
)
// Make 5M events appear only once
highSweep5 = highSweepRaw and not highSweepRaw[1]
lowSweep5 = lowSweepRaw and not lowSweepRaw[1]
bullBreak5 = bullBreakRaw and not bullBreakRaw[1]
bearBreak5 = bearBreakRaw and not bearBreakRaw[1]
buy5Signal = buy5Raw and not buy5Raw[1]
sell5Signal = sell5Raw and not sell5Raw[1]
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 1 MINUTE ENTRY CONFIRMATION
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
range1 = math.max(high - low, syminfo.mintick)
pressure1 =
((close - low) - (high - close)) /
range1
delta1 = volume * pressure1
deltaAvg1 =
ta.sma(math.abs(delta1), deltaLen1)
bullDelta1 =
delta1 > 0 and
math.abs(delta1) >= deltaAvg1 * deltaMult1
bearDelta1 =
delta1 < 0 and
math.abs(delta1) >= deltaAvg1 * deltaMult1
fvgMid5 =
fvgReady5 ?
(fvgTop5 + fvgBottom5) / 2 :
na
touchLong1 =
fvgReady5 and
direction5 == 1 and
low <= fvgTop5 and
high >= fvgBottom5
touchShort1 =
fvgReady5 and
direction5 == -1 and
high >= fvgBottom5 and
low <= fvgTop5
bullReject1 =
touchLong1 and
close > fvgMid5 and
close > open and
bullDelta1
bearReject1 =
touchShort1 and
close < fvgMid5 and
close < open and
bearDelta1
var int lastBuy1Setup = na
var int lastSell1Setup = na
buy1Signal =
bullReject1 and
(na(lastBuy1Setup) or setupID5 != lastBuy1Setup)
sell1Signal =
bearReject1 and
(na(lastSell1Setup) or setupID5 != lastSell1Setup)
if buy1Signal
lastBuy1Setup := setupID5
if sell1Signal
lastSell1Setup := setupID5
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// PROFESSIONAL VISUALS
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
plot(
showRange ? rangeHigh5 : na,
"Opening Range High",
color=color.new(color.gray, 15),
linewidth=1,
style=plot.style_linebr
)
plot(
showRange ? rangeLow5 : na,
"Opening Range Low",
color=color.new(color.gray, 15),
linewidth=1,
style=plot.style_linebr
)
plot(
showFVG and fvgReady5 ? fvgTop5 : na,
"Primary FVG Top",
color=color.new(color.silver, 25),
linewidth=1,
style=plot.style_linebr
)
plot(
showFVG and fvgReady5 ? fvgBottom5 : na,
"Primary FVG Bottom",
color=color.new(color.silver, 25),
linewidth=1,
style=plot.style_linebr
)
plotshape(
showSweeps and highSweep5,
title="High Fakeout",
style=shape.circle,
location=location.abovebar,
size=size.tiny,
color=color.new(color.red, 10)
)
plotshape(
showSweeps and lowSweep5,
title="Low Fakeout",
style=shape.circle,
location=location.belowbar,
size=size.tiny,
color=color.new(color.teal, 10)
)
plotshape(
showBreakout and bullBreak5,
title="Bull Breakout",
text="BO",
style=shape.labelup,
location=location.belowbar,
size=size.tiny,
color=color.new(color.teal, 20),
textcolor=color.white
)
plotshape(
showBreakout and bearBreak5,
title="Bear Breakout",
text="BO",
style=shape.labeldown,
location=location.abovebar,
size=size.tiny,
color=color.new(color.red, 20),
textcolor=color.white
)
plotshape(
show1M and buy1Signal,
title="1M Buy",
text="1B",
style=shape.labelup,
location=location.belowbar,
size=size.tiny,
color=color.new(color.teal, 0),
textcolor=color.white
)
plotshape(
show1M and sell1Signal,
title="1M Sell",
text="1S",
style=shape.labeldown,
location=location.abovebar,
size=size.tiny,
color=color.new(color.red, 0),
textcolor=color.white
)
plotshape(
show5M and buy5Signal,
title="5M Buy",
text="5B",
style=shape.labelup,
location=location.belowbar,
size=size.small,
color=color.new(color.teal, 0),
textcolor=color.white
)
plotshape(
show5M and sell5Signal,
title="5M Sell",
text="5S",
style=shape.labeldown,
location=location.abovebar,
size=size.small,
color=color.new(color.red, 0),
textcolor=color.white
)
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// ALERTS
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
alertcondition(
buy1Signal,
"Sniper Akshita 1M BUY",
"1M BUY: 5M setup + Primary FVG retest + 1M bullish delta confirmation."
)
alertcondition(
sell1Signal,
"Sniper Akshita 1M SELL",
"1M SELL: 5M setup + Primary FVG retest + 1M bearish delta confirmation."
)
alertcondition(
buy5Signal,
"Sniper Akshita 5M BUY",
"5M BUY: Primary FVG retest confirmed on 5-minute setup."
)
alertcondition(
sell5Signal,
"Sniper Akshita 5M SELL",
"5M SELL: Primary FVG retest confirmed on 5-minute setup."
)