diff --git a/Experts/x-saherelm.xfima.backtester.ea.mq5 b/Experts/x-saherelm.xfima.backtester.ea.mq5 index 8ef981c7..fb78395e 100644 --- a/Experts/x-saherelm.xfima.backtester.ea.mq5 +++ b/Experts/x-saherelm.xfima.backtester.ea.mq5 @@ -106,6 +106,9 @@ input int zigzagDeviation = 5; // ZigZag Devia input int zigzagBackStep = 3; // ZigZag Back Step input ENUM_X_PRICE zigzagUppersMode = X_PRICE_HIGH; // ZigZag High Detect Mode input ENUM_X_PRICE zigzagLowersMode = X_PRICE_LOW; // ZigZag Low Detect Mode +input bool hkIgnoreShadows = true; // HK Remove noises +input int hkSmoothingLength = 21; // HK Smoothing Length +input ENUM_X_MA_METHOD hkSmoothingMode = X_MA_MODE_EMA; // HK Smoothing Method // input group "Bar Timer"; @@ -120,6 +123,7 @@ input group "Presentation"; input bool showPV = true; // Show PV input bool showHK = true; // Show HK input bool showSAR = true; // Show Sar +input bool showBars = true; // Show Bars input bool showMAFast = true; // Show MA Fast input bool showMASlow = true; // Show MA Slow input bool showMABand = true; // Show MA Band @@ -163,10 +167,22 @@ XBarTracker eaBarTracker; // EA Bar Traker ... // // Registered Handlers ... int eaCTHandler = INVALID_HANDLE; // Candle Timer Handler ... +int eaCCHandler = INVALID_HANDLE; // Candle Cleaner Handler ... // bool eaIsNewBar; // Check New Bar ... +// +ENUM_CHART_MODE eaBarMode = CHART_CANDLES; + +// +color eaBarUpColor = clrLime; +color eaBarDownColor = clrRed; +color eaBarLineColor = clrLime; +color eaBarBearishColor = clrRed; +color eaBarBullishColor = clrLime; +color eaBarVolumesColor = clrGreen; + // // Define Indicators Here ... @@ -293,6 +309,9 @@ int OnInit() fimaInputs.zigzagBackStep = zigzagBackStep; fimaInputs.zigzagUppersMode = zigzagUppersMode; fimaInputs.zigzagLowersMode = zigzagLowersMode; + fimaInputs.hkIgnoreShadows = hkIgnoreShadows; + fimaInputs.hkSmoothingLength = hkSmoothingLength; + fimaInputs.hkSmoothingMode = hkSmoothingMode; fimaInputs.showPV = showPV; fimaInputs.showHK = showHK; fimaInputs.showSAR = showSAR; @@ -358,6 +377,38 @@ int OnInit() return INIT_FAILED; } + // + // Initialize Candle Cleaner Handler ... + eaCCHandler = iCustom( + _Symbol, + _Period, + "x-saherelm.x121.xcc", + // + // Inputs ... + // + // Chart Style ... + "", + eaBarMode, // Mode + eaBarUpColor, // Up Color + eaBarDownColor, // Down Color + eaBarLineColor, // Line mode and Doji candlestick Color + eaBarBullishColor, // Bearish Color + eaBarBearishColor, // Bullish Color + eaBarVolumesColor, // Volumes Color + // + // Presentation ... + "", + showBars // Show Candles + // + ); + isInited = eaCCHandler != INVALID_HANDLE; + if (!isInited) + { + // + Print(ShortName, ": Initialization Failed ..."); + return INIT_FAILED; + } + // // Initialize Bar Tracker ... isInited = eaBarTracker.Init( @@ -614,11 +665,11 @@ void OnSignalExecuted(XSignal &signal) /** * Check For Guard ... - * + * * @param guards: XGuard, reference Collection to holds result ... * @param positions: XPosition, refrence collection to Provides Positions ... * @param barIndex: int, Specified Bar index ... - * + * * @return ( int ) */ int CheckForGuard( diff --git a/Helpers/x-saherelm.xfima.helper.mq5 b/Helpers/x-saherelm.xfima.helper.mq5 index bbeddd4b..b4934f30 100644 --- a/Helpers/x-saherelm.xfima.helper.mq5 +++ b/Helpers/x-saherelm.xfima.helper.mq5 @@ -60,6 +60,10 @@ enum ENUM_XFIMA_BUFFERS XFIMA_HK_LOW_LINE = 16, XFIMA_HK_CLOSE_LINE = 17, XFIMA_HK_COLOR_LINE = 18, + XFIMA_HK_RAW_OPEN_LINE = 34, + XFIMA_HK_RAW_HIGH_LINE = 35, + XFIMA_HK_RAW_LOW_LINE = 36, + XFIMA_HK_RAW_CLOSE_LINE = 37, // 19 Ma Fast State // 20 Ma Slow State // 21 Sar State @@ -75,6 +79,10 @@ enum ENUM_XFIMA_BUFFERS // 31 ZigZag Highs Time // 32 ZigZag Lows // 33 ZigZag Lows Time + // 34 HK Raw Open + // 35 HK Raw High + // 36 HK Raw Low + // 37 HK Raw Close }; // @@ -111,6 +119,9 @@ struct XFIMAInputs int zigzagBackStep; // ZigZag Back Step ENUM_X_PRICE zigzagUppersMode; // ZigZag High Detect Mode ENUM_X_PRICE zigzagLowersMode; // ZigZag Low Detect Mode + bool hkIgnoreShadows; // HK Remove noises + int hkSmoothingLength; // HK Smoothing Length + ENUM_X_MA_METHOD hkSmoothingMode; // HK Smoothing Method // // Presentation ... @@ -175,6 +186,9 @@ struct XFIMAInputs zigzagBackStep = 3; // ZigZag Back Step zigzagUppersMode = X_PRICE_HIGH; // ZigZag High Detect Mode zigzagLowersMode = X_PRICE_LOW; // ZigZag Low Detect Mode + hkIgnoreShadows = true; // HK Remove noises + hkSmoothingLength = 21; // HK Smoothing Length + hkSmoothingMode = X_MA_MODE_EMA; // HK Smoothing Method // // Presentation ... @@ -546,6 +560,9 @@ class XCXFIMAHelper : public XCBaseHelper mInputs.zigzagBackStep, mInputs.zigzagUppersMode, mInputs.zigzagLowersMode, + mInputs.hkIgnoreShadows, + mInputs.hkSmoothingLength, + mInputs.hkSmoothingMode, "", // Presentation ... mInputs.showPV, mInputs.showHK, diff --git a/Indicators/x-saherelm.xfima.mq5 b/Indicators/x-saherelm.xfima.mq5 index 961e150c..a93db0b4 100644 --- a/Indicators/x-saherelm.xfima.mq5 +++ b/Indicators/x-saherelm.xfima.mq5 @@ -89,6 +89,9 @@ input int zigzagDeviation = 5; // ZigZag Devia input int zigzagBackStep = 3; // ZigZag Back Step input ENUM_X_PRICE zigzagUppersMode = X_PRICE_HIGH; // ZigZag High Detect Mode input ENUM_X_PRICE zigzagLowersMode = X_PRICE_LOW; // ZigZag Low Detect Mode +input bool hkIgnoreShadows = true; // HK Remove noises +input int hkSmoothingLength = 21; // HK Smoothing Length +input ENUM_X_MA_METHOD hkSmoothingMode = X_MA_MODE_EMA; // HK Smoothing Method // // Presentation ... @@ -134,7 +137,7 @@ input int valeArrowCode = 159; // Vales Arrow Code #property indicator_chart_window // -#property indicator_buffers 34 +#property indicator_buffers 38 #property indicator_plots 12 // @@ -333,7 +336,7 @@ double hkColorBuffer[]; #define hkBufferPlotIndex 11 #property indicator_label12 "XHK Open;XHK High;XHK Low;XHK Close" #property indicator_type12 DRAW_COLOR_CANDLES -#property indicator_color12 CLR_NONE, clrAqua, clrMagenta +#property indicator_color12 CLR_NONE, clrAqua, clrMagenta, clrGray // // Data Buffers ... @@ -425,6 +428,25 @@ double lowsBuffer[]; #define lowsTimeBufferIndex mLastBufferIndex + 15 double lowsTimeBuffer[]; +// +// XHK Data ... + +// +#define hkRawHighBufferIndex mLastBufferIndex + 16 +double hkRawHighBuffer[]; + +// +#define hkRawOpenBufferIndex mLastBufferIndex + 17 +double hkRawOpenBuffer[]; + +// +#define hkRawLowBufferIndex mLastBufferIndex + 18 +double hkRawLowBuffer[]; + +// +#define hkRawCloseBufferIndex mLastBufferIndex + 19 +double hkRawCloseBuffer[]; + // // Variables, Properties and etc ... @@ -1086,6 +1108,25 @@ void DefineBuffers() SetIndexBuffer(lowsBufferIndex, lowsBuffer, INDICATOR_CALCULATIONS); SetIndexBuffer(lowsTimeBufferIndex, lowsTimeBuffer, INDICATOR_CALCULATIONS); + // + // XHK Data ... + + // + ArraySetAsSeries(hkRawHighBuffer, true); + SetIndexBuffer(hkRawHighBufferIndex, hkRawHighBuffer, INDICATOR_DATA); + + // + ArraySetAsSeries(hkRawOpenBuffer, true); + SetIndexBuffer(hkRawOpenBufferIndex, hkRawOpenBuffer, INDICATOR_DATA); + + // + ArraySetAsSeries(hkRawLowBuffer, true); + SetIndexBuffer(hkRawLowBufferIndex, hkRawLowBuffer, INDICATOR_DATA); + + // + ArraySetAsSeries(hkRawCloseBuffer, true); + SetIndexBuffer(hkRawCloseBufferIndex, hkRawCloseBuffer, INDICATOR_DATA); + // } @@ -2032,18 +2073,101 @@ void CalculateHKBar( double iHKLowValue = MathMin(low[barIndex], MathMin(iHKOpenValue, iHKCloseValue)); // - // Raw HK Buffers ... + bool isBullish = iHKOpenValue < iHKCloseValue; + bool isBearish = iHKOpenValue > iHKCloseValue; + + // + if (hkIgnoreShadows) + { + // + iHKHighValue = isBullish + ? iHKCloseValue + : iHKOpenValue; + + // + iHKLowValue = isBullish + ? iHKOpenValue + : iHKCloseValue; + } + + // + // XHK Buffers ... hkOpenBuffer[barIndex] = iHKOpenValue; hkHighBuffer[barIndex] = iHKHighValue; hkLowBuffer[barIndex] = iHKLowValue; hkCloseBuffer[barIndex] = iHKCloseValue; + // + // XHK Raw Bufferss ... + hkRawOpenBuffer[barIndex] = iHKOpenValue; + hkRawHighBuffer[barIndex] = iHKHighValue; + hkRawLowBuffer[barIndex] = iHKLowValue; + hkRawCloseBuffer[barIndex] = iHKCloseValue; + + // + // Smoothing ... + if (IsXValid(hkSmoothingMode) && hkSmoothingLength > 0) + { + // + // XHK Signal ... + + // + // High ... + iMAOnBuffer( + ratesTotal, + prevCalculated, + barIndex, + hkSmoothingLength, + hkRawHighBuffer, + hkHighBuffer, + hkSmoothingMode // + ); + + // + // Open ... + iMAOnBuffer( + ratesTotal, + prevCalculated, + barIndex, + hkSmoothingLength, + hkRawOpenBuffer, + hkOpenBuffer, + hkSmoothingMode // + ); + + // + // Close ... + iMAOnBuffer( + ratesTotal, + prevCalculated, + barIndex, + hkSmoothingLength, + hkRawLowBuffer, + hkLowBuffer, + hkSmoothingMode // + ); + + // + // Close ... + iMAOnBuffer( + ratesTotal, + prevCalculated, + barIndex, + hkSmoothingLength, + hkRawCloseBuffer, + hkCloseBuffer, + hkSmoothingMode // + ); + } + // // Calculate HK Color ... double iHKColorValue = - hkOpenBuffer[barIndex] < hkCloseBuffer[barIndex] + isBullish ? bullishColorIDX - : bearishColorIDX; + : isBearish + ? bearishColorIDX + : neuturalColorIDX; hkColorBuffer[barIndex] = showHK ? iHKColorValue diff --git a/Libraries/x-saherelm.x-enums.lib.mq5 b/Libraries/x-saherelm.x-enums.lib.mq5 index b66cb6e7..343c63fa 100644 --- a/Libraries/x-saherelm.x-enums.lib.mq5 +++ b/Libraries/x-saherelm.x-enums.lib.mq5 @@ -233,6 +233,10 @@ ENUM_APPLIED_PRICE ToAppliedPrice(ENUM_X_PRICE value) // return result; } +ENUM_APPLIED_PRICE ToXAppliedPrice(ENUM_X_PRICE value) +{ + return ToAppliedPrice(value); +} /** * Converts To String ... @@ -308,6 +312,10 @@ string ToString(ENUM_X_PRICE value) // return result; } +string ToXString(ENUM_X_PRICE value) +{ + return ToString(value); +} // // END Price Type ... @@ -379,6 +387,10 @@ string ToString(ENUM_X_BOUNDARY_PRICE value) // return result; } +string ToXString(ENUM_X_BOUNDARY_PRICE value) +{ + return ToString(value); +} // // END Boundary Price Type ... @@ -559,6 +571,10 @@ ENUM_X_DIRECTION Opposit(ENUM_X_DIRECTION value) // return result; } +ENUM_X_DIRECTION XOpposit(ENUM_X_DIRECTION value) +{ + return Opposit(value); +} /** * Converts To String ... @@ -680,6 +696,10 @@ string ToString(ENUM_X_FIBO_LEVELS value) // return result; } +string ToXString(ENUM_X_FIBO_LEVELS value) +{ + return ToString(value); +} /** * Converts To String ... @@ -820,6 +840,10 @@ string ToString(ENUM_X_SWING_TYPE value) // return result; } +string ToXString(ENUM_X_SWING_TYPE value) +{ + return ToString(value); +} /** * Converts To ENUM_SERIESMODE ... @@ -851,6 +875,10 @@ ENUM_SERIESMODE ToSeriesMode(ENUM_X_SWING_TYPE value) // return result; } +ENUM_SERIESMODE ToXSeriesMode(ENUM_X_SWING_TYPE value) +{ + return ToSeriesMode(value); +} // // END Swing Types ... @@ -892,6 +920,10 @@ bool IsValid(ENUM_X_PERIOD_METHOD value) // return result; } +bool IsXValid(ENUM_X_PERIOD_METHOD value) +{ + return IsValid(value); +} /** * Converts To String ... @@ -927,6 +959,10 @@ string ToString(ENUM_X_PERIOD_METHOD value) // return result; } +string ToXString(ENUM_X_PERIOD_METHOD value) +{ + return ToString(value); +} // // END Period Method ... @@ -1015,6 +1051,10 @@ ENUM_X_MARKET_CYCLES ToCycle(string value) // return result; } +ENUM_X_MARKET_CYCLES ToXCycle(string value) +{ + return ToCycle(value); +} /** * Converts To String ... @@ -1153,6 +1193,10 @@ bool IsValid(ENUM_X_WEEK_DAYS value) // return result; } +bool IsXValid(ENUM_X_WEEK_DAYS value) +{ + return IsValid(value); +} /** * Converts To String ... @@ -1179,7 +1223,7 @@ string ToString(ENUM_X_WEEK_DAYS value) result = "Sunday"; break; - // + // case X_WEEK_DAY_MONDAY: result = "Monday"; break; @@ -1194,7 +1238,7 @@ string ToString(ENUM_X_WEEK_DAYS value) result = "Wednesday"; break; - // + // case X_WEEK_DAY_THURSDAY: result = "Thursday"; break; @@ -1213,6 +1257,10 @@ string ToString(ENUM_X_WEEK_DAYS value) // return result; } +string ToXString(ENUM_X_WEEK_DAYS value) +{ + return ToString(value); +} // // END Week Days ... @@ -1259,6 +1307,10 @@ bool IsValid(ENUM_X_MA_METHOD value) // return result; } +bool IsXValid(ENUM_X_MA_METHOD value) +{ + return IsValid(value); +} /** * Converts To String ... @@ -1304,6 +1356,10 @@ string ToString(ENUM_X_MA_METHOD value) // return result; } +string ToXString(ENUM_X_MA_METHOD value) +{ + return ToString(value); +} // // END Ma Methods ... diff --git a/Libraries/x-saherelm.x-trade.lib.mq5 b/Libraries/x-saherelm.x-trade.lib.mq5 index 756d97b4..856e11c0 100644 --- a/Libraries/x-saherelm.x-trade.lib.mq5 +++ b/Libraries/x-saherelm.x-trade.lib.mq5 @@ -5712,13 +5712,21 @@ void ApplyTargetsOnSignal( // XTarget tpTarget; tpTarget = targets[idx]; + tpTarget.actingDistance = 0; tpTarget.target = signal.tp; + + // signal.tp = targets[idx].target; + targets[idx].actingDistance = 0; + + // ArrayRemove( targets, idx, 1 // ); + + // AddRef( tpTarget, targets // diff --git a/XFIMAEA/Classes/x-saherelm.xfima.signaller.class.mq5 b/XFIMAEA/Classes/x-saherelm.xfima.signaller.class.mq5 index 680210a5..5f3dba76 100644 --- a/XFIMAEA/Classes/x-saherelm.xfima.signaller.class.mq5 +++ b/XFIMAEA/Classes/x-saherelm.xfima.signaller.class.mq5 @@ -569,6 +569,45 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller analyserConfig // ); + // + // Draw Market Analysis ... + // has = iStructure.pvAnalysis.IsValid(); + // if (has) + // { + // // + // XBoxZone iBox; + // XCBoxObject *iBoxObj; + + // // + // has = iStructure.pvAnalysis.HasSupportBox(iBox); + // if (has) + // { + // // + // iBox.to = iBar.time; + // poiDrawer.DrawBox( + // iBox, + // iBoxObj, + // true, + // iBox.type // + // ); + // } + + // // + // ZeroMemory(iBoxObj); + // has = iStructure.pvAnalysis.HasResistanceBox(iBox); + // if (has) + // { + // // + // iBox.to = iBar.time; + // poiDrawer.DrawBox( + // iBox, + // iBoxObj, + // true, + // iBox.type // + // ); + // } + // } + // // Disable Signallers ... has = false; @@ -856,6 +895,74 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller : IsXBearish(patternDir) ? bar.low < zone.lower : false; + // + // Validate Zone ... + if (result) + { + // + // + } + + // + // Draw Requirements ... + // if (result) + // { + // // + // // Support and Resistances ... + // CArrayObj *zoneObjs; + // poiDrawer.DrawBoxes( + // supports, + // zoneObjs // + // ); + // poiDrawer.DrawBoxes( + // resistances, + // zoneObjs // + // ); + + // // + // // Zone ... + // XCBoxObject *iZoneObj; + // bool isDrawn = poiDrawer.DrawBox( + // zone, + // iZoneObj, + // true, + // zone.type // + // ); + // if (isDrawn) + // { + // // + // XPOIStyle iStyle; + // iStyle.width = 2; + // iStyle.clr = clrYellow; + // poiDrawer.ApplyBoxStyle( + // iZoneObj, + // iStyle // + // ); + // } + + // // + // // Pattern ... + // XCBarArrowObject *iPObj; + // poiDrawer.DrawBarArrow( + // bar, + // iPObj, + // zone.IsBullish() ? X_PRICE_LOW : X_PRICE_HIGH, + // 159, + // clrYellow, + // 3, // With ... + // zone.IsBullish() ? ANCHOR_BOTTOM : ANCHOR_TOP, + // patternName // + // ); + + // // poiDrawer.DrawBoxes( + // // structure.fvgs, + // // zoneObjs, + // // false // + // // ); + + // Print("SALAM"); + // } + if (result) { // @@ -872,7 +979,7 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller int numberOfTargets = 3; double actingDistance = 20; double iValue = EMPTY_VALUE; - bool ignoreFirstTarget = true; + bool ignoreFirstTarget = false; ENUM_X_DIRECTION targetsDir = Opposit(dir); int count = ExtractByDirection( targetZones, @@ -973,27 +1080,6 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller XClean(targetZones); } - // - // TODO: Remove this ... - if (result) - { - // - CArrayObj *zoneObjs; - poiDrawer.DrawBoxes( - supports, - zoneObjs // - ); - poiDrawer.DrawBoxes( - resistances, - zoneObjs // - ); - poiDrawer.DrawBoxes( - structure.fvgs, - zoneObjs, - false // - ); - } - // // Cleanup Resources ... if (!result)