Indicator · Pine Script v5 · On the chart

LIT - Timing

by rpanchyk

LIT - Timing plots key market session ranges directly on the price chart based on Liquidity Inducement Theorem concepts.

View on GitHub

Repaints

GitHub stars7on the repository
Pine versionv5runs as is
Lines of code179
Settings9inputs
LicenceMIT
Last update2 years ago24 Oct 2024

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

179 lines of Pine Script v5 from docs/LIT_Timing.txt, published under MIT. Keep the author's credit and licence lines when you reuse it.

LIT_Timing.txt
// LIT Reimfx
//@version=5
indicator('LIT - Timing', overlay=true, max_labels_count=500, max_boxes_count=500)

// ---------- INPUTS --------------
HideTFAbove = input.int(59, 'Hide Boxes on TF above (Minutes)', minval=15, maxval=120)
HideTFAbove_asia = 60

show_asia      = input(true, 'Show Asian Session')
show_lon       = input(true, 'Show London Session')
show_nyt       = input(true, 'Show NY Session')


asia_color      = input(color.new(color.rgb(152, 0, 255), 90), 'Asian Fill Color')
asia_line_color = input(color.new(color.rgb(152, 0, 255), 70), 'Asian Line Color')
lon_color       = input(color.new(color.rgb(67, 70, 81), 90), 'London Fill Color')
nyt_color       = input(color.new(color.rgb(67, 70, 81), 90), 'NY Fill Color')
// ------- END INPUTS -----------

// ---------- FUNCTIONS --------------
GetTFSeconds() =>
    (time - time[1]) / 1000
GetTFMinutes() =>
    GetTFSeconds() / 60
TFIsCorrect = GetTFMinutes() <= HideTFAbove
TFIsCorrect_asia = GetTFMinutes() <= HideTFAbove_asia
// ---------

GetSessionHighLow(session_active, start) =>
    var hh = high
    var ll = low

    if session_active == 1
        if high > hh or start
            hh := high
            hh
        if low < ll or start
            ll := low
            ll
    [hh, ll]
// ----------------------------------------------------------------------------------//

