l
This commit is contained in:
@@ -305,23 +305,28 @@ public:
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Loop through Bars ...
|
// Loop through Bars ...
|
||||||
for (int i = start; i< totalBars; i++) {
|
for (int i = start; i < limit && !IsStopped(); i++)
|
||||||
|
{
|
||||||
//
|
//
|
||||||
XOHCL iBar;
|
// XOHCL iBar;
|
||||||
iBar.Init(
|
// iBar.Init(
|
||||||
mSymbol,
|
// mSymbol,
|
||||||
mPeriod,
|
// mPeriod,
|
||||||
i //
|
// i //
|
||||||
);
|
// );
|
||||||
|
|
||||||
//
|
//
|
||||||
double iValue = iBar.close;
|
double iValue = iClose(mSymbol, mPeriod, i);
|
||||||
|
// Print("BarIndex: " + ToString(i), ", iValue: ", iValue);
|
||||||
|
|
||||||
//
|
//
|
||||||
int count = mBuffers[mainIDX].Count();
|
int count = mBuffers[mainIDX].Count();
|
||||||
if (count > 0 && i == count - 1) {
|
if (count > 0 && i == count - 1)
|
||||||
|
{
|
||||||
mBuffers[mainIDX].Set(i, iValue);
|
mBuffers[mainIDX].Set(i, iValue);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
mBuffers[mainIDX].Add(iValue);
|
mBuffers[mainIDX].Add(iValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3143,13 +3143,13 @@ public:
|
|||||||
if (isPrepared)
|
if (isPrepared)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
mSignal = sSignal;
|
// mSignal = sSignal;
|
||||||
|
|
||||||
// //
|
//
|
||||||
// AddRef(
|
AddRef(
|
||||||
// sSignal,
|
sSignal,
|
||||||
// mSignal.supports //
|
mSignal.supports //
|
||||||
// );
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -546,15 +546,13 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
int CopyBuffer(
|
double GetBufferValue(
|
||||||
string mTitle, // Required Buffer Title
|
string mTitle, // Required Buffer Title
|
||||||
double &buffer[], // Buffer Dest
|
int index // Bar Index
|
||||||
int start = 0, // Start
|
|
||||||
int count = 0 // Count, if 0 Whole
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
int result = 0;
|
double result = EMPTY_VALUE;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Validate State ...
|
// Validate State ...
|
||||||
@@ -563,9 +561,6 @@ public:
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Clean(buffer);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
int bufferIDX = GetBufferIndex(mTitle);
|
int bufferIDX = GetBufferIndex(mTitle);
|
||||||
if (bufferIDX < 0)
|
if (bufferIDX < 0)
|
||||||
@@ -577,25 +572,63 @@ public:
|
|||||||
Calculate();
|
Calculate();
|
||||||
|
|
||||||
//
|
//
|
||||||
bool asSeries = ArrayGetAsSeries(buffer);
|
result = mBuffers[bufferIDX].Get(index);
|
||||||
ArraySetAsSeries(buffer, false);
|
|
||||||
|
|
||||||
//
|
|
||||||
result = ArrayCopy(
|
|
||||||
buffer,
|
|
||||||
mBuffers[bufferIDX].values,
|
|
||||||
start,
|
|
||||||
start,
|
|
||||||
count //
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
ArraySetAsSeries(buffer, asSeries);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
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 ...
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -106,37 +106,29 @@ int OnCalculate(
|
|||||||
int limit;
|
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();
|
int midCalculatedBars = mMid.GetCalculatedBars();
|
||||||
if (prev_calculated > 0 && midCalculatedBars != prev_calculated)
|
if (midCalculatedBars < maxLength)
|
||||||
{
|
{
|
||||||
return prev_calculated;
|
return prev_calculated;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Calculating Limit ...
|
limit = prev_calculated < maxLength ? rates_total - (maxLength + 1) : rates_total - prev_calculated;
|
||||||
limit = (prev_calculated > rates_total || prev_calculated <= 0) ? rates_total : (rates_total - prev_calculated) + 1;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
|
// Main Loop ...
|
||||||
//
|
for (int i = limit; i >= 0 && !IsStopped(); i--)
|
||||||
// Print("Limit: ", limit);
|
{
|
||||||
// mMid.Calculate();
|
//
|
||||||
|
CalculateBuffers(i);
|
||||||
//
|
}
|
||||||
int midMainBufferCopied = mMid.CopyBuffer(
|
|
||||||
"XSCMid",
|
|
||||||
mainBuffer,
|
|
||||||
0,
|
|
||||||
limit //
|
|
||||||
);
|
|
||||||
// if (!IsValidSize(midMainBufferCopied))
|
|
||||||
// {
|
|
||||||
// return prev_calculated;
|
|
||||||
// }
|
|
||||||
|
|
||||||
//
|
|
||||||
// ChartRedraw();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
return rates_total;
|
return rates_total;
|
||||||
@@ -228,3 +220,21 @@ void SetIndicatorName()
|
|||||||
{
|
{
|
||||||
IndicatorSetString(INDICATOR_SHORTNAME, ShortName);
|
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