last ...
This commit is contained in:
@@ -391,7 +391,7 @@ void DefineBuffers()
|
|||||||
PlotIndexSetInteger(peakBufferPlotIndex, PLOT_DRAW_TYPE, pvDrawType);
|
PlotIndexSetInteger(peakBufferPlotIndex, PLOT_DRAW_TYPE, pvDrawType);
|
||||||
|
|
||||||
//
|
//
|
||||||
PlotIndexSetDouble(peakBufferPlotIndex, PLOT_EMPTY_VALUE, emptyValue);
|
PlotIndexSetDouble(peakBufferPlotIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
|
||||||
PlotIndexSetInteger(peakBufferPlotIndex, PLOT_ARROW, peakArrowCode);
|
PlotIndexSetInteger(peakBufferPlotIndex, PLOT_ARROW, peakArrowCode);
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -406,7 +406,7 @@ void DefineBuffers()
|
|||||||
PlotIndexSetInteger(valeBufferPlotIndex, PLOT_DRAW_TYPE, pvDrawType);
|
PlotIndexSetInteger(valeBufferPlotIndex, PLOT_DRAW_TYPE, pvDrawType);
|
||||||
|
|
||||||
//
|
//
|
||||||
PlotIndexSetDouble(valeBufferPlotIndex, PLOT_EMPTY_VALUE, emptyValue);
|
PlotIndexSetDouble(valeBufferPlotIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
|
||||||
PlotIndexSetInteger(valeBufferPlotIndex, PLOT_ARROW, valeArrowCode);
|
PlotIndexSetInteger(valeBufferPlotIndex, PLOT_ARROW, valeArrowCode);
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -427,7 +427,7 @@ void DefineBuffers()
|
|||||||
PlotIndexSetInteger(highBufferPlotIndex, PLOT_DRAW_TYPE, hlDrawType);
|
PlotIndexSetInteger(highBufferPlotIndex, PLOT_DRAW_TYPE, hlDrawType);
|
||||||
|
|
||||||
//
|
//
|
||||||
PlotIndexSetDouble(highBufferPlotIndex, PLOT_EMPTY_VALUE, emptyValue);
|
PlotIndexSetDouble(highBufferPlotIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
|
||||||
PlotIndexSetInteger(highBufferPlotIndex, PLOT_ARROW, highArrowCode);
|
PlotIndexSetInteger(highBufferPlotIndex, PLOT_ARROW, highArrowCode);
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -442,7 +442,7 @@ void DefineBuffers()
|
|||||||
PlotIndexSetInteger(lowBufferPlotIndex, PLOT_DRAW_TYPE, hlDrawType);
|
PlotIndexSetInteger(lowBufferPlotIndex, PLOT_DRAW_TYPE, hlDrawType);
|
||||||
|
|
||||||
//
|
//
|
||||||
PlotIndexSetDouble(lowBufferPlotIndex, PLOT_EMPTY_VALUE, emptyValue);
|
PlotIndexSetDouble(lowBufferPlotIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
|
||||||
PlotIndexSetInteger(lowBufferPlotIndex, PLOT_ARROW, lowArrowCode);
|
PlotIndexSetInteger(lowBufferPlotIndex, PLOT_ARROW, lowArrowCode);
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -450,11 +450,11 @@ void DefineBuffers()
|
|||||||
|
|
||||||
//
|
//
|
||||||
ArraySetAsSeries(lowRawBuffer, true);
|
ArraySetAsSeries(lowRawBuffer, true);
|
||||||
SetIndexBuffer(lowRawBufferIndex, lowRawBuffer, INDICATOR_DATA);
|
SetIndexBuffer(lowRawBufferIndex, lowRawBuffer, INDICATOR_CALCULATIONS);
|
||||||
|
|
||||||
//
|
//
|
||||||
ArraySetAsSeries(highRawBuffer, true);
|
ArraySetAsSeries(highRawBuffer, true);
|
||||||
SetIndexBuffer(highRawBufferIndex, highRawBuffer, INDICATOR_DATA);
|
SetIndexBuffer(highRawBufferIndex, highRawBuffer, INDICATOR_CALCULATIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -582,6 +582,9 @@ void CalculateValues(
|
|||||||
//
|
//
|
||||||
// Common Requirements ...
|
// Common Requirements ...
|
||||||
|
|
||||||
|
//
|
||||||
|
FillBuffersZero(barIndex);
|
||||||
|
|
||||||
//
|
//
|
||||||
int lastBarIndex = barIndex + 1;
|
int lastBarIndex = barIndex + 1;
|
||||||
int maxBarIndex = startCalculationForLastBars > 0
|
int maxBarIndex = startCalculationForLastBars > 0
|
||||||
@@ -596,95 +599,167 @@ void CalculateValues(
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Calculate Highs and Lows ...
|
// Calculate Highs and Lows ...
|
||||||
double iLow = IsLow(barIndex);
|
|
||||||
double iHigh = IsHigh(barIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Calculator Functions ...
|
|
||||||
|
|
||||||
bool IsLow(
|
|
||||||
double &value,
|
|
||||||
int barIndex //
|
|
||||||
) {
|
|
||||||
//
|
|
||||||
bool result = false;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Prepare ...
|
|
||||||
value = emptyValue;
|
|
||||||
|
|
||||||
//
|
|
||||||
XOHCL iBar;
|
XOHCL iBar;
|
||||||
result = iBar.Init(
|
bool has = iBar.Init(
|
||||||
_Symbol,
|
_Symbol,
|
||||||
_Period,
|
_Period,
|
||||||
barIndex //
|
barIndex //
|
||||||
);
|
);
|
||||||
if (!result) {
|
if (!has)
|
||||||
//
|
{
|
||||||
iBar.Clean();
|
return;
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
value = iBar.FindXLowest(pvValidationLength, peakPriceType);
|
int lowestIDX = -1;
|
||||||
result = value >= iBar.low;
|
double iRawLow = iBar.FindLowest(
|
||||||
if (!result) {
|
lowestIDX,
|
||||||
//
|
pvValidationLength,
|
||||||
iBar.Clean();
|
valePriceType //
|
||||||
value = emptyValue;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Cleanup Resources ...
|
|
||||||
iBar.Clean();
|
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsHigh(
|
|
||||||
double &value,
|
|
||||||
int barIndex //
|
|
||||||
) {
|
|
||||||
//
|
|
||||||
bool result = false;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Prepare ...
|
|
||||||
value = emptyValue;
|
|
||||||
|
|
||||||
//
|
|
||||||
XOHCL iBar;
|
|
||||||
result = iBar.Init(
|
|
||||||
_Symbol,
|
|
||||||
_Period,
|
|
||||||
barIndex //
|
|
||||||
);
|
);
|
||||||
if (!result) {
|
|
||||||
//
|
|
||||||
iBar.Clean();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
value = iBar.FindXHighest(pvValidationLength, valePriceType);
|
int highestIDX = -1;
|
||||||
result = value <= iBar.high;
|
double iRawHigh = iBar.FindHighest(
|
||||||
if (!result) {
|
highestIDX,
|
||||||
|
pvValidationLength,
|
||||||
|
peakPriceType //
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
iBar.Clean();
|
lowRawBuffer[barIndex] = iRawLow;
|
||||||
value = emptyValue;
|
highRawBuffer[barIndex] = iRawHigh;
|
||||||
return result;
|
|
||||||
}
|
//
|
||||||
|
lowBuffer[barIndex] = iRawLow;
|
||||||
|
highBuffer[barIndex] = iRawHigh;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (barIndex < firstBarIndex - (pvValidationLength + 1))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double tmp[];
|
||||||
|
ArrayCopy(
|
||||||
|
tmp,
|
||||||
|
lowRawBuffer,
|
||||||
|
0,
|
||||||
|
barIndex,
|
||||||
|
pvValidationLength //
|
||||||
|
);
|
||||||
|
double minLow = GetMin(tmp);
|
||||||
|
bool isLow = iRawLow < minLow;
|
||||||
|
lowBuffer[barIndex] =
|
||||||
|
isLow
|
||||||
|
? iRawLow
|
||||||
|
: lowBuffer[lastBarIndex];
|
||||||
|
|
||||||
|
//
|
||||||
|
XClean(tmp);
|
||||||
|
ArrayCopy(
|
||||||
|
tmp,
|
||||||
|
highRawBuffer,
|
||||||
|
0,
|
||||||
|
barIndex,
|
||||||
|
pvValidationLength //
|
||||||
|
);
|
||||||
|
double maxHigh = GetMax(tmp);
|
||||||
|
bool isHigh = iRawHigh > maxHigh;
|
||||||
|
highBuffer[barIndex] =
|
||||||
|
isHigh
|
||||||
|
? iRawHigh
|
||||||
|
: highBuffer[lastBarIndex];
|
||||||
|
|
||||||
//
|
//
|
||||||
// Cleanup Resources ...
|
// Cleanup Resources ...
|
||||||
iBar.Clean();
|
XClean(tmp);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
// //
|
||||||
return result;
|
// double iLow = emptyValue;
|
||||||
|
// // IsLow(iLow, barIndex);
|
||||||
|
// double iPLow = isFirstBar
|
||||||
|
// ? iLow
|
||||||
|
// : lowRawBuffer[lastBarIndex];
|
||||||
|
|
||||||
|
// //
|
||||||
|
// double iHigh = emptyValue;
|
||||||
|
// IsHigh(iHigh, barIndex);
|
||||||
|
// double iPHigh = isFirstBar
|
||||||
|
// ? iHigh
|
||||||
|
// : highRawBuffer[lastBarIndex];
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Clculate Values ...
|
||||||
|
|
||||||
|
// //
|
||||||
|
// lowRawBuffer[barIndex] = iLow;
|
||||||
|
// highRawBuffer[barIndex] = iHigh;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// lowBuffer[barIndex] = NotEmptyZero(iLow)
|
||||||
|
// ? iLow
|
||||||
|
// : iPLow;
|
||||||
|
// highBuffer[barIndex] = NotEmptyZero(iHigh)
|
||||||
|
// ? iHigh
|
||||||
|
// : iPHigh;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// double iP2Low =
|
||||||
|
// barIndex < maxBarIndex - 2
|
||||||
|
// ? lowBuffer[barIndex + 2]
|
||||||
|
// : emptyValue;
|
||||||
|
// double iP2High =
|
||||||
|
// barIndex < maxBarIndex - 2
|
||||||
|
// ? highBuffer[barIndex + 2]
|
||||||
|
// : emptyValue;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// double mLowValues[];
|
||||||
|
// double iVale = emptyValue;
|
||||||
|
// if (NotEmptyZero(iPLow))
|
||||||
|
// {
|
||||||
|
// Add(iPLow, mLowValues);
|
||||||
|
// }
|
||||||
|
// if (NotEmptyZero(iP2Low))
|
||||||
|
// {
|
||||||
|
// Add(iP2Low, mLowValues);
|
||||||
|
// }
|
||||||
|
// bool isVale = iLow <= GetMin(mLowValues);
|
||||||
|
// iVale = isVale
|
||||||
|
// ? iLow
|
||||||
|
// : isFirstBar
|
||||||
|
// ? emptyValue
|
||||||
|
// : valeBuffer[lastBarIndex];
|
||||||
|
// valeBuffer[barIndex] = iVale;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// double mHighValues[];
|
||||||
|
// double iPeak = emptyValue;
|
||||||
|
// if (NotEmptyZero(iPHigh))
|
||||||
|
// {
|
||||||
|
// Add(iPHigh, mHighValues);
|
||||||
|
// }
|
||||||
|
// if (NotEmptyZero(iP2High))
|
||||||
|
// {
|
||||||
|
// Add(iP2High, mHighValues);
|
||||||
|
// }
|
||||||
|
// bool isPeak = iHigh >= GetMax(mHighValues);
|
||||||
|
// iPeak = isPeak
|
||||||
|
// ? iHigh
|
||||||
|
// : isFirstBar
|
||||||
|
// ? emptyValue
|
||||||
|
// : peakBuffer[lastBarIndex];
|
||||||
|
// peakBuffer[barIndex] = iPeak;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// bool has =
|
||||||
|
// NotEmptyZero(iLow) ||
|
||||||
|
// NotEmptyZero(iPLow) ||
|
||||||
|
// NotEmptyZero(iHigh) ||
|
||||||
|
// NotEmptyZero(iPHigh);
|
||||||
|
// if (has)
|
||||||
|
// {
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -1214,6 +1214,81 @@ struct XOHCL
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detect Highest of Specified Price type in Market ...
|
||||||
|
*
|
||||||
|
* @param index: souble, reference to hold detected Value Bar index ...
|
||||||
|
* @param mLength: int, Specified Loopback Length ...
|
||||||
|
* @param mPriceType: ENUM_X_PRICE, Specified Price type to Detect ...
|
||||||
|
*
|
||||||
|
* @return ( double )
|
||||||
|
*/
|
||||||
|
double FindHighest(
|
||||||
|
int &index, // Index ...
|
||||||
|
int mLength, // Loopback ...
|
||||||
|
ENUM_X_PRICE mPriceType // Price Type ...
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double result = EMPTY_VALUE;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare ...
|
||||||
|
index = -1;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Normalize ...
|
||||||
|
mLength = NormalizeInt(mLength, 1);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
bool has = IsValid() &&
|
||||||
|
IsXValid(mPriceType);
|
||||||
|
if (!has)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL iBar;
|
||||||
|
int start = Index();
|
||||||
|
int end = start + mLength;
|
||||||
|
double iValue = EMPTY_VALUE;
|
||||||
|
for (int i = start; i < end; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
iBar.Clean();
|
||||||
|
has = BarAt(i, iBar);
|
||||||
|
if (!has)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Calculate Price ...
|
||||||
|
iValue = iBar.GetPrice(mPriceType);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Compare Price With Prev Detected ...
|
||||||
|
has = !NotEmptyZero(result)
|
||||||
|
? true
|
||||||
|
: iValue > result;
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
index = i;
|
||||||
|
result = iValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cleanup Resources ...
|
||||||
|
iBar.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Find Highest ...
|
// Find Highest ...
|
||||||
double FindHighestUp(
|
double FindHighestUp(
|
||||||
@@ -1316,6 +1391,81 @@ struct XOHCL
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detect Lowest of Specified Price type in Market ...
|
||||||
|
*
|
||||||
|
* @param index: souble, reference to hold detected Value Bar index ...
|
||||||
|
* @param mLength: int, Specified Loopback Length ...
|
||||||
|
* @param mPriceType: ENUM_X_PRICE, Specified Price type to Detect ...
|
||||||
|
*
|
||||||
|
* @return ( double )
|
||||||
|
*/
|
||||||
|
double FindLowest(
|
||||||
|
int &index, // Index ...
|
||||||
|
int mLength, // Loopback ...
|
||||||
|
ENUM_X_PRICE mPriceType // Price Type ...
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double result = EMPTY_VALUE;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare ...
|
||||||
|
index = -1;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Normalize ...
|
||||||
|
mLength = NormalizeInt(mLength, 1);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
bool has = IsValid() &&
|
||||||
|
IsXValid(mPriceType);
|
||||||
|
if (!has)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL iBar;
|
||||||
|
int start = Index();
|
||||||
|
int end = start + mLength;
|
||||||
|
double iValue = EMPTY_VALUE;
|
||||||
|
for (int i = start; i < end; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
iBar.Clean();
|
||||||
|
has = BarAt(i, iBar);
|
||||||
|
if (!has)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Calculate Price ...
|
||||||
|
iValue = iBar.GetPrice(mPriceType);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Compare Price With Prev Detected ...
|
||||||
|
has = !NotEmptyZero(result)
|
||||||
|
? true
|
||||||
|
: iValue < result;
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
index = i;
|
||||||
|
result = iValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cleanup Resources ...
|
||||||
|
iBar.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Find Lowest ...
|
// Find Lowest ...
|
||||||
double FindLowesttDown(
|
double FindLowesttDown(
|
||||||
|
|||||||
+2
-1
@@ -13,7 +13,8 @@
|
|||||||
"C_Cpp.clang_format_style": "{ BasedOnStyle: Microsoft, UseTab: Never, IndentWidth: 4, TabWidth: 4, ColumnLimit: 0}",
|
"C_Cpp.clang_format_style": "{ BasedOnStyle: Microsoft, UseTab: Never, IndentWidth: 4, TabWidth: 4, ColumnLimit: 0}",
|
||||||
"files.associations": {
|
"files.associations": {
|
||||||
"*.mq5": "cpp",
|
"*.mq5": "cpp",
|
||||||
"*.mqh": "cpp"
|
"*.mqh": "cpp",
|
||||||
|
"*.ex5": "cpp"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user