anandanand84 / technicalindicators

A javascript technical indicators written in typescript with pattern recognition right in the browser
MIT License
2.15k stars 558 forks source link

VWAP.ts 'period' parameter is ignored #89

Closed paroxysm closed 6 years ago

paroxysm commented 6 years ago

VWAPInput takes a 'period' parameter, however in the actual code for calculation, it's never used. The correct behavior would be to assert that the length of the lows/highs/closes arrays should at least equal to 'period'. Then iterating over the lows to calculate the vwap, the algorithm should consider AT MOST 'period' values. Right now it considers all the values passed(even if their length > period)

anandanand84 commented 6 years ago

@paroxysm I think the indicator is working as expected. I should the remove the period parameter in the input.

paroxysm commented 6 years ago

Yes because it's misleading, that means it's up to the user to limit the number of inputs to 'period' rather than expecting the algorithm to. But this is inconsistent with other indicators such as RSI which DO limit calculations to 'period' values.

anandanand84 commented 6 years ago

Fixed