From 410c6793ae84d5852f465770d25edc8fe463453d Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Thu, 2 Jan 2025 13:24:37 +0330 Subject: [PATCH] last ... --- Classes/x-saherelm.x-poi.drawer.class.mq5 | 428 ++++++++++++++++++ Helpers/x-saherelm.x121.helper.mq5 | 185 +++++++- Libraries/x-saherelm.common.lib.mq5 | 13 + Libraries/x-saherelm.x-poi.lib.mq5 | 136 +++++- .../x-121.smc.market.cycle.helper.class.mq5 | 285 ++---------- .../Signals/x-121.smc.test.signal.lib.mq5 | 6 +- .../Signals/x-121.smc.xtwpv.signal.lib.mq5 | 4 +- .../Strategy/x-121.smc.strategy.class.mq5 | 4 +- 8 files changed, 795 insertions(+), 266 deletions(-) diff --git a/Classes/x-saherelm.x-poi.drawer.class.mq5 b/Classes/x-saherelm.x-poi.drawer.class.mq5 index d9540298..5116f3a7 100644 --- a/Classes/x-saherelm.x-poi.drawer.class.mq5 +++ b/Classes/x-saherelm.x-poi.drawer.class.mq5 @@ -2923,6 +2923,434 @@ class XCPOIDrawer : public XCBase return result; } + /** + * Draw Price Zone ... + * + * @param zone: XPriceZones instance Reference ... + * @param forDir: ENUM_X_DIRECTION member ... + * + * @return ( int ) + */ + int DrawPriceZone( + XPriceZones &zone, + XCBaseObject *&drawnObjects[], + ENUM_X_DIRECTION forDir = X_DIRECTION_NONE // + ) + { + // + int result = 0; + + // + Clean(drawnObjects); + + // + if (!zone.IsValid()) + { + return result; + } + + // + bool isBullish = IsBullish(forDir); + bool isAll = forDir == X_DIRECTION_ALL || + forDir == X_DIRECTION_NONE; + + // + if (isAll || isBullish) + { + // + // Support Zone ... + if (zone.HasSupportZone()) + { + // + XCSupportZoneObject *iObj; + bool isCreated = CreateSupportZone( + zone.supportZone, + iObj // + ); + if (isCreated) + { + // + Add( + (XCBaseObject *)iObj, + drawnObjects // + ); + } + } + + // + // Demand Zone ... + if (zone.HasDemandZone()) + { + // + XCDemandZoneObject *iObj; + bool isCreated = CreateDemandZone( + zone.demandZone, + iObj // + ); + if (isCreated) + { + // + Add( + (XCBaseObject *)iObj, + drawnObjects // + ); + } + } + + // + // OrderBlock ... + if (zone.HasOrderBlock() && + zone.orderBlock.IsBullish()) + { + // + XCBullishOrderBlockObject *iObj; + bool isCreated = CreateBullishOrderBlock( + zone.orderBlock, + iObj // + ); + if (isCreated) + { + // + Add( + (XCBaseObject *)iObj, + drawnObjects // + ); + } + } + + // + // FairValueGap ... + if (zone.HasFairValueGap() && + zone.fairValueGap.IsBullish()) + { + // + XCBullishFairValueGapObject *iObj; + bool isCreated = CreateBullishFairValueGap( + zone.fairValueGap, + iObj // + ); + if (isCreated) + { + // + Add( + (XCBaseObject *)iObj, + drawnObjects // + ); + } + } + } + + // + if (isAll || !isBullish) + { + // + // Resistance Zone ... + if (zone.HasResistanceZone()) + { + // + XCResistanceZoneObject *iObj; + bool isCreated = CreateResistanceZone( + zone.resistanceZone, + iObj // + ); + if (isCreated) + { + // + Add( + (XCBaseObject *)iObj, + drawnObjects // + ); + } + } + + // + // Supply Zone ... + if (zone.HasSupplyZone()) + { + // + XCSupplyZoneObject *iObj; + bool isCreated = CreateSupplyZone( + zone.supplyZone, + iObj // + ); + if (isCreated) + { + // + Add( + (XCBaseObject *)iObj, + drawnObjects // + ); + } + } + + // + // OrderBlock ... + if (zone.HasOrderBlock() && + zone.orderBlock.IsBearish()) + { + // + XCBearishOrderBlockObject *iObj; + bool isCreated = CreateBearishOrderBlock( + zone.orderBlock, + iObj // + ); + if (isCreated) + { + // + Add( + (XCBaseObject *)iObj, + drawnObjects // + ); + } + } + + // + // FairValueGap ... + if (zone.HasFairValueGap() && + zone.fairValueGap.IsBearish()) + { + // + XCBearishFairValueGapObject *iObj; + bool isCreated = CreateBearishFairValueGap( + zone.fairValueGap, + iObj // + ); + if (isCreated) + { + // + Add( + (XCBaseObject *)iObj, + drawnObjects // + ); + } + } + } + + // + result = ArraySize(drawnObjects); + + // + return result; + } + + /** + * Draw Specified Market Structure ... + * + * @param model: XMarketStructure instance Reference ... + * + * @return ( int ) + */ + int DrawMarketStructure( + XMarketStructure &model, + XCBaseObject *&drawnObjects[] // + ) + { + // + int result = 0; + + // + Clean(drawnObjects); + + // + datetime cTime = TimeCurrent(); + + // + bool isValid = + model.IsValid(); + if (!isValid) + { + return result; + } + + // + if (model.lowestValeBar.IsValid()) + { + // + XCOHCLObject *iObj; + bool isCreated = CreateBar( + model.lowestValeBar, + iObj // + ); + + // + if (isCreated) + { + // + Add( + (XCBaseObject *)iObj, + drawnObjects // + ); + } + } + + // + if (model.lowestValePeakBreakeUpBar.IsValid()) + { + // + XCOHCLObject *iObj; + bool isCreated = CreateBar( + model.lowestValePeakBreakeUpBar, + iObj // + ); + + // + if (isCreated) + { + // + Add( + (XCBaseObject *)iObj, + drawnObjects // + ); + } + } + + // + if (model.valeAboveLowestValePeakBar.IsValid()) + { + // + XCOHCLObject *iObj; + bool isCreated = CreateBar( + model.valeAboveLowestValePeakBar, + iObj // + ); + + // + if (isCreated) + { + // + Add( + (XCBaseObject *)iObj, + drawnObjects // + ); + } + } + + // + if (model.highestPeakBar.IsValid()) + { + // + XCOHCLObject *iObj; + bool isCreated = CreateBar( + model.highestPeakBar, + iObj // + ); + + // + if (isCreated) + { + // + Add( + (XCBaseObject *)iObj, + drawnObjects // + ); + } + } + + // + if (model.peakBelowHighestPeakValeBar.IsValid()) + { + // + XCOHCLObject *iObj; + bool isCreated = CreateBar( + model.peakBelowHighestPeakValeBar, + iObj // + ); + + // + if (isCreated) + { + // + Add( + (XCBaseObject *)iObj, + drawnObjects // + ); + } + } + + // + if (model.highestPeakValeBreakeDownBar.IsValid()) + { + // + XCOHCLObject *iObj; + bool isCreated = CreateBar( + model.highestPeakValeBreakeDownBar, + iObj // + ); + + // + if (isCreated) + { + // + Add( + (XCBaseObject *)iObj, + drawnObjects // + ); + } + } + + // + if (HasChild(model.valePriceZones)) + { + // + int count = ArraySize(model.valePriceZones); + for (int i = 0; i < count; i++) + { + // + XPriceZones ipZone = model.valePriceZones[i]; + + // + XCBaseObject *ipObjects[]; + int ipDrawnObjects = DrawPriceZone( + ipZone, + ipObjects // + ); + if (IsValidSize(ipObjects)) + { + // + Copy( + ipObjects, + drawnObjects, + false // + ); + } + } + } + + // + if (HasChild(model.peakPriceZones)) + { + // + int count = ArraySize(model.peakPriceZones); + for (int i = 0; i < count; i++) + { + // + XPriceZones ipZone = model.peakPriceZones[i]; + + // + XCBaseObject *ipObjects[]; + int ipDrawnObjects = DrawPriceZone( + ipZone, + ipObjects // + ); + if (IsValidSize(ipObjects)) + { + // + Copy( + ipObjects, + drawnObjects, + false // + ); + } + } + } + + // + result = ArraySize(drawnObjects); + + // + return result; + } + /** * Draw Specified POI State ... * diff --git a/Helpers/x-saherelm.x121.helper.mq5 b/Helpers/x-saherelm.x121.helper.mq5 index 9f8cc718..22310419 100644 --- a/Helpers/x-saherelm.x121.helper.mq5 +++ b/Helpers/x-saherelm.x121.helper.mq5 @@ -128,6 +128,12 @@ struct X121Inputs double sarStep; // Step double sarMax; // Maximum + // + // RSI ... + int rsiLength; // RSI Length + double rsiOverSoldLevel; // RSI Over Sold Level + double rsiOverBoughtLevel; // RSI Over Bought Level + // // Atr Detection ... int atrLength; // Length @@ -250,6 +256,12 @@ struct X121Inputs hhMode = MODE_HIGH; llMode = MODE_LOW; + // + // RSI ... + rsiLength = 0; + rsiOverSoldLevel = 0; + rsiOverBoughtLevel = 0; + // // Paraboli Sar Detection ... sarStep = 0; @@ -368,6 +380,12 @@ struct X121Inputs hhMode = MODE_HIGH; llMode = MODE_LOW; + // + // RSI ... + rsiLength = 14; + rsiOverSoldLevel = 30; + rsiOverBoughtLevel = 70; + // // Paraboli Sar Detection ... sarStep = 0.02; @@ -466,6 +484,11 @@ struct X121Inputs // result = // + // RSI ... + rsiLength > 0 && + rsiOverSoldLevel > 0 && + rsiOverBoughtLevel > 0 && + rsiOverSoldLevel < rsiOverBoughtLevel && // PSAR ... sarMax > 0 && sarStep > 0 && @@ -514,6 +537,7 @@ struct X121Inputs // // ATR ... result = MathMax(result, atrLength); + result = MathMax(result, rsiLength); // return result; @@ -571,12 +595,24 @@ struct X121Conditions double vwapFastStateBuffer[]; double vwapMidStateBuffer[]; double vwapSlowStateBuffer[]; - double validPeaksBuffer[]; - double validValesBuffer[]; + double rsiBuffer[]; // // Conditions ... + // + // XRSI ... + + // + bool isRSIOverBought; + bool isRSICrossedOverOverBought; + bool isRSICrossedUnderOverBought; + + // + bool isRSIOverSold; + bool isRSICrossedUnderOverSold; + bool isRSICrossedOverOverSold; + // // XSAR ... @@ -746,8 +782,7 @@ struct X121Conditions Clean(vwapFastStateBuffer); Clean(vwapMidStateBuffer); Clean(vwapSlowStateBuffer); - Clean(validPeaksBuffer); - Clean(validValesBuffer); + Clean(rsiBuffer); // ArraySetAsSeries(peaksBuffer, true); @@ -789,12 +824,24 @@ struct X121Conditions ArraySetAsSeries(vwapFastStateBuffer, true); ArraySetAsSeries(vwapMidStateBuffer, true); ArraySetAsSeries(vwapSlowStateBuffer, true); - ArraySetAsSeries(validPeaksBuffer, true); - ArraySetAsSeries(validValesBuffer, true); + ArraySetAsSeries(rsiBuffer, true); // // Conditions ... + // + // XRSI ... + + // + isRSIOverBought = false; + isRSICrossedUnderOverBought = false; + isRSICrossedOverOverBought = false; + + // + isRSIOverSold = false; + isRSICrossedOverOverSold = false; + isRSICrossedUnderOverSold = false; + // // XSAR ... @@ -1089,6 +1136,7 @@ class XCX121Helper : public XCBaseHelper // Deconstructor ... ~XCX121Helper() { + IndicatorRelease(mRSIHandler); } // @@ -1168,6 +1216,7 @@ class XCX121Helper : public XCBaseHelper ArraySetAsSeries(vwapFastStateBuffer, true); ArraySetAsSeries(vwapMidStateBuffer, true); ArraySetAsSeries(vwapSlowStateBuffer, true); + ArraySetAsSeries(rsiBuffer, true); // mHandler = iCustom( @@ -1290,6 +1339,19 @@ class XCX121Helper : public XCBaseHelper return result; } + // + mRSIHandler = iRSI( + symbol, + period, + mInputs.rsiLength, + PRICE_CLOSE // + ); + result = mRSIHandler != INVALID_HANDLE; + if (!result) + { + return result; + } + // return result; } @@ -1324,18 +1386,60 @@ class XCX121Helper : public XCBaseHelper ); } - /** - * Retrieve DON Chain Length ... - * - * @return ( int ) - */ - int GetDonChainLength() + // + // Implement Value Getters ... + + // + // XRSI ... + + // + double GetRSI( + int barIndex // Bar Index + ) { - return mInputs.donchainLength; + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + int count = ArraySize(rsiBuffer); + if (barIndex >= count) + { + barIndex = count - 1; + } + + // + return rsiBuffer[barIndex]; } // - // Implement Value Getters ... + int CopyRSI( + int start, // Start + int count, // Number of Items for read + double &buffer[], // Dest Buffer + bool forceClean = true // Force To Clean buffer + ) + { + // + // Update Calculations ... + Calculate(); + + // + // Copy Items ... + return Copy( + start, + count, + rsiBuffer, + buffer, + forceClean + // + ); + } // // SAR ... @@ -3717,6 +3821,13 @@ class XCX121Helper : public XCBaseHelper // // Buffers ... + // + CopyRSI( + zIndex, + loopback, + conditions.rsiBuffer // + ); + // CopySar( zIndex, @@ -3997,6 +4108,29 @@ class XCX121Helper : public XCBaseHelper int cIDX = 1; int pIDX = cIDX + 1; + // + // XRSI ... + + // + bool isRSIOverBought = conditions.rsiBuffer[cIDX] > mInputs.rsiOverBoughtLevel; + bool isRSIOverBoughtPrev = conditions.rsiBuffer[pIDX] > mInputs.rsiOverBoughtLevel; + + // + bool isRSICrossedOverOverBought = isRSIOverBought && + !isRSIOverBoughtPrev; + bool isRSICrossedUnderOverBought = !isRSIOverBought && + isRSIOverBoughtPrev; + + // + bool isRSIOverSold = conditions.rsiBuffer[cIDX] < mInputs.rsiOverSoldLevel; + bool isRSIOverSoldPrev = conditions.rsiBuffer[pIDX] < mInputs.rsiOverSoldLevel; + + // + bool isRSICrossedUnderOverSold = isRSIOverSold && + !isRSIOverSoldPrev; + bool isRSICrossedOverOverSold = !isRSIOverSold && + isRSIOverSoldPrev; + // // XSAR ... @@ -4174,6 +4308,12 @@ class XCX121Helper : public XCBaseHelper // // Set ... + conditions.isRSIOverBought = isRSIOverBought; + conditions.isRSICrossedOverOverBought = isRSICrossedOverOverBought; + conditions.isRSICrossedUnderOverBought = isRSICrossedUnderOverBought; + conditions.isRSIOverSold = isRSIOverSold; + conditions.isRSICrossedUnderOverSold = isRSICrossedUnderOverSold; + conditions.isRSICrossedOverOverSold = isRSICrossedOverOverSold; conditions.isSarBullish = isSarBullish; conditions.isSarBearish = isSarBearish; conditions.isSarSwitchedToBullish = isSarSwitchedToBullish; @@ -4245,6 +4385,9 @@ class XCX121Helper : public XCBaseHelper // // Buffers ... + // + int mRSIHandler; // RSI Handler ... + // // Buffers ... double peaksBuffer[]; @@ -4286,8 +4429,7 @@ class XCX121Helper : public XCBaseHelper double vwapFastStateBuffer[]; double vwapMidStateBuffer[]; double vwapSlowStateBuffer[]; - double validPeaksBuffer[]; - double validValesBuffer[]; + double rsiBuffer[]; // // Tools ... @@ -4307,6 +4449,17 @@ class XCX121Helper : public XCBaseHelper // // Buffers ... + // + // RSI ... + CopyBuffer( + mRSIHandler, + 0, + 0, + totalBars, + rsiBuffer + // + ); + // // XSAR ... CopyBuffer( diff --git a/Libraries/x-saherelm.common.lib.mq5 b/Libraries/x-saherelm.common.lib.mq5 index 234260a6..71fbf439 100644 --- a/Libraries/x-saherelm.common.lib.mq5 +++ b/Libraries/x-saherelm.common.lib.mq5 @@ -6821,6 +6821,19 @@ int AddRef( return result; } +// +// Check Specified Array Has Childs or not ... +template +bool HasChild(T &buffer[]) +{ + return IsValidSize(ArraySize(buffer)); +} +template +bool SpecificHasChild(T &buffer[]) +{ + return HasChild(buffer); +} + // // Remove Specified Item from an Array ... template diff --git a/Libraries/x-saherelm.x-poi.lib.mq5 b/Libraries/x-saherelm.x-poi.lib.mq5 index 4364e72d..8b33c3fe 100644 --- a/Libraries/x-saherelm.x-poi.lib.mq5 +++ b/Libraries/x-saherelm.x-poi.lib.mq5 @@ -5400,7 +5400,7 @@ struct XPriceZones }; // -// TODO: Complete this ... +// Market Strucutre Model ... struct XMarketStructure { // @@ -5412,7 +5412,11 @@ struct XMarketStructure // XPVPivotPoint vales[]; + XPriceZones valePriceZones[]; + + // XPVPivotPoint peaks[]; + XPriceZones peakPriceZones[]; // XOHCL lowestValeBar; @@ -5423,6 +5427,136 @@ struct XMarketStructure XOHCL highestPeakBar; XOHCL peakBelowHighestPeakValeBar; XOHCL highestPeakValeBreakeDownBar; + + // + XMarketStructure() + { + Clean(); + } + + /** + * Cleanup ... + */ + void Clean() + { + // + symbol = NULL; + period = NULL; + bias = X_DIRECTION_NONE; + + // + Clean(vales); + Clean(peaks); + Clean(valePriceZones); + Clean(peakPriceZones); + + // + lowestValeBar.Clean(); + lowestValePeakBreakeUpBar.Clean(); + valeAboveLowestValePeakBar.Clean(); + + // + highestPeakBar.Clean(); + peakBelowHighestPeakValeBar.Clean(); + highestPeakValeBreakeDownBar.Clean(); + } + + /** + * Validate Model ... + * + * @return ( bool ) + */ + bool IsValid() + { + // + bool result = false; + + // + result = + IsValid(symbol) && + IsValid(period) && + bias != X_DIRECTION_NONE; + + // + return result; + } + + /** + * Check Bullish Trend ... + * + * @return ( bool ) + */ + bool IsBullish() + { + // + bool result = false; + + // + result = + // + IsValid() && + IsBullish(bias) && + HasChild(peaks) && + HasDirection(bias) && + lowestValeBar.IsValid() && + HasChild(peakPriceZones) && + lowestValePeakBreakeUpBar.IsValid() && + valeAboveLowestValePeakBar.IsValid() + // + ; + + // + return result; + } + + /** + * Check Bearish Trend ... + * + * @return ( bool ) + */ + bool IsBearish() + { + // + bool result = false; + + // + result = + // + IsValid() && + IsBearish(bias) && + HasChild(vales) && + HasDirection(bias) && + highestPeakBar.IsValid() && + HasChild(valePriceZones) && + peakBelowHighestPeakValeBar.IsValid() && + highestPeakValeBreakeDownBar.IsValid() + // + ; + + // + return result; + } + + /** + * Check Has Trend ... + * + * @return ( bool ) + */ + bool HasTrend() + { + // + bool result = false; + + // + result = IsValid() && + (IsBullish() || + IsBearish()); + + // + return result; + } + + // }; // 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 56f95f1c..5046288d 100644 --- a/X121SMCEA/Classes/x-121.smc.market.cycle.helper.class.mq5 +++ b/X121SMCEA/Classes/x-121.smc.market.cycle.helper.class.mq5 @@ -519,15 +519,22 @@ class XC121SMCCycleHelper : public XCBase return result; } + /** + * Detect Market Structure ... + * + * @param model: XMarketStructure instance Reference ... + * + * @return ( bool ) + */ bool DetectMarketStructure( - ENUM_X_DIRECTION &dir // + XMarketStructure &model // ) { // bool result = false; // - dir = X_DIRECTION_NONE; + model.Clean(); // int barIndex = 0; @@ -536,6 +543,10 @@ class XC121SMCCycleHelper : public XCBase string symbol = GetSymbol(); ENUM_TIMEFRAMES period = GetPeriod(); + // + model.symbol = symbol; + model.period = period; + // int highestPeakIndex = -1; double highestPeakVale = 0; @@ -565,7 +576,7 @@ class XC121SMCCycleHelper : public XCBase } // - dir = + model.bias = highestPeakIndex < lowestValeIndex ? X_DIRECTION_BEARISH : highestPeakIndex > lowestValeIndex @@ -573,14 +584,14 @@ class XC121SMCCycleHelper : public XCBase : X_DIRECTION_NONE; // - result = HasDirection(dir); + result = HasDirection(model.bias); if (!result) { return result; } // - bool isBullish = IsBullish(dir); + bool isBullish = IsBullish(model.bias); // // Looking for Change Of Character Proved ... @@ -714,14 +725,10 @@ class XC121SMCCycleHelper : public XCBase // based on Detected Range ... // - XPVPivotPoint vales[]; - XPVPivotPoint peaks[]; XPVPivotPoint iPeakPoint; XPVPivotPoint iValePoint; XPriceZones peakPriceZone; XPriceZones valePriceZone; - XPriceZones peakPriceZones[]; - XPriceZones valePriceZones[]; // XPOIState state; @@ -730,7 +737,7 @@ class XC121SMCCycleHelper : public XCBase ); // - int minRepetition = 5; // ValidPivotRepetition(); + int minRepetition = 5; // int from = @@ -788,13 +795,13 @@ class XC121SMCCycleHelper : public XCBase // AddRef( iPeakPoint, - peaks // + model.peaks // ); // AddRef( peakPriceZone, - peakPriceZones // + model.peakPriceZones // ); } @@ -838,13 +845,13 @@ class XC121SMCCycleHelper : public XCBase // AddRef( iValePoint, - vales // + model.vales // ); // AddRef( valePriceZone, - valePriceZones // + model.valePriceZones // ); } @@ -865,306 +872,102 @@ class XC121SMCCycleHelper : public XCBase // in Bearish Bias we Looking for Peaks Oder ... // - // Draw ... - XCBaseObject *drawnObjects[]; - - // - // Bearish Bias ... + // Bullish Bias Drawn ... if (isBullish) { // - // Draw Lowest Vale Bar ... - XOHCL lowestValeBar; result = GetBar( - lowestValeBar, + model.lowestValeBar, lowestValeIndex // ); if (!result) { return result; } - XCOHCLObject *iLowestValeBarObj; - bool isCreated = mPOIDetector.mDrawer.CreateBar( - lowestValeBar, - iLowestValeBarObj, - TimeCurrent() // - ); - if (isCreated) - { - // - Add( - (XCBaseObject *)iLowestValeBarObj, - drawnObjects // - ); - } // - // Draw Lowest Vale Peak Breaker Bar ... - XOHCL lowestValePeakBreakeUpBar; if (isValidBreakeUpLowestValePeak) { // result = GetBar( - lowestValePeakBreakeUpBar, + model.lowestValePeakBreakeUpBar, lowestValePeakBreakeUpIndex // ); if (!result) { return result; } - - // - XCOHCLObject *iObj; - bool isCreated = mPOIDetector.mDrawer.CreateBar( - lowestValePeakBreakeUpBar, - iObj, - TimeCurrent() // - ); - if (isCreated) - { - // - Add( - (XCBaseObject *)iObj, - drawnObjects // - ); - } } // - // Draw Vale Above Lowest Vale Peak ... - XOHCL valeAboveLowestValePeakBar; if (isValidValeAboveLowestValePeak) { // - result = GetBar(valeAboveLowestValePeakBar, - valeAboveLowestValePeakIndex // + result = GetBar( + model.valeAboveLowestValePeakBar, + valeAboveLowestValePeakIndex // ); if (!result) { return result; } - - // - XCOHCLObject *iObj; - bool isCreated = mPOIDetector.mDrawer.CreateBar( - valeAboveLowestValePeakBar, - iObj, - TimeCurrent() // - ); - if (isCreated) - { - // - Add( - (XCBaseObject *)iObj, - drawnObjects // - ); - } - } - - // - // Draw Vales ... - int valesCount = ArraySize(vales); - if (IsValidSize(valesCount)) - { - // - for (int i = 0; i < valesCount; i++) - { - // - iValePoint = vales[i]; - - // - CChartObjectTrend *iValeObj; - iValeObj = new CChartObjectTrend(); - - // - string iValeName = "XVALE_" + ToString(iValePoint.value); - - // - long chartID = mPOIDetector.mDrawer.ChartIdentification(); - int window = mPOIDetector.mDrawer.SubWindowIdentification(); - - // - bool isCreate = iValeObj.Create( - chartID, - iValeName, - window, - iValePoint.time, - iValePoint.value, - TimeCurrent(), - iValePoint.value // - ); - if (isCreated) - { - } - } - } - - // - // Draw Price Zone ... - valesCount = ArraySize(valePriceZones); - if (IsValidSize(valesCount)) - { - // - for (int i = 0; i < valesCount; i++) - { - // - XPriceZones iZone = valePriceZones[i]; - - // - bool hasSupport = iZone.HasSupportZone(); - if (hasSupport) - { - // - XCSupportZoneObject *iObj; - bool isCreated = mPOIDetector.mDrawer.CreateSupportZone( - iZone.supportZone, - iObj // - ); - if (isCreated) - { - // - Add( - (XCBaseObject *)iObj, - drawnObjects // - ); - } - } - } } } // - // Bullish Bias Drawn ... + // Bearish Bias Drawn ... if (!isBullish) { // - // Draw Highest Peak Bar ... - XOHCL highestPeakBar; result = GetBar( - highestPeakBar, + model.highestPeakBar, highestPeakIndex // ); if (!result) { return result; } - XCOHCLObject *iHighestPeakBarObj; - bool isCreated = mPOIDetector.mDrawer.CreateBar( - highestPeakBar, - iHighestPeakBarObj, - TimeCurrent() // - ); - if (isCreated) - { - // - Add( - (XCBaseObject *)iHighestPeakBarObj, - drawnObjects // - ); - } // - // Draw Highest Peak Vale Breaker Bar ... - XOHCL highestPeakValeBreakeDownBar; if (isValidBreakeDownHighestPeakVale) { // result = GetBar( - highestPeakValeBreakeDownBar, + model.highestPeakValeBreakeDownBar, highestPeakValeBreakeDownIndex // ); if (!result) { return result; } - - // - XCOHCLObject *iObj; - bool isCreated = mPOIDetector.mDrawer.CreateBar( - highestPeakValeBreakeDownBar, - iObj, - TimeCurrent() // - ); - if (isCreated) - { - // - Add( - (XCBaseObject *)iObj, - drawnObjects // - ); - } } // - // Draw Peak Below Highest Peak Vale ... - XOHCL peakBelowHighestPeakValeBar; if (isValidPeakBelowHighestPeakVale) { // - result = GetBar(peakBelowHighestPeakValeBar, - peakBelowHighestPeakValeIndex // + result = GetBar( + model.peakBelowHighestPeakValeBar, + peakBelowHighestPeakValeIndex // ); if (!result) { return result; } - - // - XCOHCLObject *iObj; - bool isCreated = mPOIDetector.mDrawer.CreateBar( - peakBelowHighestPeakValeBar, - iObj, - TimeCurrent() // - ); - if (isCreated) - { - // - Add( - (XCBaseObject *)iObj, - drawnObjects // - ); - } - } - - // - // Draw Peaks ... - int peaksCount = ArraySize(peaks); - if (IsValidSize(peaksCount)) - { - // - for (int i = 0; i < peaksCount; i++) - { - // - iPeakPoint = peaks[i]; - - // - CChartObjectTrend *iPeakObj; - iPeakObj = new CChartObjectTrend(); - - // - string iPeakName = "XPEAK_" + ToString(iPeakPoint.value); - - // - long chartID = mPOIDetector.mDrawer.ChartIdentification(); - int window = mPOIDetector.mDrawer.SubWindowIdentification(); - - // - bool isCreate = iPeakObj.Create( - chartID, - iPeakName, - window, - iPeakPoint.time, - iPeakPoint.value, - TimeCurrent(), - iPeakPoint.value // - ); - if (isCreated) - { - } - } } } + // + result = model.IsValid(); + + // + // TODO: Remove this ... + XCBaseObject *objects[]; + int dObjects = mPOIDetector.mDrawer.DrawMarketStructure( + model, + objects // + ); + // return result; } diff --git a/X121SMCEA/Signals/x-121.smc.test.signal.lib.mq5 b/X121SMCEA/Signals/x-121.smc.test.signal.lib.mq5 index 57e1256e..24beeff4 100644 --- a/X121SMCEA/Signals/x-121.smc.test.signal.lib.mq5 +++ b/X121SMCEA/Signals/x-121.smc.test.signal.lib.mq5 @@ -246,8 +246,7 @@ bool DetectX121SMCTestSiganlSetup( // int zoneValidationDivider = 10; - int validPivotRepetition = triggerCycleHelper.mX121Helper - .GetDonChainLength(); + int validPivotRepetition = 10; // double selectedSL = 0; @@ -492,8 +491,7 @@ bool DetectX121SMCTestSiganlTrigger( // int zoneValidationDivider = 10; - int validPivotRepetition = triggerCycleHelper.mX121Helper - .GetDonChainLength(); + int validPivotRepetition = 10; // double selectedSL = 0; diff --git a/X121SMCEA/Signals/x-121.smc.xtwpv.signal.lib.mq5 b/X121SMCEA/Signals/x-121.smc.xtwpv.signal.lib.mq5 index c449707b..f2c5987f 100644 --- a/X121SMCEA/Signals/x-121.smc.xtwpv.signal.lib.mq5 +++ b/X121SMCEA/Signals/x-121.smc.xtwpv.signal.lib.mq5 @@ -647,10 +647,10 @@ bool DetectX121SMCXTWPVSiganlSetup( // Setup Conditions ... // - ENUM_X_DIRECTION biasDir; + XMarketStructure marketStructure; bool hasMarketStructure = analyseCycleHelper - .DetectMarketStructure(biasDir); + .DetectMarketStructure(marketStructure); // XOHCL analyseCBar; diff --git a/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 b/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 index c0662305..248785d0 100644 --- a/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 +++ b/X121SMCEA/Strategy/x-121.smc.strategy.class.mq5 @@ -693,14 +693,14 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy x121Inputs.showFibo4Levels = false; // - x121Inputs.showSar = false; + x121Inputs.showSar = true; x121Inputs.showPeaks = true; x121Inputs.showVales = true; x121Inputs.showVWap = false; x121Inputs.showDonchain = true; // - x121Inputs.showOpen = true; + x121Inputs.showOpen = false; x121Inputs.showHigh = true; x121Inputs.showClose = true; x121Inputs.showLow = true;