UNPKG

sql-synergy

Version:

Synergy Wave TA

126 lines (125 loc) 4.96 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.WaveGenerator = void 0; const IConstants_1 = require("./IConstants"); const WaveSequence_1 = require("./WaveSequence"); const Wave_1 = require("./Wave"); const WaveOrganizerV2_1 = require("./WaveOrganizerV2"); const AbstractWaves_1 = require("./AbstractWaves"); const Step2N_1 = require("./Step2N"); class WaveGenerator { constructor(oMSQuote) { this.bReOrg = true; this.oWS = new WaveSequence_1.WaveSequence(); this.oStep2N = null; this.iStartIndex = 0; this.iDir = IConstants_1.IConstants.NONE; this.oMSQuote = oMSQuote; } getWaveSequence() { return this.oWS; } setDir(iDir) { this.iDir = iDir; } generateWave(oPC, oIC) { this.oStep2N = new Step2N_1.Step2N(this.oMSQuote, oPC); if (this.oStep2N.oIndicatorChart.oPC.getLastDay() < 10) return; this.generateWaves(oPC, oIC, this.iStartIndex, this.oStep2N.oIndicatorChart.oPC.getLastDay(), this.iDir); } generateWaves(oPC, oIC, iStartIndex, iEndIndex, iDir) { this.oWS.setPeriods(oPC.iPC, oIC.iPC); this.oStep2N = new Step2N_1.Step2N(this.oMSQuote, oPC); this.oWS.setPriceChart(oPC); let oAW = new AbstractWaves_1.AbstractWaves(this.oMSQuote, oPC, oIC); let oList = new Array(); if (IConstants_1.IConstants.NONE == iDir) oList = oAW.getWaves(iStartIndex, iEndIndex); else { oAW.setPPStart(iStartIndex); oAW.setFirstWave(iDir); oList = oAW.getWavesOpposite(iStartIndex, iEndIndex, iDir); } let n = oList.length; // console.log ( "Total Waves: " + n ) ; // int iPS = -1, iPE = -1 ; // WaveLines oPL = null ; // boolean bChangeDir = false ; for (var i = 0; i < n; i++) { let oWL = oList[i]; // console.log ( ">> Processing: " + oWL ) ; let oW = new Wave_1.Wave(); oW.setCharts(oPC, oIC); oW.setDirection(oWL.iDir); oW.setPerfect(oWL.isPerfect()); oW.set5StepsDateIndex(oWL.get5StepsDateIndex()); oW.setBiggerChannelBroken(oWL.wasBiggerChannelBroken()); oW.setLowest(oWL.getLowIndex(), oWL.getLowPrice()); oW.setHighest(oWL.getHighIndex(), oWL.getHighPrice()); /* if ( oWL.getStart ( ) == oWL.getEnd ( ) ) { if ( oPL != null ) { if ( oPL.getEnd ( ) == oWL.getStart ( ) ) { //70001687 bChangeDir = !bChangeDir ; continue ; } } } if ( bChangeDir ) { int iStart = oW.getStartIndex ( ) ; int iEnd = oW.getEndIndex ( ) ; oW.setDirection ( oW.isUp ( ) ? DOWN : UP ) ; Technicals oTPC = oWS.getPriceChart ( ) ; if ( oW.isUp ( ) ) { oW.setLowest ( iStart, oTPC.getLow ( ) [ iStart ] ) ; oW.setHighest ( iEnd, oTPC.getHigh ( ) [ iEnd ] ) ; } else { oW.setLowest ( iEnd, oTPC.getHigh ( ) [ iEnd ] ) ; oW.setHighest ( iStart, oTPC.getLow ( ) [ iStart ] ) ; } } */ let sName = this.getNextName(); if (oW.isDown() && sName === "A") sName = this.getNextName(); oW.setName(sName); // oPL = oWL ; // console.log(oW.getName() + oW.getDirection() + oW.getMinimum() + oW.getMaximum()) ; console.log(oW.toString()); this.oWS.add(oW); } this.oWS.print(); console.log("***Named all waves above**********"); if (!this.bReOrg) return; let oWO = new WaveOrganizerV2_1.WaveOrganizerV2(this.oWS, this.oMSQuote); while (oWO.reorganize() == false) { console.log("***Merging & Renaming*******"); oWO.adjustWaves(); this.oWS.print(); } console.log("***Finished Merging & Renaming****Final Result***"); console.log("*** Adjust Min MAx ***"); oWO.recomputeMinMax(); this.oWS.print(); console.log("***Renaming last Waves** "); while (oWO.consolidateLastImplusiveWave() == false) { oWO.adjustWaves(); this.oWS.print(); } console.log("***Finished Renaming last Waves** "); this.oWS.print(); console.log("*** Adjust Min MAx ***"); oWO.recomputeMinMax(); this.oWS.print(); } } exports.WaveGenerator = WaveGenerator;