last ...
This commit is contained in:
@@ -611,9 +611,25 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
|
||||
//
|
||||
// Pivot Verifications and Max Allowed Holding Items ...
|
||||
int maxAllowedPivots; // Max Allowed Holding Pibots ...
|
||||
int pivotVerifications; // Pivots Verifications ...
|
||||
int pivotDetectionLoopbac; // Pivots Detection Loopback ...
|
||||
int maxAllowedPivots; // Max Allowed Holding Pibots ...
|
||||
int pivotVerifications; // Pivots Verifications ...
|
||||
int pivotDetectionLoopbac; // Pivots Detection Loopback ...
|
||||
double ticksDividerInPoints; // Ticks and Volume Detection Divider in Point ...
|
||||
ENUM_TIMEFRAMES ticksDetectionPerid; // Ticks and Volume Detection Loopback ...
|
||||
|
||||
//
|
||||
// TICK Pivots ...
|
||||
|
||||
//
|
||||
bool detectTickPivots;
|
||||
XBoxZone tickPivots[];
|
||||
|
||||
//
|
||||
// VOLUME Pivots ...
|
||||
|
||||
//
|
||||
bool detectVolumePivots;
|
||||
XBoxZone volumePivots[];
|
||||
|
||||
//
|
||||
// RSI Peak Pivot ...
|
||||
@@ -749,9 +765,13 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
//
|
||||
maxAllowedPivots = 50;
|
||||
pivotVerifications = 5;
|
||||
ticksDividerInPoints = 15;
|
||||
pivotDetectionLoopbac = 100;
|
||||
ticksDetectionPerid = PERIOD_D1;
|
||||
|
||||
//
|
||||
detectTickPivots = true;
|
||||
detectVolumePivots = true;
|
||||
detectRSIPeakPivots = true;
|
||||
detectRSIValePivots = true;
|
||||
detectCCIPeakPivots = true;
|
||||
@@ -1016,6 +1036,161 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
//
|
||||
// Checking Pivots ...
|
||||
|
||||
//
|
||||
// Detect TICK and VOLUME Pivots ...
|
||||
if (detectTickPivots || detectVolumePivots)
|
||||
{
|
||||
//
|
||||
XOHCL ticksToBar;
|
||||
XOHCL ticksFromBar;
|
||||
XCTicksZone *ticksZone = NULL;
|
||||
|
||||
//
|
||||
datetime ticksTo = GetPeriodStartTime(
|
||||
zBar.symbol,
|
||||
ticksDetectionPerid,
|
||||
zBar.time //
|
||||
);
|
||||
bool isTicksBarInited = ticksToBar.Init(
|
||||
zBar.symbol,
|
||||
zBar.period,
|
||||
ticksTo //
|
||||
);
|
||||
datetime ticksFrom = ticksTo - PeriodSeconds(ticksDetectionPerid);
|
||||
isTicksBarInited = isTicksBarInited &&
|
||||
ticksFromBar.Init(
|
||||
zBar.symbol,
|
||||
zBar.period,
|
||||
ticksFrom //
|
||||
);
|
||||
bool hasValidTicksTimeRange = IsValid(ticksTo) &&
|
||||
isTicksBarInited &&
|
||||
IsValid(ticksFrom) &&
|
||||
ticksFrom < ticksTo;
|
||||
|
||||
//
|
||||
bool isTickPivotExists =
|
||||
hasValidTicksTimeRange &&
|
||||
IsExistsTickPivot(
|
||||
ticksTo,
|
||||
ticksFrom //
|
||||
);
|
||||
|
||||
//
|
||||
bool isVolumePivotExists =
|
||||
hasValidTicksTimeRange &&
|
||||
IsExistsVolumePivot(
|
||||
ticksTo,
|
||||
ticksFrom //
|
||||
);
|
||||
|
||||
//
|
||||
bool isInitializedZone = !isTickPivotExists ||
|
||||
!isVolumePivotExists;
|
||||
if (isInitializedZone)
|
||||
{
|
||||
//
|
||||
isInitializedZone = InitializeTicksZone(
|
||||
ticksZone,
|
||||
ticksToBar,
|
||||
ticksFromBar //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// TICK Pivots ...
|
||||
if (detectTickPivots)
|
||||
{
|
||||
//
|
||||
// Check Current Zone Exists or Not ...
|
||||
if (isInitializedZone && !isTickPivotExists)
|
||||
{
|
||||
//
|
||||
XBoxZone iBox;
|
||||
XCTickZone *iZone;
|
||||
has = ticksZone.GetMaxTickZone(iZone);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
// Try to Converts a Tick Zone to XBoxZone ...
|
||||
iBox.to = ticksTo;
|
||||
iBox.from = ticksFrom;
|
||||
iBox.lower = iZone.low;
|
||||
iBox.upper = iZone.high;
|
||||
iBox.symbol = iZone.symbol;
|
||||
iBox.period = iZone.period;
|
||||
iBox.type = "XCA_MAX_TICK";
|
||||
iBox.dir = X_DIRECTION_BULLISH; // Temparory ...
|
||||
|
||||
//
|
||||
has = iBox.IsValid();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
AddBox(
|
||||
iBox,
|
||||
tickPivots //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
iBox.Clean();
|
||||
ZeroMemory(iZone);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// VOLUME Pivots ...
|
||||
if (detectVolumePivots)
|
||||
{
|
||||
//
|
||||
// Check Current Zone Exists or Not ...
|
||||
if (isInitializedZone && !isVolumePivotExists)
|
||||
{
|
||||
//
|
||||
XBoxZone iBox;
|
||||
XCTickZone *iZone;
|
||||
has = ticksZone.GetMaxVolumeZone(iZone);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
// Try to Converts a Tick Zone to XBoxZone ...
|
||||
iBox.to = ticksTo;
|
||||
iBox.from = ticksFrom;
|
||||
iBox.lower = iZone.low;
|
||||
iBox.upper = iZone.high;
|
||||
iBox.symbol = iZone.symbol;
|
||||
iBox.period = iZone.period;
|
||||
iBox.type = "XCA_MAX_VOLUME";
|
||||
iBox.dir = X_DIRECTION_BULLISH; // Temparory ...
|
||||
|
||||
//
|
||||
has = iBox.IsValid();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
AddBox(
|
||||
iBox,
|
||||
volumePivots //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
iBox.Clean();
|
||||
ZeroMemory(iZone);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
ticksToBar.Clean();
|
||||
ticksFromBar.Clean();
|
||||
ZeroMemory(ticksZone);
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
// RSI Peak Pivot ...
|
||||
if (detectRSIPeakPivots)
|
||||
@@ -1755,6 +1930,28 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
//
|
||||
// Implement Validation Senarios ...
|
||||
|
||||
//
|
||||
// TICK Pivots ...
|
||||
|
||||
//
|
||||
// TODO: Complete this ...
|
||||
has = HasTickPivots();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
// VOLUME Pivots ...
|
||||
|
||||
//
|
||||
// TODO: Complete this ...
|
||||
has = HasVolumePivots();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
// RSI Peak Pivot ...
|
||||
|
||||
@@ -2480,6 +2677,36 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
//
|
||||
// Counters ...
|
||||
|
||||
//
|
||||
// TICK Pivot ...
|
||||
|
||||
//
|
||||
bool HasTickPivots()
|
||||
{
|
||||
return HasChild(tickPivots);
|
||||
}
|
||||
|
||||
//
|
||||
int CountTickPivots()
|
||||
{
|
||||
return ArraySize(tickPivots);
|
||||
}
|
||||
|
||||
//
|
||||
// VOLUME Pivots ...
|
||||
|
||||
//
|
||||
bool HasVolumePivots()
|
||||
{
|
||||
return HasChild(volumePivots);
|
||||
}
|
||||
|
||||
//
|
||||
int CountVolumePivots()
|
||||
{
|
||||
return ArraySize(volumePivots);
|
||||
}
|
||||
|
||||
//
|
||||
// RSI Peak Pivot ...
|
||||
|
||||
@@ -2896,6 +3123,8 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
void CleanPivots()
|
||||
{
|
||||
//
|
||||
Clean(tickPivots);
|
||||
Clean(volumePivots);
|
||||
Clean(rsiPeakPivots);
|
||||
Clean(rsiValePivots);
|
||||
Clean(cciPeakPivots);
|
||||
@@ -2912,6 +3141,8 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
void ReversePivots()
|
||||
{
|
||||
//
|
||||
ArrayReverse(tickPivots);
|
||||
ArrayReverse(volumePivots);
|
||||
ArrayReverse(rsiPeakPivots);
|
||||
ArrayReverse(rsiValePivots);
|
||||
ArrayReverse(cciPeakPivots);
|
||||
@@ -2925,6 +3156,169 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
//
|
||||
bool IsExistsTickPivot(
|
||||
datetime to,
|
||||
datetime from //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Validate Args ...
|
||||
result = IsValid(to) &&
|
||||
IsValid(from) &&
|
||||
to > from;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = HasTickPivots();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int idx = -1;
|
||||
int count = CountTickPivots();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XBoxZone iBox = tickPivots[i];
|
||||
|
||||
//
|
||||
result = iBox.to == to &&
|
||||
iBox.from == from;
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
idx = i;
|
||||
iBox.Clean();
|
||||
|
||||
//
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
iBox.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
result = IsValidIndex(idx);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool IsExistsVolumePivot(
|
||||
datetime to,
|
||||
datetime from //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Validate Args ...
|
||||
result = IsValid(to) &&
|
||||
IsValid(from) &&
|
||||
to > from;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = HasVolumePivots();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int idx = -1;
|
||||
int count = CountVolumePivots();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XBoxZone iBox = volumePivots[i];
|
||||
|
||||
//
|
||||
result = iBox.to == to &&
|
||||
iBox.from == from;
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
idx = i;
|
||||
iBox.Clean();
|
||||
|
||||
//
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
iBox.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
result = IsValidIndex(idx);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool InitializeTicksZone(
|
||||
XCTicksZone *&zone,
|
||||
XOHCL &toBar,
|
||||
XOHCL &fromBar //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = zone == NULL;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int toIDX = toBar.Index();
|
||||
int fromIDX = fromBar.Index();
|
||||
int rangeLength = fromIDX - toIDX;
|
||||
double rangeDivider = ticksDividerInPoints * GetPoints(toBar.symbol);
|
||||
double rangeL = toBar.FindLowest(rangeLength, MODE_LOW);
|
||||
double rangeH = toBar.FindHighest(rangeLength, MODE_HIGH);
|
||||
double rangeDiff = (rangeH - rangeL);
|
||||
int zoneLevels = (int)(rangeDiff / rangeDivider);
|
||||
|
||||
//
|
||||
zone = new XCTicksZone();
|
||||
zone.Levels(zoneLevels);
|
||||
|
||||
//
|
||||
result = zone.Init(
|
||||
fromBar,
|
||||
toBar //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
ZeroMemory(zone);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
//
|
||||
@@ -43,6 +43,8 @@ class XCXCAEAPOIDrawer : public XCBase
|
||||
|
||||
//
|
||||
// Drawers ...
|
||||
bool drawTickPivots;
|
||||
bool drawVolumePivots;
|
||||
bool drawRSIPeakPivots;
|
||||
bool drawRSIValePivots;
|
||||
bool drawCCIPeakPivots;
|
||||
@@ -62,6 +64,8 @@ class XCXCAEAPOIDrawer : public XCBase
|
||||
color defaultBearishColor;
|
||||
|
||||
//
|
||||
color tickPivotsColor;
|
||||
color volumePivotsColor;
|
||||
color rsiPeakPivotsColor;
|
||||
color rsiValePivotsColor;
|
||||
color cciPeakPivotsColor;
|
||||
@@ -81,6 +85,8 @@ class XCXCAEAPOIDrawer : public XCBase
|
||||
int defaultBearishWidth;
|
||||
|
||||
//
|
||||
int tickPivotsWidth;
|
||||
int volumePivotsWidth;
|
||||
int rsiPeakPivotsWidth;
|
||||
int rsiValePivotsWidth;
|
||||
int cciPeakPivotsWidth;
|
||||
@@ -100,6 +106,8 @@ class XCXCAEAPOIDrawer : public XCBase
|
||||
ENUM_LINE_STYLE defaultBearishStyle;
|
||||
|
||||
//
|
||||
ENUM_LINE_STYLE tickPivotsStyle;
|
||||
ENUM_LINE_STYLE volumePivotsStyle;
|
||||
ENUM_LINE_STYLE rsiPeakPivotsStyle;
|
||||
ENUM_LINE_STYLE rsiValePivotsStyle;
|
||||
ENUM_LINE_STYLE cciPeakPivotsStyle;
|
||||
@@ -159,6 +167,8 @@ class XCXCAEAPOIDrawer : public XCBase
|
||||
ignoreUpdateOSCTos = true;
|
||||
|
||||
//
|
||||
drawTickPivots = false;
|
||||
drawVolumePivots = false;
|
||||
drawRSIPeakPivots = false;
|
||||
drawRSIValePivots = false;
|
||||
drawCCIPeakPivots = false;
|
||||
@@ -174,6 +184,10 @@ class XCXCAEAPOIDrawer : public XCBase
|
||||
defaultBullishColor = clrLime;
|
||||
defaultBearishColor = clrRed;
|
||||
|
||||
//
|
||||
tickPivotsColor = defaultBullishColor;
|
||||
volumePivotsColor = defaultBearishColor;
|
||||
|
||||
//
|
||||
rsiValePivotsColor = defaultBullishColor;
|
||||
cciValePivotsColor = defaultBullishColor;
|
||||
@@ -192,6 +206,10 @@ class XCXCAEAPOIDrawer : public XCBase
|
||||
defaultBullishWidth = 1;
|
||||
defaultBearishWidth = 1;
|
||||
|
||||
//
|
||||
tickPivotsWidth = defaultBullishWidth;
|
||||
volumePivotsWidth = defaultBearishWidth;
|
||||
|
||||
//
|
||||
rsiValePivotsWidth = defaultBullishWidth;
|
||||
cciValePivotsWidth = defaultBullishWidth;
|
||||
@@ -210,6 +228,10 @@ class XCXCAEAPOIDrawer : public XCBase
|
||||
defaultBullishStyle = STYLE_SOLID;
|
||||
defaultBearishStyle = STYLE_SOLID;
|
||||
|
||||
//
|
||||
tickPivotsStyle = defaultBullishStyle;
|
||||
volumePivotsStyle = defaultBearishStyle;
|
||||
|
||||
//
|
||||
rsiValePivotsStyle = defaultBullishStyle;
|
||||
cciValePivotsStyle = defaultBullishStyle;
|
||||
@@ -229,6 +251,8 @@ class XCXCAEAPOIDrawer : public XCBase
|
||||
void Draw(datetime to = NULL)
|
||||
{
|
||||
//
|
||||
DrawTickPivots(to);
|
||||
DrawVolumePivots(to);
|
||||
DrawRSIPeakPivots(to);
|
||||
DrawRSIValePivots(to);
|
||||
DrawCCIPeakPivots(to);
|
||||
@@ -245,6 +269,8 @@ class XCXCAEAPOIDrawer : public XCBase
|
||||
void Clear()
|
||||
{
|
||||
//
|
||||
mTickPivotObjects.Clear();
|
||||
mVolumePivotObjects.Clear();
|
||||
mRSIPeakPivotObjects.Clear();
|
||||
mRSIValePivotObjects.Clear();
|
||||
mCCIPeakPivotObjects.Clear();
|
||||
@@ -261,6 +287,116 @@ class XCXCAEAPOIDrawer : public XCBase
|
||||
//
|
||||
//
|
||||
|
||||
//
|
||||
void DrawTickPivots(datetime to = NULL)
|
||||
{
|
||||
//
|
||||
bool has = drawTickPivots;
|
||||
if (!has)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
has = detector.HasTickPivots();
|
||||
if (!has)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
bool canUpdateTo = IsValid(to);
|
||||
|
||||
//
|
||||
int count = detector.CountTickPivots();
|
||||
for (int i = 0; i < count; i++) {
|
||||
//
|
||||
XBoxZone iBox = detector.tickPivots[i];
|
||||
|
||||
//
|
||||
if (canUpdateTo) {
|
||||
iBox.to = to;
|
||||
}
|
||||
|
||||
//
|
||||
XCBoxObject *iObj;
|
||||
has = drawer.DrawBox(
|
||||
iBox,
|
||||
iObj //
|
||||
);
|
||||
if (has) {
|
||||
//
|
||||
// Style Pivot ...
|
||||
iObj.BoxColor(tickPivotsColor);
|
||||
iObj.BoxWidth(tickPivotsWidth);
|
||||
iObj.BoxStyle(tickPivotsStyle);
|
||||
|
||||
//
|
||||
// Store Pivot ...
|
||||
mTickPivotObjects.Add(iObj);
|
||||
}
|
||||
|
||||
//
|
||||
iBox.Clean();
|
||||
ZeroMemory(iObj);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
void DrawVolumePivots(datetime to = NULL)
|
||||
{
|
||||
//
|
||||
bool has = drawVolumePivots;
|
||||
if (!has)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
has = detector.HasVolumePivots();
|
||||
if (!has)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
bool canUpdateTo = IsValid(to);
|
||||
|
||||
//
|
||||
int count = detector.CountVolumePivots();
|
||||
for (int i = 0; i < count; i++) {
|
||||
//
|
||||
XBoxZone iBox = detector.volumePivots[i];
|
||||
|
||||
//
|
||||
if (canUpdateTo) {
|
||||
iBox.to = to;
|
||||
}
|
||||
|
||||
//
|
||||
XCBoxObject *iObj;
|
||||
has = drawer.DrawBox(
|
||||
iBox,
|
||||
iObj //
|
||||
);
|
||||
if (has) {
|
||||
//
|
||||
// Style Pivot ...
|
||||
iObj.BoxColor(volumePivotsColor);
|
||||
iObj.BoxWidth(volumePivotsWidth);
|
||||
iObj.BoxStyle(volumePivotsStyle);
|
||||
|
||||
//
|
||||
// Store Pivot ...
|
||||
mVolumePivotObjects.Add(iObj);
|
||||
}
|
||||
|
||||
//
|
||||
iBox.Clean();
|
||||
ZeroMemory(iObj);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
void DrawRSIPeakPivots(datetime to = NULL)
|
||||
{
|
||||
@@ -892,6 +1028,8 @@ class XCXCAEAPOIDrawer : public XCBase
|
||||
XCXCAEAPOIDetector *detector;
|
||||
|
||||
//
|
||||
CArrayObj mTickPivotObjects;
|
||||
CArrayObj mVolumePivotObjects;
|
||||
CArrayObj mRSIPeakPivotObjects;
|
||||
CArrayObj mRSIValePivotObjects;
|
||||
CArrayObj mCCIPeakPivotObjects;
|
||||
|
||||
Reference in New Issue
Block a user