Closed dexbg closed 7 years ago
Just verified it in wikipedia and stockcharts.com both use fast - slow.
@dexbg If you find this correct you can close the issue, else provide me a resource and we can discuss and if it is correct I am happy to change.
Sorry, my mistake.
anandanand84, I cannot thank you enough for the amazing library. Unfortunately, dexbg is right, when I compare the generated MACD is different from Yahoo financial. Maybe they're wrong but it worths investigating.
@heekah7 can you send me a screenshot of the difference, did you look at cryptocurrency or other? Can you check if yahoo finance is different from https://cryptotrading-hub.com if it is cryptocurrency, cryptotrading hub uses this library
I just verified against trading view it seems to be correct, can you verify again if the parameters are the same with both yahoo and the library
I am not able to get the same MACD between binance and this MACD value. Is this formula right?
It uses the formula from http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:moving_average_convergence_divergence_macd and it has test cases from stock charts if it has one. If you see an issue in the code, I am happy to change it.
Can you send your calculation, I see it is the same with binance and this library?
@jsappme @jaggedsoft https://cryptotrading-hub.com uses the technical indicators from this library and it seems to match with binance. Can you compare the two charts you may be comparing the wrong parameters.
@anandanand84 I couldn't say for sure, seems to work great. I love this library, thanks for sharing.
@jsappme I did go through the code again since there were lot of people reporting this, I did find out an issue. By default it uses simple moving average that is where people get confused.
try below
macd({
values : [] //close prices
fastPeriod : 5,
slowPeriod : 8,
signalPeriod : 3,
SimpleMAOscillator: false, //this defaults to true that is where the problem is
SimpleMASignal : false, //this defaults to true that is where the problem is
})
Feel free to reopen the issue if you find a mismatch after using simple ma as false.
it s working but I had to play with my histo prices a bit like this:
var macdInput = {
values : _.reverse([close, ...minute_prices[pair]]).map(i=>parseFloat(i)),
fastPeriod : 12,
slowPeriod : 26,
signalPeriod : 9 ,
SimpleMAOscillator: false,
SimpleMASignal : false
}
var current_macd = MACD.calculate(macdInput)[MACD.calculate(macdInput).length-1].histogram
You can also use reversedInput
, so you nolonger have to reverse back and forth.
var macdInput = {
reversedInput : true
}
The MACD value is reversed - i.e. the formula is (slow period - fast period) and not vice versa