diff --git a/Classes/x-saherelm.x-poi.drawer.class.mq5 b/Classes/x-saherelm.x-poi.drawer.class.mq5 index eb7b9c08..3b881215 100644 --- a/Classes/x-saherelm.x-poi.drawer.class.mq5 +++ b/Classes/x-saherelm.x-poi.drawer.class.mq5 @@ -2948,6 +2948,56 @@ class XCPOIDrawer : public XCBase return result; } + /** + * Create Specific Box on Chart ... + * + * @param box: XBoxZone instance Reference ... + * @param clr: Color ... + * @param width: Integer ... + * @param fill: Boolean ... + * @param style: ENUM_LINE_STYLE member ... + * + * @return ( bool ) + */ + bool CreateBox( + XBoxZone &box, + XCBoxObject *&object, + color clr = clrYellowGreen, + int width = 1, + bool fill = false, + ENUM_LINE_STYLE style = STYLE_SOLID // + ) + { + // + bool result = false; + + // + object = NULL; + + // + result = box.IsValid(); + if (!result) + { + return result; + } + + // + result = CreateBox( + object, + box.upper, + box.lower, + box.from, + box.to, + clr, + width, + fill, + style // + ); + + // + return result; + } + /** * Draw Specified Signal ... * diff --git a/X121SMCEA/Libraries/x-121.smc.lib.mq5 b/X121SMCEA/Libraries/x-121.smc.lib.mq5 index 08f22528..c4ba5eaa 100644 --- a/X121SMCEA/Libraries/x-121.smc.lib.mq5 +++ b/X121SMCEA/Libraries/x-121.smc.lib.mq5 @@ -913,8 +913,8 @@ bool DetectPriceInsideBox( } // - bool hasBullishFVG = state.HasBullishFVGs(); - bool hasBearishFVG = state.HasBearishFVGs(); + bool hasBullishFVGs = state.HasBullishFVGs(); + bool hasBearishFVGs = state.HasBearishFVGs(); bool hasDemandZones = state.HasDemandZones(); bool hasSupplyZones = state.HasSupplyZones(); bool hasSupportZones = state.HasSupportZones(); @@ -923,7 +923,7 @@ bool DetectPriceInsideBox( // bool hasBullishZones = // - hasBullishFVG || + hasBullishFVGs || hasDemandZones || hasSupportZones // @@ -932,7 +932,7 @@ bool DetectPriceInsideBox( // bool hasBearishZones = // - hasBearishFVG || + hasBearishFVGs || hasSupplyZones || hasResistanceZones // @@ -954,6 +954,7 @@ bool DetectPriceInsideBox( hasPriceInsideOB) { // + // Use Price Inside OB as Box ... box.to = priceInsideOB.To(); box.from = priceInsideOB.From(); box.upper = priceInsideOB.Upper(); @@ -964,6 +965,365 @@ bool DetectPriceInsideBox( { // // Detect Validate Zones ... + int count = 0; + XBoxZone boxes[]; + double upper = 0; + double lower = 0; + double price = 0; + datetime to = NULL; + datetime from = NULL; + ENUM_X_DIRECTION dir = X_DIRECTION_NONE; + if (IsBullish(boxDir)) + { + // + double price = xConditions.valesBuffer[1]; + ENUM_X_DIRECTION dir = X_DIRECTION_BULLISH; + + // + // Bullish FVG ... + count = state.CountBullishFVGs(); + for (int i = 0; i < count; i++) + { + // + XCFVG *iFVG = state.bullishFVGs[i]; + + // + to = iFVG.To(); + from = iFVG.From(); + upper = iFVG.Upper(); + lower = iFVG.Lower(); + + // + bool isInside = IsPriceInsideZone( + price, + upper, + lower // + ); + if (isInside) + { + // + XBoxZone iBox; + + // + iBox.dir = dir; + iBox.symbol = symbol; + iBox.period = period; + + // + iBox.to = to; + iBox.from = from; + iBox.upper = upper; + iBox.lower = lower; + + // + if (iBox.IsValid()) + { + // + AddRef( + iBox, + boxes // + ); + } + } + } + + // + // Demand Zones ... + count = state.CountDemandZones(); + for (int i = 0; i < count; i++) + { + // + XCDemandZone *iDemand = state.demandZones[i]; + + // + to = iDemand.To(); + from = iDemand.From(); + upper = iDemand.Upper(); + lower = iDemand.Lower(); + + // + bool isInside = IsPriceInsideZone( + price, + upper, + lower // + ); + if (isInside) + { + // + XBoxZone iBox; + + // + iBox.dir = dir; + iBox.symbol = symbol; + iBox.period = period; + + // + iBox.to = to; + iBox.from = from; + iBox.upper = upper; + iBox.lower = lower; + + // + if (iBox.IsValid()) + { + // + AddRef( + iBox, + boxes // + ); + } + } + } + + // + // Support Zones ... + count = state.CountSupportZones(); + for (int i = 0; i < count; i++) + { + // + XCSupportZone *iSupport = state.supportZones[i]; + + // + to = iSupport.To(); + from = iSupport.From(); + upper = iSupport.Upper(); + lower = iSupport.Lower(); + + // + bool isInside = IsPriceInsideZone( + price, + upper, + lower // + ); + if (isInside) + { + // + XBoxZone iBox; + + // + iBox.dir = dir; + iBox.symbol = symbol; + iBox.period = period; + + // + iBox.to = to; + iBox.from = from; + iBox.upper = upper; + iBox.lower = lower; + + // + if (iBox.IsValid()) + { + // + AddRef( + iBox, + boxes // + ); + } + } + } + } + else + { + // + double price = xConditions.peaksBuffer[1]; + ENUM_X_DIRECTION dir = X_DIRECTION_BEARISH; + + // + // Bearish FVG ... + count = state.CountBearishFVGs(); + for (int i = 0; i < count; i++) + { + // + XCFVG *iFVG = state.bearishFVGs[i]; + + // + to = iFVG.To(); + from = iFVG.From(); + upper = iFVG.Upper(); + lower = iFVG.Lower(); + + // + bool isInside = IsPriceInsideZone( + price, + upper, + lower // + ); + if (isInside) + { + // + XBoxZone iBox; + + // + iBox.dir = dir; + iBox.symbol = symbol; + iBox.period = period; + + // + iBox.to = to; + iBox.from = from; + iBox.upper = upper; + iBox.lower = lower; + + // + if (iBox.IsValid()) + { + // + AddRef( + iBox, + boxes // + ); + } + } + } + + // + // Supply Zones ... + count = state.CountSupplyZones(); + for (int i = 0; i < count; i++) + { + // + XCSupplyZone *iSupply = state.supplyZones[i]; + + // + to = iSupply.To(); + from = iSupply.From(); + upper = iSupply.Upper(); + lower = iSupply.Lower(); + + // + bool isInside = IsPriceInsideZone( + price, + upper, + lower // + ); + if (isInside) + { + // + XBoxZone iBox; + + // + iBox.dir = dir; + iBox.symbol = symbol; + iBox.period = period; + + // + iBox.to = to; + iBox.from = from; + iBox.upper = upper; + iBox.lower = lower; + + // + if (iBox.IsValid()) + { + // + AddRef( + iBox, + boxes // + ); + } + } + } + + // + // Demand Zones ... + count = state.CountResistanceZones(); + for (int i = 0; i < count; i++) + { + // + XCResistanceZone *iResistance = state.resistanceZones[i]; + + // + to = iResistance.To(); + from = iResistance.From(); + upper = iResistance.Upper(); + lower = iResistance.Lower(); + + // + bool isInside = IsPriceInsideZone( + price, + upper, + lower // + ); + if (isInside) + { + // + XBoxZone iBox; + + // + iBox.dir = dir; + iBox.symbol = symbol; + iBox.period = period; + + // + iBox.to = to; + iBox.from = from; + iBox.upper = upper; + iBox.lower = lower; + + // + if (iBox.IsValid()) + { + // + AddRef( + iBox, + boxes // + ); + } + } + } + } + + // + int boxesCount = ArraySize(boxes); + bool hasBoxes = IsValidSize(boxes); + if (hasBoxes) + { + // + // Filter Boxes ... + for (int i = 0; i < boxesCount; i++) + { + // + XBoxZone iBox = boxes[i]; + + // + // Upper ... + if (box.upper == 0 || box.upper < iBox.upper) + { + box.upper = iBox.upper; + } + + // + // Lower ... + if (box.lower == 0 || box.lower < iBox.lower) + { + box.lower = iBox.lower; + } + + // + // To ... + if (!IsValid(box.to) || box.to < iBox.to) + { + box.to = iBox.to; + } + + // + // From ... + if (!IsValid(box.from) || box.from > iBox.from) + { + box.from = iBox.from; + } + } + } + else + { + // + // Use Price Inside OB as Box ... + box.to = priceInsideOB.To(); + box.from = priceInsideOB.From(); + box.upper = priceInsideOB.Upper(); + box.lower = priceInsideOB.Lower(); + } } // diff --git a/X121SMCEA/Signals/x-121.smc.xhkpv.signal.lib.mq5 b/X121SMCEA/Signals/x-121.smc.xhkpv.signal.lib.mq5 index cc9c0af6..5878f378 100644 --- a/X121SMCEA/Signals/x-121.smc.xhkpv.signal.lib.mq5 +++ b/X121SMCEA/Signals/x-121.smc.xhkpv.signal.lib.mq5 @@ -687,106 +687,27 @@ bool DetectX121SMCXHKPVSignalSetup( // Detect Cycle State ... // - visionCycleHelper.GetCycleState(conditions.state); + bool hasState = visionCycleHelper.GetCycleState(conditions.state); // - // - // + XBoxZone priceBox; + bool hasBox = false; + if (hasState) + { + // + hasBox = DetectPriceInsideBox( + priceBox, + decisionXConditions, + conditions.state // + ); - // // - // bool hasPriceInsideOB = false; - // XCOrderBlock *priceInsideOB = NULL; - - // // - // if (!hasPriceInsideOB && - // hasBullishOBs) - // { - // // - // for (int i = 0; i < bullishOBsCount; i++) - // { - // // - // XCOrderBlock *iOb = conditions.bullishOBs[i]; - - // // - // bool isInside = IsPriceInsideZone( - // decisionXConditions.valesBuffer[1], - // (XCZone *)iOb // - // ); - // if (isInside) - // { - // // - // hasPriceInsideOB = true; - // priceInsideOB = iOb; - // break; - // } - // } - // } - - // // - // if (!hasPriceInsideOB && - // hasBearishOBs) - // { - // // - // for (int i = 0; i < bearishOBsCount; i++) - // { - // // - // XCOrderBlock *iOb = conditions.bearishOBs[i]; - - // // - // bool isInside = IsPriceInsideZone( - // decisionXConditions.peaksBuffer[1], - // (XCZone *)iOb // - // ); - // if (isInside) - // { - // // - // hasPriceInsideOB = true; - // priceInsideOB = iOb; - // break; - // } - // } - // } - - // // - // XStateZones obState; - // bool hasOBState = false; - // XOHCL priceInsideOBBreakerBar; - // if (hasPriceInsideOB) - // { - // // - // XOHCL toBar; - // XOHCL fromBar; - // ENUM_X_DIRECTION forDir = - // priceInsideOB.IsBullish() - // ? X_DIRECTION_BULLISH - // : X_DIRECTION_BEARISH; - // bool hasBreakerBar = HasBreakerBar( - // toBar, - // fromBar, - // priceInsideOBBreakerBar, - // forDir, - // priceInsideOB.GetSymbol(), - // priceInsideOB.GetPeriod(), - // priceInsideOB.Upper(), - // priceInsideOB.Lower(), - // priceInsideOB.From(), - // priceInsideOB.To() // - // ); - // if (hasBreakerBar) - // { - // // - // CalculateStateZones( - // obState, - // analyseState, - // priceInsideOB.Upper(), - // priceInsideOB.Lower(), - // priceInsideOBBreakerBar.time // - // ); - // } - - // // - // hasOBState = obState.IsValid(); - // } + // + if (hasBox) + { + // + // Here We Can Validate Box by Same Cycles Peaks and Vales ... + } + } // // Draw ... @@ -795,6 +716,36 @@ bool DetectX121SMCXHKPVSignalSetup( conditions.state, drawnObjects // ); + + // + if (hasBox) + { + // + bool isBullish = IsBullish(priceBox.dir); + color boxColor = isBullish ? clrYellow : clrOrange; + // + XCBoxObject *iObj; + bool isCreated = visionCycleHelper.mPOIDrawer.CreateBox( + priceBox, + iObj, + boxColor, + 1, + false, + STYLE_DASHDOTDOT // + ); + + // + if (isCreated) + { + // + Add( + (XCBaseObject *)iObj, + drawnObjects // + ); + } + } + + // if (IsValidSize(drawnObjectsCount)) { Print("Drawn Objects ...");