last ...
This commit is contained in:
@@ -232,60 +232,6 @@ class XCMarketPatternDetector : public XCBase
|
|||||||
//
|
//
|
||||||
// Detectors ...
|
// 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 ...
|
* Check Specified Bar is Peak or Vale ...
|
||||||
*
|
*
|
||||||
@@ -298,7 +244,9 @@ class XCMarketPatternDetector : public XCBase
|
|||||||
bool IsPV(
|
bool IsPV(
|
||||||
XOHCL &bar,
|
XOHCL &bar,
|
||||||
ENUM_X_DIRECTION &dir,
|
ENUM_X_DIRECTION &dir,
|
||||||
int validationLength = 7 //
|
int validationLength = 7,
|
||||||
|
ENUM_X_PRICE peakPriceType = X_PRICE_HIGH, //
|
||||||
|
ENUM_X_PRICE valePriceType = X_PRICE_LOW //
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -314,64 +262,55 @@ class XCMarketPatternDetector : public XCBase
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Validate ...
|
// Validate ...
|
||||||
result = bar.IsValid();
|
result = bar.IsValid() &&
|
||||||
|
IsXValid(peakPriceType) &&
|
||||||
|
IsXValid(valePriceType);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Define Requirements ...
|
int valeIndex = -1;
|
||||||
XOHCL iBar;
|
double vale = bar.FindLowest(
|
||||||
bool isPeak = true;
|
valeIndex,
|
||||||
bool isVale = true;
|
validationLength,
|
||||||
int start = bar.Index();
|
valePriceType //
|
||||||
int end = start + validationLength;
|
);
|
||||||
for (int i = start; i < end; i++)
|
double barVale = bar.GetPrice(valePriceType);
|
||||||
|
bool isVale =
|
||||||
|
NotEmptyZero(vale) &&
|
||||||
|
NotEmptyZero(barVale) &&
|
||||||
|
IsValidIndex(valeIndex) &&
|
||||||
|
vale >= barVale;
|
||||||
|
|
||||||
|
//
|
||||||
|
int peakIndex = -1;
|
||||||
|
double peak = bar.FindHighest(
|
||||||
|
peakIndex,
|
||||||
|
validationLength,
|
||||||
|
peakPriceType //
|
||||||
|
);
|
||||||
|
double barPeak = bar.GetPrice(peakPriceType);
|
||||||
|
bool isPeak =
|
||||||
|
NotEmptyZero(peak) &&
|
||||||
|
NotEmptyZero(barPeak) &&
|
||||||
|
IsValidIndex(peakIndex) &&
|
||||||
|
peak <= barPeak;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = (isVale && !isPeak) ||
|
||||||
|
(isPeak && !isVale);
|
||||||
|
if (result)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
iBar.Clean();
|
dir =
|
||||||
result = bar.BarAt(i, iBar);
|
isVale
|
||||||
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_BULLISH
|
||||||
: X_DIRECTION_BEARISH;
|
: isPeak
|
||||||
|
? X_DIRECTION_BEARISH
|
||||||
|
: X_DIRECTION_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Get Result ...
|
// Get Result ...
|
||||||
@@ -379,7 +318,6 @@ class XCMarketPatternDetector : public XCBase
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Cleanup Resources ...
|
// Cleanup Resources ...
|
||||||
iBar.Clean();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -3364,7 +3364,7 @@ class XCXFIMAHelper : public XCBaseHelper
|
|||||||
maxAllowedLoopbackLength = NormalizeInt(maxAllowedLoopbackLength, 50);
|
maxAllowedLoopbackLength = NormalizeInt(maxAllowedLoopbackLength, 50);
|
||||||
|
|
||||||
//
|
//
|
||||||
pvValidationLength = NormalizeInt(pvValidationLength, 2);
|
pvValidationLength = NormalizeInt(pvValidationLength, 0);
|
||||||
|
|
||||||
//
|
//
|
||||||
momentumBarValidationLength = NormalizeInt(momentumBarValidationLength, 2);
|
momentumBarValidationLength = NormalizeInt(momentumBarValidationLength, 2);
|
||||||
@@ -3392,12 +3392,14 @@ class XCXFIMAHelper : public XCBaseHelper
|
|||||||
XOHCL iBar;
|
XOHCL iBar;
|
||||||
XOHCL tmpBar;
|
XOHCL tmpBar;
|
||||||
XPivot iPivot;
|
XPivot iPivot;
|
||||||
|
int count = 0;
|
||||||
string iPrefix = NULL;
|
string iPrefix = NULL;
|
||||||
ENUM_X_DIRECTION iDir;
|
|
||||||
int idx = barIndex - 1;
|
int idx = barIndex - 1;
|
||||||
double iMin = EMPTY_VALUE;
|
double iMin = EMPTY_VALUE;
|
||||||
double iMax = EMPTY_VALUE;
|
double iMax = EMPTY_VALUE;
|
||||||
double iValue = EMPTY_VALUE;
|
double iValue = EMPTY_VALUE;
|
||||||
|
ENUM_X_DIRECTION iDir = X_DIRECTION_NONE;
|
||||||
|
ENUM_X_DIRECTION tmpDir = X_DIRECTION_NONE;
|
||||||
ENUM_X_PIVOT_TYPE iType = X_PIVOT_TYPE_NONE;
|
ENUM_X_PIVOT_TYPE iType = X_PIVOT_TYPE_NONE;
|
||||||
int end = barIndex + maxAllowedLoopbackLength;
|
int end = barIndex + maxAllowedLoopbackLength;
|
||||||
while (
|
while (
|
||||||
@@ -3430,83 +3432,146 @@ class XCXFIMAHelper : public XCBaseHelper
|
|||||||
|
|
||||||
//
|
//
|
||||||
// PV ...
|
// PV ...
|
||||||
has = patternDetector.IsPV(
|
bool isPV = false;
|
||||||
iBar,
|
bool isPeak = false;
|
||||||
iDir,
|
bool isVale = false;
|
||||||
pvValidationLength //
|
tmpDir = X_DIRECTION_NONE;
|
||||||
);
|
if (pvValidationLength > 0)
|
||||||
if (has)
|
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
iPrefix =
|
isPV = patternDetector.IsPV(
|
||||||
IsXBullish(iDir)
|
iBar,
|
||||||
? "XLow"
|
tmpDir,
|
||||||
: "XHigh";
|
pvValidationLength //
|
||||||
|
);
|
||||||
|
isPeak = isPV &&
|
||||||
|
IsXBearish(tmpDir);
|
||||||
|
isVale = isPV &&
|
||||||
|
IsXBullish(tmpDir);
|
||||||
|
if (isPV)
|
||||||
|
{
|
||||||
|
iPrefix += isPeak ? "XPK" : "XVL";
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Continue Loopback if PV Validation Provided and not isPV ...
|
||||||
|
if (!isPV)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Momentum Bar ...
|
// Momentum Bar ...
|
||||||
if (!has)
|
bool isMomentum = patternDetector.IsMomentumBar(
|
||||||
{
|
|
||||||
//
|
|
||||||
has = patternDetector.IsMomentumBar(
|
|
||||||
iBar,
|
iBar,
|
||||||
iDir,
|
iDir,
|
||||||
momentumBarValidationLength,
|
momentumBarValidationLength,
|
||||||
momentumBarApprovedMultiplier //
|
momentumBarApprovedMultiplier //
|
||||||
);
|
);
|
||||||
if (has)
|
if (isMomentum)
|
||||||
{
|
{
|
||||||
iPrefix = "XMomentum";
|
//
|
||||||
|
if (!IsXValid(tmpDir))
|
||||||
|
{
|
||||||
|
tmpDir = iDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (iDir != tmpDir)
|
||||||
|
{
|
||||||
|
isMomentum = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//
|
||||||
|
count++;
|
||||||
|
iPrefix += (IsXValid(iPrefix) ? "_" : "") + "MNTM";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Engulf Bar ...
|
// Engulf Bar ...
|
||||||
if (!has)
|
bool isEngulfed = patternDetector.IsEngulfedBar(
|
||||||
{
|
|
||||||
//
|
|
||||||
has = patternDetector.IsEngulfedBar(
|
|
||||||
iBar,
|
iBar,
|
||||||
iDir //
|
iDir //
|
||||||
);
|
);
|
||||||
if (has)
|
if (isEngulfed)
|
||||||
{
|
{
|
||||||
iPrefix = "XEngulfed";
|
//
|
||||||
|
if (!IsXValid(tmpDir))
|
||||||
|
{
|
||||||
|
tmpDir = iDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (iDir != tmpDir)
|
||||||
|
{
|
||||||
|
isEngulfed = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//
|
||||||
|
count++;
|
||||||
|
iPrefix += (IsXValid(iPrefix) ? "_" : "") + "ENGLF";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// True Gap ...
|
// True Gap ...
|
||||||
if (!has)
|
bool isTrueGaped = patternDetector.IsTrueGapedBar(
|
||||||
{
|
|
||||||
//
|
|
||||||
has = patternDetector.IsTrueGapedBar(
|
|
||||||
iBar,
|
iBar,
|
||||||
iDir,
|
iDir,
|
||||||
trueGapApprovedStrength //
|
trueGapApprovedStrength //
|
||||||
);
|
);
|
||||||
if (has)
|
if (isTrueGaped)
|
||||||
{
|
{
|
||||||
iPrefix = "XTrueGap";
|
//
|
||||||
|
if (!IsXValid(tmpDir))
|
||||||
|
{
|
||||||
|
tmpDir = iDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (iDir != tmpDir)
|
||||||
|
{
|
||||||
|
isTrueGaped = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//
|
||||||
|
count++;
|
||||||
|
iPrefix += (IsXValid(iPrefix) ? "_" : "") + "TG";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Pin Bar ...
|
// Pin Bar ...
|
||||||
if (!has)
|
bool isPinned = patternDetector.IsPinnedBar(
|
||||||
{
|
|
||||||
//
|
|
||||||
has = patternDetector.IsPinnedBar(
|
|
||||||
iBar,
|
iBar,
|
||||||
iDir,
|
iDir,
|
||||||
pinBarShadowApprovedMultiplier,
|
pinBarShadowApprovedMultiplier,
|
||||||
pinBarRangeMultiplier,
|
pinBarRangeMultiplier,
|
||||||
pinBarForceDirection //
|
pinBarForceDirection //
|
||||||
);
|
);
|
||||||
if (has)
|
if (isPinned)
|
||||||
{
|
{
|
||||||
iPrefix = "XPinned";
|
//
|
||||||
|
if (!IsXValid(tmpDir))
|
||||||
|
{
|
||||||
|
tmpDir = iDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (iDir != tmpDir)
|
||||||
|
{
|
||||||
|
isPinned = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//
|
||||||
|
count++;
|
||||||
|
iPrefix += (IsXValid(iPrefix) ? "_" : "") + "PND";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3515,85 +3580,155 @@ class XCXFIMAHelper : public XCBaseHelper
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Star Pattern ...
|
// Star Pattern ...
|
||||||
if (!has)
|
bool isStarPattern = patternDetector.IsStartPattern(
|
||||||
{
|
|
||||||
//
|
|
||||||
has = patternDetector.IsStartPattern(
|
|
||||||
iBar,
|
iBar,
|
||||||
iDir //
|
iDir //
|
||||||
);
|
);
|
||||||
if (has)
|
if (isStarPattern)
|
||||||
{
|
{
|
||||||
iPrefix = "XStar";
|
//
|
||||||
|
if (!IsXValid(tmpDir))
|
||||||
|
{
|
||||||
|
tmpDir = iDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (iDir != tmpDir)
|
||||||
|
{
|
||||||
|
isStarPattern = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//
|
||||||
|
count++;
|
||||||
|
iPrefix += (IsXValid(iPrefix) ? "_" : "") + "STR";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Piercing Pattern ...
|
// Piercing Pattern ...
|
||||||
if (!has)
|
bool isPiercingPattern = patternDetector.IsPiercingPattern(
|
||||||
{
|
|
||||||
//
|
|
||||||
has = patternDetector.IsPiercingPattern(
|
|
||||||
iBar,
|
iBar,
|
||||||
iDir //
|
iDir //
|
||||||
);
|
);
|
||||||
if (has)
|
if (isPiercingPattern)
|
||||||
{
|
{
|
||||||
iPrefix = "XPiercing";
|
//
|
||||||
|
if (!IsXValid(tmpDir))
|
||||||
|
{
|
||||||
|
tmpDir = iDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (iDir != tmpDir)
|
||||||
|
{
|
||||||
|
isPiercingPattern = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//
|
||||||
|
count++;
|
||||||
|
iPrefix += (IsXValid(iPrefix) ? "_" : "") + "PRCG";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Rising Pattern ...
|
// Rising Pattern ...
|
||||||
if (!has)
|
bool isRisingPattern = patternDetector.IsRisingPattern(
|
||||||
{
|
|
||||||
//
|
|
||||||
has = patternDetector.IsRisingPattern(
|
|
||||||
iBar,
|
iBar,
|
||||||
iDir //
|
iDir //
|
||||||
);
|
);
|
||||||
if (has)
|
if (isRisingPattern)
|
||||||
{
|
{
|
||||||
iPrefix = "XRising";
|
//
|
||||||
|
if (!IsXValid(tmpDir))
|
||||||
|
{
|
||||||
|
tmpDir = iDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (iDir != tmpDir)
|
||||||
|
{
|
||||||
|
isRisingPattern = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//
|
||||||
|
count++;
|
||||||
|
iPrefix += (IsXValid(iPrefix) ? "_" : "") + "RSG";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Flag Pattern ...
|
// Flag Pattern ...
|
||||||
if (!has)
|
bool isFlagPattern = patternDetector.IsFlagPattern(
|
||||||
{
|
|
||||||
//
|
|
||||||
has = patternDetector.IsFlagPattern(
|
|
||||||
iBar,
|
iBar,
|
||||||
iDir,
|
iDir,
|
||||||
tmpBar,
|
tmpBar,
|
||||||
flagPatternPullbackLength //
|
flagPatternPullbackLength //
|
||||||
);
|
);
|
||||||
if (has)
|
if (isFlagPattern)
|
||||||
{
|
{
|
||||||
iPrefix = "XFlag";
|
//
|
||||||
|
if (!IsXValid(tmpDir))
|
||||||
|
{
|
||||||
|
tmpDir = iDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (iDir != tmpDir)
|
||||||
|
{
|
||||||
|
isFlagPattern = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//
|
||||||
|
count++;
|
||||||
|
iPrefix += (IsXValid(iPrefix) ? "_" : "") + "FLG";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Signal Key Pattern ...
|
// Signal Key Pattern ...
|
||||||
if (!has)
|
bool isSignalKeyPattern = patternDetector.IsSignalKeyBarPattern(
|
||||||
{
|
|
||||||
//
|
|
||||||
has = patternDetector.IsSignalKeyBarPattern(
|
|
||||||
iBar,
|
iBar,
|
||||||
iDir,
|
iDir,
|
||||||
pinBarShadowApprovedMultiplier,
|
pinBarShadowApprovedMultiplier,
|
||||||
pinBarRangeMultiplier,
|
pinBarRangeMultiplier,
|
||||||
pinBarForceDirection //
|
pinBarForceDirection //
|
||||||
);
|
);
|
||||||
if (has)
|
if (isSignalKeyPattern)
|
||||||
{
|
{
|
||||||
iPrefix = "XSignalKey";
|
//
|
||||||
|
if (!IsXValid(tmpDir))
|
||||||
|
{
|
||||||
|
tmpDir = iDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (iDir != tmpDir)
|
||||||
|
{
|
||||||
|
isSignalKeyPattern = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//
|
||||||
|
count++;
|
||||||
|
iPrefix += (IsXValid(iPrefix) ? "_" : "") + "SKB";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
has =
|
||||||
|
isPinned ||
|
||||||
|
isMomentum ||
|
||||||
|
isEngulfed ||
|
||||||
|
isTrueGaped ||
|
||||||
|
isStarPattern ||
|
||||||
|
isFlagPattern ||
|
||||||
|
isRisingPattern ||
|
||||||
|
isPiercingPattern ||
|
||||||
|
isSignalKeyPattern;
|
||||||
if (!has)
|
if (!has)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
Reference in New Issue
Block a user