Indicator · Pine Script v6 · On the chart

Capital41 Session Flow Simple v2

by damianpitt· code credited to Capital41 | MIT License

This indicator plots session boxes, high-low ranges, and optional open lines for Asia, London, and New York sessions on the price chart.

View on GitHub

GitHub stars6on the repository
Pine versionv6current
Lines of code143
Settings9inputs
LicenceMIT
Last update2 months ago31 Aug 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

143 lines of Pine Script v6 from Capital41_Session_Flow/Capital41_Session_Flow_Simple_v2.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

Capital41_Session_Flow_Simple_v2.pine
// Copyright (c) 2026 Capital41 | MIT License
// CAPITAL41 SESSION FLOW SIMPLE v2

// What it does:
// - Draws session boxes for Asia, London, and New York using a US timezone.
// - Tracks each session high/low and optional open line.
// - Optional breakout markers when price breaks the prior session range.
//
// v2 changes:
// - FIXED: Breakout markers and alerts gated by barstate.isconfirmed, so they
//          print on bar close rather than the moment price ticks through the
//          prior session level.
//
// TradingView setup:
// 1) Open TradingView -> Pine Editor.
// 2) Paste this script, Save, and Add to chart.
// 3) Use 30m or 4h on BTC or US stocks.
// 4) If you trade futures, set chart session to "All Sessions" to see Asia/London.
// 5) Confirm the session timezone (default America/New_York).
//
// Usage guide (30m/4h):
// - Keep boxes on for context; turn on breakouts only if you trade them.
// - For US stocks, focus on New York session and pre-market London context.
// - For BTC, all sessions are active; boxes help identify liquidity windows.



//@version=6
indicator("Capital41 Session Flow Simple v2", overlay = true, max_boxes_count = 300, max_labels_count = 50,max_lines_count = 50)

// Inputs
useExchangeTz = input.bool(false, "Use exchange timezone")
sessTz     = input.string("America/New_York", "Session timezone",
                          options = ["America/New_York", "America/Chicago", "Etc/UTC", "Europe/London", "Asia/Tokyo"])
sessAsia   = input.session("0000-0800", "Asia session")
sessLondon = input.session("0800-1600", "London session")
sessNY     = input.session("0930-1600", "New York session")

showBoxes    = input.bool(true, "Show session boxes")
showOpenLine = input.bool(false, "Show session open")
showBreakout = input.bool(false, "Show breakouts")
showLabels   = input.bool(false, "Show session range label")

colorAsia   = color.new(color.teal,  88)
colorLondon = color.new(color.orange,88)
colorNY     = color.new(color.blue,  88)
colorBull   = color.new(color.lime, 0)
colorBear   = color.new(color.red, 0)

// Session detection
inAsia   = useExchangeTz ? not na(time(timeframe.period, sessAsia)) : not na(time(timeframe.period, sessAsia, sessTz))
inLondon = useExchangeTz ? not na(time(timeframe.period, sessLondon)) : not na(time(timeframe.period, sessLondon, sessTz))
inNY     = useExchangeTz ? not na(time(timeframe.period, sessNY)) : not na(time(timeframe.period, sessNY, sessTz))

sessionId = inAsia ? 1 : inLondon ? 2 : inNY ? 3 : 0

var int   prevSessionId = 0
var float sessHigh      = na
var float sessLow       = na
var float sessOpen      = na
var float sessClose     = na
var float prevRange     = na
var float prevSessHigh  = na
var float prevSessLow   = na
var box   sessBox       = na
var line  openLine      = na


isSessionChange = sessionId != prevSessionId
if isSessionChange
    // Close previous session
    if prevSessionId != 0
        if not na(sessBox)
            box.set_right(sessBox, bar_index)
        if not na(openLine)
            line.set_x2(openLine, bar_index)

        if showLabels and not na(prevRange) and prevRange > 0 and not na(sessClose)
            rangeNow  = sessHigh - sessLow
            changePct = (rangeNow - prevRange) / prevRange * 100.0
            priceChangePct = sessOpen != 0 ? (sessClose - sessOpen) / sessOpen * 100.0 : 0
            volStatus = changePct > 10 ? "Expanding" : changePct < -10 ? "Contracting" : "Neutral"
            direction = priceChangePct >= 0 ? "+" : "-"
            txt = volStatus + " " + direction + str.tostring(priceChangePct, "#.##") + "%"
            lblY = sessHigh + (rangeNow * 0.12)
            lblColor = priceChangePct >= 0 ? colorBull : colorBear
            label.new(bar_index, lblY, txt, style = label.style_label_down,
                      textcolor = color.white, color = lblColor, size = size.tiny)

        prevRange := sessHigh - sessLow
        prevSessHigh := sessHigh
        prevSessLow := sessLow

    // Start new session
    if sessionId != 0
        sessHigh := high
        sessLow  := low
        sessOpen := open
        sessClose := close

        if showBoxes
            sessBox := box.new(left = bar_index, right = bar_index + 1,
                               top = high, bottom = low, border_width = 0)
            boxColor = sessionId == 1 ? colorAsia : sessionId == 2 ? colorLondon : colorNY
            box.set_bgcolor(sessBox, boxColor)

        if showOpenLine
            openLine := line.new(bar_index, open, bar_index + 1, open,
                                 color = color.new(color.yellow, 0), width = 1,
                                 style = line.style_dashed)

    prevSessionId := sessionId

