-
Notifications
You must be signed in to change notification settings - Fork 566
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
Incorrect Stochastic output #236
Comments
I think so. Any one is not match? |
Mine is correct, just add more candle data 👍 |
@anandanand84 your Stochastic Oscillator implementation is very different from the results of the famous Tulip Indicators. I used the values from the Example Calculation of Tulip Indicators and created a test script to verify your implementation: const Stochastic = require('technicalindicators').Stochastic;
const candles: [number, number, number][] = [
[82.15, 81.29, 81.59],
[81.89, 80.64, 81.06],
[83.03, 81.31, 82.87],
[83.3, 82.65, 83.0],
[83.85, 83.07, 83.61],
[83.9, 83.11, 83.15],
[83.33, 82.49, 82.84],
[84.3, 82.3, 83.99],
[84.84, 84.15, 84.55],
[85.0, 84.11, 84.36],
[85.9, 84.03, 85.53],
[86.58, 85.39, 86.54],
[86.98, 85.76, 86.89],
[88.0, 87.17, 87.77],
[87.87, 87.01, 87.29],
];
const highs = [];
const lows = [];
const closes = [];
for (let i = 0; i < candles.length; i++) {
const [high, low, close] = candles[i];
highs.push(high);
lows.push(low);
closes.push(close);
}
let input = {
high: highs,
low: lows,
close: closes,
period: 5,
signalPeriod: 3,
};
console.log(Stochastic.calculate(input)); Here are your results:
With Tulip Indicators the last values should be: 91.09 (k) & 94.36 (d) |
@bennycode if you add more candles you get the same value as tradingview. 👍 |
doesn't work with values matching the period, but it works when we add more values, so basically try to pass all the candles data and it should work! |
I can't match Stoch modules output with tradingview output,
any idea or sample code for it?
thanks.
The text was updated successfully, but these errors were encountered: