'First Candle closing price

I want to get close of the first morning candle when i enter close it returns last candle close value. How can I get closing price of the first morning candle in five minute chart? (9.15 to 9.20)



Solution 1:[1]

The next code plots close of a first bar of a session.

//@version=4
study("Close of first bar of a day")
// If start of the daily session changed, then it's first bar of the new session
isNewDay = time("D") != time("D")[1]
var firstBarCloseValue = close
if isNewDay
    firstBarCloseValue := close
plot(firstBarCloseValue)

Sources

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

Source: Stack Overflow

Solution Source
Solution 1 Michel_T.