1.0.2 • Published 8 months ago

zero-lag-ma v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

zero-lag-ma

NPM Version License

ZLEMA is a specialized variant of EMA that excels at reducing lag in moving averages.

De-Lagged Data 🔄

ZLEMA works with "de-lagged" data, removing older data points to reduce cumulative effects and improve responsiveness.

Applications 💡

  • Regular EMA: Use standard EMA for financial data but accept lag.
  • ZLEMA: Remove past data influence for quick response in financial analysis.

ZLEMA provides a smoother, timely representation of data trends, ideal for various analytical and forecasting needs.

For details, see Wikipedia's ZLEMA page.

Install 🛠️

$ npm i zero-lag-ma
# or
$ yarn add zero-lag-ma

Note: To run this library successfully, you'll need a transpiler to convert its modern JavaScript code.

Usage 🚀

You can use the zlema function from the zero-lag-ma library to calculate the Zero-Lag Exponential Moving Average (ZLEMA) of an input array. Here are some examples of how to use it:

import {zlema} from "zero-lag-ma"

// Calculate ZLEMA with a lookback length of 2
const result1 = zlema([1, 2, 3, 4, 5], 2)
// Result: [1, 1.66, 2.55, 3.51, 4.50]

// Calculate ZLEMA with a lookback length of 4
const result2 = zlema([1, 2, 3, 4, 5], 4)
// Result: [undefined, 3, 3.4, 4.04, 4.824]

// When the lookback length is greater than the array length, it returns an array of undefined values
const result3 = zlema([1, 2, 3, 4, 5], 5)
// Result: [5x undefined]

const result4 = zlema([1, 2, 3, 4, 5, 6, 7], 5)
// Result: [undefined, undefined, 5, 5.33, 5.88, 6.59, 7.39]

// When the lookback length is less than 1 (or equal), it returns the untouched input array
const result5 = zlema([1, 2, 3, 4, 5], 0.5)
// Result: [1, 2, 3, 4, 5]

// When the lookback length is bigger than the length of the array, it returns an empty array
const result6 = zlema([1, 2, 3, 4, 5], 200)
// Result: [5x undefined]

Contributing 🤝

We welcome contributions to improve this library. Here's how:

  • Report Issues: If you find a bug or have suggestions, open an issue on GitHub.
  • Pull Requests: Fork, make changes, and create a PR to the main branch.
  • Code Guidelines: Follow coding conventions and style guidelines.
  • Testing: Include tests for new features or changes.
  • Documentation: Update docs if needed.

Your contributions help make this library better for everyone. Thank you! 🙌

License 📝

This project is available under the MIT License.

1.0.2

8 months ago

1.0.1

1 year ago

1.0.0

1 year ago