bennycode / trading-signals

Technical indicators to run technical analysis with JavaScript & TypeScript. 📈
https://bennycode.com/trading-signals
MIT License
621 stars 90 forks source link

How to remove old datas #672

Closed emmtte closed 6 months ago

emmtte commented 6 months ago

Hi and thanks for this great library

A general question about all technicals indicators.

How to limit the size of data ?

Exemple, I want only add max 500 values for calculations.

How to limit this ? What is the command to remove the first element of the values ?

bennycode commented 6 months ago

Hi @emmtte and thank you! If you want to limit the size of data per indicator, simply init the indicator with the size limit.

Example: This limits the SMA to 3 values:

const sma = new SMA(3);

There is no command to remove the first element pushed to an indicator. You can only replace the latest value.

emmtte commented 6 months ago

Sorry to bother you, but in your exemple is the 3 corresponding to a period of 3 ? I have used https://tulipindicators.org/sma and there a difference between the size of the datas with the same period to calculate the SMA. For exemple there is a different with a size of 500 compared to a size of 100 with the a period of 3 How to set period ?