CreateSessionBoxT(start_T, hours, session_active, h, l, fillColor, drawLines, lineColor) =>
    if session_active == 1
        int timeDelta = time - time[1]
        int endShift  = hours * 60 * 1000
        // int endShift = hours * 60 * 60 * 1000
        box_dev = box.new(left=start_T, bottom=l, top=h, right=start_T + endShift, xloc=xloc.bar_time, bgcolor=fillColor, border_color=color.new(#000000, 100))
        if session_active[1] == 1
            box.delete(box_dev[1])
        if drawLines
            m = (h + l) / 2
            h_line = line.new(x1=start_T, y1=h, x2=start_T + endShift * 2, y2=h, xloc=xloc.bar_time, color=lineColor, width=1)
            m_line = line.new(x1=start_T, y1=m, x2=start_T + endShift * 2, y2=m, xloc=xloc.bar_time, color=lineColor, width=1)
            l_line = line.new(x1=start_T, y1=l, x2=start_T + endShift * 2, y2=l, xloc=xloc.bar_time, color=lineColor, width=1)
            if session_active[1] == 1
                line.delete(h_line[1])
                line.delete(m_line[1])
                line.delete(l_line[1])
// ----------------------------------------------------------------------------------//

// -------- FUNCTIONS END -----------------------------------------------------------//

var asia_hours = 475
var lon_hours  = 60
var nyt_hours  = 60

// -------- UTC ---------------------------------------------------------------------//
UTC_minus_7 = 'UTC-7'

// -------- DLS and timing 2022 -----------------------------------------------------//
start_22_summer     = timestamp('UTC-7', 2022, 03, 26, 00, 00, 00)
end_22_summer       = timestamp('UTC-7', 2022, 10, 29, 23, 59, 00)
start_22_dls_autumn = timestamp('UTC-7', 2022, 10, 30, 00, 00, 00)
end_22_dls_autumn   = timestamp('UTC-7', 2022, 11, 05, 23, 59, 00)
start_23_spring     = timestamp('UTC-7', 2023, 03, 12, 00, 00, 00)
end_23_spring       = timestamp('UTC-7', 2023, 03, 25, 23, 59, 00)
start_23_summer     = timestamp('UTC-7', 2023, 03, 26, 00, 00, 00)
end_23_summer       = timestamp('UTC-7', 2023, 10, 29, 23, 59, 00)

// -------- Forex or not ------------------------------------------------------------//
current_symbol = syminfo.type

asia_timing_14 = "1405-2200:123456"
asia_timing_15 = "1505-2300:123456"

if current_symbol   != 'forex'
    asia_timing_14  := "1505-2200:123456"
    asia_timing_15  := "1605-2300:123456"
    asia_hours      := 415

time_now = time

// Winter time ----------------------------------------------------------------------//
t_asia  = time(timeframe.period, asia_timing_15,       UTC_minus_7)
t_ff    = time(timeframe.period, '0000-0100:23456', UTC_minus_7)
t_lon   = time(timeframe.period, '0100-0200:23456', UTC_minus_7)
t_nyt   = time(timeframe.period, '0600-0700:23456', UTC_minus_7)

// Summer 2022
if time_now <= end_22_summer and time_now >= start_22_summer
    t_asia  := time(timeframe.period, asia_timing_14, UTC_minus_7)
    t_ff    := time(timeframe.period, '2300-2401:23456', UTC_minus_7)
    t_lon   := time(timeframe.period, '0000-0100:23456', UTC_minus_7)
    t_nyt   := time(timeframe.period, '0500-0600:23456', UTC_minus_7)

// Autumn 2022
if time_now <= end_22_dls_autumn and time_now >= start_22_dls_autumn
    t_asia  := time(timeframe.period, asia_timing_14, UTC_minus_7)
    t_nyt   := time(timeframe.period, '0500-0600:23456', UTC_minus_7)

// Spring 2023
if time_now <= end_23_spring and time_now >= start_23_spring
    t_asia  := time(timeframe.period, asia_timing_14, UTC_minus_7)
    t_nyt   := time(timeframe.period, '0500-0600:23456', UTC_minus_7)

// Summer 2023
if time_now <= end_23_summer and time_now >= start_23_summer
    t_asia  := time(timeframe.period, asia_timing_14, UTC_minus_7)
    t_lon   := time(timeframe.period, '0000-0100:23456', UTC_minus_7)
    t_nyt   := time(timeframe.period, '0500-0600:23456', UTC_minus_7)


// ----------------------------------------------------------------------------------//
//                    end                                                            //
// ----------------------------------------------------------------------------------//

// Active Session Conditions --------------------------------------------------------//
asia_session_active = TFIsCorrect_asia and show_asia      ? not na(t_asia)  ? 1 : 0 : 0
lon_session_active  = TFIsCorrect      and show_lon       ? not na(t_lon)   ? 1 : 0 : 0
nyt_session_active  = TFIsCorrect      and show_nyt       ? not na(t_nyt)   ? 1 : 0 : 0


// Session Starting Points ----------------------------------------------------------//
asia_start = asia_session_active[1] == 0 and asia_session_active == 1 ? 1 : 0
lon_start  = lon_session_active[1]  == 0 and lon_session_active  == 1 ? 1 : 0
nyt_start  = nyt_session_active[1]  == 0 and nyt_session_active  == 1 ? 1 : 0

// Session Highs & Lows -------------------------------------------------------------//
[asia_h, asia_l] = GetSessionHighLow(asia_session_active, asia_start)
[lon_h, lon_l]   = GetSessionHighLow(lon_session_active, lon_start)
[nyt_h, nyt_l]   = GetSessionHighLow(nyt_session_active, nyt_start)

// Session Box Drawing Function -----------------------------------------------------//
asia_time_start  = int(na)
lon_time_start   = int(na)
nyo_time_start   = int(na)
nyt_time_start   = int(na)
asia_time_start := asia_start ? time : asia_time_start[1]
lon_time_start  := lon_start  ? time : lon_time_start[1]
nyt_time_start  := nyt_start  ? time : nyt_time_start[1]


CreateSessionBoxT(asia_time_start, asia_hours, asia_session_active, asia_h, asia_l, asia_color, true, asia_line_color)
CreateSessionBoxT(lon_time_start,  lon_hours,  lon_session_active,  lon_h,  lon_l,  lon_color,  false, #000000)
CreateSessionBoxT(nyt_time_start,  nyt_hours,  nyt_session_active,  nyt_h,  nyt_l,  nyt_color,  false, #000000)

// ----------- YHL,WHL ---------------------------------------------------------------//
// Inputs
i_displayLast = input(false, 'Display on current only')

// Variable -------------------------------------------------------------------------//
yesterdayHigh  = request.security(syminfo.tickerid, 'D', high[1], lookahead=barmerge.lookahead_on)
yesterdayLow   = request.security(syminfo.tickerid, 'D', low[1], lookahead=barmerge.lookahead_on)
yesterdayClose = request.security(syminfo.tickerid, 'D', close[1], lookahead=barmerge.lookahead_on)
weeklyHigh     = request.security(syminfo.tickerid, 'W', high[1], lookahead=barmerge.lookahead_on)
weeklyLow      = request.security(syminfo.tickerid, 'W', low[1], lookahead=barmerge.lookahead_on)

isLastBar      = request.security(syminfo.tickerid, '', barstate.islast, lookahead=barmerge.lookahead_on)
plotCondition(_price) =>
    i_displayLast ? isLastBar ? _price : na : _price


// Plots ----------------------------------------------------------------------------//
plot(plotCondition(weeklyHigh), 'Weekly high', color.new(color.green, 0), style=plot.style_circles, display=display.none)
plot(plotCondition(weeklyLow), 'Weekly low', color.new(color.red, 0), style=plot.style_circles, display=display.none)
plot(plotCondition(yesterdayHigh), 'Yesterday\'s high', color.rgb(48, 193, 236), style=plot.style_circles, display=display.none)
plot(plotCondition(yesterdayLow), 'Yesterday\'s low', color.rgb(48, 193, 236), style=plot.style_circles, display=display.none)
plot(plotCondition(yesterdayClose), 'Day Open', color.new(color.gray, 0), style=plot.style_cross, display=display.none)

Overview

LIT - Timing renders customizable boxes alongside horizontal projection lines representing the high, low, and midpoint for the Asian, London, and New York trading sessions. Users can toggle specific sessions, adjust box colors, and set a maximum timeframe threshold to hide overlays on higher charts.

Details

Published by

rpanchyk on GitHub

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

Sessions & time, Support & resistance, SMC / ICT / price action

Markets

Forex

Timeframes

M1-M5, M15-H1

Risk Notes

  • Reads higher-timeframe data with lookahead on, so the history can show signals that were not there in real time

Topics

forexindicatormt5mql

Settings

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

SettingTypeDefaultVariable
Hide Boxes on TF above (Minutes)int59HideTFAbove
Show Asian Sessionbooltrueshow_asia
Show London Sessionbooltrueshow_lon
Show NY Sessionbooltrueshow_nyt
Asian Fill Colorcolorcolor.new(color.rgb(152, 0, 255), 90)asia_color
Asian Line Colorcolorcolor.new(color.rgb(152, 0, 255), 70)asia_line_color
London Fill Colorcolorcolor.new(color.rgb(67, 70, 81), 90)lon_color
NY Fill Colorcolorcolor.new(color.rgb(67, 70, 81), 90)nyt_color
Display on current onlyboolfalsei_displayLast
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

Golden Bullet Strategy

by TradersPost
218 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

This indicator detects and draws the first Fair Value Gap (FVG) that forms in each hourly session based on a selected lower timeframe, with specialized handling for Regular Trading Hours (RTH) confluence windows. It draws FVG range boxes, midpoint lines, hourl

Indicator v5 SMC / ICT / price actionSupport & resistance Repaints

This indicator combines six trading tools into a single chart overlay to optimize indicator limits. It calculates Bollinger Bands, projects weekend price boundaries, plots market structure elements like order blocks, breaker blocks, and MSB lines, marks New Yo

Indicator v6 Support & resistanceSMC / ICT / price action Repaints
19 stars

This indicator highlights Inner Circle Trader (ICT) killzones and key session pivot points directly on the price chart. It projects shaded boxes for specific trading sessions, including Asia, London, NY AM, NY Lunch, and NY PM, to help traders identify high-li

Indicator v5 SMC / ICT / price actionSessions & time
Updated 3 years ago · MIT GitHub repository of ICT Killzones & Pivots

Bandz Session Ranges + ORG + Opening Prices plots trading session ranges, killzones, opening RTH gaps, standard deviation projections, and key opening prices directly on the price chart. It calculates gap ranges based on prior regular trading hours close sourc

Indicator v6 Sessions & timeSupport & resistance
Updated 2 weeks ago · MPL-2.0 GitHub repository of Bandz Session Ranges + ORG + Opening Prices

More indicators

Trade Your Charts With a Regulated Broker

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

Compare brokers