l
This commit is contained in:
@@ -305,23 +305,28 @@ public:
|
||||
|
||||
//
|
||||
// Loop through Bars ...
|
||||
for (int i = start; i< totalBars; i++) {
|
||||
for (int i = start; i < limit && !IsStopped(); i++)
|
||||
{
|
||||
//
|
||||
XOHCL iBar;
|
||||
iBar.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
i //
|
||||
);
|
||||
// XOHCL iBar;
|
||||
// iBar.Init(
|
||||
// mSymbol,
|
||||
// mPeriod,
|
||||
// i //
|
||||
// );
|
||||
|
||||
//
|
||||
double iValue = iBar.close;
|
||||
double iValue = iClose(mSymbol, mPeriod, i);
|
||||
// Print("BarIndex: " + ToString(i), ", iValue: ", iValue);
|
||||
|
||||
//
|
||||
int count = mBuffers[mainIDX].Count();
|
||||
if (count > 0 && i == count - 1) {
|
||||
if (count > 0 && i == count - 1)
|
||||
{
|
||||
mBuffers[mainIDX].Set(i, iValue);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
mBuffers[mainIDX].Add(iValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3143,13 +3143,13 @@ public:
|
||||
if (isPrepared)
|
||||
{
|
||||
//
|
||||
mSignal = sSignal;
|
||||
// mSignal = sSignal;
|
||||
|
||||
// //
|
||||
// AddRef(
|
||||
// sSignal,
|
||||
// mSignal.supports //
|
||||
// );
|
||||
//
|
||||
AddRef(
|
||||
sSignal,
|
||||
mSignal.supports //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -546,15 +546,13 @@ public:
|
||||
}
|
||||
|
||||
//
|
||||
int CopyBuffer(
|
||||
string mTitle, // Required Buffer Title
|
||||
double &buffer[], // Buffer Dest
|
||||
int start = 0, // Start
|
||||
int count = 0 // Count, if 0 Whole
|
||||
double GetBufferValue(
|
||||
string mTitle, // Required Buffer Title
|
||||
int index // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
double result = EMPTY_VALUE;
|
||||
|
||||
//
|
||||
// Validate State ...
|
||||
@@ -563,9 +561,6 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Clean(buffer);
|
||||
|
||||
//
|
||||
int bufferIDX = GetBufferIndex(mTitle);
|
||||
if (bufferIDX < 0)
|
||||
@@ -577,25 +572,63 @@ public:
|
||||
Calculate();
|
||||
|
||||
//
|
||||
bool asSeries = ArrayGetAsSeries(buffer);
|
||||
ArraySetAsSeries(buffer, false);
|
||||
|
||||
//
|
||||
result = ArrayCopy(
|
||||
buffer,
|
||||
mBuffers[bufferIDX].values,
|
||||
start,
|
||||
start,
|
||||
count //
|
||||
);
|
||||
|
||||
//
|
||||
ArraySetAsSeries(buffer, asSeries);
|
||||
result = mBuffers[bufferIDX].Get(index);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// int CopyBuffer(
|
||||
// string mTitle, // Required Buffer Title
|
||||
// double &buffer[], // Buffer Dest
|
||||
// int start = 0, // Start
|
||||
// int count = 0 // Count, if 0 Whole
|
||||
// )
|
||||
// {
|
||||
// //
|
||||
// int result = 0;
|
||||
|
||||
// //
|
||||
// // Validate State ...
|
||||
// if (!IsValid())
|
||||
// {
|
||||
// return result;
|
||||
// }
|
||||
|
||||
// //
|
||||
// // Clean(buffer);
|
||||
|
||||
// //
|
||||
// int bufferIDX = GetBufferIndex(mTitle);
|
||||
// if (bufferIDX < 0)
|
||||
// {
|
||||
// return result;
|
||||
// }
|
||||
|
||||
// //
|
||||
// Calculate();
|
||||
|
||||
// //
|
||||
// bool asSeries = ArrayGetAsSeries(buffer);
|
||||
// ArraySetAsSeries(buffer, false);
|
||||
|
||||
// //
|
||||
// result = ArrayCopy(
|
||||
// buffer,
|
||||
// mBuffers[bufferIDX].values,
|
||||
// start,
|
||||
// start,
|
||||
// count //
|
||||
// );
|
||||
|
||||
// //
|
||||
// ArraySetAsSeries(buffer, asSeries);
|
||||
|
||||
// //
|
||||
// return result;
|
||||
// }
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user