From 0aff395f394fd9a192de5cb1f783af8be2840a10 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Thu, 30 May 2024 12:32:21 +0330 Subject: [PATCH] last ... --- Classes/Indicators/x-saherelm.mid.class.mq5 | 75 +++++++++++++-------- Classes/x-saherelm.x121.xea.class.mq5 | 2 + Classes/x-saherelm.xind.class.mq5 | 25 +++++-- Indicators/x-saherelm.xmidtest.mq5 | 12 ++-- 4 files changed, 75 insertions(+), 39 deletions(-) diff --git a/Classes/Indicators/x-saherelm.mid.class.mq5 b/Classes/Indicators/x-saherelm.mid.class.mq5 index 28c98075..2efdf611 100644 --- a/Classes/Indicators/x-saherelm.mid.class.mq5 +++ b/Classes/Indicators/x-saherelm.mid.class.mq5 @@ -286,27 +286,26 @@ public: // int start = 0; - // - if (prevCalculated == 0) - { - // - if (max > 0) - { - for (int i = 0; i < max; i++) - { - // - for (int j = 0; j < CountBuffers(); j++) - { - mBuffers[j].Add(0); - } - } - } - } + // // + // if (prevCalculated == 0) + // { + // // + // if (max > 0) + // { + // for (int i = 0; i < max; i++) + // { + // // + // for (int j = 0; j < CountBuffers(); j++) + // { + // mBuffers[j].Add(0); + // } + // } + // } + // } // // Loop through Bars ... - for (int i = totalBars - 1; i >= start && !IsStopped(); i--) - { + for (int i = start; i< totalBars; i++) { // XOHCL iBar; iBar.Init( @@ -319,18 +318,40 @@ public: double iValue = iBar.close; // - // Print("BarIndex: " + ToString(i), ", iValue: ", iValue); - - // - if (i > ArraySize(mBuffers[mainIDX].values) - 1) - { - ArrayResize(mBuffers[mainIDX].values, i + 1); + int count = mBuffers[mainIDX].Count(); + if (count > 0 && i == count - 1) { + mBuffers[mainIDX].Set(i, iValue); + } else { + mBuffers[mainIDX].Add(iValue); } - - // - mBuffers[mainIDX].values[i] = iValue; } + // for (int i = totalBars - 1; i >= start && !IsStopped(); i--) + // { + // // + // XOHCL iBar; + // iBar.Init( + // mSymbol, + // mPeriod, + // i // + // ); + + // // + // double iValue = iBar.close; + + // // + // // Print("BarIndex: " + ToString(i), ", iValue: ", iValue); + + // // + // if (i > ArraySize(mBuffers[mainIDX].values) - 1) + // { + // ArrayResize(mBuffers[mainIDX].values, i + 1); + // } + + // // + // mBuffers[mainIDX].values[i] = iValue; + // } + // // Prevent Double Calculation Same Bars ... mCalculatedBars = totalBars; diff --git a/Classes/x-saherelm.x121.xea.class.mq5 b/Classes/x-saherelm.x121.xea.class.mq5 index 618e05d9..36e08b4b 100644 --- a/Classes/x-saherelm.x121.xea.class.mq5 +++ b/Classes/x-saherelm.x121.xea.class.mq5 @@ -784,6 +784,8 @@ public: // void HandleTrailManagement(XPosition &positions[]) { + // + return; // // TODO: // Make them Configurable ... diff --git a/Classes/x-saherelm.xind.class.mq5 b/Classes/x-saherelm.xind.class.mq5 index a0d877d6..096ce791 100644 --- a/Classes/x-saherelm.xind.class.mq5 +++ b/Classes/x-saherelm.xind.class.mq5 @@ -70,6 +70,7 @@ struct XBuffer // title = mTitle; + // ArraySetAsSeries(values, false); // result = IsValid(); @@ -174,6 +175,19 @@ struct XBuffer return result; } + // + void Set( + int index, + double value // + ) + { + // + NormalizeIndex(index, values); + + // + values[index] = value; + } + // // Get Specified Index Value ... double Get( @@ -562,6 +576,10 @@ public: // Calculate(); + // + bool asSeries = ArrayGetAsSeries(buffer); + ArraySetAsSeries(buffer, false); + // result = ArrayCopy( buffer, @@ -572,12 +590,7 @@ public: ); // - // for (int i = start; i < start + count - 1; i++) - // { - // // - // result++; - // buffer[i] = mBuffers[bufferIDX].values[i]; - // } + ArraySetAsSeries(buffer, asSeries); // return result; diff --git a/Indicators/x-saherelm.xmidtest.mq5 b/Indicators/x-saherelm.xmidtest.mq5 index 84a1099a..204374cf 100644 --- a/Indicators/x-saherelm.xmidtest.mq5 +++ b/Indicators/x-saherelm.xmidtest.mq5 @@ -120,7 +120,7 @@ int OnCalculate( // // - Print("Limit: ", limit); + // Print("Limit: ", limit); // mMid.Calculate(); // @@ -130,10 +130,10 @@ int OnCalculate( 0, limit // ); - if (!IsValidSize(midMainBufferCopied)) - { - return prev_calculated; - } + // if (!IsValidSize(midMainBufferCopied)) + // { + // return prev_calculated; + // } // // ChartRedraw(); @@ -202,7 +202,7 @@ void DefineBuffers() // // mainBufferStruct.asSeries - // ArraySetAsSeries(mainBuffer, mainBufferStruct.asSeries); + // ArraySetAsSeries(mainBuffer, false); // XBufferPlotStyle mainBufferStyle;