Open and Close price are identical?

@Nikola I am not sure if I am doing anything wrong but the open and close price in the Debugger always shows the same value?
image
Sorry I can only post one image but no matter what time frame I use it is always the same.

Thanks in advance!

1 Like

This is expected.

It’s covered in the docs here and here.

The time you’re seeing in the debugger is of the “open bar” for which the script executes. This “open bar” does not have high, low and close prices. These are taken from the previous bar.

Of course I’ve put “open bar” in quotes as, in reality, the bar is closed as it is in the past, however this “bar opening” behaviour is simulated for the backtest/debugging, as explained in the docs.

2 Likes

Thanks for your reply! I will check out the docs.

The docs say that all data other than open are from the previously closed data set and it makes total sense. But it doesn’t make sense that the open and close value are always the same. Most open values on volatile stocks are different than the last closing value.
I would detect gaps by comparing open and close.

# 1% gap up series
series gapUp:
  once: false
  then: open / close > 1.01 # <-- doesn't work, must use close[1]  WHY?

The way we currently build our candles does not include preserving gaps, unfortunately.

We understand that this information is important and we’re already working on separating the opening price from the closing price.

Unfortunately, this won’t be a retroactive change, meaning that only new adjacent candles will (possibly) have gaps between their closing and opening prices.

P.S. Your “gapUp” custom series does not need to be a custom series. Simply writing gapUp = open / close > 1.01 would do the same job. Any expression that consists of at least one series (in this case open and close are both series) automatically becomes a series itself and you can access its previous values by time travelling with the [] operator.

1 Like