// Update current session
if sessionId != 0
    sessHigh := math.max(sessHigh, high)
    sessLow  := math.min(sessLow,  low)
    sessClose := close

    if not na(sessBox)
        box.set_top(sessBox, sessHigh)
        box.set_bottom(sessBox, sessLow)
    if not na(openLine)
        line.set_x2(openLine, bar_index + 1)


// Breakouts from previous session (confirmed: marker prints on bar close)
breakAbove = showBreakout and barstate.isconfirmed and not na(prevSessHigh) and high > prevSessHigh and high[1] <= prevSessHigh
breakBelow = showBreakout and barstate.isconfirmed and not na(prevSessLow) and low < prevSessLow and low[1] >= prevSessLow

plotshape(breakAbove, title = "Session High Breakout",
          style = shape.triangleup, location = location.belowbar,
          color = colorBull, size = size.tiny, text = "BO")

plotshape(breakBelow, title = "Session Low Breakdown",
          style = shape.triangledown, location = location.abovebar,
          color = colorBear, size = size.tiny, text = "BD")

alertcondition(breakAbove, title = "Session High Breakout",
               message = "Session Flow: price broke above previous session high on {{ticker}} ({{interval}})")

alertcondition(breakBelow, title = "Session Low Breakdown",
               message = "Session Flow: price broke below previous session low on {{ticker}} ({{interval}})")

Overview

Capital41 Session Flow Simple v2 detects breakouts when price crosses the prior session range. Inputs let users toggle visibility of boxes, open lines, breakouts, and labels, plus select the base timezone and session times. The script draws directly on the chart for visual context on 30-minute and 4-hour timeframes. It includes no trading signals or stop-loss logic.

Details

Published by

damianpitt on GitHub

Code credit

Capital41 | MIT License, as written in the script's header

Draws

On the price chart

Markets

Stocks, Crypto

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

cryptoindicatorsmarket-structureorder-blockspinescriptsmart-moneytechnical-analysistechnical-analysis-indicatorstradingtradingview

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Use exchange timezoneboolfalseuseExchangeTz
Session timezonestringAmerica/New_YorksessTz
Asia sessionsession0000-0800sessAsia
London sessionsession0800-1600sessLondon
New York sessionsession0930-1600sessNY
Show session boxesbooltrueshowBoxes
Show session openboolfalseshowOpenLine
Show breakoutsboolfalseshowBreakout
Show session range labelboolfalseshowLabels
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

947 stars

This indicator counts down to a fixed Litecoin halving timestamp in August 2019, using Greenwich Mean Time. It subtracts the current time from that stamp and formats the remaining days, hours, minutes, and seconds. The day, hour, and minute of the target are u

Indicator v4 Sessions & time
Updated 12 days ago · GPL-3.0 GitHub repository of Litecoin Halving UTC Countdown
575 stars

This indicator builds Market Profile Time Price Opportunity (TPO) structures across defined session timeframes directly on the main price chart. It visualizes the Point of Control (POC) and Value Area boundaries using dynamic box drawings. An integrated multi-

Indicator v5 Support & resistanceScreeners & dashboards
Updated 1 year ago · MPL-2.0 GitHub repository of Market Profile with Screener

This indicator identifies and plots key options expiration dates on the price chart. It calculates monthly OpEx (the third Friday of each month), quarterly OpEx (March, June, September, December), and corresponding VIX expiration dates, drawing vertical lines

Indicator v6 Sessions & time
Updated 2 months ago · MIT GitHub repository of Expiration Highlights: Opex, Quarterly Opex & VIX with Vanna/Charm
257 stars

This indicator plots auto trade signals for E-mini S&P 500 futures on the price chart. It computes an EMA200 filter along with day ETH RTH session levels and percentage-based entry zones. Signals trigger CALL or PUT cases when price crosses defined thresholds

Indicator v6 TrendSupport & resistance
Updated 7 weeks ago · None stated GitHub repository of Auto Trade Futures ES

Golden Bullet Strategy

by TradersPost
228 stars

The Golden Bullet Strategy is an overlay signal indicator based on Smart Money Concepts and time-based liquidity models. It identifies liquidity sweeps of a designated reference session range during a specified hunt window. It then confirms Market Structure Sh

Indicator v6 SMC / ICT / price actionSessions & time
Updated 3 months ago · None stated GitHub repository of Golden Bullet Strategy
219 stars

This indicator plots reference levels for previous daily high and low prices directly on the price chart. It requests daily timeframe data using the security function and plots the offset values as continuous lines, displaying resistance in red and support in

Indicator v4 Support & resistanceSessions & time
Updated 5 years ago · None stated GitHub repository of 昨日高低點標示

More Sessions & time scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers