last ...
This commit is contained in:
@@ -3499,11 +3499,11 @@ bool AddIfNotExists(
|
||||
|
||||
/**
|
||||
* Extract Specified Directional Items ...
|
||||
*
|
||||
*
|
||||
* @param dest: reference collection to holds extracted items ...
|
||||
* @param source: reference collection to provides data source ...
|
||||
* @param forDir: Specified which direction to Extract items ...
|
||||
*
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
template <typename T>
|
||||
@@ -3534,7 +3534,7 @@ int ExtractByDirection(
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
has = source[i].dir == forDir;
|
||||
has = source[i].dir == forDir;
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
@@ -4313,6 +4313,219 @@ bool IsInside(
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Specified Bar is Acted On Specified Zone or not ...
|
||||
*
|
||||
* @param bar: Specified Bar ...
|
||||
* @param zone: Specified Zone ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsActed(
|
||||
XOHCL &bar,
|
||||
XBoxZone &zone //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = bar.IsValid() &&
|
||||
zone.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Get Previous Bar ...
|
||||
XOHCL pBar;
|
||||
result = bar.GetPreviousBar(pBar);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Previous Bar must one of Following States:
|
||||
// - Tested;
|
||||
// - Inside;
|
||||
// - Breaked;
|
||||
bool isTested = IsTested(pBar, zone);
|
||||
bool isInside = IsInside(pBar, zone);
|
||||
bool isBreaked = IsBreaked(pBar, zone);
|
||||
result = isTested ||
|
||||
isInside ||
|
||||
isBreaked;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Current Bar Must Close Over / Under Zone ...
|
||||
result =
|
||||
zone.IsBullish()
|
||||
? bar.close > zone.upper
|
||||
: zone.IsBearish()
|
||||
? bar.close < zone.lower
|
||||
: false;
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
pBar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Specified Bar is Acted On Specified Zone or not ...
|
||||
*
|
||||
* @param bar: Specified Bar ...
|
||||
* @param zone: Specified Zone ...
|
||||
* @param validationLength: Specified Length for Breaks ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsValidBreaked(
|
||||
XOHCL &bar,
|
||||
XBoxZone &zone,
|
||||
int validationLength = 3 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
validationLength = NormalizeInt(validationLength, 1);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = bar.IsValid() &&
|
||||
zone.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL iBar;
|
||||
int count = 0;
|
||||
int start = bar.Index();
|
||||
int end = start + validationLength;
|
||||
for (int i = start; i < end; i++)
|
||||
{
|
||||
//
|
||||
// Initialize Indexed Bar ...
|
||||
result = bar.BarAt(i, iBar);
|
||||
if (!result)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
result = IsBreaked(iBar, zone);
|
||||
if (result)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = IsValidSize(count) &&
|
||||
count >= validationLength;
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
iBar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Specified Bar is Fake Breaked Specified Zone or not ...
|
||||
*
|
||||
* @param bar: Specified Bar ...
|
||||
* @param zone: Specified Zone ...
|
||||
* @param validationLength: Specified Length for Breaks ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsFakeBreaked(
|
||||
XOHCL &bar,
|
||||
XBoxZone &zone,
|
||||
int validationLength = 3 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
validationLength = NormalizeInt(validationLength, 1);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = bar.IsValid() &&
|
||||
zone.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Bar Must Acting Zone ...
|
||||
result = zone.IsBullish()
|
||||
? bar.close > zone.upper
|
||||
: zone.IsBearish()
|
||||
? bar.close < zone.lower
|
||||
: false;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Detect Breaker Bars ...
|
||||
XOHCL breakerBars[];
|
||||
int breakerBarsCount = GetBreakerBars(
|
||||
zone,
|
||||
breakerBars //
|
||||
);
|
||||
result = IsValidSize(breakerBarsCount);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
XClean(breakerBars);
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Get Youngest Breaker Bars ...
|
||||
int idx = GetYoungestBar(breakerBars);
|
||||
result = IsValidIndex(idx);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
XClean(breakerBars);
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = breakerBars[idx].Index() - bar.Index() <= validationLength;
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
XClean(breakerBars);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check a Bar is Inside a Zone or not ...
|
||||
*
|
||||
|
||||
@@ -537,6 +537,15 @@ struct XBoxZone
|
||||
string type;
|
||||
ENUM_X_DIRECTION dir;
|
||||
|
||||
//
|
||||
// Special Props ...
|
||||
datetime breakAt;
|
||||
datetime tests[];
|
||||
datetime acteds[];
|
||||
datetime breaks[];
|
||||
datetime insides[];
|
||||
datetime fakeBreaks[];
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
XBoxZone()
|
||||
@@ -562,10 +571,27 @@ struct XBoxZone
|
||||
period = NULL;
|
||||
dir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
SpecialClean();
|
||||
|
||||
//
|
||||
ZeroMemory(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean Special Props ...
|
||||
*/
|
||||
void SpecialClean()
|
||||
{
|
||||
//
|
||||
breakAt = NULL;
|
||||
XClean(tests);
|
||||
XClean(acteds);
|
||||
XClean(breaks);
|
||||
XClean(insides);
|
||||
XClean(fakeBreaks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate Model ...
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user