diff --git a/Libraries/x-saherelm.common.extensions.lib.mq5 b/Libraries/x-saherelm.common.extensions.lib.mq5 index a7d7c03e..716c54e0 100644 --- a/Libraries/x-saherelm.common.extensions.lib.mq5 +++ b/Libraries/x-saherelm.common.extensions.lib.mq5 @@ -4623,7 +4623,7 @@ T FindLesserThan( return result; } template -T FindLesserThan( +T FindLesserThanByIndex( T value, // Specified Value ... int &index, // Item Index ... const T &source[], // Source ... @@ -4749,7 +4749,7 @@ T FindBiggerThan( return result; } template -T FindBiggerThan( +T FindBiggerThanByIndex( T value, // Specified Value ... int &index, // Item Index ... const T &source[], // Source ... diff --git a/Libraries/x-saherelm.x-poi.lib.mq5 b/Libraries/x-saherelm.x-poi.lib.mq5 index 070c3e0a..b8620d4f 100644 --- a/Libraries/x-saherelm.x-poi.lib.mq5 +++ b/Libraries/x-saherelm.x-poi.lib.mq5 @@ -5791,6 +5791,36 @@ struct XBoxZone // return result; } + + /** + * Retrieve Unique Middle Identifier ... + * + * @return ( string ) + */ + string GetMiddleTag() + { + // + int digits = GetDigits(symbol); + double nMid = NormalizeDouble(NormalizePrice(GetMid(), symbol), digits); + + // + string typeStr = IsValid(type) + ? type + : "XBOX"; + string result = + // + typeStr + "_" + + "Mid_" + + ToString(dir) + "_" + + symbol + "_" + + ToString(period) + "_" + + ToString(nMid) + // + ; + + // + return result; + } }; // diff --git a/XCAEA/Classes/xcaea.x-poi.detector.class.mq5 b/XCAEA/Classes/xcaea.x-poi.detector.class.mq5 index 58f44112..ea7169e2 100644 --- a/XCAEA/Classes/xcaea.x-poi.detector.class.mq5 +++ b/XCAEA/Classes/xcaea.x-poi.detector.class.mq5 @@ -33,8 +33,12 @@ enum ENUM_XCA_PIVOTS { XCA_NONE, // None + XCA_SWL, // Swing Low + XCA_SWH, // Swing High XCA_PEAK, // Peak XCA_VALE, // Vale + XCA_OB_BULL, // OBBull + XCA_OB_BEAR, // OBBear XCA_FVG_BULL, // FVGBull XCA_FVG_BEAR, // FVGBear XCA_RSI_COOS, // RSICOOS @@ -79,7 +83,9 @@ ENUM_X_DIRECTION GetDirection(ENUM_XCA_PIVOTS value) switch (value) { // + case XCA_SWL: case XCA_VALE: + case XCA_OB_BULL: case XCA_FVG_BULL: case XCA_RSI_COOS: case XCA_TREND_BULL: @@ -87,7 +93,9 @@ ENUM_X_DIRECTION GetDirection(ENUM_XCA_PIVOTS value) break; // + case XCA_SWH: case XCA_PEAK: + case XCA_OB_BEAR: case XCA_FVG_BEAR: case XCA_RSI_CUOB: case XCA_TREND_BEAR: @@ -109,6 +117,8 @@ string GetBoxType(ENUM_XCA_PIVOTS value) switch (value) { // + case XCA_SWL: + case XCA_SWH: case XCA_VALE: case XCA_PEAK: case XCA_RSI_COOS: @@ -116,6 +126,11 @@ string GetBoxType(ENUM_XCA_PIVOTS value) result = ToString(value); break; // + case XCA_OB_BULL: + case XCA_OB_BEAR: + result = "XCA_OB"; + break; + // case XCA_FVG_BULL: case XCA_FVG_BEAR: result = "XCA_FVG"; @@ -146,10 +161,18 @@ ENUM_XCA_PIVOTS GetPivotType(XBoxZone &value) } // + bool isSWL = value.type == GetBoxType(XCA_SWL) && + value.dir == GetDirection(XCA_SWL); + bool isSWH = value.type == GetBoxType(XCA_SWH) && + value.dir == GetDirection(XCA_SWH); bool isPeak = value.type == GetBoxType(XCA_PEAK) && value.dir == GetDirection(XCA_PEAK); bool isVale = value.type == GetBoxType(XCA_VALE) && value.dir == GetDirection(XCA_VALE); + bool isOBBull = value.type == GetBoxType(XCA_OB_BULL) && + value.dir == GetDirection(XCA_OB_BULL); + bool isOBBear = value.type == GetBoxType(XCA_OB_BEAR) && + value.dir == GetDirection(XCA_OB_BEAR); bool isFVGBull = value.type == GetBoxType(XCA_FVG_BULL) && value.dir == GetDirection(XCA_FVG_BULL); bool isFVGBear = value.type == GetBoxType(XCA_FVG_BEAR) && @@ -164,7 +187,15 @@ ENUM_XCA_PIVOTS GetPivotType(XBoxZone &value) value.dir == GetDirection(XCA_TREND_BEAR); // - if (isPeak) + if (isSWL) + { + result = XCA_SWL; + } + else if (isSWH) + { + result = XCA_SWH; + } + else if (isPeak) { result = XCA_PEAK; } @@ -172,6 +203,14 @@ ENUM_XCA_PIVOTS GetPivotType(XBoxZone &value) { result = XCA_VALE; } + else if (isOBBull) + { + result = XCA_OB_BULL; + } + else if (isOBBear) + { + result = XCA_OB_BEAR; + } else if (isFVGBull) { result = XCA_FVG_BULL; @@ -809,6 +848,16 @@ class XCXCAEAPOIDetector : public XCBase ticksDividerInPoints = 15; pivotDetectionLoopbac = 100; + // + // SWING ... + + // + maxAllowedSwingLifetime = 0; + + // + detectSWHPivots = false; + detectSWLPivots = false; + // // PV ... @@ -842,8 +891,17 @@ class XCXCAEAPOIDetector : public XCBase applyLastBarToFVGBoundary = false; selectOnlyFVGWhichHasIndirectionalLastBar = false; + // + // OB ... + maxAllowedOBLifetime = 0; + + // + detectOBBullishPivots = false; + detectOBBearishPivots = false; + // // TREND ... + maxAllowedTrendLifetime = 0; // detectTrendBullishPivots = false; @@ -880,8 +938,12 @@ class XCXCAEAPOIDetector : public XCBase int p3IDX = p2IDX + 1; // + newSWHPivotDetected = false; + newSWLPivotDetected = false; newPeakPivotDetected = false; newValePivotDetected = false; + newOBBullishPivotDetected = false; + newOBBearishPivotDetected = false; newFVGBullishPivotDetected = false; newFVGBearishPivotDetected = false; newTrendBullishPivotDetected = false; @@ -943,6 +1005,41 @@ class XCXCAEAPOIDetector : public XCBase // // Checking Pivots ... + // + // SWING ... + + // + // SWH ... + if (detectSWHPivots) + { + // + newSWHPivotDetected = DetectSwingPivot( + barIndex, + X_DIRECTION_BEARISH, + zBar, + cBar, + pBar, + p2Bar, + conditions // + ); + } + + // + // SWL ... + if (detectSWLPivots) + { + // + newSWLPivotDetected = DetectSwingPivot( + barIndex, + X_DIRECTION_BULLISH, + zBar, + cBar, + pBar, + p2Bar, + conditions // + ); + } + // // PV ... @@ -1013,6 +1110,41 @@ class XCXCAEAPOIDetector : public XCBase ); } + // + // OB ... + + // + // Bullish ... + if (detectOBBullishPivots) + { + // + newOBBullishPivotDetected = DetectOBPivot( + barIndex, + X_DIRECTION_BULLISH, + zBar, + cBar, + pBar, + p2Bar, + conditions // + ); + } + + // + // Bearish ... + if (detectOBBearishPivots) + { + // + newOBBearishPivotDetected = DetectOBPivot( + barIndex, + X_DIRECTION_BEARISH, + zBar, + cBar, + pBar, + p2Bar, + conditions // + ); + } + // // TREND ... @@ -1075,6 +1207,13 @@ class XCXCAEAPOIDetector : public XCBase // // Implement Validation Senarios ... + // + // SWING ... + ValidateSwingPivots( + unavailables, + barIndex // + ); + // // PV ... ValidatePeakValePivots( @@ -1082,6 +1221,13 @@ class XCXCAEAPOIDetector : public XCBase barIndex // ); + // + // OB ... + ValidateOBPivots( + unavailables, + barIndex // + ); + // // FVG ... ValidateFVGPivots( @@ -1136,6 +1282,13 @@ class XCXCAEAPOIDetector : public XCBase // Bullish ... if (canFillBullish) { + // + Copy( + swlPivots, + pivots, + false // + ); + // Copy( valePivots, @@ -1143,6 +1296,13 @@ class XCXCAEAPOIDetector : public XCBase false // ); + // + Copy( + obBullishPivots, + pivots, + false // + ); + // Copy( fvgBullishPivots, @@ -1162,6 +1322,13 @@ class XCXCAEAPOIDetector : public XCBase // Bearish ... if (canFillBearish) { + // + Copy( + swhPivots, + pivots, + false // + ); + // Copy( peakPivots, @@ -1169,6 +1336,13 @@ class XCXCAEAPOIDetector : public XCBase false // ); + // + Copy( + obBearishPivots, + pivots, + false // + ); + // Copy( fvgBearishPivots, @@ -1209,6 +1383,425 @@ class XCXCAEAPOIDetector : public XCBase return ArraySize(invalidPivots); } + // + // SWING ... + + // + int maxAllowedSwingLifetime; // Max Allowed Swing Life ... + + // + bool DetectSwingPivot( + int barIndex, + ENUM_X_DIRECTION forDir, + XOHCL &zBar, + XOHCL &cBar, + XOHCL &pBar, + XOHCL &p2Bar, + XCAEAConditions &conditions // + ) + { + // + bool result = false; + + // + // Checking Direction ... + result = HasDirection(forDir); + if (!result) + { + return result; + } + + // + bool forBullish = IsBullish(forDir); + bool forBearish = IsBearish(forDir); + + // + // Check Allowed ... + result = + forBullish + ? detectSWLPivots + : detectSWHPivots; + if (!result) + { + return result; + } + + // + // Validate Args ... + result = + // + barIndex >= 0 && + zBar.IsValid() && + cBar.IsValid() && + pBar.IsValid() && + p2Bar.IsValid() + // + ; + 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]; + + // + // VALE ... + double zVale = conditions.valeBuffer[zIDX]; + double cVale = conditions.valeBuffer[cIDX]; + double pVale = conditions.valeBuffer[pIDX]; + double p2Vale = conditions.valeBuffer[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]; + + // + // Prepare Conditinal Conditions ... + + // + // SWH ... + + // + bool isSWHSameLast = cSwingHigh == pSwingHigh; + bool isSWHSameLastPrev = pSwingHigh == p2SwingHigh; + + // + bool isSWHSwitchedToSameLast = isSWHSameLast && + !isSWHSameLastPrev; + bool isSWHFinishedFromSameLast = !isSWHSameLast && + isSWHSameLastPrev; + + // + // SWL ... + + // + bool isSWLSameLast = cSwingLow == pSwingLow; + bool isSWLSameLastPrev = pSwingLow == p2SwingLow; + + // + bool isSWLSwitchedToSameLast = isSWLSameLast && + !isSWLSameLastPrev; + bool isSWLFinishedFromSameLast = !isSWLSameLast && + isSWLSameLastPrev; + + // + // Summarizing Conditions ... + + // + result = false; + + // + bool hasStartCondition = + // + forBullish + ? isSWLFinishedFromSameLast + : isSWHFinishedFromSameLast + // + ; + + // + bool hasContinuationCondition = + // + forBullish + ? isSWLSameLast + : isSWHSameLast + // + ; + + // + bool hasEndCondition = + // + forBullish + ? isSWLSwitchedToSameLast + : isSWHSwitchedToSameLast + // + ; + + // + // + // + + // + // ReInstance Pivot ... + if (hasStartCondition) + { + // + // SWL ... + if (forBullish) + { + // + swlPivot.Clean(); + + // + swlPivot.type = XCA_SWL; + swlPivot.symbol = symbol; + swlPivot.period = period; + + // + swlPivot.to = pBar.time; + swlPivot.from = pBar.time; + swlPivot.value = pSwingLow; + swlPivot.reserve = pVale; + } + + // + // SWH ... + if (forBearish) + { + // + swhPivot.Clean(); + + // + swhPivot.type = XCA_SWH; + swhPivot.symbol = symbol; + swhPivot.period = period; + + // + swhPivot.to = pBar.time; + swhPivot.from = pBar.time; + swhPivot.value = pSwingHigh; + swhPivot.reserve = pPeak; + } + } + + // + // Calculate and Fill Pivot Requirements ... + if (hasContinuationCondition) + { + // + // SWL ... + if (forBullish) + { + // + swlPivot.from = pBar.time; + + // + swlPivot.reserve = + swlPivot.reserve == 0 + ? pVale + : MathMin(swlPivot.reserve, pVale); + } + + // + // SWH ... + if (forBearish) + { + // + swhPivot.from = pBar.time; + + // + swhPivot.reserve = + swhPivot.reserve == 0 + ? pPeak + : MathMin(swhPivot.reserve, pPeak); + } + } + + // + // End up Pivot and Store it ... + if (hasEndCondition) + { + // + // SWL ... + if (forBullish) + { + // + result = + swlPivot.IsValid() && + swlPivot.GetAge() >= pivotVerifications; + if (result) + { + // + XBoxZone iBox; + result = swlPivot.AsBox(iBox); + if (result) + { + // + newSWLPivotDetected = AddBox( + iBox, + swlPivots // + ); + } + + // + iBox.Clean(); + } + + // + swlPivot.Clean(); + } + + // + // SWH ... + if (forBearish) + { + // + result = + swhPivot.IsValid() && + swhPivot.GetAge() >= pivotVerifications; + if (result) + { + // + XBoxZone iBox; + result = swhPivot.AsBox(iBox); + if (result) + { + // + newSWHPivotDetected = AddBox( + iBox, + swhPivots // + ); + } + + // + iBox.Clean(); + } + + // + swhPivot.Clean(); + } + } + + // + return result; + } + + // + void ValidateSwingPivots( + XBoxZone &unavailables[], + int barIndex = 0 // + ) + { + // + bool has = false; + + // + bool applyLifetimeValidating = maxAllowedSwingLifetime > 0; + + // + // SWH ... + has = HasSWHPivots(); + if (has) + { + // + ApplyValidationOnBoxes( + swhPivots, + unavailables, + barIndex // + ); + + // + if (applyLifetimeValidating) + { + // + ApplyLifeTimeValidationOnBoxes( + swhPivots, + maxAllowedSwingLifetime, + barIndex // + ); + } + } + + // + // SWL ... + has = HasSWLPivots(); + if (has) + { + // + ApplyValidationOnBoxes( + swlPivots, + unavailables, + barIndex // + ); + + // + if (applyLifetimeValidating) + { + // + ApplyLifeTimeValidationOnBoxes( + swlPivots, + maxAllowedSwingLifetime, + barIndex // + ); + } + } + } + + // + // SWL ... + + // + XCAPivot swlPivot; + bool detectSWLPivots; + XBoxZone swlPivots[]; + bool newSWLPivotDetected; + + // + bool HasSWLPivots() + { + return HasChild(swlPivots); + } + + // + int CountSWLPivots() + { + return ArraySize(swlPivots); + } + + // + // SWH ... + + // + XCAPivot swhPivot; + bool detectSWHPivots; + XBoxZone swhPivots[]; + bool newSWHPivotDetected; + + // + bool HasSWHPivots() + { + return HasChild(swhPivots); + } + + // + int CountSWHPivots() + { + return ArraySize(swhPivots); + } + // // PV ... @@ -1728,7 +2321,7 @@ class XCXCAEAPOIDetector : public XCBase if (result) { // - newPeakPivotDetected = AddBox( + newValePivotDetected = AddBox( iBox, valePivots // ); @@ -1880,6 +2473,271 @@ class XCXCAEAPOIDetector : public XCBase return ArraySize(valePivots); } + // + // OB ... + int maxAllowedOBLifetime; // Max Allowed OB Life ... + + // + bool DetectOBPivot( + int barIndex, + ENUM_X_DIRECTION forDir, + XOHCL &zBar, + XOHCL &cBar, + XOHCL &pBar, + XOHCL &p2Bar, + XCAEAConditions &conditions // + ) + { + // + bool result = false; + + // + // Checking Direction ... + result = HasDirection(forDir); + if (!result) + { + return result; + } + + // + bool forBullish = IsBullish(forDir); + bool forBearish = IsBearish(forDir); + + // + // Check Allowed ... + result = + forBullish + ? detectOBBullishPivots + : detectOBBearishPivots; + if (!result) + { + return result; + } + + // + // Validate Args ... + result = + // + barIndex >= 0 && + zBar.IsValid() && + cBar.IsValid() && + pBar.IsValid() && + p2Bar.IsValid() + // + ; + if (!result) + { + return result; + } + + // + // Prepare Conditinal Conditions ... + + // + // Default OB Detection ... + XBoxZone obBox; + bool isOB = barAnalyser.IsOB( + cBar, + obBox, + true, // OB FVG Bar Type ... + true // TWO Bar Verification ... + ); + bool isBullishOB = + isOB && + forBullish && + obBox.IsBullish(); + bool isBearishOB = + isOB && + forBearish && + obBox.IsBearish(); + + // + // Summarizing Conditions ... + + // + result = false; + + // + bool hasStartCondition = false; + bool hasContinuationCondition = false; + bool hasEndCondition = isBullishOB || + isBearishOB; + + // + // ReInstance Pivot ... + if (hasStartCondition) + { + // + } + + // + // Calculate and Fill Pivot Requirements ... + if (hasContinuationCondition) + { + // + } + + // + // End up Pivot and Store it ... + if (hasEndCondition) + { + // + XBoxZone iBox; + XCAPivot iPivot; + + // + iPivot.to = obBox.to; + iPivot.from = obBox.from; + iPivot.symbol = obBox.symbol; + iPivot.period = obBox.period; + iPivot.type = forBullish + ? XCA_OB_BULL + : XCA_OB_BEAR; + iPivot.value = forBullish + ? obBox.lower + : obBox.upper; + iPivot.reserve = forBullish + ? obBox.upper + : obBox.lower; + + // + result = iPivot.IsValid(); + if (result) + { + // + result = iPivot.AsBox(iBox); + if (result) + { + // + if (forBullish) + { + // + result = AddBox( + iBox, + obBullishPivots // + ); + } + else + { + // + result = AddBox( + iBox, + obBearishPivots // + ); + } + } + } + + // + iBox.Clean(); + iPivot.Clean(); + } + + // + return result; + } + + // + void ValidateOBPivots( + XBoxZone &unavailables[], + int barIndex = 0 // + ) + { + // + bool has = false; + + // + bool applyLifetimeValidating = maxAllowedOBLifetime > 0; + + // + // Bullish ... + has = HasOBBullishPivots(); + if (has) + { + // + ApplyValidationOnBoxes( + obBullishPivots, + unavailables, + barIndex // + ); + + // + if (applyLifetimeValidating) + { + // + ApplyLifeTimeValidationOnBoxes( + obBullishPivots, + maxAllowedOBLifetime, + barIndex // + ); + } + } + + // + // Bearish ... + has = HasOBBearishPivots(); + if (has) + { + // + ApplyValidationOnBoxes( + obBearishPivots, + unavailables, + barIndex // + ); + + // + if (applyLifetimeValidating) + { + // + ApplyLifeTimeValidationOnBoxes( + obBearishPivots, + maxAllowedOBLifetime, + barIndex // + ); + } + } + } + + // + // OB Bullish Pivots ... + + // + bool detectOBBullishPivots; + XBoxZone obBullishPivots[]; + bool newOBBullishPivotDetected; + + // + bool HasOBBullishPivots() + { + return HasChild(obBullishPivots); + } + + // + int CountOBBullishPivots() + { + return ArraySize(obBullishPivots); + } + + // + // OB Bearish Pivots ... + + // + bool detectOBBearishPivots; + XBoxZone obBearishPivots[]; + bool newOBBearishPivotDetected; + + // + bool HasOBBearishPivots() + { + return HasChild(obBearishPivots); + } + + // + int CountOBBearishPivots() + { + return ArraySize(obBearishPivots); + } + // // FVG ... @@ -3097,15 +3955,25 @@ class XCXCAEAPOIDetector : public XCBase Clean(invalidPivots); // + swlPivot.Clean(); + swhPivot.Clean(); peakPivot.Clean(); valePivot.Clean(); trendBullishPivot.Clean(); trendBearishPivot.Clean(); + // + Clean(swlPivots); + Clean(swhPivots); + // Clean(peakPivots); Clean(valePivots); + // + Clean(obBullishPivots); + Clean(obBearishPivots); + // Clean(fvgBullishPivots); Clean(fvgBearishPivots); @@ -3129,6 +3997,25 @@ class XCXCAEAPOIDetector : public XCBase ApplySortOnBoxes(invalidPivots); } + // + // SWING ... + + // + // SWH ... + has = HasSWHPivots(); + if (has) + { + ApplySortOnBoxes(swhPivots); + } + + // + // SWL ... + has = HasSWLPivots(); + if (has) + { + ApplySortOnBoxes(swlPivots); + } + // // PV ... @@ -3148,6 +4035,25 @@ class XCXCAEAPOIDetector : public XCBase ApplySortOnBoxes(valePivots); } + // + // OB ... + + // + // Bullish ... + has = HasOBBullishPivots(); + if (has) + { + ApplySortOnBoxes(obBullishPivots); + } + + // + // Bearish ... + has = HasOBBearishPivots(); + if (has) + { + ApplySortOnBoxes(obBearishPivots); + } + // // FVG ... diff --git a/XCAEA/Classes/xcaea.x-poi.drawer.class.mq5 b/XCAEA/Classes/xcaea.x-poi.drawer.class.mq5 index c115473c..380186f1 100644 --- a/XCAEA/Classes/xcaea.x-poi.drawer.class.mq5 +++ b/XCAEA/Classes/xcaea.x-poi.drawer.class.mq5 @@ -84,8 +84,12 @@ class XCXCAEAPOIDrawer : public XCBase // // Drawers ... + bool drawSWHPivots; + bool drawSWLPivots; bool drawPeakPivots; bool drawValePivots; + bool drawOBBullishPivots; + bool drawOBBearishPivots; bool drawFVGBullishPivots; bool drawFVGBearishPivots; bool drawTrendBullishPivots; @@ -98,10 +102,18 @@ class XCXCAEAPOIDrawer : public XCBase XCAPivotStyle defaultBullishStyle; XCAPivotStyle defaultBearishStyle; + // + XCAPivotStyle swhPivotStyle; + XCAPivotStyle swlPivotStyle; + // XCAPivotStyle peakPivotStyle; XCAPivotStyle valePivotStyle; + // + XCAPivotStyle obBullishPivotStyle; + XCAPivotStyle obBearishPivotStyle; + // XCAPivotStyle fvgBullishPivotStyle; XCAPivotStyle fvgBearishPivotStyle; @@ -147,8 +159,12 @@ class XCXCAEAPOIDrawer : public XCBase { // // Drawing ... + drawSWHPivots = false; + drawSWLPivots = false; drawPeakPivots = false; drawValePivots = false; + drawOBBullishPivots = false; + drawOBBearishPivots = false; drawFVGBullishPivots = false; drawFVGBearishPivots = false; drawTrendBullishPivots = false; @@ -172,11 +188,21 @@ class XCXCAEAPOIDrawer : public XCBase // // Pivots ... + // + // SWING ... + swhPivotStyle = defaultBearishStyle; + swlPivotStyle = defaultBullishStyle; + // // PV ... peakPivotStyle = defaultBearishStyle; valePivotStyle = defaultBullishStyle; + // + // OB ... + obBullishPivotStyle = defaultBullishStyle; + obBearishPivotStyle = defaultBearishStyle; + // // FVG ... fvgBullishPivotStyle = defaultBullishStyle; @@ -191,11 +217,21 @@ class XCXCAEAPOIDrawer : public XCBase // void Draw(datetime to = NULL) { + // + // SWING ... + DrawSWHPivots(to); + DrawSWLPivots(to); + // // PV ... DrawPeakPivots(to); DrawValePivots(to); + // + // OB ... + DrawOBBullishPivots(to); + DrawOBBearishPivots(to); + // // FVG ... DrawFVGBullishPivots(to); @@ -210,7 +246,9 @@ class XCXCAEAPOIDrawer : public XCBase // void DrawBox( XBoxZone &box, - datetime to = NULL // + datetime to = NULL, + bool drawMiddle = false, + bool ignoreType = false // ) { // @@ -219,78 +257,205 @@ class XCXCAEAPOIDrawer : public XCBase { return; } + // - // Detect Pivot Type ... - ENUM_XCA_PIVOTS iType = GetPivotType(box); - has = IsValid(iType); - if (!has) + bool canUpdateTo = IsValid(to); + if (canUpdateTo) { - return; + box.to = to; } // - switch (iType) + // Draw Box as POI ... + if (!ignoreType) { - // - case XCA_PEAK: // - DrawPeakPivot( - box, - to // - ); - break; + // Detect Pivot Type ... + ENUM_XCA_PIVOTS iType = GetPivotType(box); + has = IsValid(iType); + if (!has) + { + return; + } // - case XCA_VALE: + switch (iType) + { // - DrawValePivot( - box, - to // - ); - break; + case XCA_SWH: + // + DrawSWHPivot( + box, + to // + ); + break; - // - case XCA_FVG_BULL: - // - DrawFVGBullishPivot( - box, - to // - ); - break; + // + case XCA_SWL: + // + DrawSWLPivot( + box, + to // + ); + break; - // - case XCA_FVG_BEAR: // - DrawFVGBearishPivot( - box, - to // - ); - break; + case XCA_PEAK: + // + DrawPeakPivot( + box, + to // + ); + break; - // - case XCA_TREND_BULL: - // - DrawTrendBullishPivot( - box, - to // - ); - break; + // + case XCA_VALE: + // + DrawValePivot( + box, + to // + ); + break; - // - case XCA_TREND_BEAR: // - DrawTrendBearishPivot( + case XCA_OB_BULL: + // + DrawOBBullishPivot( + box, + to // + ); + break; + + // + case XCA_OB_BEAR: + // + DrawOBBearishPivot( + box, + to // + ); + break; + + // + case XCA_FVG_BULL: + // + DrawFVGBullishPivot( + box, + to // + ); + break; + + // + case XCA_FVG_BEAR: + // + DrawFVGBearishPivot( + box, + to // + ); + break; + + // + case XCA_TREND_BULL: + // + DrawTrendBullishPivot( + box, + to // + ); + break; + + // + case XCA_TREND_BEAR: + // + DrawTrendBearishPivot( + box, + to // + ); + break; + } + } + // + // Draw Regular Box ... + else + { + // + // Select Styling Config ... + XCAPivotStyle style; + + // + if (box.IsBullish()) + { + style = defaultBullishStyle; + } + else + { + style = defaultBearishStyle; + } + + // + // Draw Box itself ... + XCBoxObject *iBoxObj; + has = drawer.DrawBox( box, - to // + iBoxObj // ); - break; + if (has) + { + // + // Style Object ... + ApplyPivotStyle( + iBoxObj, + style // + ); + + // + // Store Object ... + mObjects.Add(iBoxObj); + } + + // + // Draw Box Middle Range ... + if (drawMiddle) + { + // + double middle = box.GetMid(); + string middleName = box.GetMiddleTag(); + + // + CChartObjectTrend *iMidObj; + iMidObj = new CChartObjectTrend(); + has = iMidObj.Create( + drawer.ChartIdentification(), + middleName, + drawer.SubWindowIdentification(), + box.from, + middle, + box.to, + middle // + ); + if (has) + { + // + // Styling Object ... + iMidObj.Color(style.clr); + iMidObj.Width(style.width); + iMidObj.Style(style.style); + + // + // Store Object ... + mObjects.Add(iMidObj); + } + } + + // + style.Clean(); } } // void DrawBoxes( XBoxZone &boxes[], - datetime to = NULL // + datetime to = NULL, + bool drawMiddle = false, + bool ignoreType = false // ) { // @@ -311,7 +476,9 @@ class XCXCAEAPOIDrawer : public XCBase // Detect Pivot Type ... DrawBox( iBox, - to // + to, + drawMiddle, + ignoreType // ); // @@ -329,8 +496,12 @@ class XCXCAEAPOIDrawer : public XCBase // // Cleanup Styles ... + swhPivotStyle.Clean(); + swlPivotStyle.Clean(); peakPivotStyle.Clean(); valePivotStyle.Clean(); + obBullishPivotStyle.Clean(); + obBearishPivotStyle.Clean(); fvgBullishPivotStyle.Clean(); fvgBearishPivotStyle.Clean(); trendBullishPivotStyle.Clean(); @@ -338,8 +509,13 @@ class XCXCAEAPOIDrawer : public XCBase // // Cleanup Pivot Objects Holder ... + mObjects.Clear(); + mSWHPivotObjects.Clear(); + mSWLPivotObjects.Clear(); mPeakPivotObjects.Clear(); mValePivotObjects.Clear(); + mOBBullishPivotObjects.Clear(); + mOBBearishPivotObjects.Clear(); mFVGBullishPivotObjects.Clear(); mFVGBearishPivotObjects.Clear(); mTrendBullishPivotObjects.Clear(); @@ -349,6 +525,76 @@ class XCXCAEAPOIDrawer : public XCBase // // Collection Drawers ... + // + void DrawSWHPivots(datetime to = NULL) + { + // + bool has = drawSWHPivots; + if (!has) + { + return; + } + + // + has = detector.HasSWHPivots(); + if (!has) + { + return; + } + + // + int count = detector.CountSWHPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox = detector.swhPivots[i]; + + // + DrawSWHPivot( + iBox, + to // + ); + + // + iBox.Clean(); + } + } + + // + void DrawSWLPivots(datetime to = NULL) + { + // + bool has = drawSWLPivots; + if (!has) + { + return; + } + + // + has = detector.HasSWLPivots(); + if (!has) + { + return; + } + + // + int count = detector.CountSWLPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox = detector.swlPivots[i]; + + // + DrawSWLPivot( + iBox, + to // + ); + + // + iBox.Clean(); + } + } + // void DrawPeakPivots(datetime to = NULL) { @@ -419,6 +665,76 @@ class XCXCAEAPOIDrawer : public XCBase } } + // + void DrawOBBullishPivots(datetime to = NULL) + { + // + bool has = drawOBBullishPivots; + if (!has) + { + return; + } + + // + has = detector.HasOBBullishPivots(); + if (!has) + { + return; + } + + // + int count = detector.CountOBBullishPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox = detector.obBullishPivots[i]; + + // + DrawOBBullishPivot( + iBox, + to // + ); + + // + iBox.Clean(); + } + } + + // + void DrawOBBearishPivots(datetime to = NULL) + { + // + bool has = drawOBBearishPivots; + if (!has) + { + return; + } + + // + has = detector.HasOBBearishPivots(); + if (!has) + { + return; + } + + // + int count = detector.CountOBBearishPivots(); + for (int i = 0; i < count; i++) + { + // + XBoxZone iBox = detector.obBearishPivots[i]; + + // + DrawOBBearishPivot( + iBox, + to // + ); + + // + iBox.Clean(); + } + } + // void DrawFVGBullishPivots(datetime to = NULL) { @@ -562,6 +878,112 @@ class XCXCAEAPOIDrawer : public XCBase // // One Item Drawers ... + // + void DrawSWHPivot( + XBoxZone &item, + datetime to = NULL // + ) + { + // + bool has = drawSWHPivots; + if (!has) + { + return; + } + + // + has = item.IsValid() && + item.type == GetBoxType(XCA_SWH) && + item.dir == GetDirection(XCA_SWH); + if (!has) + { + return; + } + + // + bool canUpdateTo = IsValid(to); + if (canUpdateTo) + { + item.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + item, + iObj // + ); + if (has) + { + // + // Style Object ... + ApplyPivotStyle( + iObj, + swhPivotStyle // + ); + + // + // Store Object ... + mSWHPivotObjects.Add(iObj); + } + + // + ZeroMemory(iObj); + } + + // + void DrawSWLPivot( + XBoxZone &item, + datetime to = NULL // + ) + { + // + bool has = drawSWLPivots; + if (!has) + { + return; + } + + // + has = item.IsValid() && + item.type == GetBoxType(XCA_SWL) && + item.dir == GetDirection(XCA_SWL); + if (!has) + { + return; + } + + // + bool canUpdateTo = IsValid(to); + if (canUpdateTo) + { + item.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + item, + iObj // + ); + if (has) + { + // + // Style Object ... + ApplyPivotStyle( + iObj, + swlPivotStyle // + ); + + // + // Store Object ... + mSWLPivotObjects.Add(iObj); + } + + // + ZeroMemory(iObj); + } + // void DrawPeakPivot( XBoxZone &item, @@ -668,6 +1090,112 @@ class XCXCAEAPOIDrawer : public XCBase ZeroMemory(iObj); } + // + void DrawOBBullishPivot( + XBoxZone &item, + datetime to = NULL // + ) + { + // + bool has = drawOBBullishPivots; + if (!has) + { + return; + } + + // + has = item.IsValid() && + item.type == GetBoxType(XCA_OB_BULL) && + item.dir == GetDirection(XCA_OB_BULL); + if (!has) + { + return; + } + + // + bool canUpdateTo = IsValid(to); + if (canUpdateTo) + { + item.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + item, + iObj // + ); + if (has) + { + // + // Style Object ... + ApplyPivotStyle( + iObj, + obBullishPivotStyle // + ); + + // + // Store Object ... + mOBBullishPivotObjects.Add(iObj); + } + + // + ZeroMemory(iObj); + } + + // + void DrawOBBearishPivot( + XBoxZone &item, + datetime to = NULL // + ) + { + // + bool has = drawOBBearishPivots; + if (!has) + { + return; + } + + // + has = item.IsValid() && + item.type == GetBoxType(XCA_OB_BEAR) && + item.dir == GetDirection(XCA_OB_BEAR); + if (!has) + { + return; + } + + // + bool canUpdateTo = IsValid(to); + if (canUpdateTo) + { + item.to = to; + } + + // + XCBoxObject *iObj; + has = drawer.DrawBox( + item, + iObj // + ); + if (has) + { + // + // Style Object ... + ApplyPivotStyle( + iObj, + obBearishPivotStyle // + ); + + // + // Store Object ... + mOBBearishPivotObjects.Add(iObj); + } + + // + ZeroMemory(iObj); + } + // void DrawFVGBullishPivot( XBoxZone &item, @@ -914,10 +1442,21 @@ class XCXCAEAPOIDrawer : public XCBase XCPOIDrawer *drawer; XCXCAEAPOIDetector *detector; + // + CArrayObj mObjects; + + // + CArrayObj mSWHPivotObjects; + CArrayObj mSWLPivotObjects; + // CArrayObj mPeakPivotObjects; CArrayObj mValePivotObjects; + // + CArrayObj mOBBullishPivotObjects; + CArrayObj mOBBearishPivotObjects; + // CArrayObj mFVGBullishPivotObjects; CArrayObj mFVGBearishPivotObjects; diff --git a/XCAEA/Libraries/xcaea.signaller.lib.mq5 b/XCAEA/Libraries/xcaea.signaller.lib.mq5 index a8fb4339..6dbf9993 100644 --- a/XCAEA/Libraries/xcaea.signaller.lib.mq5 +++ b/XCAEA/Libraries/xcaea.signaller.lib.mq5 @@ -1773,6 +1773,11 @@ bool CanTriggerCond3( barIndex // ); + // + // Validate Box ... + // For Box Validating we use 50% of Box Range ... + // if Price Touched Box 50% rate we Invalidate Box ... + // // Detect Box FVG ... diff --git a/XCAEA/Signals/xcaea.signaller.class.mq5 b/XCAEA/Signals/xcaea.signaller.class.mq5 index 744522fb..7a553f4d 100644 --- a/XCAEA/Signals/xcaea.signaller.class.mq5 +++ b/XCAEA/Signals/xcaea.signaller.class.mq5 @@ -40,13 +40,11 @@ class XCXCAEASignaller : XCBase // // Props ... bool useGuards; - bool useTargets; int poiLoopback; XCAEAInputs inputs; XBarTracker barTraker; XCXCAEAHelper *helper; XCXCAEAPOIDrawer *drawer; - bool continuesRFTillTarget; XBoxZone unAvailableBoxes[]; XCXCAEAHelper *analyseHelper; XCXCAEAPOIDetector *detector; @@ -87,8 +85,6 @@ class XCXCAEASignaller : XCBase { // useGuards = false; - useTargets = true; - continuesRFTillTarget = false; // barTraker.Init( @@ -97,248 +93,12 @@ class XCXCAEASignaller : XCBase ); // - inputs.Default(); + // Initial Indicators ... + InitHelper(); // - // Configure Indicators ... - - // - // XCC ... - inputs.ccInputs.showCandles = true; - - // - // XCT ... - inputs.ctInputs.showCandleTime = true; - - // - // XCA ... - - // - inputs.caInputs.supResSmoothingLength = 7; - inputs.caInputs.supResSmoothingMode = X_MA_MODE_NONE; - - // - inputs.x3maInputs.applyColor = true; - - // - inputs.x3maInputs.fastLength = 5; - - // - inputs.x3maInputs.showFast = false; - inputs.x3maInputs.showSlow = false; - inputs.x3maInputs.showMedium = false; - - // - inputs.caInputs.showMAH = false; - inputs.caInputs.showMAL = false; - inputs.caInputs.showMAC = false; - inputs.caInputs.showSar = false; - inputs.caInputs.showSwings = true; - inputs.caInputs.showFiboLevel1 = false; - inputs.caInputs.showFiboLevel2 = false; - inputs.caInputs.showFiboLevel3 = false; - inputs.caInputs.showFiboLevel4 = false; - inputs.caInputs.showFiboLevel5 = false; - inputs.caInputs.showPeaksAndVales = true; - - // - inputs.caInputs.showKI = false; - inputs.caInputs.showTKI = false; - inputs.caInputs.showVidya = false; - inputs.caInputs.showTrend = false; - inputs.caInputs.showPeakAndValeGolden = false; - inputs.caInputs.showSupportAndResistance = false; - - // - // XOSCS ... - // inputs.oscsInputs.rsiLength = 5; - // inputs.oscsInputs.rsiOBLevel = 90; - // inputs.oscsInputs.rsiOSLevel = 10; - // inputs.oscsInputs.cciLength = 7; - // inputs.oscsInputs.cciOBLevel = 130; - // inputs.oscsInputs.cciOSLevel = -130; - // inputs.oscsInputs.mfiLength = 5; - // inputs.oscsInputs.rviLength = 5; - - // - // Oscillators Views ... - inputs.showRSI = false; - inputs.showCCI = false; - inputs.showMFI = false; - inputs.showRVI = false; - inputs.showADX = false; - inputs.showMACD = false; - - // - // XCAEA Helper ... - helper = new XCXCAEAHelper(); - helper.Init( - symbol, - period, - inputs // - ); - - // - // XCAEA Analyse Helper ... - analyseHelper = new XCXCAEAHelper(); - analyseHelper.Init( - symbol, - analysePeriod, - inputs // - ); - - // - // Initialize and Configure Detector ... - detector = new XCXCAEAPOIDetector(helper); - - // - // Common Configurations ... - detector.maxAllowedPivots = 0; - detector.pivotVerifications = 5; - detector.ticksDividerInPoints = 15; - detector.pivotDetectionLoopbac = 1000; - - // - // Configure Detector ... - - // - // PV ... - - // - detector.maxAllowedPVLifetime = 0; - detector.applySwingsOnPVPivots = true; - detector.selectRejectedPVPivots = true; - detector.selectEngulfedPVPivots = true; - detector.applySupportAndResistanceOnPVPivots = true; - - // - // PEAK ... - detector.detectPeakPivots = true; - - // - // VALE ... - detector.detectValePivots = true; - - // - // FVG ... - - // - detector.selectSameBarFVGs = false; - detector.maxAllowedFVGLifetime = 0; - detector.validateFVGUsingPV = false; - detector.applyPVToFVGBoundary = false; - detector.selectRejectedFVGPivots = false; - detector.selectEngulfedFVGPivots = false; - detector.validateFVGUsingManalyser = true; - detector.applyLastBarToFVGBoundary = false; - detector.selectOnlyFVGWhichHasIndirectionalLastBar = true; - - // - // Bullish ... - detector.detectFVGBullishPivots = true; - - // - // Bearish ... - detector.detectFVGBearishPivots = true; - - // - // TREND ... - - // - detector.maxAllowedTrendLifetime = 0; - - // - // Bullish ... - detector.detectTrendBullishPivots = true; - - // - // Bearish ... - detector.detectTrendBearishPivots = true; - - // - // DRAWER ... - - // - // Initialize and Configure Drawer ... - drawer = new XCXCAEAPOIDrawer(detector); - - // - drawer.ignoreUpdateOSCTos = true; - - // - // Configure Drawer ... - drawer.drawPeakPivots = true; - drawer.drawValePivots = true; - drawer.drawFVGBullishPivots = true; - drawer.drawFVGBearishPivots = true; - drawer.drawTrendBullishPivots = true; - drawer.drawTrendBearishPivots = true; - - // - // Configure Styles ... - - // - // PV ... - - // - // PEAK ... - XCAPivotStyle peakStyle; - peakStyle.width = 2; - peakStyle.clr = clrMagenta; - peakStyle.style = STYLE_SOLID; - drawer.peakPivotStyle = peakStyle; - peakStyle.Clean(); - - // - // VALE ... - XCAPivotStyle valeStyle; - valeStyle.width = 2; - valeStyle.clr = clrAqua; - valeStyle.style = STYLE_SOLID; - drawer.valePivotStyle = valeStyle; - valeStyle.Clean(); - - // - // FVG ... - - // - // Bullish ... - XCAPivotStyle fvgBullishStyle; - fvgBullishStyle.width = 2; - fvgBullishStyle.clr = clrLime; - fvgBullishStyle.style = STYLE_DASH; - drawer.fvgBullishPivotStyle = fvgBullishStyle; - fvgBullishStyle.Clean(); - - // - // Bearish ... - XCAPivotStyle fvgBearishStyle; - fvgBearishStyle.width = 2; - fvgBearishStyle.clr = clrRed; - fvgBearishStyle.style = STYLE_DASH; - drawer.fvgBearishPivotStyle = fvgBearishStyle; - fvgBearishStyle.Clean(); - - // - // TREND ... - - // - // Bullish ... - XCAPivotStyle trendBullishStyle; - trendBullishStyle.width = 2; - trendBullishStyle.clr = clrLime; - trendBullishStyle.style = STYLE_DOT; - drawer.trendBullishPivotStyle = trendBullishStyle; - trendBullishStyle.Clean(); - - // - // Bearish ... - XCAPivotStyle trendBearishStyle; - trendBearishStyle.width = 2; - trendBearishStyle.clr = clrRed; - trendBearishStyle.style = STYLE_DOT; - drawer.trendBearishPivotStyle = trendBearishStyle; - trendBearishStyle.Clean(); + // Initial POI Detector and Drawer ... + InitDetectorAndDrawer(); // } @@ -465,39 +225,50 @@ class XCXCAEASignaller : XCBase return result; } + // + // Detect Pivots ... + detector.Detect(zIndex); + + // + // Validate Pivots ... + detector.Validate( + unAvailableBoxes, + zIndex // + ); + + // + // Draw Pivots ... + drawer.Draw(cTime); + // // Setup Conditions ... XBoxZone decisionZone; - bool hasDecisionZone = false; XCAEAConditions conditions; + bool hasDecisionZone = false; ENUM_X_DIRECTION decisionZoneDir = X_DIRECTION_NONE; // // Checking Signal's Decision Zone ... // On Analyse Time Frame ... - if (!HasChild(mConditionsCollection)) + hasDecisionZone = DetectDecisionZone( + analyseHelper, + drawer, + decisionZone, + decisionZoneDir, + conditions, + zIndex, + loopback // + ); + + // + // Make Signal Box UnAvailable ... + if (hasDecisionZone) { // - hasDecisionZone = DetectDecisionZone( - analyseHelper, - drawer, + AddRef( decisionZone, - decisionZoneDir, - conditions, - zIndex, - loopback // + unAvailableBoxes // ); - - // - // Make Signal Box UnAvailable ... - if (hasDecisionZone) - { - // - AddRef( - decisionZone, - unAvailableBoxes // - ); - } } // @@ -558,7 +329,7 @@ class XCXCAEASignaller : XCBase bool DetectSignalTrigger( XCAEAStrategyConditions &conditions, int barIndex = 0, - int maxAllowedSetupAge = 1000 // + int maxAllowedSetupAge = 576 // ) { // @@ -683,16 +454,49 @@ class XCXCAEASignaller : XCBase // // Draw Decision Zone ... - XCBoxObject *iObj; + XCBoxObject *iDecisionObj; has = helper.poiDrawer.DrawBox( conditions.decisionZone, - iObj // + iDecisionObj // ); if (has) { - mObjects.Add(iObj); + mObjects.Add(iDecisionObj); } - ZeroMemory(iObj); + ZeroMemory(iDecisionObj); + + // + // Drw Box Range Middle ... + double decisionMiddlePrice = conditions.decisionZone.GetMid(); + string iDecisionMiddleName = conditions.decisionZone.GetMiddleTag(); + CChartObjectTrend *iDecisionMiddleObj; + iDecisionMiddleObj = new CChartObjectTrend(); + has = iDecisionMiddleObj.Create( + 0, + iDecisionMiddleName, + 0, + conditions.decisionZone.from, + decisionMiddlePrice, + conditions.decisionZone.to, + decisionMiddlePrice // + ); + if (has) + { + // + iDecisionMiddleObj.Width(2); + iDecisionMiddleObj.Style(STYLE_DASH); + + // + color iColor = + conditions.decisionZone.IsBullish() + ? clrAqua + : clrMagenta; + iDecisionMiddleObj.Color(iColor); + + // + mObjects.Add(iDecisionMiddleObj); + } + ZeroMemory(iDecisionMiddleObj); // for (int i = 0; i < iObjects.Total(); i++) @@ -753,26 +557,26 @@ class XCXCAEASignaller : XCBase // // Handling RF ... - double rfReward = risk * 1.85; - double rfPrice = - isBullish - ? entry + rfReward - : entry - rfReward; - Add( - rfPrice, - conditions.targets // - ); + // double rfReward = risk * 1.85; + // double rfPrice = + // isBullish + // ? entry + rfReward + // : entry - rfReward; + // Add( + // rfPrice, + // conditions.targets // + // ); // - rfReward = risk * 2.85; - rfPrice = - isBullish - ? entry + rfReward - : entry - rfReward; - Add( - rfPrice, - conditions.targets // - ); + // rfReward = risk * 2.85; + // rfPrice = + // isBullish + // ? entry + rfReward + // : entry - rfReward; + // Add( + // rfPrice, + // conditions.targets // + // ); // // Handling Partial Close ... @@ -953,6 +757,308 @@ class XCXCAEASignaller : XCBase CArrayObj mObjects; CArrayObj mBarObjects; + // + void InitHelper() + { + // + inputs.Default(); + + // + // Configure Indicators ... + + // + // XCC ... + inputs.ccInputs.showCandles = true; + + // + // XCT ... + inputs.ctInputs.showCandleTime = true; + + // + // XCA ... + + // + inputs.caInputs.supResSmoothingLength = 7; + inputs.caInputs.supResSmoothingMode = X_MA_MODE_NONE; + + // + inputs.x3maInputs.applyColor = true; + + // + inputs.x3maInputs.fastLength = 5; + + // + inputs.x3maInputs.showFast = false; + inputs.x3maInputs.showSlow = false; + inputs.x3maInputs.showMedium = false; + + // + inputs.caInputs.showMAH = false; + inputs.caInputs.showMAL = false; + inputs.caInputs.showMAC = false; + inputs.caInputs.showSar = false; + inputs.caInputs.showSwings = true; + inputs.caInputs.showFiboLevel1 = false; + inputs.caInputs.showFiboLevel2 = false; + inputs.caInputs.showFiboLevel3 = false; + inputs.caInputs.showFiboLevel4 = false; + inputs.caInputs.showFiboLevel5 = false; + inputs.caInputs.showPeaksAndVales = true; + + // + inputs.caInputs.showKI = false; + inputs.caInputs.showTKI = false; + inputs.caInputs.showVidya = false; + inputs.caInputs.showTrend = false; + inputs.caInputs.showPeakAndValeGolden = false; + inputs.caInputs.showSupportAndResistance = false; + + // + // XOSCS ... + // inputs.oscsInputs.rsiLength = 5; + // inputs.oscsInputs.rsiOBLevel = 90; + // inputs.oscsInputs.rsiOSLevel = 10; + // inputs.oscsInputs.cciLength = 7; + // inputs.oscsInputs.cciOBLevel = 130; + // inputs.oscsInputs.cciOSLevel = -130; + // inputs.oscsInputs.mfiLength = 5; + // inputs.oscsInputs.rviLength = 5; + + // + // Oscillators Views ... + inputs.showRSI = false; + inputs.showCCI = false; + inputs.showMFI = false; + inputs.showRVI = false; + inputs.showADX = false; + inputs.showMACD = false; + + // + // XCAEA Helper ... + helper = new XCXCAEAHelper(); + helper.Init( + symbol, + period, + inputs // + ); + + // + // XCAEA Analyse Helper ... + analyseHelper = new XCXCAEAHelper(); + analyseHelper.Init( + symbol, + analysePeriod, + inputs // + ); + } + + // + void InitDetectorAndDrawer() + { + // + // Initialize and Configure Detector ... + detector = new XCXCAEAPOIDetector(helper); + + // + // Common Configurations ... + detector.maxAllowedPivots = 0; + detector.pivotVerifications = 5; + detector.ticksDividerInPoints = 15; + detector.pivotDetectionLoopbac = 1000; + + // + // Configure Detector ... + + // + // SWING ... + + // + detector.maxAllowedSwingLifetime = 0; + + // + detector.detectSWLPivots = false; + detector.detectSWHPivots = false; + + // + // PV ... + + // + detector.maxAllowedPVLifetime = 0; + detector.applySwingsOnPVPivots = false; + detector.selectRejectedPVPivots = false; + detector.selectEngulfedPVPivots = false; + detector.applySupportAndResistanceOnPVPivots = false; + + // + detector.detectPeakPivots = true; + detector.detectValePivots = true; + + // + // OB ... + detector.maxAllowedOBLifetime = 0; + + // + detector.detectOBBullishPivots = true; + detector.detectOBBearishPivots = true; + + // + // FVG ... + + // + detector.selectSameBarFVGs = false; + detector.maxAllowedFVGLifetime = 0; + detector.validateFVGUsingPV = false; + detector.applyPVToFVGBoundary = false; + detector.selectRejectedFVGPivots = false; + detector.selectEngulfedFVGPivots = false; + detector.validateFVGUsingManalyser = false; + detector.applyLastBarToFVGBoundary = false; + detector.selectOnlyFVGWhichHasIndirectionalLastBar = false; + + // + detector.detectFVGBullishPivots = false; + detector.detectFVGBearishPivots = false; + + // + // TREND ... + + // + detector.maxAllowedTrendLifetime = 0; + detector.detectTrendBullishPivots = false; + detector.detectTrendBearishPivots = false; + + // + // DRAWER ... + + // + // Initialize and Configure Drawer ... + drawer = new XCXCAEAPOIDrawer(detector); + + // + drawer.ignoreUpdateOSCTos = true; + + // + // Configure Drawer ... + drawer.drawSWHPivots = false; + drawer.drawSWLPivots = false; + drawer.drawPeakPivots = true; + drawer.drawValePivots = true; + drawer.drawOBBullishPivots = false; + drawer.drawOBBearishPivots = false; + drawer.drawFVGBullishPivots = false; + drawer.drawFVGBearishPivots = false; + drawer.drawTrendBullishPivots = false; + drawer.drawTrendBearishPivots = false; + + // + // Configure Styles ... + + // + // SWING ... + + // + // SWH ... + XCAPivotStyle swhStyle; + swhStyle.width = 2; + swhStyle.clr = clrMagenta; + swhStyle.style = STYLE_SOLID; + drawer.swhPivotStyle = swhStyle; + swhStyle.Clean(); + + // + // SWL ... + XCAPivotStyle swlStyle; + swlStyle.width = 2; + swlStyle.clr = clrAqua; + swlStyle.style = STYLE_SOLID; + drawer.swlPivotStyle = swlStyle; + swlStyle.Clean(); + + // + // PV ... + + // + // PEAK ... + XCAPivotStyle peakStyle; + peakStyle.width = 2; + peakStyle.clr = clrMagenta; + peakStyle.style = STYLE_SOLID; + drawer.peakPivotStyle = peakStyle; + peakStyle.Clean(); + + // + // VALE ... + XCAPivotStyle valeStyle; + valeStyle.width = 2; + valeStyle.clr = clrAqua; + valeStyle.style = STYLE_SOLID; + drawer.valePivotStyle = valeStyle; + valeStyle.Clean(); + + // + // OB ... + + // + // Bullish ... + XCAPivotStyle obBullishStyle; + obBullishStyle.width = 2; + obBullishStyle.clr = clrLime; + obBullishStyle.style = STYLE_DASH; + drawer.obBullishPivotStyle = obBullishStyle; + obBullishStyle.Clean(); + + // + // Bearish ... + XCAPivotStyle obBearishStyle; + obBearishStyle.width = 2; + obBearishStyle.clr = clrRed; + obBearishStyle.style = STYLE_DASH; + drawer.obBearishPivotStyle = obBearishStyle; + obBearishStyle.Clean(); + + // + // FVG ... + + // + // Bullish ... + XCAPivotStyle fvgBullishStyle; + fvgBullishStyle.width = 2; + fvgBullishStyle.clr = clrLime; + fvgBullishStyle.style = STYLE_DASH; + drawer.fvgBullishPivotStyle = fvgBullishStyle; + fvgBullishStyle.Clean(); + + // + // Bearish ... + XCAPivotStyle fvgBearishStyle; + fvgBearishStyle.width = 2; + fvgBearishStyle.clr = clrRed; + fvgBearishStyle.style = STYLE_DASH; + drawer.fvgBearishPivotStyle = fvgBearishStyle; + fvgBearishStyle.Clean(); + + // + // TREND ... + + // + // Bullish ... + XCAPivotStyle trendBullishStyle; + trendBullishStyle.width = 2; + trendBullishStyle.clr = clrLime; + trendBullishStyle.style = STYLE_DOT; + drawer.trendBullishPivotStyle = trendBullishStyle; + trendBullishStyle.Clean(); + + // + // Bearish ... + XCAPivotStyle trendBearishStyle; + trendBearishStyle.width = 2; + trendBearishStyle.clr = clrRed; + trendBearishStyle.style = STYLE_DOT; + drawer.trendBearishPivotStyle = trendBearishStyle; + trendBearishStyle.Clean(); + } + // };