Open JanHomann opened 1 year ago
@JanHomann
I see. 🤔
One way to achieve this would be to first compute the rolling z-score of the closing prices ...
Since we have the whole candle (ohlc), what about using hl2 or oc2 or ohlc4 instead of close? Wouldn't one of those mean values be better? Thoughts?
Kind Regards, KJ
Problem Description
The current implementation of
cdl_z()
often createslow
values that are higher than the open, close or high andhigh
values that are lower than the open, close or low.Example
Expected Behavior
As you can see in the example above, the last row has an
open
that is lower than thelow
(0.334565 < 0.360631) and aclose
that is higher than thehigh
(1.1173 > 0.725941). This happens a lot, see two rows higher. Three rows higher thelow
is even higher than thehigh
. This can be easily seen in any dataset, no need to exactly use the data in this example.Additional Context
This seems to be related to the way the computation is performed. In the computation, the time series for
open
,high
,low
andclose
are independently z-scored, but they need to be z-scored together OR theopen
high
low
close
need to be reassigned.One way to achieve this would be to first compute the rolling z-score of the closing prices and then construct rescaled candles that have at least the property that the relative position of the open stays like it was before the z-scoring. (meaning that if we gapped up, we should still gap up in the z-scored version and not gap down suddenly just because of the z-scoring).