Last works ...
This commit is contained in:
@@ -476,138 +476,6 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
|
||||
return result;
|
||||
}
|
||||
|
||||
int ExtractXFIMAZones(
|
||||
XBoxZone &zones[],
|
||||
int barIndex = 0,
|
||||
int requiredNumberOfZones = 50,
|
||||
double shadowMultiplier = 4,
|
||||
int maxAllowedLoopbackLength = 1500 //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
// Prepare ...
|
||||
XClean(zones);
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
barIndex = NormalizeInt(barIndex, 0);
|
||||
shadowMultiplier = NormalizeDouble(shadowMultiplier, 2);
|
||||
requiredNumberOfZones = NormalizeInt(requiredNumberOfZones, 5);
|
||||
maxAllowedLoopbackLength = NormalizeInt(maxAllowedLoopbackLength, 50);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool has =
|
||||
fimaHelper != NULL &&
|
||||
fimaHelper.IsValid();
|
||||
if (!has)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Create a Loop ...
|
||||
XOHCL iBar;
|
||||
XBoxZone iBox;
|
||||
bool isBullish = false;
|
||||
bool isBearish = false;
|
||||
double iUpper = EMPTY_VALUE;
|
||||
double iLower = EMPTY_VALUE;
|
||||
double iHKUpper = EMPTY_VALUE;
|
||||
double iHKLower = EMPTY_VALUE;
|
||||
double iMAUpper = EMPTY_VALUE;
|
||||
double iMALower = EMPTY_VALUE;
|
||||
string symbol = fimaHelper.GetSymbol();
|
||||
ENUM_X_DIRECTION iDir = X_DIRECTION_NONE;
|
||||
ENUM_TIMEFRAMES period = fimaHelper.GetPeriod();
|
||||
|
||||
//
|
||||
int start = barIndex;
|
||||
int idx = start - 1;
|
||||
int end = start + maxAllowedLoopbackLength;
|
||||
while (ArraySize(zones) < requiredNumberOfZones && idx < end)
|
||||
{
|
||||
//
|
||||
idx++;
|
||||
|
||||
//
|
||||
// Initialize Indexed Bar ...
|
||||
has = iBar.Init(
|
||||
symbol,
|
||||
period,
|
||||
idx //
|
||||
);
|
||||
if (!has)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Reading Bars ...
|
||||
iMAUpper = fimaHelper.GetMABondUpper(idx);
|
||||
iMALower = fimaHelper.GetMABondLower(idx);
|
||||
iHKUpper = fimaHelper.GetHKBondUpper(idx);
|
||||
iHKLower = fimaHelper.GetHKBondLower(idx);
|
||||
|
||||
//
|
||||
iUpper = MathMax(iMAUpper, iHKUpper);
|
||||
iLower = MathMin(iMALower, iHKLower);
|
||||
|
||||
//
|
||||
// Check Bar State ...
|
||||
has =
|
||||
NotEmptyZero(iUpper) &&
|
||||
NotEmptyZero(iLower);
|
||||
if (!has)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Direction of Zone ...
|
||||
isBullish = iBar.low < iLower;
|
||||
isBearish = iBar.high > iUpper;
|
||||
has = (isBullish && !isBearish) ||
|
||||
(isBearish && !isBullish);
|
||||
if (!has)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate Shadow Multiplier ...
|
||||
has =
|
||||
isBullish
|
||||
? iBar.GetLowShadow() > iBar.GetHighShadow() * shadowMultiplier
|
||||
: iBar.GetHighShadow() > iBar.GetLowShadow() * shadowMultiplier;
|
||||
if (!has)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
iDir = isBullish
|
||||
? X_DIRECTION_BULLISH
|
||||
: X_DIRECTION_BEARISH;
|
||||
|
||||
//
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
iBar.Clean();
|
||||
iBox.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
result = ArraySize(zones);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy ...
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user