cinar / indicatorts

IndicatorTS - Stock technical indicators and strategies in TypeScript for browser and server programs.
MIT License
283 stars 48 forks source link

ATR is calculated wrongly #422

Closed pristas-peter closed 6 months ago

pristas-peter commented 6 months ago

Describe the bug ATR is calculated wrongly

Function atr (average true range) returns the RMA of true range. True range is max(high - low, abs(high - close[1]), abs(low - close[1])).

whereas this library is subtracting values from the same day

Expected behavior The close prices should taken from close price from previous day.

cinar commented 6 months ago

An attempt to fix the True Range calculation. I am still not happy with the way the first value is getting calculated, but that is something that needs to be changed across the whole library at this point.

@pristas-peter please take a look.