last ...
This commit is contained in:
@@ -232,6 +232,159 @@ class XCMarketPatternDetector : public XCBase
|
||||
//
|
||||
// Detectors ...
|
||||
|
||||
bool IsPeak(
|
||||
XOHCL &bar,
|
||||
int validationLength = 7 //
|
||||
) {
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
validationLength = NormalizeInt(validationLength, 2);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = bar.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Define Requirements ...
|
||||
result = bar.FindHighest(validationLength, MODE_HIGH) <= bar.high;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool IsVale(
|
||||
XOHCL &bar,
|
||||
int validationLength = 7 //
|
||||
) {
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
validationLength = NormalizeInt(validationLength, 2);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = bar.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Define Requirements ...
|
||||
result = bar.FindLowest(validationLength, MODE_LOW) >= bar.low;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Specified Bar is Peak or Vale ...
|
||||
*
|
||||
* @param bar: XOHCL, Specified Bar ...
|
||||
* @param dir: ENUM_X_DIRECTION a reference for Direction ...
|
||||
* @param validationLength: int, Validation Length ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsPV(
|
||||
XOHCL &bar,
|
||||
ENUM_X_DIRECTION &dir,
|
||||
int validationLength = 7 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Prepare ...
|
||||
CleanDirection(dir);
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
validationLength = NormalizeInt(validationLength, 2);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = bar.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Define Requirements ...
|
||||
XOHCL iBar;
|
||||
bool isPeak = true;
|
||||
bool isVale = true;
|
||||
int start = bar.Index();
|
||||
int end = start + validationLength;
|
||||
for (int i = start; i < end; i++)
|
||||
{
|
||||
//
|
||||
iBar.Clean();
|
||||
result = bar.BarAt(i, iBar);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
isVale = false;
|
||||
isPeak = false;
|
||||
|
||||
//
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
isPeak =
|
||||
isPeak &&
|
||||
iBar.high <= bar.high;
|
||||
|
||||
//
|
||||
isVale =
|
||||
isVale &&
|
||||
iBar.low >= bar.low;
|
||||
|
||||
//
|
||||
if (!isPeak && !isVale)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
(isPeak && !isVale) ||
|
||||
(isVale && !isPeak);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
dir = isVale
|
||||
? X_DIRECTION_BULLISH
|
||||
: X_DIRECTION_BEARISH;
|
||||
|
||||
//
|
||||
// Get Result ...
|
||||
result = HasDirection(dir);
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
iBar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Specified Bar is Momentum Bar or not ...
|
||||
*
|
||||
@@ -1886,7 +2039,7 @@ class XCMarketPatternDetector : public XCBase
|
||||
|
||||
/**
|
||||
* Check Zones and Manage them ...
|
||||
*
|
||||
*
|
||||
* @param forBar: XOHCL, reference to Specified Bar ...
|
||||
* @param zones: XBoxZone, reference to Specified Zone Collection ...
|
||||
* @param sortBy: X_SORT_BY_DATE, Sort Zones by ...
|
||||
|
||||
Reference in New Issue
Block a user