0

I am trying to code an indicator to measure the Gap between the previous day close and new day opening bar in pinescript. My script works for markets that operate on regular session but when I use it on futures contract, it gives me a different close value than the US regular session for the ES contract.

//@version=5

t = ticker.new(syminfo.prefix ,syminfo.tickerid, session.regular)
PDC = request.security(t,"D", close[1]) 
CDO = request.security(t,"D", open)

GAP = CDO - PDC

I get a different value than I expect

1 Answers1

0

This should give you the previous close.

previousClose = close[1]