FULL AL Brooks Open Bars Theory Breakout Signals (52% Win Rate)

everevolving365 · study · 199 行 · 点赞 40 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

//@version=6
indicator('FULL AL Brooks Open Bars Theory NY + Globex Session Breakout Signals', overlay = true, max_boxes_count = 500, max_lines_count = 500)
 
// ==========================================
// USER INPUTS & TIMEZONE CONFIGURATION
// ==========================================
i_timeZone = input.string('America/Chicago', title = 'Session Time Zone', tooltip = 'Set to America/Chicago for Central Time (08:30 AM Open)')
i_sessTime = input.session('0830-1500:23456', title = 'RTH Session Window', tooltip = '08:30 AM to 03:00 PM Central Time, Monday-Friday')
i_barsToCount = input.int(12, title = 'Opening Range Bar Count', minval = 1, tooltip = 'Number of 5-MINUTE bars to evaluate from the session open. Always counted on the 5-minute timeframe, whatever chart timeframe is open (Al Brooks Concept = 18)')
 
// Color & Style Inputs
i_highColor = input.color(color.green, title = 'First 12-Bar High Level Color')
i_lowColor = input.color(color.red, title = 'First 12-Bar Low Level Color')
i_fillColor = input.color(color.new(color.blue, 92), title = 'Opening Range Background Fill')
 
// Display toggles
i_showNY = input.bool(true, title = 'Show NY Session (08:30) Range & Signals', group = 'Display')
i_showGlobex = input.bool(true, title = 'Show Globex Open (17:00) Range & Signals', group = 'Display')
 
// Globex open inputs
i_gSessTime = input.session('1700-0300:1234567', title = 'Globex Session Window', group = 'Globex Open', tooltip = '05:00 PM to 03:00 AM Central Time. The session that opens at 17:00 runs straight through midnight as ONE session, so the reset happens at 17:00 only.')
i_gBarsToCount = input.int(12, title = 'Globex Opening Range Bar Count', minval = 1, group = 'Globex Open', tooltip = 'Number of 5-MINUTE bars from the 17:00 open (12 = 17:00-17:59, range locks at 18:00)')
i_gHighColor = input.color(color.orange, title = 'Globex 12-Bar High Level Color', group = 'Globex Open')
i_gLowColor = input.color(color.purple, title = 'Globex 12-Bar Low Level Color', group = 'Globex Open')
i_gFillColor = input.color(color.new(color.purple, 92), title = 'Globex Opening Range Background Fill', group = 'Globex Open')
 
// ==========================================
// 5-MINUTE ENGINE (HARD-CODED TIMEFRAME)
// ==========================================
ENGINE_TF = '5'
 
f_engine5m(string sess, int barsToCount) =>
    bool inSession5m = not na(time(ENGINE_TF, sess, i_timeZone))
    bool isNewSession5m = inSession5m and not inSession5m[1]
 
    var int sessionBarCount5m = 0
    var float rangeHigh5m = na
    var float rangeLow5m = na
    var bool rangeLocked5m = false
    var int lockTime5m = na
    var int buyTime5m = na
    var int sellTime5m = na
 
    if isNewSession5m
        sessionBarCount5m := 1
        rangeHigh5m := high
        rangeLow5m := low
        rangeLocked5m := false
        lockTime5m := na
        buyTime5m := na
        sellTime5m := na
        sellTime5m
    else if inSession5m and not rangeLocked5m
        sessionBarCount5m := sessionBarCount5m + 1
        rangeHigh5m := math.max(rangeHigh5m, high)
        rangeLow5m := math.min(rangeLow5m, low)
        rangeLow5m
 
    if inSession5m and sessionBarCount5m == barsToCount and not rangeLocked5m
        rangeLocked5m := true
        lockTime5m := time_close
        lockTime5m
 
    if inSession5m and rangeLocked5m
        if high > rangeHigh5m and na(buyTime5m)
            buyTime5m := time
            buyTime5m
        if low < rangeLow5m and na(sellTime5m)
            sellTime5m := time
            sellTime5m
 
    [rangeHigh5m, rangeLow5m, rangeLocked5m, inSession5m, lockTime5m, buyTime5m, sellTime5m]
 
[rangeHigh, rangeLow, engineLocked, engineInSession, lockTime, buyTime, sellTime] = request.security(syminfo.tickerid, ENGINE_TF, f_engine5m(i_sessTime, i_barsToCount), lookahead = barmerge.lookahead_off)
[gRangeHigh, gRangeLow, gEngineLocked, gEngineInSession, gLockTime, gBuyTime, gSellTime] = request.security(syminfo.tickerid, ENGINE_TF, f_engine5m(i_gSessTime, i_gBarsToCount), lookahead = barmerge.lookahead_off)
 
bool sub5m = timeframe.in_seconds() < 300
 
// ==========================================
// NY SESSION: CHART SESSION TRACKING
// ==========================================
inSession = false
if not na(time(timeframe.period, i_sessTime, i_timeZone))
    inSession := true
    inSession
 
isNewSession = inSession and not inSession[1]
 
var bool buyTriggered = false
var bool sellTriggered = false
 
if isNewSession
    buyTriggered := false
    sellTriggered := false
    sellTriggered
 
bool rangeLocked = sub5m ? engineLocked and engineInSession : engineLocked
bool rangeReady = rangeLocked and time_close >= lockTime
 
// ==========================================
// NY SESSION: BREAKOUT DETECTION
// ==========================================
bool buySignal = false
bool sellSignal = false
 
