UNPKG

sql-synergy

Version:

Synergy Wave TA

146 lines (145 loc) 6.29 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SynergySystem = void 0; const IConstants_1 = require("./IConstants"); const Step2_1 = require("./Step2"); const Step3_1 = require("./Step3"); const Step4_1 = require("./Step4"); const Step5_1 = require("./Step5"); const Step6_1 = require("./Step6"); class SynergySystem { constructor(oMSQuote) { this.i3P = -1; this.i3I = -1; // public int getRecent5Steps ( int i3P, int i3I ) throws Exception // { // Technicals oPC = oMSQuote.getData ( i3P ) ; // Technicals oIC = oMSQuote.getData ( i3I ) ; // Step2 oStep2 = new Step2 ( oPC ) ; // Step3 oStep3 = new Step3 ( oPC ) ; // Step4 oStep4 = new Step4 ( oIC ) ; // Step5 oStep5 = new Step5 ( oIC, 10, 3, 10 ) ; // Step6 oStep6 = new Step6 ( oIC ) ; // int iSignal = 0 ; // int iPC = oPC.getLastDay() ; // int iIC = oIC.getLastDay() ; // int iSignalType = 0 ; // if ( oStep2.hasBuySignal(iPC) && oStep3.hasBuySignal(iPC) && oStep4.hasBuySignal(iIC) && oStep5.hasBuySignal(iIC) && oStep6.hasBuySignal(iIC) ) // { // int iTCF = iPC ; // while ( --iTCF > 0 ) // { // if ( oStep2.hasBRFCS(iTCF)) // break ; // } // int iCB = oStep3.getSignalDay() ; // int n = Math.max(iTCF, iCB ) ; // int i = Math.min(iTCF, iCB) ; // for ( ; i <= n ; i++ ) // { // if ( oStep2.hasBuySignal(i) && oStep3.hasBuySignal(i) && oStep4.hasBuySignal(i) && oStep5.hasBuySignal(i) && oStep6.hasBuySignal(i) ) // break ; // } // if ( i > n ) // return 0 ; //// if ( oStep2.hasBuySignal(iPC) && oStep3.hasBuySignal(iPC) && oStep4.hasBuySignal(iIC) && oStep5.hasBuySignal(iIC) && oStep6.hasBuySignal(iIC) ) //// continue ; //// //// if ( !oStep2.hasSellSignal() || !oStep3.hasSellSignal() || !oStep4.hasSellSignal() || !oStep5.hasSellSignal() || !oStep6.hasSellSignal() ) //// iSignalType = -1 ; // iSignalType = 1 ; // } // else // if ( oStep2.hasSellSignal() && oStep3.hasSellSignal() && oStep4.hasSellSignal() && oStep5.hasSellSignal() && oStep6.hasSellSignal() ) // iSignalType = -1 ; //// int iTotal = oStep2.getSingalDateInt() + oStep3.getSingalDateInt() + oStep4.getSingalDateInt() + oStep5.getSingalDateInt() + oStep6.getSingalDateInt() ; // iSignal = oStep2.getSignalDay() ; // iSignal = Math.max ( oStep3.getSignalDay(), iSignal ) ; // iSignal = Math.max ( oStep4.getSignalDay(), iSignal ) ; // iSignal = Math.max ( oStep5.getSignalDay(), iSignal ) ; // iSignal = Math.max ( oStep6.getSignalDay(), iSignal ) ; // return oStep2.oPC.getDate()[iSignal] * iSignalType ; // } this.iSmallerChartDate = 0; this.oMSQuote = oMSQuote; } isLevelII() { return this.check6Steps(IConstants_1.IConstants.YEARLY, IConstants_1.IConstants.MONTHLY); } isLevelI() { return this.check6Steps(IConstants_1.IConstants.QUARTERLY, IConstants_1.IConstants.MONTHLY); } check6Steps(i3P, i3I) { try { this.i3P = i3P; this.i3I = i3I; this.oPC = this.oMSQuote.getData(i3P); let oIC = this.oMSQuote.getData(i3I); let iLastPeriod = this.oPC.getLastDay(); this.oStep2 = new Step2_1.Step2(this.oPC); this.oStep3 = new Step3_1.Step3(this.oPC); // While determining level 1 or 2 3MI cannot be neutralized. this.oStep4 = new Step4_1.Step4(this.oMSQuote, oIC); this.oStep5 = new Step5_1.Step5(this.oMSQuote, oIC); this.oStep6 = new Step6_1.Step6(this.oMSQuote, oIC); // this.oStep4 = new Step4N ( this.oMSQuote, this.oPC, oIC ) ; // this.oStep5 = new Step5N ( this.oMSQuote, this.oPC, oIC ) ; // this.oStep6 = new Step6N ( this.oMSQuote, this.oPC, oIC ) ; for (var i = 10; i < iLastPeriod; i++) { try { this.iSmallerChartDate = this.getSmallerChartDateIndex(this.oPC, i, oIC); } catch (err) { console.error(err); break; } if (this.hasAllSteps(i)) return true; } } catch (err) { console.error(err); } return false; } getStep2Date() { return this.oStep2.getSignalDate(); } getStep3Date() { return this.oStep3.getSignalDate(); } getStep4Date() { return this.oStep4.getSignalDate(); } getStep5Date() { return this.oStep5.getSignalDate(); } getStep6Date() { return this.oStep6.getSignalDate(); } hasAllSteps(iDay) { // System.out.println ( iDay + " " + oStep3.oPC.getDate ( ) [ iDay ] ) ; // System.out.println ( iSmallerChartDate + " " + // oStep4.oIndicatorChart.oPC.getDate ( ) [ iSmallerChartDate ] ) ; if (this.oStep3.hasBuySignal(iDay) && this.oStep2.hasBuySignal(iDay) && this.oStep4.hasBuySignal(this.iSmallerChartDate) && this.oStep5.hasBuySignal(this.iSmallerChartDate) && this.oStep6.hasBuySignal(this.iSmallerChartDate)) return true; if (this.oStep3.hasSellSignal(iDay) && this.oStep2.hasSellSignal(iDay) && this.oStep4.hasSellSignal(this.iSmallerChartDate) && this.oStep5.hasSellSignal(this.iSmallerChartDate) && this.oStep6.hasSellSignal(this.iSmallerChartDate)) return true; return false; } getSmallerChartDateIndex(oPC, iBigChartIndex, oSC) { try { return oSC.getSmallerChartDate(oPC.getDate()[iBigChartIndex]); } catch (err) { console.error(err); } return -1; } getBigChartIndex(oPC, iSmallChartIndex, oBPC) { return oBPC.getChartDate(oPC.getDate()[iSmallChartIndex]); } } exports.SynergySystem = SynergySystem;