UNPKG

sql-synergy

Version:

Synergy Wave TA

91 lines (90 loc) 2.72 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Step5 = void 0; const Analyzer_1 = require("./Analyzer"); const Stochastics_1 = require("./Stochastics"); class Step5 extends Analyzer_1.Analyzer { constructor(oPC, nK = 10, nD = 3, nMA = 10) { super(oPC); this.nK = 10; this.nD = 3; this.nMA = 10; // Stochastics oS ; this.fS = []; //fK: Array<number> = []; this.nDays = 0; this.nK = nK; this.nD = nD; this.nMA = nMA; // let input = { // high: oPC.getHigh(), // low: oPC.getLow(), // close: oPC.getClose(), // period: nK, // signalPeriod: nD // }; // this.fK = this.getColumn(vStochastic, "k") // this.fD = this.getColumn(vStochastic, "d") let o = new Stochastics_1.Stochastics(oPC, nK, nD, nMA); // this.fK = o.fK ; this.fS = o.fD; this.nDays = nK + nD + nMA - 2; this.calculateSignals(); } // getColumn(iData: any, iColumn: any): Array<number> { // return iData.map(function (r: any) { // return r[iColumn]; // }); // } // public Stochastics getStochastics ( ) // { // return oS ; // } // public Step5 ( Technicals oPC ) // { // this ( oPC, 10, 3, 10 ) ; // } // public float [ ] getK ( ) // { // return oS.getK ( ) ; // } // public float [ ] getD ( ) // { // return oS.getD ( ) ; // } // public getK(iDay: number): number { // return this.fK[iDay]; // } // public getD(iDay: number): number { // return this.fS[iDay]; // } // fAction: Array<number> = []; calculateSignals() { let n = this.fS.length; let iDir = 0; this.fAction[0] = 0; for (var i = 1; i < n; i++) { if (iDir != 1 && this.fS[i] >= 25.0 && this.fS[i - 1] <= 25.0) { iDir = 1; this.fAction[i] = 1; continue; } if (iDir != 1 && this.fS[i] >= 75.0 && this.fS[i - 1] <= 75.0) { iDir = 1; this.fAction[i] = 1; continue; } if (iDir != -1 && this.fS[i] <= 25.0 && this.fS[i - 1] >= 25.0) { iDir = -1; this.fAction[i] = -1; continue; } if (iDir != -1 && this.fS[i] <= 75.0 && this.fS[i - 1] >= 75.0) { iDir = -1; this.fAction[i] = -1; continue; } // this.fAction[i] = 0 ; } } } exports.Step5 = Step5;