diff --git a/Experts/x-saherelm.xfima.backtester.ea.mq5 b/Experts/x-saherelm.xfima.backtester.ea.mq5 index a7692f35..eb4234cd 100644 --- a/Experts/x-saherelm.xfima.backtester.ea.mq5 +++ b/Experts/x-saherelm.xfima.backtester.ea.mq5 @@ -453,11 +453,11 @@ void OnTick() } // - fima1Signaller.OnTick(); + // fima1Signaller.OnTick(); fima2Signaller.OnTick(); // - AnalyseMarket(1); + // AnalyseMarket(1); } // @@ -611,32 +611,44 @@ void OnSignalTriggered(XSignal &signal) return; } + // + // Draw Signal on Chart ... + // XCSignalObject *iSignalObj; + // bool has = fima2Signaller.poiDrawer.DrawSignal( + // signal, + // iSignalObj, + // 7 // + // ); + + // + // Try to Execute Signal ... + // // Draw Signal Vertical Line ... // - // CChartObjectVLine *iObj = new CChartObjectVLine(); + CChartObjectVLine *iObj = new CChartObjectVLine(); - // // - // string iName = signal.GetTag(); - // color iColor = IsLong(signal.type) ? clrLime : clrRed; + // + string iName = signal.GetTag(); + color iColor = IsLong(signal.type) ? clrLime : clrRed; - // // - // bool has = iObj.Create( - // fima2Signaller.poiDrawer.ChartIdentification(), - // iName, - // fima2Signaller.poiDrawer.SubWindowIdentification(), - // signal.time // - // ); - // if (has) - // { - // // - // iObj.Width(2); - // iObj.Color(iColor); + // + bool has = iObj.Create( + fima2Signaller.poiDrawer.ChartIdentification(), + iName, + fima2Signaller.poiDrawer.SubWindowIdentification(), + signal.time // + ); + if (has) + { + // + iObj.Width(2); + iObj.Color(iColor); - // // - // // eaDraws.Add(iObj); - // } + // + // eaDraws.Add(iObj); + } // // // // Alert Issued Signal ... @@ -901,7 +913,7 @@ void AnalyseMarket(int barIndex = 0) ); // - HandleSignalLookup(bar); + // HandleSignalLookup(bar); // bar.Clean(); diff --git a/XFIMAEA/Classes/x-saherelm.xfima.signaller.class.mq5 b/XFIMAEA/Classes/x-saherelm.xfima.signaller.class.mq5 index 1ade2d49..66b249d6 100644 --- a/XFIMAEA/Classes/x-saherelm.xfima.signaller.class.mq5 +++ b/XFIMAEA/Classes/x-saherelm.xfima.signaller.class.mq5 @@ -584,19 +584,6 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller analyserConfig.Clean(); } - // - // Reading ZigZag ... - - // - bool GetZigZagPoint() - { - // - bool result = false; - - // - return result; - } - // // Overrides ... @@ -628,20 +615,31 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller XOHCL bar; XSignal signal; XBoxZone iZone; + int count = 0; bool has = false; int cIdx = barIndex + 1; int pIdx = cIdx + 1; string iName = NULL; + XBoxZone supports[]; + XBoxZone resistances[]; bool isBullish = false; bool isBearish = false; double iPrice = EMPTY_VALUE; - XBoxZone supports[]; - XBoxZone resistances[]; - ENUM_X_PRICE iPriceType = X_PRICE_NONE; XFIMAMarketStructure structure; XFIMAConditions fimaConditions; + ENUM_X_PRICE iPriceType = X_PRICE_NONE; ENUM_X_DIRECTION iDir = X_DIRECTION_NONE; + // + string pvTrendName = "XXIFMA2PVTrend"; + CChartObjectTrend *pvTrendLine = NULL; + ENUM_X_DIRECTION pvTrend = X_DIRECTION_NONE; + + // + string zgTrendName = "XFIMA2ZGTrend"; + CChartObjectTrend *zgTrendLine = NULL; + ENUM_X_DIRECTION zgTrend = X_DIRECTION_NONE; + // // Initialize Bar as CBar ... has = bar.Init( @@ -786,6 +784,9 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller : iPrice > iMABandUpper; if (!has) { + // + isBullish = false; + isBearish = false; iDir = X_DIRECTION_NONE; } } @@ -795,16 +796,12 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller // // PV Trend Line ... - string pvTrendName = "XXIFMA2PVTrend"; - CChartObjectTrend *pvTrendLine = NULL; - ENUM_X_DIRECTION pvTrend = X_DIRECTION_NONE; bool hasPVAnalysis = structure.pvAnalysis.IsValid(); if (hasPVAnalysis) { // // Support ... XBoxZone supportBox; - XCBoxObject *iSupportObj; has = structure.pvAnalysis.HasSupportBox(supportBox); if (has) { @@ -814,32 +811,31 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller supportBox, supports // ); - has = poiDrawer.DrawBox( - supportBox, - iSupportObj, - true, // Ignore At ... - supportBox.type // Name ... - ); - if (has) - { - // - XPOIStyle iStyle; - poiDrawer.GetBoxStyle( - iStyle, - supportBox.dir // - ); - poiDrawer.ApplyBoxStyle( - iSupportObj, - iStyle // - ); - iStyle.Clean(); - } + // has = poiDrawer.DrawBox( + // supportBox, + // iSupportObj, + // true, // Ignore At ... + // supportBox.type // Name ... + // ); + // if (has) + // { + // // + // XPOIStyle iStyle; + // poiDrawer.GetBoxStyle( + // iStyle, + // supportBox.dir // + // ); + // poiDrawer.ApplyBoxStyle( + // iSupportObj, + // iStyle // + // ); + // iStyle.Clean(); + // } } // // Resistance ... XBoxZone resistanceBox; - XCBoxObject *iResistanceObj; has = structure.pvAnalysis.HasResistanceBox(resistanceBox); if (has) { @@ -849,26 +845,26 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller resistanceBox, supports // ); - has = poiDrawer.DrawBox( - resistanceBox, - iResistanceObj, - true, // Ignore At ... - resistanceBox.type // Name ... - ); - if (has) - { - // - XPOIStyle iStyle; - poiDrawer.GetBoxStyle( - iStyle, - resistanceBox.dir // - ); - poiDrawer.ApplyBoxStyle( - iResistanceObj, - iStyle // - ); - iStyle.Clean(); - } + // has = poiDrawer.DrawBox( + // resistanceBox, + // iResistanceObj, + // true, // Ignore At ... + // resistanceBox.type // Name ... + // ); + // if (has) + // { + // // + // XPOIStyle iStyle; + // poiDrawer.GetBoxStyle( + // iStyle, + // resistanceBox.dir // + // ); + // poiDrawer.ApplyBoxStyle( + // iResistanceObj, + // iStyle // + // ); + // iStyle.Clean(); + // } } // @@ -1066,16 +1062,13 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller // // ZigZag Trend Line ... - string zgTrendName = "XFIMA2ZGTrend"; - CChartObjectTrend *zgTrendLine = NULL; - ENUM_X_DIRECTION zgTrend = X_DIRECTION_NONE; bool hasZGAnalysis = structure.zigzagAnalysis.IsValid(); if (hasZGAnalysis) { // // Support ... XBoxZone supportBox; - XCBoxObject *iSupportObj; + // XCBoxObject *iSupportObj; has = structure.zigzagAnalysis.HasSupportBox(supportBox); if (has) { @@ -1085,32 +1078,32 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller supportBox, supports // ); - has = poiDrawer.DrawBox( - supportBox, - iSupportObj, - true, // Ignore At ... - supportBox.type // Name ... - ); - if (has) - { - // - XPOIStyle iStyle; - poiDrawer.GetBoxStyle( - iStyle, - supportBox.dir // - ); - poiDrawer.ApplyBoxStyle( - iSupportObj, - iStyle // - ); - iStyle.Clean(); - } + // has = poiDrawer.DrawBox( + // supportBox, + // iSupportObj, + // true, // Ignore At ... + // supportBox.type // Name ... + // ); + // if (has) + // { + // // + // XPOIStyle iStyle; + // poiDrawer.GetBoxStyle( + // iStyle, + // supportBox.dir // + // ); + // poiDrawer.ApplyBoxStyle( + // iSupportObj, + // iStyle // + // ); + // iStyle.Clean(); + // } } // // Resistance ... XBoxZone resistanceBox; - XCBoxObject *iResistanceObj; + // XCBoxObject *iResistanceObj; has = structure.zigzagAnalysis.HasResistanceBox(resistanceBox); if (has) { @@ -1120,26 +1113,26 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller resistanceBox, supports // ); - has = poiDrawer.DrawBox( - resistanceBox, - iResistanceObj, - true, // Ignore At ... - resistanceBox.type // Name ... - ); - if (has) - { - // - XPOIStyle iStyle; - poiDrawer.GetBoxStyle( - iStyle, - resistanceBox.dir // - ); - poiDrawer.ApplyBoxStyle( - iResistanceObj, - iStyle // - ); - iStyle.Clean(); - } + // has = poiDrawer.DrawBox( + // resistanceBox, + // iResistanceObj, + // true, // Ignore At ... + // resistanceBox.type // Name ... + // ); + // if (has) + // { + // // + // XPOIStyle iStyle; + // poiDrawer.GetBoxStyle( + // iStyle, + // resistanceBox.dir // + // ); + // poiDrawer.ApplyBoxStyle( + // iResistanceObj, + // iStyle // + // ); + // iStyle.Clean(); + // } } // @@ -1346,14 +1339,14 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller supports // ); - // - XCBoxObject *iObj; - has = fima2Signaller.poiDrawer.DrawBox( - structure.support, - iObj); - if (has) - { - } + // // + // XCBoxObject *iObj; + // has = fima2Signaller.poiDrawer.DrawBox( + // structure.support, + // iObj); + // if (has) + // { + // } } // @@ -1367,14 +1360,14 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller resistances // ); - // - XCBoxObject *iObj; - has = fima2Signaller.poiDrawer.DrawBox( - structure.resistance, - iObj); - if (has) - { - } + // // + // XCBoxObject *iObj; + // has = fima2Signaller.poiDrawer.DrawBox( + // structure.resistance, + // iObj); + // if (has) + // { + // } } // @@ -1415,16 +1408,173 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller : bar.low < resistances[insideZoneIDX].lower; if (!has) { + // + isBullish = false; + isBearish = false; iDir = X_DIRECTION_NONE; } } + else + { + // + isBullish = false; + isBearish = false; + iDir = X_DIRECTION_NONE; + } // // Checking Liquidities ... // // Do all Draws Here ... - + bool canDraw = true; + if (canDraw) + { + // + int iWidth = 2; + XPOIStyle iStyle; + XCBoxObject *iBoxObj = NULL; + color iClr = isBullish + ? clrYellow + : clrDarkOrange; + + // + // Supports ... + has = HasChild(supports); + if (has) + { + // + count = ArraySize(supports); + for (int i = 0; i < count; i++) + { + // + has = poiDrawer.DrawBox( + supports[i], + iBoxObj, + true, // Ignore At ... + supports[i].type // Name ... + ); + if (has) + { + // + poiDrawer.GetBoxStyle( + iStyle, + supports[i].dir // + ); + + // + poiDrawer.ApplyBoxStyle( + iBoxObj, + iStyle // + ); + } + + // + iStyle.Clean(); + ZeroMemory(iBoxObj); + } + } + + // + // Resistances ... + has = HasChild(resistances); + if (has) + { + // + count = ArraySize(resistances); + for (int i = 0; i < count; i++) + { + // + has = poiDrawer.DrawBox( + resistances[i], + iBoxObj, + true, // Ignore At ... + resistances[i].type // Name ... + ); + if (has) + { + // + poiDrawer.GetBoxStyle( + iStyle, + resistances[i].dir // + ); + + // + poiDrawer.ApplyBoxStyle( + iBoxObj, + iStyle // + ); + } + + // + iStyle.Clean(); + ZeroMemory(iBoxObj); + } + } + + // + // Selected Zone ... + has = iZone.IsValid(); + if (has) + { + // + has = poiDrawer.DrawBox( + iZone, + iBoxObj, + true, // Ignore At ... + iZone.type // Name ... + ); + if (has) + { + // + poiDrawer.GetBoxStyle( + iStyle, + iZone.dir // + ); + + // + iStyle.clr = iClr; + iStyle.width = iWidth; + + // + poiDrawer.ApplyBoxStyle( + iBoxObj, + iStyle // + ); + } + } + + // + // TrendLines ... + + // + // Patterns Bar ... + has = HasDirection(iDir); + if (has) + { + // + int iCode = 159; + ENUM_ARROW_ANCHOR iAnchor = isBullish + ? ANCHOR_TOP + : ANCHOR_BOTTOM; + + // + XCBarArrowObject *iPatternObj; + has = poiDrawer.DrawBarArrow( + bar, + iPatternObj, + iPriceType, + iCode, + iClr, + iWidth, + iAnchor, + iName, + true, // Ignore Bar Tag ... + 10 // Threshold ... + ); + } + } + // // Check Signal Founded ... has = HasDirection(iDir); @@ -1452,8 +1602,12 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller // // Cleanup Resources ... bar.Clean(); + iZone.Clean(); signal.Clean(); + structure.Clean(); fimaConditions.Clean(); + SpecifiedClean(supports); + SpecifiedClean(resistances); } /**