diff --git a/X121SMCEA/Signals/x-121.smc.xind.signal.lib.mq5 b/X121SMCEA/Signals/x-121.smc.xind.signal.lib.mq5 index c0cb8c8b..408073d6 100644 --- a/X121SMCEA/Signals/x-121.smc.xind.signal.lib.mq5 +++ b/X121SMCEA/Signals/x-121.smc.xind.signal.lib.mq5 @@ -604,61 +604,59 @@ bool IsFVGBoxValid( // bool isBullish = isBoxBullish && - !hasBearishOrConditions // && - // hasBullishAndConditions - ; + !hasBearishOrConditions && + hasBullishOrConditions; // bool isBearish = !isBoxBullish && - !hasBullishOrConditions // && - // hasBearishAndConditions - ; + !hasBullishOrConditions && + hasBearishOrConditions; // result = isBullish || isBearish; // - if (result) - { - // - XCBoxObject *iBoxObj; - XCBoxObject *iInBoxObj; + // if (result) + // { + // // + // XCBoxObject *iBoxObj; + // XCBoxObject *iInBoxObj; - // - has = provider - .verificationCycleHelper - .mPOIDrawer - .DrawBox( - box, - iBoxObj // - ); - if (has) - { - // - iBoxObj.BoxWidth(2); - iBoxObj.BoxStyle(STYLE_SOLID); - } + // // + // has = provider + // .verificationCycleHelper + // .mPOIDrawer + // .DrawBox( + // box, + // iBoxObj // + // ); + // if (has) + // { + // // + // iBoxObj.BoxWidth(2); + // iBoxObj.BoxStyle(STYLE_SOLID); + // } - // - has = provider - .verificationCycleHelper - .mPOIDrawer - .DrawBox( - selectedBox, - iInBoxObj // - ); - if (has) - { - // - iInBoxObj.BoxWidth(2); - iInBoxObj.BoxStyle(STYLE_DASH); - } + // // + // has = provider + // .verificationCycleHelper + // .mPOIDrawer + // .DrawBox( + // selectedBox, + // iInBoxObj // + // ); + // if (has) + // { + // // + // iInBoxObj.BoxWidth(2); + // iInBoxObj.BoxStyle(STYLE_DASH); + // } - // - Print("Inside Selected Box ..."); - } + // // + // Print("Inside Selected Box ..."); + // } } // @@ -801,8 +799,8 @@ bool HasXINDConditions( // Select Waiting Box ... XBoxZone selectedBox; bool hasSelectedBox = false; - bool useWaitingBoxes = false; - bool useActivtedBoxes = false; + bool useWaitingBoxes = true; + bool useActivtedBoxes = true; bool useBreakedBoxes = false; if (useWaitingBoxes && IsValidSize(waitingBoxesCount)) { @@ -812,6 +810,21 @@ bool HasXINDConditions( // XBoxZone iBox = waitingBoxes[i]; + // + has = IsBoxPVPassed( + iBox, + cXConditions // + ); + if (has) + { + // + selectedBox = iBox; + iBox.Clean(); + + // + break; + } + // iBox.Clean(); } @@ -831,6 +844,21 @@ bool HasXINDConditions( // XBoxZone iBox = activatedBoxes[i]; + // + has = IsBoxPVPassed( + iBox, + cXConditions // + ); + if (has) + { + // + selectedBox = iBox; + iBox.Clean(); + + // + break; + } + // iBox.Clean(); } @@ -890,6 +918,28 @@ bool HasXINDConditions( // // + // + // Reading Resources ... + + // + double priceChange = cXConditions.priceChangeBuffer[cIDX]; + double priceChangeZ = cXConditions.priceChangeBuffer[zIDX]; + double priceChangeP = cXConditions.priceChangeBuffer[pIDX]; + double priceChangePP = cXConditions.priceChangeBuffer[ppIDX]; + + // + // Generate Conditions ... + + // + bool isCBarBullishPriceChangeVPattern = + priceChange > priceChangeP && + priceChange > priceChangeZ; + + // + bool isCBarBearishPriceChangeVPattern = + priceChange < priceChangeP && + priceChange < priceChangeZ; + // // // @@ -900,16 +950,22 @@ bool HasXINDConditions( // isBullish = // - false + // false // + hasSelectedBox && + selectedBox.IsBullish() && + isCBarBullishPriceChangeVPattern // ; // isBearish = // - false + // false // + hasSelectedBox && + selectedBox.IsBearish() && + isCBarBearishPriceChangeVPattern // ; @@ -939,7 +995,9 @@ bool HasXINDConditions( // // Usually is Preffered SL ... double pivot = - 0; + isBullish + ? selectedBox.lower + : selectedBox.upper; // // Usually is Current Price or Entry Price ... @@ -1018,4 +1076,43 @@ bool HasXINDConditions( // // +// +bool IsBoxPVPassed( + XBoxZone &box, + X121Conditions &conditions // +) +{ + // + bool result = false; + + // + result = box.IsValid(); + if (!result) + { + return result; + } + + // + double boxMid = box.lower + ((box.upper - box.lower) / 2); + + // + bool isBullishPassed = + box.IsBullish() && + conditions.valesBuffer[0] < boxMid && + conditions.valesBuffer[0] > box.lower; + + // + bool isBearishPassed = + box.IsBearish() && + conditions.peaksBuffer[0] > boxMid && + conditions.peaksBuffer[0] < box.upper; + + // + result = isBullishPassed || + isBearishPassed; + + // + return result; +} + // \ No newline at end of file