if sub5m
    if inSession and rangeLocked and time_close > lockTime
        if high > rangeHigh and not buyTriggered
            buySignal := true
            buyTriggered := true
            buyTriggered
        if low < rangeLow and not sellTriggered
            sellSignal := true
            sellTriggered := true
            sellTriggered
else if timeframe.isintraday
    buySignal := not na(buyTime) and (na(buyTime[1]) or buyTime != buyTime[1])
    sellSignal := not na(sellTime) and (na(sellTime[1]) or sellTime != sellTime[1])
    sellSignal
 
// ==========================================
// GLOBEX OPEN: CHART SESSION TRACKING
// ==========================================
gInSession = false
if not na(time(timeframe.period, i_gSessTime, i_timeZone))
    gInSession := true
    gInSession
 
gIsNewSession = gInSession and not gInSession[1]
 
var bool gBuyTriggered = false
var bool gSellTriggered = false
 
if gIsNewSession
    gBuyTriggered := false
    gSellTriggered := false
    gSellTriggered
 
bool gRangeLocked = sub5m ? gEngineLocked and gEngineInSession : gEngineLocked
bool gRangeReady = gRangeLocked and time_close >= gLockTime
 
// ==========================================
// GLOBEX OPEN: BREAKOUT DETECTION
// ==========================================
bool gBuySignal = false
bool gSellSignal = false
 
if sub5m
    if gInSession and gRangeLocked and time_close > gLockTime
        if high > gRangeHigh and not gBuyTriggered
            gBuySignal := true
            gBuyTriggered := true
            gBuyTriggered
        if low < gRangeLow and not gSellTriggered
            gSellSignal := true
            gSellTriggered := true
            gSellTriggered
else if timeframe.isintraday
    gBuySignal := not na(gBuyTime) and (na(gBuyTime[1]) or gBuyTime != gBuyTime[1])
    gSellSignal := not na(gSellTime) and (na(gSellTime[1]) or gSellTime != gSellTime[1])
    gSellSignal
 
// ==========================================
// PLOTTING & VISUALS: NY SESSION
// ==========================================
plotHigh = i_showNY and rangeReady and inSession ? rangeHigh : na
plotLow = i_showNY and rangeReady and inSession ? rangeLow : na
 
pHigh = plot(plotHigh, title = '12-Bar High', color = i_highColor, linewidth = 2, style = plot.style_linebr)
pLow = plot(plotLow, title = '12-Bar Low', color = i_lowColor, linewidth = 2, style = plot.style_linebr)
fill(pHigh, pLow, color = i_showNY and rangeReady and inSession ? i_fillColor : na, title = '12-Bar Range Zone')
 
plotshape(i_showNY and buySignal, title = 'Bullish 12-Bar Breakout', style = shape.labelup, location = location.belowbar, color = color.green, text = 'BUY', textcolor = color.white, size = size.small)
plotshape(i_showNY and sellSignal, title = 'Bearish 12-Bar Breakout', style = shape.labeldown, location = location.abovebar, color = color.red, text = 'SELL', textcolor = color.white, size = size.small)
 
bgcolor(i_showNY and inSession and not rangeReady ? color.new(color.orange, 90) : na, title = 'Evaluating First 12 Bars')
 
// ==========================================
// PLOTTING & VISUALS: GLOBEX OPEN
// ==========================================
gPlotHigh = i_showGlobex and gRangeReady and gInSession ? gRangeHigh : na
gPlotLow = i_showGlobex and gRangeReady and gInSession ? gRangeLow : na
 
gpHigh = plot(gPlotHigh, title = 'Globex 12-Bar High', color = i_gHighColor, linewidth = 2, style = plot.style_linebr)
gpLow = plot(gPlotLow, title = 'Globex 12-Bar Low', color = i_gLowColor, linewidth = 2, style = plot.style_linebr)
fill(gpHigh, gpLow, color = i_showGlobex and gRangeReady and gInSession ? i_gFillColor : na, title = 'Globex 12-Bar Range Zone')
 
plotshape(i_showGlobex and gBuySignal, title = 'Bullish Globex 12-Bar Breakout', style = shape.labelup, location = location.belowbar, color = color.teal, text = 'G BUY', textcolor = color.white, size = size.small)
plotshape(i_showGlobex and gSellSignal, title = 'Bearish Globex 12-Bar Breakout', style = shape.labeldown, location = location.abovebar, color = color.maroon, text = 'G SELL', textcolor = color.white, size = size.small)
 
bgcolor(i_showGlobex and gInSession and not gRangeReady ? color.new(color.purple, 90) : na, title = 'Evaluating First 12 Globex Bars')
 
// ==========================================
// ALERT CONDITIONS
// ==========================================
alertcondition(buySignal, title = 'NY 12-Bar High Breakout (BUY)', message = 'NQ 18-Bar High Breakout BUY Signal Triggered!')
alertcondition(sellSignal, title = 'NY 12-Bar Low Breakout (SELL)', message = 'NQ 18-Bar Low Breakout SELL Signal Triggered!')
alertcondition(gBuySignal, title = 'Globex 12-Bar High Breakout (BUY)', message = 'NQ Globex 12-Bar High Breakout BUY Signal Triggered!')
alertcondition(gSellSignal, title = 'Globex 12-Bar Low Breakout (SELL)', message = 'NQ Globex 12-Bar Low Breakout SELL Signal Triggered!')

← 返回列表