Git Product home page Git Product logo

debut-js / indicators Goto Github PK

View Code? Open in Web Editor NEW
322.0 9.0 51.0 5.11 MB

Technical indicators for cryptocurrencies, stocks and forex. To work with historical and real price data. One of the most efficient Javascript library implementations. The library has such indicators as: Relative Strength Index (RSI), Moving Average C / D (MACD), Average Directional Index (ADX), Stochastic Oscillator, Bollinger Bands, Average True Range (ATR) and many others

TypeScript 99.78% JavaScript 0.22%
tradingview technical-indicators candlestick trading-indicator ema bollinger-bands cryptocurrency exchange trading-strategies bitfinex

indicators's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

indicators's Issues

MFI indicator

Feature Request: Add Money Flow Index (MFI) Indicator

Description

Your library currently lacks the Money Flow Index (MFI) indicator, which is a standard indicator available on the Metatrader platform.

The Money Flow Index (MFI) is a technical oscillator that uses price and volume data to identify overbought or oversold signals in an asset. It can also be used to spot divergences that warn of a trend change in price. The oscillator moves between 0 and 100.

Request

It would be greatly appreciated if you could include the MFI indicator in your library. This addition would enhance the functionality and provide users with a valuable tool for technical analysis.

Thank you for considering this request.

momentValue undefined on period-matching count

Create SMA(10) and add 9 numbers, using nextValue(). Now the 10th value is added via momentValue(). Currently, this leads to undefined, which is also proven by code review.

The 10th added momentValue() must result in a "momentally" of the 10th next-value pendant. Only after the SMA (and other indicators) are lifted over their undefined states, incoming moment-values are suitable.

ATR sometimes return undefined value

Problem:

If the same low, close and high values are passed to the ATR indicator, the result will be undefined.

const atr = new ATR(14)
const result = atr.nextvalue(10, 10, 10) // undefined

Potential Solve:

This is due to the fact that you need to do a check after getting the result of the work getTrueRange on trueRange === null because value is 0 its normal result, but getTrueRange return null only if not provided prevClose argument

https://github.com/debut-js/Indicators/blob/master/src/atr.ts#L42

smaSlowValue always undefined

HI, first off thanks for this. I wish I could help on docs - maybe if i get around to understand how this work i might document it :D

I am trying your AO example 1:1 but it's not working. I am passing a dataset i get from tradinview of btc but I get nothing, the result is undefined and I noticed inside the nextValue method , smaFast value do get a value after a couple of entries, but the slow one returns always undefined... Why is that?

Trendlines

Thanks for providing this excellent package!
I noticed that you have a sub-project in a folder for trend lines.
What is the status, since you didnt include it in the description of this project?
Are you still using it, or did you abandon it and therefore not include it?

Supertend - different values comparing with Tradingview

BTCUSDT Perpetual - 1 day - ST (period = 10, multiplier = 3)

https://www.tradingview.com/chart/?symbol=BINANCE%3ABTCUSDTPERP

2022-07-01 H: 20926.4 L: 18948.8 C: 19272 Supertrend-Debut: undefined Supertend-TW: 23675.0
2022-07-02 H: 19456 L: 18959 C: 19240.9 Supertrend-Debut: undefined Supertend-TW: 23382.5
2022-07-03 H: 19645.4 L: 18780.1 C: 19305.9 Supertrend-Debut: undefined Supertend-TW: 23229.8
2022-07-04 H: 20350 L: 19046.3 C: 20226.6 Supertrend-Debut: undefined Supertend-TW: 23229.8
2022-07-05 H: 20749.2 L: 19291.6 C: 20170 Supertrend-Debut: undefined Supertend-TW: 23229.8
2022-07-06 H: 20667.6 L: 19753 C: 20554.1 Supertrend-Debut: undefined Supertend-TW: 23229.8
2022-07-07 H: 21830 L: 20244.9 C: 21613.4 Supertrend-Debut: undefined Supertend-TW: 23229.8
2022-07-08 H: 22579.9 L: 21175.2 C: 21587.9 Supertrend-Debut: undefined Supertend-TW: 23229.8
2022-07-09 H: 22000 L: 21309.6 C: 21580 Supertrend-Debut: undefined Supertend-TW: 23229.8
2022-07-10 H: 21594.2 L: 20600 C: 20853.8 Supertrend-Debut: undefined Supertend-TW: 23229.8
2022-07-11 H: 20853.9 L: 19870 C: 19954.3 Supertrend-Debut: 23570.9 Supertend-TW: 23229.8
2022-07-12 H: 20048.9 L: 19228.3 C: 19322.9 Supertrend-Debut: 22772.835 Supertend-TW: 23179.9
2022-07-13 H: 20401.6 L: 18901 C: 20220.1 Supertrend-Debut: 22772.835 Supertend-TW: 23179.9
2022-07-14 H: 20900 L: 19600 C: 20578.6 Supertrend-Debut: 22772.835 Supertend-TW: 23179.9
2022-07-15 H: 21200 L: 20364.3 C: 20823.1 Supertrend-Debut: 22772.835 Supertend-TW: 23179.9
2022-07-16 H: 21580 L: 20471 C: 21183.5 Supertrend-Debut: 22772.835 Supertend-TW: 23179.9
2022-07-17 H: 21674.1 L: 20742 C: 20794.4 Supertrend-Debut: 22772.835 Supertend-TW: 23179.9
2022-07-18 H: 22800 L: 20764.4 C: 22423.9 Supertrend-Debut: 22772.835 Supertend-TW: 23179.9
2022-07-19 H: 23817.9 L: 21575 C: 23385.9 Supertrend-Debut: 18871.8084752485 Supertend-TW: 18702.9
2022-07-20 H: 24277 L: 22912.4 C: 23221.5 Supertrend-Debut: 19743.14262772365 Supertend-TW: 19567.9
2022-07-21 H: 23441.1 L: 22340.2 C: 23144.5 Supertrend-Debut: 19743.14262772365 Supertend-TW: 19567.9
2022-07-22 H: 23750 L: 22500 C: 22675.1 Supertrend-Debut: 19743.14262772365 Supertend-TW: 19567.9
2022-07-23 H: 22990 L: 21933.5 C: 22440.2 Supertrend-Debut: 19743.14262772365 Supertend-TW: 19567.9
2022-07-24 H: 22999 L: 22256.4 C: 22570.6 Supertrend-Debut: 19743.14262772365 Supertend-TW: 19567.9
2022-07-25 H: 22656.8 L: 21232 C: 21300 Supertrend-Debut: 19743.14262772365 Supertend-TW: 19567.9
2022-07-26 H: 21334.4 L: 20689.6 C: 21241 Supertrend-Debut: 19743.14262772365 Supertend-TW: 19567.9
2022-07-27 H: 23100 L: 21031 C: 22941.1 Supertrend-Debut: 19743.14262772365 Supertend-TW: 19567.9
2022-07-28 H: 24194.6 L: 22583.1 C: 23836.2 Supertrend-Debut: 19743.14262772365 Supertend-TW: 19567.9
2022-07-29 H: 24500 L: 23426.3 C: 23771.1 Supertrend-Debut: 20168.013285324443 Supertend-TW: 20100.1
2022-07-30 H: 24700 L: 23505 C: 23629.9 Supertrend-Debut: 20328.376956791995 Supertend-TW: 20267.3
2022-07-31 H: 24187.3 L: 23222 C: 23290.1 Supertrend-Debut: 20328.376956791995 Supertend-TW: 20267.3

