Skip to content

Update STOCH.js#4

Open
bgh91 wants to merge 3 commits intoGab0:masterfrom
bgh91:patch-1
Open

Update STOCH.js#4
bgh91 wants to merge 3 commits intoGab0:masterfrom
bgh91:patch-1

Conversation

@bgh91
Copy link

@bgh91 bgh91 commented Jul 12, 2018

Getting the same values as Tradingview.
Make sure the time zone is correct on tradingview to compare.
When the exchange data fails Tradingview cut out the data that is missing but gekko just freezes and all the numbers go to the same for close, high and low candle. Then causes the K and D numbers to NaN, stopped this with - if (candle.high !== candle.low).
Added Smooth K, set to 1 to disable
Takes 5-6 candles for K % D calculations to catch up initially ?? not sure how to correct this

Test with:

var method = {};

method.init = function() {

this.name = "Tradingview-tester";

this.addIndicator('ind', 'STOCH', {KPeriods: 5, DPeriods: 3, smoothKPeriods :2});

};

method.check = function() {};
method.update= function(candle) {

console.log("Time: " + candle.start.format())
console.log("High : " + candle.high);
console.log("Low : " + candle.low);
console.log("Close : " + candle.close);
console.log("LL : " + this.indicators.ind.getLowest());
console.log("HH : " + this.indicators.ind.getHighest());
console.log("%K: " + this.indicators.ind.K);
console.log("%D: " + this.indicators.ind.D);
console.log();

};
method.log = function() {};

module.exports = method;

bgh91 added 3 commits July 12, 2018 16:02
Getting the same values as Tradingview.
Make sure the time zone is correct on tradingview to compare. 
When the exchange  data fails Tradingview cut out the data that is missing but gekko just freezes and all the numbers go to the same for close, high and low candle. Then causes the K and D numbers to NaN, stopped this with - if (candle.high !== candle.low).
Added Smooth K, set to 1 to disable
Takes 5-6 candles for K % D calculations to catch up initially ?? not sure how to correct this

Test with:

var method = {};

method.init = function() {

    this.name = "Tradingview-tester";

    this.addIndicator('ind', 'STOCH', {KPeriods: 5, DPeriods: 3, smoothKPeriods :2});

};

method.check = function() {};
method.update= function(candle) {

    console.log("Time: " + candle.start.format())
    console.log("High : " + candle.high);
    console.log("Low : " + candle.low);
    console.log("Close : " + candle.close);
    console.log("LL : " + this.indicators.ind.getLowest());
    console.log("HH : " + this.indicators.ind.getHighest());
    console.log("%K: " + this.indicators.ind.K);
    console.log("%D: " + this.indicators.ind.D);
    console.log();
};
method.log = function() {};

module.exports = method;
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

Successfully merging this pull request may close these issues.

1 participant