last ...
This commit is contained in:
@@ -1300,6 +1300,137 @@ class XCMarketPatternDetector : public XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Specified Bar has Pullback Bar Pattern or not ...
|
||||
*
|
||||
* @param bar: XOHCL, Specified Bar ...
|
||||
* @param zone: XBoxZone, refrence to hold pullback zone ...
|
||||
* @param dir: ENUM_X_DIRECTION a reference for Direction ...
|
||||
* @param pullbackLength: int, min required indirectional bars to confirm pullback ...
|
||||
* @param forceBreak: bool, force pullback bar breaks peak or vale of Zone ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsPullbackPattern(
|
||||
XOHCL &bar,
|
||||
XBoxZone &zone,
|
||||
ENUM_X_DIRECTION &dir,
|
||||
int pullbackLength = 2,
|
||||
bool forceBreak = false //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Prepare ...
|
||||
zone.Clean();
|
||||
CleanDirection(dir);
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
pullbackLength = NormalizeInt(pullbackLength, 2);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = bar.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// First Bar Direction ...
|
||||
dir = bar.GetDirection();
|
||||
result = HasDirection(dir);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Loop through Pullback Length ...
|
||||
XOHCL iBar;
|
||||
datetime from = NULL;
|
||||
double max = EMPTY_VALUE;
|
||||
double min = EMPTY_VALUE;
|
||||
int start = bar.Index() + 1;
|
||||
int end = start + pullbackLength;
|
||||
for (int i = start; i < end; i++)
|
||||
{
|
||||
//
|
||||
// Initialize Indexed Bar ...
|
||||
iBar.Clean();
|
||||
result = bar.BarAt(i, iBar) &&
|
||||
iBar.GetDirection() == Opposit(dir);
|
||||
if (!result)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Calculate Max and Min ...
|
||||
max =
|
||||
!NotEmptyZero(max)
|
||||
? iBar.high
|
||||
: MathMax(max, iBar.high);
|
||||
min =
|
||||
!NotEmptyZero(min)
|
||||
? iBar.low
|
||||
: MathMin(min, iBar.low);
|
||||
from = iBar.time;
|
||||
}
|
||||
|
||||
//
|
||||
// Apply Force Break ...
|
||||
if (result &&
|
||||
forceBreak)
|
||||
{
|
||||
//
|
||||
result =
|
||||
result &&
|
||||
NotEmptyZero(min) &&
|
||||
NotEmptyZero(max) &&
|
||||
(IsXBullish(dir)
|
||||
? bar.close > max
|
||||
: bar.close < min);
|
||||
}
|
||||
|
||||
//
|
||||
// Prepare Zone ...
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
ToBox(
|
||||
bar,
|
||||
zone,
|
||||
dir,
|
||||
ToXString(X_BAR_PATTERN_PULLBACK) //
|
||||
);
|
||||
zone.upper = max;
|
||||
zone.lower = min;
|
||||
zone.from = from;
|
||||
zone.at = bar.time;
|
||||
zone.to = bar.time;
|
||||
|
||||
//
|
||||
result = zone.IsValid();
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup ...
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
zone.Clean();
|
||||
CleanDirection(dir);
|
||||
}
|
||||
iBar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// FVG ...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user