last ...
This commit is contained in:
@@ -734,6 +734,80 @@ struct XCAPVTick
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool GetMaxVolumeBox(XBoxZone &box)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
box.Clean();
|
||||
|
||||
//
|
||||
result = IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Select MAX Volume Zone ...
|
||||
XCTickZone *selectedZone = NULL;
|
||||
int zonesCount = zone.Count();
|
||||
for (int j = 0; j < zonesCount; j++)
|
||||
{
|
||||
//
|
||||
XCTickZone *jZone = zone.GetZone(j);
|
||||
|
||||
//
|
||||
bool canSet =
|
||||
selectedZone == NULL
|
||||
? true
|
||||
: selectedZone.volume < jZone.volume;
|
||||
if (canSet)
|
||||
{
|
||||
selectedZone = jZone;
|
||||
}
|
||||
|
||||
//
|
||||
ZeroMemory(jZone);
|
||||
}
|
||||
|
||||
//
|
||||
result = selectedZone != NULL;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
box.Clean();
|
||||
ZeroMemory(selectedZone);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = pivot.AsBox(box);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
box.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
box.upper = selectedZone.high;
|
||||
box.lower = selectedZone.low;
|
||||
box.type =
|
||||
pivot.type == XCA_PEAKSWHRES
|
||||
? "PEAKTICK"
|
||||
: pivot.type == XCA_VALESWLSUP
|
||||
? "VALETICK"
|
||||
: box.type;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
@@ -5828,7 +5902,22 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
ArrayRemove(
|
||||
tmpTicks,
|
||||
0,
|
||||
1);
|
||||
1 //
|
||||
);
|
||||
|
||||
//
|
||||
XBoxZone iBox;
|
||||
bool isBoxBreaked = false;
|
||||
has = iPVTick.GetMaxVolumeBox(iBox);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
isBoxBreaked = IsBoxBreaked(
|
||||
iBox,
|
||||
unAvailableBoxes,
|
||||
barIndex //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
has = IsPivotBreaked(
|
||||
@@ -5836,7 +5925,7 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
unAvailableBoxes,
|
||||
barIndex //
|
||||
);
|
||||
if (!has)
|
||||
if (!has && !isBoxBreaked)
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
@@ -5865,7 +5954,22 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
ArrayRemove(
|
||||
tmpTicks,
|
||||
0,
|
||||
1);
|
||||
1 //
|
||||
);
|
||||
|
||||
//
|
||||
XBoxZone iBox;
|
||||
bool isBoxBreaked = false;
|
||||
has = iPVTick.GetMaxVolumeBox(iBox);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
isBoxBreaked = IsBoxBreaked(
|
||||
iBox,
|
||||
unAvailableBoxes,
|
||||
barIndex //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
has = IsPivotBreaked(
|
||||
@@ -5873,7 +5977,7 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
unAvailableBoxes,
|
||||
barIndex //
|
||||
);
|
||||
if (!has)
|
||||
if (!has && !isBoxBreaked)
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
@@ -7450,6 +7554,137 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool IsBoxBreaked(
|
||||
XBoxZone &box,
|
||||
XBoxZone &unAvailableBoxes[],
|
||||
int barIndex = 0 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
barIndex = NormalizeInt(barIndex, 0);
|
||||
|
||||
//
|
||||
result = box.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
// Assume Invalid Boxes as Broken ...
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
int idx = -1;
|
||||
result = FindBoxIndex(
|
||||
idx,
|
||||
box,
|
||||
unAvailableBoxes //
|
||||
);
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
// Assume UnAvailable Boxes as Broken ...
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int toIDX = box.ToIndex();
|
||||
result = toIDX > barIndex;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool isBullish = box.IsBullish();
|
||||
double boundary =
|
||||
isBullish
|
||||
? box.lower
|
||||
: box.upper;
|
||||
|
||||
//
|
||||
// for validating Box Break we have to wait At Least 3 Bars Close
|
||||
// out of Box Boundary ...
|
||||
int barsLength = 3;
|
||||
|
||||
//
|
||||
int startCheckBreaktionBarIndex = toIDX - barsLength;
|
||||
result = startCheckBreaktionBarIndex > 0 &&
|
||||
barIndex < startCheckBreaktionBarIndex;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL cBar;
|
||||
XOHCL pBar;
|
||||
XOHCL p2Bar;
|
||||
for (int i = barIndex; i < startCheckBreaktionBarIndex; i++)
|
||||
{
|
||||
//
|
||||
result = cBar.Init(
|
||||
box.symbol,
|
||||
box.period,
|
||||
i + 1 //
|
||||
);
|
||||
result =
|
||||
result &&
|
||||
cBar.GetPreviousBar(pBar);
|
||||
result =
|
||||
result &&
|
||||
pBar.GetPreviousBar(p2Bar);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
cBar.Clean();
|
||||
pBar.Clean();
|
||||
p2Bar.Clean();
|
||||
|
||||
//
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
bool isBullishBreaked =
|
||||
isBullish &&
|
||||
cBar.close < boundary &&
|
||||
pBar.close < boundary &&
|
||||
p2Bar.close < boundary;
|
||||
|
||||
//
|
||||
bool isBearishBreaked =
|
||||
!isBullish &&
|
||||
cBar.close > boundary &&
|
||||
pBar.close > boundary &&
|
||||
p2Bar.close > boundary;
|
||||
|
||||
//
|
||||
result = isBullishBreaked ||
|
||||
isBearishBreaked;
|
||||
if (result)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
cBar.Clean();
|
||||
pBar.Clean();
|
||||
p2Bar.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
cBar.Clean();
|
||||
pBar.Clean();
|
||||
p2Bar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user