'Pine Script: How to determine how many bars back was the last session close?

I have written a pretty complex code for my strategy and I need to figure out how to determine how many bars back the last forex session daily close happened regardless of chart timeframe? i.e how many bars back was the session close in 5m, 15m, or 1hr charts. I can't for the life of me figure it out. I've tried barssince, bars_index, etc. If anyone can help me with this that would be great and I can move forward with the rest of my code. Thank you.

ADDED: I found this code online but I get a Syntax error at input '=>'.

f_isLastBar() =>
    t = time("1440", session.regular) // Resolution of 1440 = 60*24 minutes in a whole day
    not na(t[1]) and na(t) or t[1] < t

if f_isLastBar()
    label.new(bar_index[1], high, "Last Bar")enter code here


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source