Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sma always returns null #262

Open
csidi90 opened this issue Nov 23, 2022 · 1 comment
Open

sma always returns null #262

csidi90 opened this issue Nov 23, 2022 · 1 comment

Comments

@csidi90
Copy link

csidi90 commented Nov 23, 2022

I am using a bunch of indicators of this module, but the sma always returns me a null no matter what I enter. I am using it the same way I use the ema and wma both work.

` export function SMA(
ohlcv: ccxt.OHLCV[],
period: number,
getLastValue: boolean,
) {
const close = ohlcv.map((candle) => candle[CandleIndex.CLOSE]);
const result = technicalindicators.sma({ values: close, period: period });

const lastVal = result[result.length - 1];
if (getLastValue)
return {
name: 'SMA',
description: 'Simple Moving Average',
options: { period: period },
result: lastVal,
};
return {
name: 'SMA',
description: 'Simple Moving Average',
options: { period: period },
result: result,
};
}
`

@csidi90
Copy link
Author

csidi90 commented Nov 23, 2022

when I log the whole result I get values, but the last value inside the array is always null. For EMA its not like that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant