This commit is contained in:
2024-05-30 13:02:39 +03:30
parent 0aff395f39
commit ca5d23c43f
4 changed files with 111 additions and 63 deletions
+33 -23
View File
@@ -106,37 +106,29 @@ int OnCalculate(
int limit;
//
// Check Calculated Bars ...
// because in some cases we may have more than one input for
// calculation and we must prevent any calculation
// untill we pass the biggest input length, here we get max Input length
// and then wait until pass it ...
int maxLength = mMid.GetInputs().Max();
//
int midCalculatedBars = mMid.GetCalculatedBars();
if (prev_calculated > 0 && midCalculatedBars != prev_calculated)
if (midCalculatedBars < maxLength)
{
return prev_calculated;
}
//
// Calculating Limit ...
limit = (prev_calculated > rates_total || prev_calculated <= 0) ? rates_total : (rates_total - prev_calculated) + 1;
limit = prev_calculated < maxLength ? rates_total - (maxLength + 1) : rates_total - prev_calculated;
//
//
// Print("Limit: ", limit);
// mMid.Calculate();
//
int midMainBufferCopied = mMid.CopyBuffer(
"XSCMid",
mainBuffer,
0,
limit //
);
// if (!IsValidSize(midMainBufferCopied))
// {
// return prev_calculated;
// }
//
// ChartRedraw();
// Main Loop ...
for (int i = limit; i >= 0 && !IsStopped(); i--)
{
//
CalculateBuffers(i);
}
//
return rates_total;
@@ -228,3 +220,21 @@ void SetIndicatorName()
{
IndicatorSetString(INDICATOR_SHORTNAME, ShortName);
}
//
void CalculateBuffers(int barIndex)
{
//
// double iValue = mMid.GetBufferValue(
// "XSCMid",
// barIndex //
// );
//
double iValue = iClose(
_Symbol,
_Period,
barIndex //
);
mainBuffer[barIndex] = iValue;
}