UNPKG

sql-synergy

Version:

Synergy Wave TA

84 lines (83 loc) 4.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Neutralization = void 0; const IConstants_1 = require("./IConstants"); const Step3_1 = require("./Step3"); const Analyzer_1 = require("./Analyzer"); class Neutralization { constructor(oMSQuote, oPC) { this.iPC = 0; this.oMSQuote = oMSQuote; this.iPC = oPC.getPeriod(); if (this.iPC >= IConstants_1.IConstants.YEARLY) return; try { this.oPC = oPC; //oMSQuote.getData(iPC); this.oBPC = oMSQuote.getData(this.iPC + 1); this.oStep3 = new Step3_1.Step3(this.oBPC); } catch (err) { console.error(err); } } getBiggerChart() { return this.oBPC; } isUpWaveNeutralized(iDay) { if (this.oBPC == null || this.oStep3.hasEnoughData() == false) return 0; // Cannot Neutralize let iBP = this.getPeriodicityDates(this.iPC, this.oPC, this.iPC + 1, this.oBPC, iDay); if (iBP == -1) return 0; // System.out.println ( "IsUpWave S " + oPC.getDate ( ) [ iDay ] ) ; // System.out.println ( "IsUpWave B " + oBPC.getDate ( ) [ iBP ] ) ; var fCL = 0.0; iBP++; while (--iBP > this.oStep3.nCLDays) { fCL = this.oStep3.getCL(iBP); // f = Analyzer.getOPBUp ( fCL ) ; if (this.oBPC.isWhiteAndNonReversal(iBP) && this.oBPC.getClose()[iBP] >= Analyzer_1.Analyzer.getOPBUp(fCL)) { // System.err.println ( oMSQuote.getSymbol ( ) + " " + sTable [ iPC ] + "," + sTable [ iPC + 1 ] + " CL Broken UPward by W+NRCS => Neutralization on " + oPC.getDate ( ) [ iDay ] + " Failed " + oBPC.getDate ( ) [ iBP ] ) ; return 0; } // f = Analyzer.getOPBDown ( fCL ) ; if (this.oBPC.isBlackAndNonReversal(iBP) && this.oBPC.getClose()[iBP] <= Analyzer_1.Analyzer.getOPBDown(fCL)) { // System.err.println ( oMSQuote.getSymbol ( ) + " " + sTable [ iPC ] + "," + sTable [ iPC + 1 ] + " CL Broken DNward by B+NRCS => Neutralized on " + oPC.getDate ( ) [ iDay ] + " BigChart " + oBPC.getDate ( ) [ iBP ] ) ; return iBP; } } return 0; } getPeriodicityDates(iPC, oPC, iBPC, oBPC, iDay) { // if ( iBP == -1 ) // return 0 ; var lDate = oPC.getDate()[iDay]; return oBPC.getChartDate(lDate); } isDownWaveNeutralized(iDay) { if (iDay == 0 || this.oBPC == null || this.oStep3.hasEnoughData() == false) return 0; // Cannot Neutralize var iBP = this.getPeriodicityDates(this.iPC, this.oPC, this.iPC + 1, this.oBPC, iDay); if (iBP == -1) return 0; // System.out.println ( "IsDnWave " + sTable [ iPC ] + " " + oPC.getDate ( ) [ iDay ] ) ; // System.out.println ( "IsDnWave " + sTable [ iPC + 1 ] + " " + oBPC.getDate ( ) [ iBP ] ) ; var fCH = 0.0; iBP++; while (--iBP > this.oStep3.nCHDays) { fCH = this.oStep3.getCH(iBP); // f = Analyzer.getOPBDown ( fCH ) ; if (this.oBPC.isBlackAndNonReversal(iBP) && this.oBPC.getClose()[iBP] <= Analyzer_1.Analyzer.getOPBDown(fCH)) { // System.err.println ( oMSQuote.getSymbol ( ) + " " + sTable [ iPC ] + "," + sTable [ iPC + 1 ] + " CH Broken DNward by B+NRCS => Neutralization on " + oPC.getDate ( ) [ iDay ] + " Failed " + oBPC.getDate ( ) [ iBP ] ) ; return 0; } // f = Analyzer.getOPBUp ( fCH ) ; if (this.oBPC.isWhiteAndNonReversal(iBP) && this.oBPC.getClose()[iBP] >= Analyzer_1.Analyzer.getOPBUp(fCH)) { // System.err.println ( oMSQuote.getSymbol ( ) + " " + sTable [ iPC ] + "," + sTable [ iPC + 1 ] + " CH Broken UPward by B+NRCS => Neutralized on " + oPC.getDate ( ) [ iDay ] + " BigChart " + oBPC.getDate ( ) [ iBP ] ) ; return iBP; } } return 0; } } exports.Neutralization = Neutralization;