diff --git a/X121SMCEA/Classes/x-121.smc.market.cycle.helper.class.mq5 b/X121SMCEA/Classes/x-121.smc.market.cycle.helper.class.mq5 index c648d692..b81c645c 100644 --- a/X121SMCEA/Classes/x-121.smc.market.cycle.helper.class.mq5 +++ b/X121SMCEA/Classes/x-121.smc.market.cycle.helper.class.mq5 @@ -1302,7 +1302,11 @@ class XC121SMCCycleHelper : public XCBase */ int DrawCycleState( X121SMCCycleState &state, - XCBaseObject *&drawnObjects[] // + XCBaseObject *&drawnObjects[], + bool drawOrderBlocks = true, + bool drawFairValueGaps = true, + bool drawSupplyAndDemandZones = false, + bool drawSupportAndResistanceZones = false // ) { // @@ -1310,260 +1314,274 @@ class XC121SMCCycleHelper : public XCBase // // Order Blocks ... - - // - // Bullish ... - bool hasBullishOBs = state.HasBullishOBs(); - int bullishOBsCount = state.CountBullishOBs(); - if (hasBullishOBs) + if (drawOrderBlocks) { // - for (int i = 0; i < bullishOBsCount; i++) + // Bullish ... + bool hasBullishOBs = state.HasBullishOBs(); + int bullishOBsCount = state.CountBullishOBs(); + if (hasBullishOBs) { // - XCOrderBlock *iOb = state.bullishOBs[i]; - - // - XCBullishOrderBlockObject *iObObj; - bool isCreated = mPOIDrawer - .CreateBullishOrderBlock( - iOb, - iObObj // - ); - if (isCreated) + for (int i = 0; i < bullishOBsCount; i++) { // - Add( - (XCBaseObject *)iObObj, - drawnObjects // - ); + XCOrderBlock *iOb = state.bullishOBs[i]; + + // + XCBullishOrderBlockObject *iObObj; + bool isCreated = mPOIDrawer + .CreateBullishOrderBlock( + iOb, + iObObj // + ); + if (isCreated) + { + // + Add( + (XCBaseObject *)iObObj, + drawnObjects // + ); + } } } - } - // - // Bearish ... - bool hasBearishOBs = state.HasBearishOBs(); - int bearishOBsCount = state.CountBearishOBs(); - if (hasBearishOBs) - { // - for (int i = 0; i < bearishOBsCount; i++) + // Bearish ... + bool hasBearishOBs = state.HasBearishOBs(); + int bearishOBsCount = state.CountBearishOBs(); + if (hasBearishOBs) { // - XCOrderBlock *iOb = state.bearishOBs[i]; - - // - XCBearishOrderBlockObject *iObObj; - bool isCreated = mPOIDrawer - .CreateBearishOrderBlock( - iOb, - iObObj // - ); - if (isCreated) + for (int i = 0; i < bearishOBsCount; i++) { // - Add( - (XCBaseObject *)iObObj, - drawnObjects // - ); + XCOrderBlock *iOb = state.bearishOBs[i]; + + // + XCBearishOrderBlockObject *iObObj; + bool isCreated = mPOIDrawer + .CreateBearishOrderBlock( + iOb, + iObObj // + ); + if (isCreated) + { + // + Add( + (XCBaseObject *)iObObj, + drawnObjects // + ); + } } } } // // Fair Value Gaps ... - - // - // Bullish ... - bool hasBullishFVGs = state.HasBullishFVGs(); - int bullishFVGsCount = state.CountBullishFVGs(); - if (hasBullishFVGs) + if (drawFairValueGaps) { // - for (int i = 0; i < bullishFVGsCount; i++) + // Bullish ... + bool hasBullishFVGs = state.HasBullishFVGs(); + int bullishFVGsCount = state.CountBullishFVGs(); + if (hasBullishFVGs) { // - XCFVG *iFVG = state.bullishFVGs[i]; - - // - XCBullishFairValueGapObject *iFVGObj; - bool isCreated = mPOIDrawer - .CreateBullishFairValueGap( - iFVG, - iFVGObj // - ); - if (isCreated) + for (int i = 0; i < bullishFVGsCount; i++) { // - iFVGObj.ZoneColor(clrLime); + XCFVG *iFVG = state.bullishFVGs[i]; // - Add( - (XCBaseObject *)iFVGObj, - drawnObjects // - ); + XCBullishFairValueGapObject *iFVGObj; + bool isCreated = mPOIDrawer + .CreateBullishFairValueGap( + iFVG, + iFVGObj // + ); + if (isCreated) + { + // + iFVGObj.ZoneColor(clrLime); + + // + Add( + (XCBaseObject *)iFVGObj, + drawnObjects // + ); + } + } + } + + // + // Bearish ... + bool hasBearishFVGs = state.HasBearishFVGs(); + int bearishFVGsCount = state.CountBearishFVGs(); + if (hasBearishFVGs) + { + // + for (int i = 0; i < bearishFVGsCount; i++) + { + // + XCFVG *iFVG = state.bearishFVGs[i]; + + // + XCBearishFairValueGapObject *iFVGObj; + bool isCreated = mPOIDrawer + .CreateBearishFairValueGap( + iFVG, + iFVGObj // + ); + if (isCreated) + { + // + iFVGObj.ZoneColor(clrRed); + + // + Add( + (XCBaseObject *)iFVGObj, + drawnObjects // + ); + } } } } // - // Bearish ... - bool hasBearishFVGs = state.HasBearishFVGs(); - int bearishFVGsCount = state.CountBearishFVGs(); - if (hasBearishFVGs) + // Support and Resistance Zones ... + if (drawSupportAndResistanceZones) { // - for (int i = 0; i < bearishFVGsCount; i++) + // Support Zones ... + bool hasSupportZones = state.HasSupportZones(); + int supportZonesCount = state.CountSupportZones(); + if (hasSupportZones) { // - XCFVG *iFVG = state.bearishFVGs[i]; - - // - XCBearishFairValueGapObject *iFVGObj; - bool isCreated = mPOIDrawer - .CreateBearishFairValueGap( - iFVG, - iFVGObj // - ); - if (isCreated) + for (int i = 0; i < supportZonesCount; i++) { // - iFVGObj.ZoneColor(clrRed); + XCSupportZoneObject *iObj; + bool isCreated = mPOIDrawer + .CreateSupportZone( + state.supportZones[i], + iObj // + ); // - Add( - (XCBaseObject *)iFVGObj, - drawnObjects // - ); + if (isCreated) + { + // + iObj.ZoneColor(clrDarkSeaGreen); + + // + Add( + (XCBaseObject *)iObj, + drawnObjects // + ); + } + } + } + + // + // Resistance Zones ... + bool hasResistanceZones = state.HasResistanceZones(); + int resistanceZonesCount = state.CountResistanceZones(); + if (hasResistanceZones) + { + // + for (int i = 0; i < resistanceZonesCount; i++) + { + // + XCResistanceZoneObject *iObj; + bool isCreated = mPOIDrawer + .CreateResistanceZone( + state.resistanceZones[i], + iObj // + ); + + // + if (isCreated) + { + // + iObj.ZoneColor(clrSaddleBrown); + + // + Add( + (XCBaseObject *)iObj, + drawnObjects // + ); + } } } } // - // Support Zones ... - bool hasSupportZones = state.HasSupportZones(); - int supportZonesCount = state.CountSupportZones(); - if (hasSupportZones) + // Supply and Demand Zones ... + if (drawSupplyAndDemandZones) { // - for (int i = 0; i < supportZonesCount; i++) + // Demand Zones ... + bool hasDemandZones = state.HasDemandZones(); + int demandZonesCount = state.CountDemandZones(); + if (hasDemandZones) { // - XCSupportZoneObject *iObj; - bool isCreated = mPOIDrawer - .CreateSupportZone( - state.supportZones[i], - iObj // - ); - - // - if (isCreated) + for (int i = 0; i < demandZonesCount; i++) { // - iObj.ZoneColor(clrDarkSeaGreen); + XCDemandZoneObject *iObj; + bool isCreated = mPOIDrawer + .CreateDemandZone( + state.demandZones[i], + iObj // + ); // - Add( - (XCBaseObject *)iObj, - drawnObjects // - ); + if (isCreated) + { + // + iObj.ZoneColor(clrDarkTurquoise); + + // + Add( + (XCBaseObject *)iObj, + drawnObjects // + ); + } } } - } - // - // Resistance Zones ... - bool hasResistanceZones = state.HasResistanceZones(); - int resistanceZonesCount = state.CountResistanceZones(); - if (hasResistanceZones) - { // - for (int i = 0; i < resistanceZonesCount; i++) + // Supply Zones ... + bool hasSupplyZones = state.HasSupplyZones(); + int supplyZonesCount = state.CountSupplyZones(); + if (hasSupplyZones) { // - XCResistanceZoneObject *iObj; - bool isCreated = mPOIDrawer - .CreateResistanceZone( - state.resistanceZones[i], - iObj // - ); - - // - if (isCreated) + for (int i = 0; i < supplyZonesCount; i++) { // - iObj.ZoneColor(clrSaddleBrown); + XCSupplyZoneObject *iObj; + bool isCreated = mPOIDrawer + .CreateSupplyZone( + state.supplyZones[i], + iObj // + ); // - Add( - (XCBaseObject *)iObj, - drawnObjects // - ); - } - } - } + if (isCreated) + { + // + iObj.ZoneColor(clrChocolate); - // - // Demand Zones ... - bool hasDemandZones = state.HasDemandZones(); - int demandZonesCount = state.CountDemandZones(); - if (hasDemandZones) - { - // - for (int i = 0; i < demandZonesCount; i++) - { - // - XCDemandZoneObject *iObj; - bool isCreated = mPOIDrawer - .CreateDemandZone( - state.demandZones[i], - iObj // - ); - - // - if (isCreated) - { - // - iObj.ZoneColor(clrDarkTurquoise); - - // - Add( - (XCBaseObject *)iObj, - drawnObjects // - ); - } - } - } - - // - // Supply Zones ... - bool hasSupplyZones = state.HasSupplyZones(); - int supplyZonesCount = state.CountSupplyZones(); - if (hasSupplyZones) - { - // - for (int i = 0; i < supplyZonesCount; i++) - { - // - XCSupplyZoneObject *iObj; - bool isCreated = mPOIDrawer - .CreateSupplyZone( - state.supplyZones[i], - iObj // - ); - - // - if (isCreated) - { - // - iObj.ZoneColor(clrChocolate); - - // - Add( - (XCBaseObject *)iObj, - drawnObjects // - ); + // + Add( + (XCBaseObject *)iObj, + drawnObjects // + ); + } } } } diff --git a/X121SMCEA/Libraries/x-121.smc.lib.mq5 b/X121SMCEA/Libraries/x-121.smc.lib.mq5 index c4ba5eaa..1bd60dfe 100644 --- a/X121SMCEA/Libraries/x-121.smc.lib.mq5 +++ b/X121SMCEA/Libraries/x-121.smc.lib.mq5 @@ -804,10 +804,21 @@ struct X121SMCCycleState // }; +/** + * Detect Price inside Box ... + * + * @param box: XBoxZone instance Reference, Founded Price Inside Box ... + * @param orderBlock: XCOrderBlock pointer Reference, Founded Price Inside Order Block ... + * @param xConditions: X121Conditions instance Reference, provides Market Conditions ... + * @param state: X121SMCCycleState instance Reference ... + * + * @return ( bool ) + */ bool DetectPriceInsideBox( - XBoxZone &box, - X121Conditions &xConditions, - X121SMCCycleState &state // + XBoxZone &box, // Price Inside Bo ... + XCOrderBlock *&orderBlock, // Price Inside Order Block ... + X121Conditions &xConditions, // X121Conditions for Validation ... + X121SMCCycleState &state // Cycle State ... ) { // @@ -912,6 +923,12 @@ bool DetectPriceInsideBox( } } + // + if (hasPriceInsideOB) + { + orderBlock = priceInsideOB; + } + // bool hasBullishFVGs = state.HasBullishFVGs(); bool hasBearishFVGs = state.HasBearishFVGs(); diff --git a/X121SMCEA/Signals/x-121.smc.xhkpv.signal.lib.mq5 b/X121SMCEA/Signals/x-121.smc.xhkpv.signal.lib.mq5 index 5878f378..0b815dda 100644 --- a/X121SMCEA/Signals/x-121.smc.xhkpv.signal.lib.mq5 +++ b/X121SMCEA/Signals/x-121.smc.xhkpv.signal.lib.mq5 @@ -691,18 +691,20 @@ bool DetectX121SMCXHKPVSignalSetup( // XBoxZone priceBox; - bool hasBox = false; + bool hasPriceBox = false; + XCOrderBlock *priceOB = NULL; if (hasState) { // - hasBox = DetectPriceInsideBox( + hasPriceBox = DetectPriceInsideBox( priceBox, + priceOB, decisionXConditions, conditions.state // ); // - if (hasBox) + if (hasPriceBox) { // // Here We Can Validate Box by Same Cycles Peaks and Vales ... @@ -718,11 +720,12 @@ bool DetectX121SMCXHKPVSignalSetup( ); // - if (hasBox) + if (hasPriceBox) { // bool isBullish = IsBullish(priceBox.dir); color boxColor = isBullish ? clrYellow : clrOrange; + // XCBoxObject *iObj; bool isCreated = visionCycleHelper.mPOIDrawer.CreateBox( @@ -743,6 +746,65 @@ bool DetectX121SMCXHKPVSignalSetup( drawnObjects // ); } + + // + XCBaseObject *priceOBObj = NULL; + if (isBullish) + { + // + XCBullishOrderBlockObject *iObj; + isCreated = visionCycleHelper + .mPOIDrawer + .CreateBullishOrderBlock( + priceOB, + iObj // + ); + + // + if (isCreated) + { + // + iObj.ZoneWidth(2); + iObj.ZoneColor(boxColor); + iObj.ZoneStyle(STYLE_SOLID); + + // + priceOBObj = (XCBaseObject *)iObj; + } + } + else + { + // + XCBearishOrderBlockObject *iObj; + isCreated = visionCycleHelper + .mPOIDrawer + .CreateBearishOrderBlock( + priceOB, + iObj // + ); + + // + if (isCreated) + { + // + iObj.ZoneWidth(2); + iObj.ZoneColor(boxColor); + iObj.ZoneStyle(STYLE_SOLID); + + // + priceOBObj = (XCBaseObject *)iObj; + } + } + + // + if (isCreated) + { + // + Add( + priceOBObj, + drawnObjects // + ); + } } //