From 0f2bcd75e78798b86ff57ed5911aeebad716e339 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Thu, 1 Aug 2024 05:10:16 +0330 Subject: [PATCH] apply some fix on XCH OSC Indicator Helpers Buffers ... --- Experts/x-test-strategies.ea.mq5 | 4 +- Helpers/x-saherelm.xchvlm.helper.mq5 | 6 +-- Indicators/x-saherelm.xchtd.mq5 | 70 +++++++++++++------------- Indicators/x-saherelm.xchvlm.mq5 | 39 +++++++------- Indicators/x-saherelm.xchvlm.osc.mq5 | 14 +++--- Strategies/x-saherelm.xch.strategy.mq5 | 10 ++-- 6 files changed, 74 insertions(+), 69 deletions(-) diff --git a/Experts/x-test-strategies.ea.mq5 b/Experts/x-test-strategies.ea.mq5 index 3b1ba11c..e1c9b325 100644 --- a/Experts/x-test-strategies.ea.mq5 +++ b/Experts/x-test-strategies.ea.mq5 @@ -46,8 +46,8 @@ double eaSLPoint = 500; // Static SL Point double eaR2R = 1.5; // Risk to Reward Ratio double eaAllowLong = true; // Allow Long Positions double eaAllowShort = true; // Allow Short Positions -int eaMaxAllowedLongs = 2; // Max Allowed Long Positions -int eaMaxAllowedShorts = 2; // Max Allowed Short Positions +int eaMaxAllowedLongs = 1; // Max Allowed Long Positions +int eaMaxAllowedShorts = 1; // Max Allowed Short Positions double eaMaxDrawdownPercentForOpenTrades = 3; // Max Drawdown Percent for Open Trades // diff --git a/Helpers/x-saherelm.xchvlm.helper.mq5 b/Helpers/x-saherelm.xchvlm.helper.mq5 index 4d062c89..e4bc4c82 100644 --- a/Helpers/x-saherelm.xchvlm.helper.mq5 +++ b/Helpers/x-saherelm.xchvlm.helper.mq5 @@ -1001,7 +1001,7 @@ public: // result = // - ToState(value) == XCHVLM_BEARISH_STATE; + ToState(value) == XCHVLM_BULLISH_STATE; // ; @@ -1449,7 +1449,7 @@ public: } // - result = GetSum(values); + result = MathAbs(GetSum(values)); // return result; @@ -1475,7 +1475,7 @@ public: } // - result = GetSum(values); + result = MathAbs(GetSum(values)); // return result; diff --git a/Indicators/x-saherelm.xchtd.mq5 b/Indicators/x-saherelm.xchtd.mq5 index 08caf78b..86ec2b54 100644 --- a/Indicators/x-saherelm.xchtd.mq5 +++ b/Indicators/x-saherelm.xchtd.mq5 @@ -561,91 +561,91 @@ void DefineBuffers() // Current ... // - ENUM_DRAW_TYPE cDrawType = showCurrent ? DRAW_LINE : DRAW_NONE; + // ENUM_DRAW_TYPE cDrawType = showCurrent ? DRAW_LINE : DRAW_NONE; // ArraySetAsSeries(cBullBuffer, true); - SetIndexBuffer(cBullBufferIndex, cBullBuffer, INDICATOR_DATA); - PlotIndexSetInteger(cBullBufferIndex, PLOT_DRAW_TYPE, cDrawType); - PlotIndexSetInteger(cBullBufferIndex, PLOT_SHOW_DATA, showCurrent); + SetIndexBuffer(cBullBufferIndex, cBullBuffer, INDICATOR_CALCULATIONS); + // PlotIndexSetInteger(cBullBufferIndex, PLOT_DRAW_TYPE, cDrawType); + // PlotIndexSetInteger(cBullBufferIndex, PLOT_SHOW_DATA, showCurrent); // ArraySetAsSeries(cBearBuffer, true); - SetIndexBuffer(cBearBufferIndex, cBearBuffer, INDICATOR_DATA); - PlotIndexSetInteger(cBearBufferIndex, PLOT_DRAW_TYPE, cDrawType); - PlotIndexSetInteger(cBearBufferIndex, PLOT_SHOW_DATA, showCurrent); + SetIndexBuffer(cBearBufferIndex, cBearBuffer, INDICATOR_CALCULATIONS); + // PlotIndexSetInteger(cBearBufferIndex, PLOT_DRAW_TYPE, cDrawType); + // PlotIndexSetInteger(cBearBufferIndex, PLOT_SHOW_DATA, showCurrent); // // Short ... // - ENUM_DRAW_TYPE sDrawType = showShort ? DRAW_LINE : DRAW_NONE; + // ENUM_DRAW_TYPE sDrawType = showShort ? DRAW_LINE : DRAW_NONE; // ArraySetAsSeries(sBullBuffer, true); - SetIndexBuffer(sBullBufferIndex, sBullBuffer, INDICATOR_DATA); - PlotIndexSetInteger(sBullBufferIndex, PLOT_DRAW_TYPE, sDrawType); - PlotIndexSetInteger(sBullBufferIndex, PLOT_SHOW_DATA, showShort); + SetIndexBuffer(sBullBufferIndex, sBullBuffer, INDICATOR_CALCULATIONS); + // PlotIndexSetInteger(sBullBufferIndex, PLOT_DRAW_TYPE, sDrawType); + // PlotIndexSetInteger(sBullBufferIndex, PLOT_SHOW_DATA, showShort); // ArraySetAsSeries(sBearBuffer, true); - SetIndexBuffer(sBearBufferIndex, sBearBuffer, INDICATOR_DATA); - PlotIndexSetInteger(sBearBufferIndex, PLOT_DRAW_TYPE, sDrawType); - PlotIndexSetInteger(sBearBufferIndex, PLOT_SHOW_DATA, showShort); + SetIndexBuffer(sBearBufferIndex, sBearBuffer, INDICATOR_CALCULATIONS); + // PlotIndexSetInteger(sBearBufferIndex, PLOT_DRAW_TYPE, sDrawType); + // PlotIndexSetInteger(sBearBufferIndex, PLOT_SHOW_DATA, showShort); // // Medium ... // - ENUM_DRAW_TYPE mDrawType = showMedium ? DRAW_LINE : DRAW_NONE; + // ENUM_DRAW_TYPE mDrawType = showMedium ? DRAW_LINE : DRAW_NONE; // ArraySetAsSeries(mBullBuffer, true); - SetIndexBuffer(mBullBufferIndex, mBullBuffer, INDICATOR_DATA); - PlotIndexSetInteger(mBullBufferIndex, PLOT_DRAW_TYPE, mDrawType); - PlotIndexSetInteger(mBullBufferIndex, PLOT_SHOW_DATA, showMedium); + SetIndexBuffer(mBullBufferIndex, mBullBuffer, INDICATOR_CALCULATIONS); + // PlotIndexSetInteger(mBullBufferIndex, PLOT_DRAW_TYPE, mDrawType); + // PlotIndexSetInteger(mBullBufferIndex, PLOT_SHOW_DATA, showMedium); // ArraySetAsSeries(mBearBuffer, true); - SetIndexBuffer(mBearBufferIndex, mBearBuffer, INDICATOR_DATA); - PlotIndexSetInteger(mBearBufferIndex, PLOT_DRAW_TYPE, mDrawType); - PlotIndexSetInteger(mBearBufferIndex, PLOT_SHOW_DATA, showMedium); + SetIndexBuffer(mBearBufferIndex, mBearBuffer, INDICATOR_CALCULATIONS); + // PlotIndexSetInteger(mBearBufferIndex, PLOT_DRAW_TYPE, mDrawType); + // PlotIndexSetInteger(mBearBufferIndex, PLOT_SHOW_DATA, showMedium); // // Long ... // - ENUM_DRAW_TYPE lDrawType = showLong ? DRAW_LINE : DRAW_NONE; + // ENUM_DRAW_TYPE lDrawType = showLong ? DRAW_LINE : DRAW_NONE; // ArraySetAsSeries(lBullBuffer, true); - SetIndexBuffer(lBullBufferIndex, lBullBuffer, INDICATOR_DATA); - PlotIndexSetInteger(lBullBufferIndex, PLOT_DRAW_TYPE, lDrawType); - PlotIndexSetInteger(lBullBufferIndex, PLOT_SHOW_DATA, showLong); + SetIndexBuffer(lBullBufferIndex, lBullBuffer, INDICATOR_CALCULATIONS); + // PlotIndexSetInteger(lBullBufferIndex, PLOT_DRAW_TYPE, lDrawType); + // PlotIndexSetInteger(lBullBufferIndex, PLOT_SHOW_DATA, showLong); // ArraySetAsSeries(lBearBuffer, true); - SetIndexBuffer(lBearBufferIndex, lBearBuffer, INDICATOR_DATA); - PlotIndexSetInteger(lBearBufferIndex, PLOT_DRAW_TYPE, lDrawType); - PlotIndexSetInteger(lBearBufferIndex, PLOT_SHOW_DATA, showLong); + SetIndexBuffer(lBearBufferIndex, lBearBuffer, INDICATOR_CALCULATIONS); + // PlotIndexSetInteger(lBearBufferIndex, PLOT_DRAW_TYPE, lDrawType); + // PlotIndexSetInteger(lBearBufferIndex, PLOT_SHOW_DATA, showLong); // // Hind ... // - ENUM_DRAW_TYPE hDrawType = showHind ? DRAW_LINE : DRAW_NONE; + // ENUM_DRAW_TYPE hDrawType = showHind ? DRAW_LINE : DRAW_NONE; // ArraySetAsSeries(hBullBuffer, true); - SetIndexBuffer(hBullBufferIndex, hBullBuffer, INDICATOR_DATA); - PlotIndexSetInteger(hBullBufferIndex, PLOT_DRAW_TYPE, hDrawType); - PlotIndexSetInteger(hBullBufferIndex, PLOT_SHOW_DATA, showHind); + SetIndexBuffer(hBullBufferIndex, hBullBuffer, INDICATOR_CALCULATIONS); + // PlotIndexSetInteger(hBullBufferIndex, PLOT_DRAW_TYPE, hDrawType); + // PlotIndexSetInteger(hBullBufferIndex, PLOT_SHOW_DATA, showHind); // ArraySetAsSeries(hBearBuffer, true); - SetIndexBuffer(hBearBufferIndex, hBearBuffer, INDICATOR_DATA); - PlotIndexSetInteger(hBearBufferIndex, PLOT_DRAW_TYPE, hDrawType); - PlotIndexSetInteger(hBearBufferIndex, PLOT_SHOW_DATA, showHind); + SetIndexBuffer(hBearBufferIndex, hBearBuffer, INDICATOR_CALCULATIONS); + // PlotIndexSetInteger(hBearBufferIndex, PLOT_DRAW_TYPE, hDrawType); + // PlotIndexSetInteger(hBearBufferIndex, PLOT_SHOW_DATA, showHind); } // diff --git a/Indicators/x-saherelm.xchvlm.mq5 b/Indicators/x-saherelm.xchvlm.mq5 index 62c190ea..2f04a893 100644 --- a/Indicators/x-saherelm.xchvlm.mq5 +++ b/Indicators/x-saherelm.xchvlm.mq5 @@ -569,9 +569,10 @@ void DefineBuffers() // // ENUM_DRAW_TYPE cDrawType = showCurrent ? DRAW_COLOR_HISTOGRAM : DRAW_NONE; // PlotIndexSetInteger(cPlotBufferIndex, PLOT_DRAW_TYPE, cDrawType); - SetIndexBuffer(cBufferIndex, cBuffer, INDICATOR_DATA); - SetIndexBuffer(cColorBufferIndex, cColorBuffer, INDICATOR_COLOR_INDEX); - PlotIndexSetInteger(cPlotBufferIndex, PLOT_SHOW_DATA, showCurrent); + // PlotIndexSetInteger(cPlotBufferIndex, PLOT_SHOW_DATA, showCurrent); + // SetIndexBuffer(cColorBufferIndex, cColorBuffer, INDICATOR_COLOR_INDEX); + SetIndexBuffer(cBufferIndex, cBuffer, INDICATOR_CALCULATIONS); + SetIndexBuffer(cColorBufferIndex, cColorBuffer, INDICATOR_CALCULATIONS); // // Short ... @@ -579,9 +580,10 @@ void DefineBuffers() // // ENUM_DRAW_TYPE sDrawType = showShort ? DRAW_COLOR_HISTOGRAM : DRAW_NONE; // PlotIndexSetInteger(sPlotBufferIndex, PLOT_DRAW_TYPE, sDrawType); - SetIndexBuffer(sBufferIndex, sBuffer, INDICATOR_DATA); - SetIndexBuffer(sColorBufferIndex, sColorBuffer, INDICATOR_COLOR_INDEX); - PlotIndexSetInteger(sPlotBufferIndex, PLOT_SHOW_DATA, showShort); + // PlotIndexSetInteger(sPlotBufferIndex, PLOT_SHOW_DATA, showShort); + // SetIndexBuffer(sColorBufferIndex, sColorBuffer, INDICATOR_COLOR_INDEX); + SetIndexBuffer(sBufferIndex, sBuffer, INDICATOR_CALCULATIONS); + SetIndexBuffer(sColorBufferIndex, sColorBuffer, INDICATOR_CALCULATIONS); // // Medium ... @@ -589,9 +591,10 @@ void DefineBuffers() // // ENUM_DRAW_TYPE mDrawType = showMedium ? DRAW_COLOR_HISTOGRAM : DRAW_NONE; // PlotIndexSetInteger(mPlotBufferIndex, PLOT_DRAW_TYPE, mDrawType); - SetIndexBuffer(mBufferIndex, mBuffer, INDICATOR_DATA); - SetIndexBuffer(mColorBufferIndex, mColorBuffer, INDICATOR_COLOR_INDEX); - PlotIndexSetInteger(mPlotBufferIndex, PLOT_SHOW_DATA, showMedium); + // PlotIndexSetInteger(mPlotBufferIndex, PLOT_SHOW_DATA, showMedium); + // SetIndexBuffer(mColorBufferIndex, mColorBuffer, INDICATOR_COLOR_INDEX); + SetIndexBuffer(mBufferIndex, mBuffer, INDICATOR_CALCULATIONS); + SetIndexBuffer(mColorBufferIndex, mColorBuffer, INDICATOR_CALCULATIONS); // // Long ... @@ -599,19 +602,21 @@ void DefineBuffers() // // ENUM_DRAW_TYPE lDrawType = showLong ? DRAW_COLOR_HISTOGRAM : DRAW_NONE; // PlotIndexSetInteger(lPlotBufferIndex, PLOT_DRAW_TYPE, lDrawType); - SetIndexBuffer(lBufferIndex, lBuffer, INDICATOR_DATA); - SetIndexBuffer(lColorBufferIndex, lColorBuffer, INDICATOR_COLOR_INDEX); - PlotIndexSetInteger(lPlotBufferIndex, PLOT_SHOW_DATA, showLong); + // PlotIndexSetInteger(lPlotBufferIndex, PLOT_SHOW_DATA, showLong); + // SetIndexBuffer(lColorBufferIndex, lColorBuffer, INDICATOR_COLOR_INDEX); + SetIndexBuffer(lBufferIndex, lBuffer, INDICATOR_CALCULATIONS); + SetIndexBuffer(lColorBufferIndex, lColorBuffer, INDICATOR_CALCULATIONS); // // Hind ... // - ENUM_DRAW_TYPE hDrawType = showHind ? DRAW_COLOR_HISTOGRAM : DRAW_NONE; - SetIndexBuffer(hBufferIndex, hBuffer, INDICATOR_DATA); - SetIndexBuffer(hColorBufferIndex, hColorBuffer, INDICATOR_COLOR_INDEX); - PlotIndexSetInteger(hPlotBufferIndex, PLOT_DRAW_TYPE, hDrawType); - PlotIndexSetInteger(hPlotBufferIndex, PLOT_SHOW_DATA, showHind); + // ENUM_DRAW_TYPE hDrawType = showHind ? DRAW_COLOR_HISTOGRAM : DRAW_NONE; + // PlotIndexSetInteger(hPlotBufferIndex, PLOT_DRAW_TYPE, hDrawType); + // PlotIndexSetInteger(hPlotBufferIndex, PLOT_SHOW_DATA, showHind); + // SetIndexBuffer(hColorBufferIndex, hColorBuffer, INDICATOR_COLOR_INDEX); + SetIndexBuffer(hBufferIndex, hBuffer, INDICATOR_CALCULATIONS); + SetIndexBuffer(hColorBufferIndex, hColorBuffer, INDICATOR_CALCULATIONS); } // diff --git a/Indicators/x-saherelm.xchvlm.osc.mq5 b/Indicators/x-saherelm.xchvlm.osc.mq5 index 6916c09d..f1f91b68 100644 --- a/Indicators/x-saherelm.xchvlm.osc.mq5 +++ b/Indicators/x-saherelm.xchvlm.osc.mq5 @@ -570,8 +570,8 @@ void DefineBuffers() // ENUM_DRAW_TYPE cDrawType = showCurrent ? DRAW_COLOR_HISTOGRAM : DRAW_NONE; // PlotIndexSetInteger(cPlotBufferIndex, PLOT_DRAW_TYPE, cDrawType); SetIndexBuffer(cBufferIndex, cBuffer, INDICATOR_DATA); - SetIndexBuffer(cColorBufferIndex, cColorBuffer, INDICATOR_COLOR_INDEX); PlotIndexSetInteger(cPlotBufferIndex, PLOT_SHOW_DATA, showCurrent); + SetIndexBuffer(cColorBufferIndex, cColorBuffer, INDICATOR_COLOR_INDEX); // // Short ... @@ -580,8 +580,8 @@ void DefineBuffers() // ENUM_DRAW_TYPE sDrawType = showShort ? DRAW_COLOR_HISTOGRAM : DRAW_NONE; // PlotIndexSetInteger(sPlotBufferIndex, PLOT_DRAW_TYPE, sDrawType); SetIndexBuffer(sBufferIndex, sBuffer, INDICATOR_DATA); - SetIndexBuffer(sColorBufferIndex, sColorBuffer, INDICATOR_COLOR_INDEX); PlotIndexSetInteger(sPlotBufferIndex, PLOT_SHOW_DATA, showShort); + SetIndexBuffer(sColorBufferIndex, sColorBuffer, INDICATOR_COLOR_INDEX); // // Medium ... @@ -590,8 +590,8 @@ void DefineBuffers() // ENUM_DRAW_TYPE mDrawType = showMedium ? DRAW_COLOR_HISTOGRAM : DRAW_NONE; // PlotIndexSetInteger(mPlotBufferIndex, PLOT_DRAW_TYPE, mDrawType); SetIndexBuffer(mBufferIndex, mBuffer, INDICATOR_DATA); - SetIndexBuffer(mColorBufferIndex, mColorBuffer, INDICATOR_COLOR_INDEX); PlotIndexSetInteger(mPlotBufferIndex, PLOT_SHOW_DATA, showMedium); + SetIndexBuffer(mColorBufferIndex, mColorBuffer, INDICATOR_COLOR_INDEX); // // Long ... @@ -600,18 +600,18 @@ void DefineBuffers() // ENUM_DRAW_TYPE lDrawType = showLong ? DRAW_COLOR_HISTOGRAM : DRAW_NONE; // PlotIndexSetInteger(lPlotBufferIndex, PLOT_DRAW_TYPE, lDrawType); SetIndexBuffer(lBufferIndex, lBuffer, INDICATOR_DATA); - SetIndexBuffer(lColorBufferIndex, lColorBuffer, INDICATOR_COLOR_INDEX); PlotIndexSetInteger(lPlotBufferIndex, PLOT_SHOW_DATA, showLong); + SetIndexBuffer(lColorBufferIndex, lColorBuffer, INDICATOR_COLOR_INDEX); // // Hind ... // - ENUM_DRAW_TYPE hDrawType = showHind ? DRAW_COLOR_HISTOGRAM : DRAW_NONE; + // ENUM_DRAW_TYPE hDrawType = showHind ? DRAW_COLOR_HISTOGRAM : DRAW_NONE; + // PlotIndexSetInteger(hPlotBufferIndex, PLOT_DRAW_TYPE, hDrawType); SetIndexBuffer(hBufferIndex, hBuffer, INDICATOR_DATA); - SetIndexBuffer(hColorBufferIndex, hColorBuffer, INDICATOR_COLOR_INDEX); - PlotIndexSetInteger(hPlotBufferIndex, PLOT_DRAW_TYPE, hDrawType); PlotIndexSetInteger(hPlotBufferIndex, PLOT_SHOW_DATA, showHind); + SetIndexBuffer(hColorBufferIndex, hColorBuffer, INDICATOR_COLOR_INDEX); } // diff --git a/Strategies/x-saherelm.xch.strategy.mq5 b/Strategies/x-saherelm.xch.strategy.mq5 index 64d25500..606069bb 100644 --- a/Strategies/x-saherelm.xch.strategy.mq5 +++ b/Strategies/x-saherelm.xch.strategy.mq5 @@ -1635,11 +1635,11 @@ private: chvlmInputs.hcPeriod = hcPeriod; // - chvlmInputs.showCurrent = false; - chvlmInputs.showShort = false; - chvlmInputs.showMedium = false; - chvlmInputs.showLong = false; - chvlmInputs.showHind = false; + chvlmInputs.showCurrent = true; + chvlmInputs.showShort = true; + chvlmInputs.showMedium = true; + chvlmInputs.showLong = true; + chvlmInputs.showHind = true; // chvlmHelper = new XSCXCHVLMHelper();