// void ApplyManalyswerValidation( XBoxZone &pivots[], int barIndex = 0 // ) { // int zIDX = 0; int cIDX = zIDX + 1; int pIDX = cIDX + 1; int p2IDX = pIDX + 1; // barIndex = NormalizeInt(barIndex, 0); // bool has = HasChild(pivots); if (!has) { return; } // XBoxZone tmp[]; Copy( pivots, tmp // ); Clean(pivots); while (HasChild(tmp)) { // XBoxZone iPivot = tmp[0]; ArrayRemove( tmp, 0, 1 // ); // // Retrieve Pivot info ... // int toIDX = iPivot.ToIndex(); // int fromIDX = iPivot.FromIndex(); // bool isBullish = iPivot.IsBullish(); // // Retrieve Conditions ... // XCAEAConditions conditions; // has = helper.GetConditions( // conditions, // toIDX, // 5 // // ); // // Retrieve Bars ... // // XOHCL cBar; // XOHCL pBar; // XOHCL p2Bar; // // // has = // has && // cBar.Init( // conditions.symbol, // conditions.period, // toIDX // // ); // has = has && // cBar.GetPreviousBar(pBar); // has = has && // pBar.GetPreviousBar(p2Bar); // if (!has) // { // // // cBar.Clean(); // pBar.Clean(); // p2Bar.Clean(); // iPivot.Clean(); // conditions.Clean(); // // // continue; // } // // Reading Conditions ... // // // // MAL ... // double zMAL = conditions.malBuffer[zIDX]; // double cMAL = conditions.malBuffer[cIDX]; // double pMAL = conditions.malBuffer[pIDX]; // double p2MAL = conditions.malBuffer[p2IDX]; // // // // MAC ... // double zMAC = conditions.macBuffer[zIDX]; // double cMAC = conditions.macBuffer[cIDX]; // double pMAC = conditions.macBuffer[pIDX]; // double p2MAC = conditions.macBuffer[p2IDX]; // // // // MAH ... // double zMAH = conditions.mahBuffer[zIDX]; // double cMAH = conditions.mahBuffer[cIDX]; // double pMAH = conditions.mahBuffer[pIDX]; // double p2MAH = conditions.mahBuffer[p2IDX]; // // Checking Conditions ... // has = isBullish // ? cBar.high < cMAL || // pBar.high < pMAL // : cBar.low < cMAH || // pBar.low < pMAL; // has = isBullish ? iPivot. if (has) { // AddRef( iPivot, pivots // ); } // // Cleanup Resources ... // cBar.Clean(); // pBar.Clean(); // p2Bar.Clean(); iPivot.Clean(); // conditions.Clean(); } // Clean(tmp); } ////////////////////////////////////////////////////////////// // // Parsing Pivots ... XBoxZone rciPivot; double providedSL = 0; XBoxZone rejectedPivot; XBoxZone insidePivots[]; XBoxZone rciContainers[]; int insidePivotsCount = 0; bool isRejectedOnMid = false; bool hasInsidePivots = false; bool hasRCIContainers = false; bool hasPivots = HasChild(pivots); if (hasPivots) { // // drawer.DrawBoxes( // pivots, // TimeCurrent() // // ); // // Select Inside Boxes ... // ENUM_XCA_PIVOTS allowedInsidePivots[] = { XCA_FVG_BULL, XCA_FVG_BEAR, XCA_PEAKSWHRES, XCA_VALESWLSUP, XCA_TREND_BULL, XCA_TREND_BEAR, }; insidePivotsCount = SelectInsideBoxes( allowedInsidePivots, insidePivots, pivots, zBar, cBar, pBar, p2Bar // ); hasInsidePivots = IsValidSize(insidePivotsCount); if (hasInsidePivots) { // // drawer.DrawBoxes( // insidePivots, // zBar.time // // ); } // // Detect Rejected Pivot ... ENUM_XCA_PIVOTS allowedRejectedPivots[] = { XCA_FVG_BULL, XCA_FVG_BEAR, // XCA_PEAKSWHRES, // XCA_VALESWLSUP, // XCA_TREND_BULL, // XCA_TREND_BEAR, }; has = SelectRejectedBox( allowedRejectedPivots, rejectedPivot, isRejectedOnMid, pivots, zBar, cBar, pBar, p2Bar, false, // Ignore Mid Rejection ... true, true // ); // // Select CCI/RSI Cross Object ... count = ArraySize(pivots); for (int i = 0; i < count; i++) { // XBoxZone iPivot = pivots[i]; // ENUM_XCA_PIVOTS iType = GetPivotType(iPivot); // // Checking Type is Passed ... has = // iType == XCA_RSI_COOS || iType == XCA_CCI_COOS || iType == XCA_RSI_CUOB || iType == XCA_CCI_CUOB // ; // // Checking cBar is Pivots' Last Bar ... has = has && cBar.time <= iPivot.to && cBar.time > iPivot.from; if (has) { // rciPivot = iPivot; // iPivot.Clean(); // break; } // iPivot.Clean(); } // // Detect RCI Pivot Containers Pivots ... count = ArraySize(pivots); has = rciPivot.IsValid(); if (has) { // for (int i = 0; i < count; i++) { // XBoxZone iPivot = pivots[i]; // ENUM_XCA_PIVOTS iType = GetPivotType(iPivot); // // Checking Type is Passed ... has = // IsValid(iType) && (iType == XCA_PEAKSWHRES || iType == XCA_VALESWLSUP) // ; // // Check Dir is Passed ... has = has && rciPivot.dir == iPivot.dir; // // Check RCI Pivot is Inside Pivot ... has = has && // ( // (rciPivot.lower >= iPivot.lower && rciPivot.lower < iPivot.upper) // || // (rciPivot.upper <= iPivot.upper && rciPivot.upper > iPivot.lower) // || // (rciPivot.upper > iPivot.upper && rciPivot.lower < iPivot.lower) // ) // ; // if (has) { // AddRef( iPivot, rciContainers // ); } // iPivot.Clean(); } // hasRCIContainers = HasChild(rciContainers); } } ///////////////////////////////////////////////////////////////////// // // Box Based Conditions ... // // if (isCBarHasStrongATR) // { // // // Print(ToString(cBar.GetDirection()), " ATR Growing ..."); // } // // bool isZeroVScore = isScoreNeutural || // isVolumeNeutural; // // // bool isBullishTested = // isZeroVScore && // isCBarValidForBullish // && // // rejectedPivot.IsValid() && // // rejectedPivot.IsBullish() // ; // bool isBearishTested = // isZeroVScore && // isCBarValidForBearish // && // // rejectedPivot.IsValid() && // // rejectedPivot.IsBearish() // ; // // // bool isTested = // // // isBullishTested || // isBearishTested // // // ; // if (isTested) // { // // // Print("Zero Volume ..."); // } ///////////////////////////////////////////////////////////////////// // bool isCond2Bullish = // false // && // // conditions. // // zPeak > cPeak && // zBar.close > cPeak && // ((zPeak - cPeak) > 2 * points) && // // z3MAFastState > 0 && // isValeGoldenRejected && // isCBarBullishRejected && // conditions.isValeIsPivot // // isPCCIOS && // isRSIBullish && // conditions.isCloseUnderMal // rciPivot.IsValid() && // rciPivot.IsBullish() && // isCCIBullish && // cBar.close > c3MAFast // isADXBullish && // hasRCIContainers && // conditions.isValeIsPivot && // (conditions.isRSICrossedOverOS || // conditions.isCCICrossedOverOS) // && // conditions.swingLowBuffer[cIDX] < conditions.fiboLevel3Buffer[cIDX] // // ; // bool isCond2Bearish = // false // && // // z3MAFastState < 0 && // isPeakGoldenRejected && // isCBarBullishRejected && // conditions.isPeakIsPivot // // isPCCIOB && // isRSIBearish && // c3MAFastState < 0 && // conditions.isCloseOverMah // rciPivot.IsValid() && // rciPivot.IsBearish() && // conditions.isRSIOB && // isCCIBearish && // cBar.close < c3MAFast // isADXBearish && // hasRCIContainers && // conditions.isPeakIsPivot && // (conditions.isRSICrossedUnderOB || // conditions.isCCICrossedUnderOB) // && // conditions.swingHighBuffer[cIDX] > conditions.fiboLevel1Buffer[cIDX] // // ; /////////////////////////////////////////////////////////////////////////////////// // // bool DetectPeakPivot( // int barIndex, // XOHCL &zBar, // XOHCL &cBar, // XOHCL &pBar, // XOHCL &p2Bar, // XCAEAConditions &conditions // // ) // { // // // bool result = false; // // // // Validate Args ... // result = // // // barIndex >= 0 && // zBar.IsValid() && // cBar.IsValid() && // pBar.IsValid() && // p2Bar.IsValid() && // detectPeakPivots // // // ; // if (!result) // { // return result; // } // // // // Define Requirements ... // // // int zIDX = 0; // int cIDX = zIDX + 1; // int pIDX = cIDX + 1; // int p2IDX = pIDX + 1; // // // datetime cTime = zBar.time; // string symbol = zBar.symbol; // ENUM_TIMEFRAMES period = zBar.period; // double points = GetPoints(symbol); // // // // Reading Conditional Values ... // // // // PEAK ... // double zPeak = conditions.peakBuffer[zIDX]; // double cPeak = conditions.peakBuffer[cIDX]; // double pPeak = conditions.peakBuffer[pIDX]; // double p2Peak = conditions.peakBuffer[p2IDX]; // // // // PEAK Golden ... // double zPeakGolden = conditions.peakGoldenBuffer[zIDX]; // double cPeakGolden = conditions.peakGoldenBuffer[cIDX]; // double pPeakGolden = conditions.peakGoldenBuffer[pIDX]; // double p2PeakGolden = conditions.peakGoldenBuffer[p2IDX]; // // // // VALE ... // double zVale = conditions.valeBuffer[zIDX]; // double cVale = conditions.valeBuffer[cIDX]; // double pVale = conditions.valeBuffer[pIDX]; // double p2Vale = conditions.valeBuffer[p2IDX]; // // // // VALE Golden ... // double zValeGolden = conditions.valeGoldenBuffer[zIDX]; // double cValeGolden = conditions.valeGoldenBuffer[cIDX]; // double pValeGolden = conditions.valeGoldenBuffer[pIDX]; // double p2ValeGolden = conditions.valeGoldenBuffer[p2IDX]; // // // // SWING High .. // double zSwingHigh = conditions.swingHighBuffer[zIDX]; // double cSwingHigh = conditions.swingHighBuffer[cIDX]; // double pSwingHigh = conditions.swingHighBuffer[pIDX]; // double p2SwingHigh = conditions.swingHighBuffer[p2IDX]; // // // // SWING Low ... // double zSwingLow = conditions.swingLowBuffer[zIDX]; // double cSwingLow = conditions.swingLowBuffer[cIDX]; // double pSwingLow = conditions.swingLowBuffer[pIDX]; // double p2SwingLow = conditions.swingLowBuffer[p2IDX]; // // // // SUPPORT ... // double zSupport = conditions.supportBuffer[zIDX]; // double cSupport = conditions.supportBuffer[cIDX]; // double pSupport = conditions.supportBuffer[pIDX]; // double p2Support = conditions.supportBuffer[p2IDX]; // // // // RESISTANCE ... // double zResistance = conditions.resistanceBuffer[zIDX]; // double cResistance = conditions.resistanceBuffer[cIDX]; // double pResistance = conditions.resistanceBuffer[pIDX]; // double p2Resistance = conditions.resistanceBuffer[p2IDX]; // // // // Detecting Bar Conditions ... // // // ENUM_X_DIRECTION cBarDir; // // // // Rejected ... // bool isCBarRejected = helper // .barAnalyser // .IsRejected( // cBar, // cBarDir, // false, // Force Type ... // true // Force Fibo Pressure ... // ); // bool isCBarBullishRejected = // isCBarRejected && // IsBullish(cBarDir); // bool isCBarBearishRejected = // isCBarRejected && // IsBearish(cBarDir); // // // // Engulfed ... // bool isCBarEngulfed = helper // .barAnalyser // .IsEngulfed( // cBar, // cBarDir // // ); // bool isCBarBullishEngulfed = // isCBarEngulfed && // IsBullish(cBarDir); // bool isCBarBearishEngulfed = // isCBarEngulfed && // IsBearish(cBarDir); // // // // Prepare Conditinal Conditions ... // // // bool isPeakSameLast = cPeak == pPeak; // bool isPeakSameLastPrev = pPeak == p2Peak; // // // if (applySwingsOnPVPivots) // { // // // isPeakSameLast = // isPeakSameLast && // cSwingHigh == cPeak && // cSwingHigh == pSwingHigh; // // // isPeakSameLastPrev = // isPeakSameLastPrev && // pSwingHigh == pPeak && // pSwingHigh == p2SwingHigh; // } // // // if (applySupportAndResistanceOnPVPivots) // { // // // isPeakSameLast = // isPeakSameLast && // cResistance == cPeak && // cResistance == pResistance; // // // isPeakSameLastPrev = // isPeakSameLastPrev && // pResistance == pPeak && // pResistance == p2Resistance; // } // // // bool isPeakSwitchedToSameLast = isPeakSameLast && // !isPeakSameLastPrev; // bool isPeakFinishedFromSameLast = !isPeakSameLast && // isPeakSameLastPrev; // // // // ZERO ... // // Default Peak and Vale Selection ... // bool isTypeZeroStart = isPeakFinishedFromSameLast; // bool isTypeZeroContinue = isPeakSameLast; // bool isTypeZeroFinished = isPeakSwitchedToSameLast; // if (isTypeZeroFinished) // { // // // bool hasSelectionType = selectRejectedPVPivots || // selectEngulfedPVPivots; // // // bool isPVRejected = // isCBarBearishRejected && // selectRejectedPVPivots; // // // bool isPVEngulfed = // isCBarBearishEngulfed && // selectEngulfedPVPivots; // // // bool isBarPassed = // !hasSelectionType // ? true // : isPVRejected || // isPVEngulfed; // // // isTypeZeroFinished = // isBarPassed && // isTypeZeroFinished; // if (!isTypeZeroFinished) // { // peakPivot.Clean(); // } // } // // // // Summarizing Conditions ... // // // result = false; // // // bool hasStartCondition = // // // isTypeZeroStart // // // ; // bool hasContinuationCondition = // // // isTypeZeroContinue // // // ; // bool hasEndCondition = // // // isTypeZeroFinished // // // ; // // // // ReInstance Pivot ... // if (hasStartCondition) // { // // // peakPivot.Clean(); // // // peakPivot.type = XCA_PEAK; // peakPivot.symbol = symbol; // peakPivot.period = period; // // // peakPivot.to = pBar.time; // peakPivot.from = pBar.time; // peakPivot.value = pPeak; // peakPivot.reserve = pPeakGolden; // } // // // // Calculate and Fill Pivot Requirements ... // if (hasContinuationCondition) // { // // // peakPivot.from = pBar.time; // // // peakPivot.reserve = // peakPivot.reserve == 0 // ? pPeakGolden // : MathMax(peakPivot.reserve, pPeakGolden); // } // // // // End up Pivot and Store it ... // if (hasEndCondition) // { // // // result = // peakPivot.IsValid() && // peakPivot.GetAge() >= pivotVerifications; // if (result) // { // // // XBoxZone iBox; // result = peakPivot.AsBox(iBox); // if (result) // { // // // newPeakPivotDetected = AddBox( // iBox, // peakPivots // // ); // } // // // iBox.Clean(); // } // // // peakPivot.Clean(); // } // // // return result; // } // // // bool DetectValePivot( // int barIndex, // XOHCL &zBar, // XOHCL &cBar, // XOHCL &pBar, // XOHCL &p2Bar, // XCAEAConditions &conditions // // ) // { // // // bool result = false; // // // // Validate Args ... // result = // // // barIndex >= 0 && // zBar.IsValid() && // cBar.IsValid() && // pBar.IsValid() && // p2Bar.IsValid() && // detectValePivots // // // ; // if (!result) // { // return result; // } // // // // Define Requirements ... // // // int zIDX = 0; // int cIDX = zIDX + 1; // int pIDX = cIDX + 1; // int p2IDX = pIDX + 1; // // // datetime cTime = zBar.time; // string symbol = zBar.symbol; // ENUM_TIMEFRAMES period = zBar.period; // double points = GetPoints(symbol); // // // // Reading Conditional Values ... // // // // PEAK ... // double zPeak = conditions.peakBuffer[zIDX]; // double cPeak = conditions.peakBuffer[cIDX]; // double pPeak = conditions.peakBuffer[pIDX]; // double p2Peak = conditions.peakBuffer[p2IDX]; // // // // PEAK Golden ... // double zPeakGolden = conditions.peakGoldenBuffer[zIDX]; // double cPeakGolden = conditions.peakGoldenBuffer[cIDX]; // double pPeakGolden = conditions.peakGoldenBuffer[pIDX]; // double p2PeakGolden = conditions.peakGoldenBuffer[p2IDX]; // // // // VALE ... // double zVale = conditions.valeBuffer[zIDX]; // double cVale = conditions.valeBuffer[cIDX]; // double pVale = conditions.valeBuffer[pIDX]; // double p2Vale = conditions.valeBuffer[p2IDX]; // // // // VALE Golden ... // double zValeGolden = conditions.valeGoldenBuffer[zIDX]; // double cValeGolden = conditions.valeGoldenBuffer[cIDX]; // double pValeGolden = conditions.valeGoldenBuffer[pIDX]; // double p2ValeGolden = conditions.valeGoldenBuffer[p2IDX]; // // // // SWING High .. // double zSwingHigh = conditions.swingHighBuffer[zIDX]; // double cSwingHigh = conditions.swingHighBuffer[cIDX]; // double pSwingHigh = conditions.swingHighBuffer[pIDX]; // double p2SwingHigh = conditions.swingHighBuffer[p2IDX]; // // // // SWING Low ... // double zSwingLow = conditions.swingLowBuffer[zIDX]; // double cSwingLow = conditions.swingLowBuffer[cIDX]; // double pSwingLow = conditions.swingLowBuffer[pIDX]; // double p2SwingLow = conditions.swingLowBuffer[p2IDX]; // // // // SUPPORT ... // double zSupport = conditions.supportBuffer[zIDX]; // double cSupport = conditions.supportBuffer[cIDX]; // double pSupport = conditions.supportBuffer[pIDX]; // double p2Support = conditions.supportBuffer[p2IDX]; // // // // RESISTANCE ... // double zResistance = conditions.resistanceBuffer[zIDX]; // double cResistance = conditions.resistanceBuffer[cIDX]; // double pResistance = conditions.resistanceBuffer[pIDX]; // double p2Resistance = conditions.resistanceBuffer[p2IDX]; // // // // Detecting Bar Conditions ... // // // ENUM_X_DIRECTION cBarDir; // // // // Rejected ... // bool isCBarRejected = helper // .barAnalyser // .IsRejected( // cBar, // cBarDir, // false, // Force Type ... // true // Force Fibo Pressure ... // ); // bool isCBarBullishRejected = // isCBarRejected && // IsBullish(cBarDir); // bool isCBarBearishRejected = // isCBarRejected && // IsBearish(cBarDir); // // // // Engulfed ... // bool isCBarEngulfed = helper // .barAnalyser // .IsEngulfed( // cBar, // cBarDir // // ); // bool isCBarBullishEngulfed = // isCBarEngulfed && // IsBullish(cBarDir); // bool isCBarBearishEngulfed = // isCBarEngulfed && // IsBearish(cBarDir); // // // // Prepare Conditinal Conditions ... // // // bool isValeSameLast = cVale == pVale; // bool isValeSameLastPrev = pVale == p2Vale; // // // if (applySwingsOnPVPivots) // { // // // isValeSameLast = // isValeSameLast && // cSwingLow == cVale && // cSwingLow == pSwingLow; // // // isValeSameLastPrev = // isValeSameLastPrev && // pSwingLow == pVale && // pSwingLow == p2SwingLow; // } // // // if (applySupportAndResistanceOnPVPivots) // { // // // isValeSameLast = // isValeSameLast && // cSupport == cVale && // cSupport == pSupport; // // // isValeSameLastPrev = // isValeSameLastPrev && // pSupport == pVale && // pSupport == p2Support; // } // // // bool isValeSwitchedToSameLast = isValeSameLast && // !isValeSameLastPrev; // bool isValeFinishedFromSameLast = !isValeSameLast && // isValeSameLastPrev; // // // // ZERO ... // // Default Peak and Vale Selection ... // bool isTypeZeroStart = isValeFinishedFromSameLast; // bool isTypeZeroContinue = isValeSameLast; // bool isTypeZeroFinished = isValeSwitchedToSameLast; // if (isTypeZeroFinished) // { // // // bool hasSelectionType = selectRejectedPVPivots || // selectEngulfedPVPivots; // // // bool isPVRejected = // isCBarBullishRejected && // selectRejectedPVPivots; // // // bool isPVEngulfed = // isCBarBullishEngulfed && // selectEngulfedPVPivots; // // // bool isBarPassed = // !hasSelectionType // ? true // : isPVRejected || // isPVEngulfed; // // // isTypeZeroFinished = // isBarPassed && // isTypeZeroFinished; // if (!isTypeZeroFinished) // { // valePivot.Clean(); // } // } // // // // Summarizing Conditions ... // // // result = false; // // // bool hasStartCondition = // // // isTypeZeroStart // // // ; // bool hasContinuationCondition = // // // isTypeZeroContinue // // // ; // bool hasEndCondition = // // // isTypeZeroFinished // // // ; // // // // ReInstance Pivot ... // if (hasStartCondition) // { // // // valePivot.Clean(); // // // valePivot.type = XCA_VALE; // valePivot.symbol = symbol; // valePivot.period = period; // // // valePivot.to = pBar.time; // valePivot.from = pBar.time; // valePivot.value = pVale; // valePivot.reserve = pValeGolden; // } // // // // Calculate and Fill Pivot Requirements ... // if (hasContinuationCondition) // { // // // valePivot.from = pBar.time; // // // valePivot.reserve = // valePivot.reserve == 0 // ? pValeGolden // : MathMin(valePivot.reserve, pValeGolden); // } // // // // End up Pivot and Store it ... // if (hasEndCondition) // { // // // result = // valePivot.IsValid() && // valePivot.GetAge() >= pivotVerifications; // if (result) // { // // // XBoxZone iBox; // result = valePivot.AsBox(iBox); // if (result) // { // // // newPeakPivotDetected = AddBox( // iBox, // valePivots // // ); // } // // // iBox.Clean(); // } // // // valePivot.Clean(); // } // // // return result; // }