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

this bugging me for so long about how this script works like this reeeeeeee xD ahahaha #237

Open
gurachan opened this issue May 27, 2021 · 1 comment

Comments

@gurachan
Copy link

gurachan commented May 27, 2021

so in rsi. if u give it a 500 array it returns 486. but why.. how can I align it per candles..

its has same value as tradingview.. the end of the 486 matches the end of the candle from traiding view..

what happen to other 14 do i just put 0 on it? in the start?.. also some of it is inacurate

..........

also same as macd ... and also its returning inacurate result also

example data

  let test = [
        2197.3325,
        2196.625,
        2226.4525,
        2226.4925,
        2210.8275,
        2222.9024999999997,
        2241.5675,
        2289.91,
        2327.7225,
        2341.94,
        2355.76,
        2334.8575,
        2321.235,
        2356.435,
        2361.9725,
        2348.19,
        2341.2200000000003,
        2384.4249999999997,
        2444.0074999999997,
        2454.2225,
        2433.7625,
        2419.1,
        2410.9125,
        2412.4025,
        2406.4025,
        2427.0675,
        2404.925,
        2401.725,
        2427.9575,
        2452.55,
        2445.7775,
        2423.0525,
        2413.0275,
        2377.5874999999996,
        2349.6525,
        2336.1525,
        2309,
        2349.4500000000003,
        2372.5299999999997,
        2360.465,
        2367.265,
        2373.4925000000003,
        2359.255,
        2353.5950000000003,
        2331.5725,
        2298.55,
        2285.1525,
        2287.7325,
        2286.2075,
     
    ]
 
 
     var macdInput = {
        values: test,
        fastPeriod: 12,
        slowPeriod: 26,
        signalPeriod: 9,
        SimpleMAOscillator: false,
        SimpleMASignal: false
    }

    let macdo2 = MACD.calculate(macdInput);
    console.log(macdo2)

it returns
image

signal and histogram doesn't even work

expected result .. look it returns full 49 values.. 0-48

image

I use the code

export function _MACD(data, slowPeriods = 26, fastPeriods = 12, signalPeriods = 9) {

   const MACD = sub(
       ema(data, fastPeriods),
       ema(data, slowPeriods),
       1
   )

   const signal = ema(MACD, signalPeriods)
   const histogram = sub(MACD, signal)

   return {
       MACD,
       signal,
       histogram
   }
}

and format it like this script input

{
           MACD: roundN(element),
           signal: roundN(macdo.signal[index]),
           histogram: roundN(macdo.histogram[index])
}

it gives 1:1 value in tradingview macd..

example of last index-2 index-3 index-4

heres the last log of eth this time using script above.. btw ema is from moving-averages npm package

image
TraidinView Snapshot
image
image
image
..

back to my problem, I don't understand why the output is incomplete and some inaccurate... did I miss something? and some have signal and histogram errors.

all of this have same config

fastPeriod: 12,
slowPeriod: 26,
signalPeriod: 9,
@muratozenc
Copy link

muratozenc commented Mar 20, 2022

The data provided by the indicators are correct, I am using them, maybe there is a 1% error but it can ignored.

If you need to calculate RSI(6), which means RSI calculated last 6 candles, the result provided by the function is going to be empty for the first 6 candles, which is natural because function tries to give you results by using them.

https://www.binance.com/tr/trade/COS_USDT?layout=pro

Select the weekly graphic and check the MACD and RSI indicator results, you are going to see that there is no results at the beginning.

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

2 participants