Certainly! Here's a TradingView Pine Script indicator that highlights the Asian and London trading sessions on the chart, marks their high and low with boxes, and provides a movable checklist label that you can position anywhere on the chart.
//@version=5
indicator("Asian and London Sessions with High/Low Boxes and Checklist", overlay=true)
// Inputs for session times
asianSession = input.session("0000-0900", "Asian Session Time")
londonSession = input.session("0700-1600", "London Session Time")
// Determine if we're in Asian or London session
inAsianSession = not na(time(timeframe.period, asianSession))
inLondonSession = not na(time(timeframe.period, londonSession))
// Variables to store session high, low, and start time
var float sessionHighAs = na
var float sessionLowAs = na
var int sessionStartAs = na
var float sessionHighLo = na
var float sessionLowLo = na
var int sessionStartLo = na
// Detect session transitions
wasInAsianSession = nz(inAsianSession[1], false)
wasInLondonSession = nz(inLondonSession[1], false)
startOfAsianSession = inAsianSession and not wasInAsianSession
endOfAsianSession = not inAsianSession and wasInAsianSession
startOfLondonSession = inLondonSession and not wasInLondonSession
endOfLondonSession = not inLondonSession and wasInLondonSession
// Update and reset session high and low for Asian session
if startOfAsianSession
sessionHighAs := high
sessionLowAs := low
sessionStartAs := time
if inAsianSession
sessionHighAs := math.max(sessionHighAs, high)
sessionLowAs := math.min(sessionLowAs, low)
if endOfAsianSession
sessionEndAs = time[1]
// Draw the box for Asian session
box.new(
x1 = sessionStartAs, y1 = sessionHighAs,
x2 = sessionEndAs, y2 = sessionLowAs,
xloc = xloc.bar_time, border_color = color.green, border_width = 1, bgcolor = color.new(color.green, 80)
)
// Update and reset session high and low for London session
if startOfLondonSession
sessionHighLo := high
sessionLowLo := low
sessionStartLo := time
if inLondonSession
sessionHighLo := math.max(sessionHighLo, high)
sessionLowLo := math.min(sessionLowLo, low)
if endOfLondonSession
sessionEndLo = time[1]
// Draw the box for London session
box.new(
x1 = sessionStartLo, y1 = sessionHighLo,
x2 = sessionEndLo, y2 = sessionLowLo,
xloc = xloc.bar_time, border_color = color.gray, border_width = 1, bgcolor = color.new(color.gray, 80)
)
// Color the background during sessions
bgcolor(inAsianSession and not inLondonSession ? color.new(color.green, 90) : na)
bgcolor(inLondonSession and not inAsianSession ? color.new(color.gray, 90) : na)
bgcolor(inAsianSession and inLondonSession ? color.new(color.teal, 90) : na) // If sessions overlap
// Inputs for the checklist label position
xOffset = input.int(title="Checklist X Offset (bars)", defval=5, minval=-500, maxval=500)
yOffset = input.float(title="Checklist Y Offset (price units)", defval=1.0)
// Create the checklist label at the desired position
var label checklistLabel = na
if barstate.islast
label.delete(checklistLabel)
checklistText = "Checklist:\n- Item 1\n- Item 2\n- Item 3" // Customize your checklist items here
labelX = bar_index + xOffset
labelY = high + yOffset
checklistLabel := label.new(
x = labelX, y = labelY, text = checklistText,
xloc = xloc.bar_index, yloc = yloc.price,
style = label.style_label_left, textcolor = color.black,
color = color.new(color.white, 0)
)
Features:
- Session Highlighting: The script colors the background green during the Asian session and gray during the London session. If both sessions overlap, it uses a teal color.
- High/Low Boxes: At the end of each session, it draws a box that spans from the session's high to low and from the session's start to end time.
- Customizable Checklist: A checklist label is displayed on the chart. You can adjust its position using the "Checklist X Offset (bars)" and "Checklist Y Offset (price units)" inputs. Modify the
checklistText variable to include your own checklist items.
Instructions:
- Apply the Indicator: Copy and paste the code into a new indicator in TradingView's Pine Script editor and apply it to your chart.
- Adjust Session Times (Optional): If you wish to change the session times, you can adjust the "Asian Session Time" and "London Session Time" inputs to match your preferred session hours.
- Customize the Checklist:
- Change the
checklistText variable to include the items you want in your checklist.
- Use the "Checklist X Offset (bars)" to move the checklist left or right.
- Use the "Checklist Y Offset (price units)" to move the checklist up or down.
Note:
- The offsets for the checklist are relative to the current bar. Positive values for
xOffset move the label into the future (to the right), while negative values move it to the past (to the left).
- The
yOffset moves the label up (positive values) or down (negative values) relative to the current bar's high price.
Feel free to customize the colors, session times, and checklist items as needed for your trading strategy.