last works on XFima Strategy 2 Signalling ...
This commit is contained in:
@@ -2650,6 +2650,430 @@ class XCXFIMAHelper : public XCBaseHelper
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Has Higher Low Based On ZigZag ...
|
||||
*
|
||||
* @param barIndex: int, Specified Bar Index ...
|
||||
* @param forceBarValidation: bool, Force Bar Price based on Pivot ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool HasZigZagHigherLow(
|
||||
int barIndex = 0,
|
||||
bool forceBarValidation = false //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
XOHCL bar;
|
||||
result = IsValid() &&
|
||||
bar.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
barIndex //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
bar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Extract Pivots ...
|
||||
XPivot pivots[];
|
||||
int count = ExtractZigZagPivots(
|
||||
pivots,
|
||||
barIndex,
|
||||
10,
|
||||
200 //
|
||||
);
|
||||
|
||||
//
|
||||
// Validate Pivots and Nearest Pivot is Low ...
|
||||
result = IsValidSize(count) &&
|
||||
pivots[0].IsVale();
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
bar.Clean();
|
||||
XClean(pivots);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Extract Directional Pivots ...
|
||||
XPivot vales[];
|
||||
count = ExtractPivots(
|
||||
vales,
|
||||
pivots,
|
||||
X_PIVOT_TYPE_VALE //
|
||||
);
|
||||
result = IsValidSize(count) &&
|
||||
count >= 2;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
bar.Clean();
|
||||
XClean(vales);
|
||||
XClean(pivots);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Result ...
|
||||
result =
|
||||
vales[0].value > vales[1].value;
|
||||
if (forceBarValidation)
|
||||
{
|
||||
//
|
||||
result =
|
||||
result &&
|
||||
bar.open > vales[0].value &&
|
||||
bar.close > vales[0].value;
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup ...
|
||||
bar.Clean();
|
||||
XClean(vales);
|
||||
XClean(pivots);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Has Lower Low Based On ZigZag ...
|
||||
*
|
||||
* @param barIndex: int, Specified Bar Index ...
|
||||
* @param forceBarValidation: bool, Force Bar Price based on Pivot ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool HasZigZagLowerLow(
|
||||
int barIndex = 0,
|
||||
bool forceBarValidation = false //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
XOHCL bar;
|
||||
result = IsValid() &&
|
||||
bar.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
barIndex //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
bar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Extract Pivots ...
|
||||
XPivot pivots[];
|
||||
int count = ExtractZigZagPivots(
|
||||
pivots,
|
||||
barIndex,
|
||||
10,
|
||||
200 //
|
||||
);
|
||||
|
||||
//
|
||||
// Validate Pivots and Nearest Pivot is Low ...
|
||||
result = IsValidSize(count) &&
|
||||
pivots[0].IsVale();
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
bar.Clean();
|
||||
XClean(pivots);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Extract Directional Pivots ...
|
||||
XPivot vales[];
|
||||
count = ExtractPivots(
|
||||
vales,
|
||||
pivots,
|
||||
X_PIVOT_TYPE_VALE //
|
||||
);
|
||||
result = IsValidSize(count) &&
|
||||
count >= 2;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
bar.Clean();
|
||||
XClean(vales);
|
||||
XClean(pivots);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Result ...
|
||||
result =
|
||||
vales[0].value < vales[1].value;
|
||||
if (forceBarValidation)
|
||||
{
|
||||
//
|
||||
result =
|
||||
result &&
|
||||
bar.open < vales[0].value &&
|
||||
bar.close < vales[0].value;
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup ...
|
||||
bar.Clean();
|
||||
XClean(vales);
|
||||
XClean(pivots);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Has Higher High Based On ZigZag ...
|
||||
*
|
||||
* @param barIndex: int, Specified Bar Index ...
|
||||
* @param forceBarValidation: bool, Force Bar Price based on Pivot ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool HasZigZagHigherHigh(
|
||||
int barIndex = 0,
|
||||
bool forceBarValidation = false //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
XOHCL bar;
|
||||
result = IsValid() &&
|
||||
bar.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
barIndex //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
bar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Extract Pivots ...
|
||||
XPivot pivots[];
|
||||
int count = ExtractZigZagPivots(
|
||||
pivots,
|
||||
barIndex,
|
||||
10,
|
||||
200 //
|
||||
);
|
||||
|
||||
//
|
||||
// Validate Pivots and Nearest Pivot is Low ...
|
||||
result = IsValidSize(count) &&
|
||||
pivots[0].IsPeak();
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
bar.Clean();
|
||||
XClean(pivots);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Extract Directional Pivots ...
|
||||
XPivot peaks[];
|
||||
count = ExtractPivots(
|
||||
peaks,
|
||||
pivots,
|
||||
X_PIVOT_TYPE_PEAK //
|
||||
);
|
||||
result = IsValidSize(count) &&
|
||||
count >= 2;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
bar.Clean();
|
||||
XClean(peaks);
|
||||
XClean(pivots);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Result ...
|
||||
result =
|
||||
peaks[0].value > peaks[1].value;
|
||||
if (forceBarValidation)
|
||||
{
|
||||
//
|
||||
result =
|
||||
result &&
|
||||
bar.open > peaks[0].value &&
|
||||
bar.close > peaks[0].value;
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup ...
|
||||
bar.Clean();
|
||||
XClean(peaks);
|
||||
XClean(pivots);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Has Lower High Based On ZigZag ...
|
||||
*
|
||||
* @param barIndex: int, Specified Bar Index ...
|
||||
* @param forceBarValidation: bool, Force Bar Price based on Pivot ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool HasZigZagLowerHigh(
|
||||
int barIndex = 0,
|
||||
bool forceBarValidation = false //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
XOHCL bar;
|
||||
result = IsValid() &&
|
||||
bar.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
barIndex //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
bar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Extract Pivots ...
|
||||
XPivot pivots[];
|
||||
int count = ExtractZigZagPivots(
|
||||
pivots,
|
||||
barIndex,
|
||||
10,
|
||||
200 //
|
||||
);
|
||||
|
||||
//
|
||||
// Validate Pivots and Nearest Pivot is Low ...
|
||||
result = IsValidSize(count) &&
|
||||
pivots[0].IsPeak();
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
bar.Clean();
|
||||
XClean(pivots);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Extract Directional Pivots ...
|
||||
XPivot peaks[];
|
||||
count = ExtractPivots(
|
||||
peaks,
|
||||
pivots,
|
||||
X_PIVOT_TYPE_PEAK //
|
||||
);
|
||||
result = IsValidSize(count) &&
|
||||
count >= 2;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
bar.Clean();
|
||||
XClean(peaks);
|
||||
XClean(pivots);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Result ...
|
||||
result =
|
||||
peaks[0].value < peaks[1].value;
|
||||
if (forceBarValidation)
|
||||
{
|
||||
//
|
||||
result =
|
||||
result &&
|
||||
bar.open < peaks[0].value &&
|
||||
bar.close < peaks[0].value;
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup ...
|
||||
bar.Clean();
|
||||
XClean(peaks);
|
||||
XClean(pivots);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Extractions ...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user