Code Library / Session/Time

Pine Script Session Highlighter

Highlight Asian, London, and NY sessions.

Language: Pine Script · Category: Session/Time · Tags: session, highlighter, Pine Script, London, New York

Source code

//@version=5
indicator("Sessions",overlay=true)
bgcolor(time(timeframe.period,"0000-0900:1234567","GMT")?color.new(color.yellow,92):na,"Asian")
bgcolor(time(timeframe.period,"0700-1600:1234567","GMT")?color.new(color.blue,92):na,"London")
bgcolor(time(timeframe.period,"1300-2200:1234567","GMT")?color.new(color.green,92):na,"NY")

How to use this snippet

This is a building block, not a finished trading system. Paste it into your own Pine Script project, compile it, and test it on a demo account with your broker's real spreads before relying on it. You can convert it to MQL4 or MQL5 with the Pine Script converter.

Related snippets