Supertrend values are quite different from what is published on Tradingview. Also direction is completely wrong based on this data.

Please advise if i'm doing something wrong beacuse i don't get the same values.

Migrate to min max heap structure in core calculations

Min/Max Head a specialised data structure that described here.

Lets to try to implement something like that kind of heap and that potentially might improve the performance for worst situations when we have same extremums and we need to loop full array to find a new one extremum (max/min)

Request add StochasticRSI

Hi,

Can you add StochasticRSI indicator like technicalindicators? But the usage is the same as yours.

Thank you.

How to work with ccxt OHLCV?

how to work with data like this? please show me some example with ema or sma

[
[ 1635435180000, 4177.79, 4181.47, 4176.42, 4181.01, 141.193 ],
[ 1635435240000, 4181.01, 4184.96, 4180.5, 4184.91, 593.7 ],
[ 1635435300000, 4184.92, 4185.2, 4182.08, 4183.29, 936.606 ],
[ 1635435360000, 4183.29, 4184.92, 4183.28, 4184.29, 270.19 ],
[ 1635435420000, 4184.28, 4184.7, 4182.03, 4183.48, 259.201 ]
]

RSI sometimes returns undefined instead of a RSI value

let closes = [
    1.59,
    1.65,
    1.65,
    1.65,
    1.65,
    1.65,
    1.65,
    1.65,
    1.65,
    1.65,
    1.65,
    1.65,
    1.65,
    1.65,
    1.65,
    1.6,
    1.6,
    1.6,
    1.6,
    1.6,
    1.6,
    1.6,
    1.6,
]

let rsi = new RSI(14)
closes.forEach(c  => console.log(rsi.nextValue(c)))

Gives the following output instead of the real RSI values:

undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined
100
undefined
undefined
undefined
undefined
undefined
undefined
undefined
undefined

I can't calculate in case realtime

Hi admin,

I try to use your indicators, everything is good but when I run it on websocket and I want to get sma in 5minutes, there are a lot of CLOSE value in 5m and your indicator is wrong maybe it push new value to buffer instead on update last value in last element in buffer.

Please help review your indicator when run on websocket.

Thanks.

WMA: momentValue commented out

It looks like WMA does not implement the momentValue. Is this as simplel as:

momentValue(value: number) {
        if (!this.buffer.filled) {
            return;
        }

        let result = 0;

        this.buffer.forEach((v, idx) => {
            result += (v * (idx + 1)) / this.denominator;
        });

        return result;
}

momentValue(value: number) {

RSI values slightly different than TradingView or Webull

I tried to calculate RSI from the chart data, but unfortunately the values I got from the RSI are not matching that what I see on the charts of the popular trading platforms.
They are using some weighting in the SMA calculation, they call it RMA(SMA for RSI I guess).
Is there a way to have this RMA as the moving average source in RSI implementation?

Indicators description and examples

Need some help with documentation pages, like this one for AcceleratorOscillator, that should be linked to main ReadMe.md indicators list.

Any PR's with documentations or examples welcome!

Each indicator in list should be a link
image

MACD

Some of the indicators simply return undefined values. See this simple example, why are all the values undefined?

const { MACD } = require('@debut/indicators');

const values = [127.75, 129.02, 132.75, 145.40, 148.98, 137.52, 147.38, 139.05, 137.23, 149.30, 162.45, 178.95, 200.35, 221.90, 243.23, 243.52, 286.42, 280.27, 277.35, 269.02, 263.23, 214.90];

const macd = new MACD();
values.forEach((value) => {
  const nextValue = macd.nextValue(value);
  console.log(nextValue);
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.