932 lines
17 KiB
Plaintext
932 lines
17 KiB
Plaintext
///////////////////////////////////////////////////////
|
|
//
|
|
// SaherElm IT Center MQL5 Indicator
|
|
// -------------------------------------------------
|
|
// Name: XCXCAEAPOIDrawer ...
|
|
// Description: Class for XCAEA POI Drawer ...
|
|
//
|
|
//
|
|
// Maintainer:
|
|
// ------------
|
|
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
|
//
|
|
//////////////////////////////////////////////////////
|
|
//
|
|
// Global Properties ...
|
|
#property library
|
|
#property copyright "Copyright 2023, SaherElm IT Center"
|
|
#property link "https://saherelm.ir"
|
|
#property version "1.00"
|
|
#property description "SaherElm Class for XCAEA POI Drawer"
|
|
#property strict
|
|
|
|
//
|
|
// Imports ...
|
|
#include "../../Classes/x-saherelm.x-poi.drawer.class.mq5"
|
|
#include "../Classes/xcaea.x-poi.detector.class.mq5"
|
|
|
|
//
|
|
// Definitions ...
|
|
struct XCAPivotStyle
|
|
{
|
|
//
|
|
// Properties ...
|
|
int width;
|
|
color clr;
|
|
ENUM_LINE_STYLE style;
|
|
|
|
//
|
|
// Constructor ...
|
|
XCAPivotStyle()
|
|
{
|
|
Default();
|
|
}
|
|
|
|
//
|
|
// Tools ...
|
|
|
|
//
|
|
// Cleanup Model ...
|
|
void Clean()
|
|
{
|
|
//
|
|
width = 1;
|
|
clr = CLR_NONE;
|
|
style = STYLE_SOLID;
|
|
|
|
//
|
|
ZeroMemory(this);
|
|
}
|
|
|
|
//
|
|
// Default Props ...
|
|
void Default()
|
|
{
|
|
//
|
|
width = 1;
|
|
clr = CLR_NONE;
|
|
style = STYLE_SOLID;
|
|
}
|
|
};
|
|
|
|
//
|
|
// Implementations ...
|
|
class XCXCAEAPOIDrawer : public XCBase
|
|
{
|
|
//
|
|
// Public ...
|
|
public:
|
|
//
|
|
// Props ...
|
|
|
|
//
|
|
bool ignoreUpdateOSCTos;
|
|
|
|
//
|
|
// Drawers ...
|
|
bool drawPeakPivots;
|
|
bool drawValePivots;
|
|
bool drawFVGBullishPivots;
|
|
bool drawFVGBearishPivots;
|
|
bool drawTrendBullishPivots;
|
|
bool drawTrendBearishPivots;
|
|
|
|
//
|
|
// Styling ...
|
|
|
|
//
|
|
XCAPivotStyle defaultBullishStyle;
|
|
XCAPivotStyle defaultBearishStyle;
|
|
|
|
//
|
|
XCAPivotStyle peakPivotStyle;
|
|
XCAPivotStyle valePivotStyle;
|
|
|
|
//
|
|
XCAPivotStyle fvgBullishPivotStyle;
|
|
XCAPivotStyle fvgBearishPivotStyle;
|
|
|
|
//
|
|
XCAPivotStyle trendBullishPivotStyle;
|
|
XCAPivotStyle trendBearishPivotStyle;
|
|
|
|
//
|
|
// Constructors ...
|
|
XCXCAEAPOIDrawer(
|
|
XCXCAEAPOIDetector *_detector //
|
|
)
|
|
{
|
|
//
|
|
detector = _detector;
|
|
drawer = new XCPOIDrawer();
|
|
|
|
//
|
|
Default();
|
|
}
|
|
|
|
//
|
|
// De Constructors ...
|
|
~XCXCAEAPOIDrawer()
|
|
{
|
|
//
|
|
Clear();
|
|
|
|
//
|
|
ZeroMemory(drawer);
|
|
ZeroMemory(detector);
|
|
}
|
|
|
|
//
|
|
// Properties ...
|
|
|
|
//
|
|
// Tools ...
|
|
|
|
//
|
|
virtual void Default()
|
|
{
|
|
//
|
|
// Drawing ...
|
|
drawPeakPivots = false;
|
|
drawValePivots = false;
|
|
drawFVGBullishPivots = false;
|
|
drawFVGBearishPivots = false;
|
|
drawTrendBullishPivots = false;
|
|
drawTrendBearishPivots = false;
|
|
|
|
//
|
|
// Styling ...
|
|
|
|
//
|
|
// Bullish ...
|
|
defaultBullishStyle.width = 1;
|
|
defaultBullishStyle.clr = clrLime;
|
|
defaultBullishStyle.style = STYLE_SOLID;
|
|
|
|
//
|
|
// Bearish ...
|
|
defaultBearishStyle.width = 1;
|
|
defaultBearishStyle.clr = clrRed;
|
|
defaultBearishStyle.style = STYLE_SOLID;
|
|
|
|
//
|
|
// Pivots ...
|
|
|
|
//
|
|
// PV ...
|
|
peakPivotStyle = defaultBearishStyle;
|
|
valePivotStyle = defaultBullishStyle;
|
|
|
|
//
|
|
// FVG ...
|
|
fvgBullishPivotStyle = defaultBullishStyle;
|
|
fvgBearishPivotStyle = defaultBearishStyle;
|
|
|
|
//
|
|
// TREND ...
|
|
trendBullishPivotStyle = defaultBullishStyle;
|
|
trendBearishPivotStyle = defaultBearishStyle;
|
|
}
|
|
|
|
//
|
|
void Draw(datetime to = NULL)
|
|
{
|
|
//
|
|
// PV ...
|
|
DrawPeakPivots(to);
|
|
DrawValePivots(to);
|
|
|
|
//
|
|
// FVG ...
|
|
DrawFVGBullishPivots(to);
|
|
DrawFVGBearishPivots(to);
|
|
|
|
//
|
|
// TREND ...
|
|
DrawTrendBullishPivots(to);
|
|
DrawTrendBearishPivots(to);
|
|
}
|
|
|
|
//
|
|
void DrawBox(
|
|
XBoxZone &box,
|
|
datetime to = NULL //
|
|
)
|
|
{
|
|
//
|
|
bool has = box.IsValid();
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
//
|
|
// Detect Pivot Type ...
|
|
ENUM_XCA_PIVOTS iType = GetPivotType(box);
|
|
has = IsValid(iType);
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
switch (iType)
|
|
{
|
|
//
|
|
case XCA_PEAK:
|
|
//
|
|
DrawPeakPivot(
|
|
box,
|
|
to //
|
|
);
|
|
break;
|
|
|
|
//
|
|
case XCA_VALE:
|
|
//
|
|
DrawValePivot(
|
|
box,
|
|
to //
|
|
);
|
|
break;
|
|
|
|
//
|
|
case XCA_FVG_BULL:
|
|
//
|
|
DrawFVGBullishPivot(
|
|
box,
|
|
to //
|
|
);
|
|
break;
|
|
|
|
//
|
|
case XCA_FVG_BEAR:
|
|
//
|
|
DrawFVGBearishPivot(
|
|
box,
|
|
to //
|
|
);
|
|
break;
|
|
|
|
//
|
|
case XCA_TREND_BULL:
|
|
//
|
|
DrawTrendBullishPivot(
|
|
box,
|
|
to //
|
|
);
|
|
break;
|
|
|
|
//
|
|
case XCA_TREND_BEAR:
|
|
//
|
|
DrawTrendBearishPivot(
|
|
box,
|
|
to //
|
|
);
|
|
break;
|
|
}
|
|
}
|
|
|
|
//
|
|
void DrawBoxes(
|
|
XBoxZone &boxes[],
|
|
datetime to = NULL //
|
|
)
|
|
{
|
|
//
|
|
bool has = HasChild(boxes);
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
int count = ArraySize(boxes);
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XBoxZone iBox = boxes[i];
|
|
|
|
//
|
|
// Detect Pivot Type ...
|
|
DrawBox(
|
|
iBox,
|
|
to //
|
|
);
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
void Clear()
|
|
{
|
|
//
|
|
// Cleanup Models ...
|
|
defaultBullishStyle.Clean();
|
|
defaultBearishStyle.Clean();
|
|
|
|
//
|
|
// Cleanup Styles ...
|
|
peakPivotStyle.Clean();
|
|
valePivotStyle.Clean();
|
|
fvgBullishPivotStyle.Clean();
|
|
fvgBearishPivotStyle.Clean();
|
|
trendBullishPivotStyle.Clean();
|
|
trendBearishPivotStyle.Clean();
|
|
|
|
//
|
|
// Cleanup Pivot Objects Holder ...
|
|
mPeakPivotObjects.Clear();
|
|
mValePivotObjects.Clear();
|
|
mFVGBullishPivotObjects.Clear();
|
|
mFVGBearishPivotObjects.Clear();
|
|
mTrendBullishPivotObjects.Clear();
|
|
mTrendBearishPivotObjects.Clear();
|
|
}
|
|
|
|
//
|
|
// Collection Drawers ...
|
|
|
|
//
|
|
void DrawPeakPivots(datetime to = NULL)
|
|
{
|
|
//
|
|
bool has = drawPeakPivots;
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
has = detector.HasPeakPivots();
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
int count = detector.CountPeakPivots();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XBoxZone iBox = detector.peakPivots[i];
|
|
|
|
//
|
|
DrawPeakPivot(
|
|
iBox,
|
|
to //
|
|
);
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
void DrawValePivots(datetime to = NULL)
|
|
{
|
|
//
|
|
bool has = drawValePivots;
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
has = detector.HasValePivots();
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
int count = detector.CountValePivots();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XBoxZone iBox = detector.valePivots[i];
|
|
|
|
//
|
|
DrawValePivot(
|
|
iBox,
|
|
to //
|
|
);
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
void DrawFVGBullishPivots(datetime to = NULL)
|
|
{
|
|
//
|
|
bool has = drawFVGBullishPivots;
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
has = detector.HasFVGBullishPivots();
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
int count = detector.CountFVGBullishPivots();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XBoxZone iBox = detector.fvgBullishPivots[i];
|
|
|
|
//
|
|
DrawFVGBullishPivot(
|
|
iBox,
|
|
to //
|
|
);
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
void DrawFVGBearishPivots(datetime to = NULL)
|
|
{
|
|
//
|
|
bool has = drawFVGBearishPivots;
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
has = detector.HasFVGBearishPivots();
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
int count = detector.CountFVGBearishPivots();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XBoxZone iBox = detector.fvgBearishPivots[i];
|
|
|
|
//
|
|
DrawFVGBearishPivot(
|
|
iBox,
|
|
to //
|
|
);
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
void DrawTrendBullishPivots(datetime to = NULL)
|
|
{
|
|
//
|
|
bool has = drawTrendBullishPivots;
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
has = detector.HasTrendBullishPivots();
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
int count = detector.CountTrendBullishPivots();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XBoxZone iBox = detector.trendBullishPivots[i];
|
|
|
|
//
|
|
DrawTrendBullishPivot(
|
|
iBox,
|
|
to //
|
|
);
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
void DrawTrendBearishPivots(datetime to = NULL)
|
|
{
|
|
//
|
|
bool has = drawTrendBearishPivots;
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
has = detector.HasTrendBearishPivots();
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
int count = detector.CountTrendBearishPivots();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XBoxZone iBox = detector.trendBearishPivots[i];
|
|
|
|
//
|
|
DrawTrendBearishPivot(
|
|
iBox,
|
|
to //
|
|
);
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
// One Item Drawers ...
|
|
|
|
//
|
|
void DrawPeakPivot(
|
|
XBoxZone &item,
|
|
datetime to = NULL //
|
|
)
|
|
{
|
|
//
|
|
bool has = drawPeakPivots;
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
has = item.IsValid() &&
|
|
item.type == GetBoxType(XCA_PEAK) &&
|
|
item.dir == GetDirection(XCA_PEAK);
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
bool canUpdateTo = IsValid(to);
|
|
if (canUpdateTo)
|
|
{
|
|
item.to = to;
|
|
}
|
|
|
|
//
|
|
XCBoxObject *iObj;
|
|
has = drawer.DrawBox(
|
|
item,
|
|
iObj //
|
|
);
|
|
if (has)
|
|
{
|
|
//
|
|
// Style Object ...
|
|
ApplyPivotStyle(
|
|
iObj,
|
|
peakPivotStyle //
|
|
);
|
|
|
|
//
|
|
// Store Object ...
|
|
mPeakPivotObjects.Add(iObj);
|
|
}
|
|
|
|
//
|
|
ZeroMemory(iObj);
|
|
}
|
|
|
|
//
|
|
void DrawValePivot(
|
|
XBoxZone &item,
|
|
datetime to = NULL //
|
|
)
|
|
{
|
|
//
|
|
bool has = drawValePivots;
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
has = item.IsValid() &&
|
|
item.type == GetBoxType(XCA_VALE) &&
|
|
item.dir == GetDirection(XCA_VALE);
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
bool canUpdateTo = IsValid(to);
|
|
if (canUpdateTo)
|
|
{
|
|
item.to = to;
|
|
}
|
|
|
|
//
|
|
XCBoxObject *iObj;
|
|
has = drawer.DrawBox(
|
|
item,
|
|
iObj //
|
|
);
|
|
if (has)
|
|
{
|
|
//
|
|
// Style Object ...
|
|
ApplyPivotStyle(
|
|
iObj,
|
|
valePivotStyle //
|
|
);
|
|
|
|
//
|
|
// Store Object ...
|
|
mValePivotObjects.Add(iObj);
|
|
}
|
|
|
|
//
|
|
ZeroMemory(iObj);
|
|
}
|
|
|
|
//
|
|
void DrawFVGBullishPivot(
|
|
XBoxZone &item,
|
|
datetime to = NULL //
|
|
)
|
|
{
|
|
//
|
|
bool has = drawFVGBullishPivots;
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
has = item.IsValid() &&
|
|
item.type == GetBoxType(XCA_FVG_BULL) &&
|
|
item.dir == GetDirection(XCA_FVG_BULL);
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
bool canUpdateTo = IsValid(to);
|
|
if (canUpdateTo)
|
|
{
|
|
item.to = to;
|
|
}
|
|
|
|
//
|
|
XCBoxObject *iObj;
|
|
has = drawer.DrawBox(
|
|
item,
|
|
iObj //
|
|
);
|
|
if (has)
|
|
{
|
|
//
|
|
// Style Object ...
|
|
ApplyPivotStyle(
|
|
iObj,
|
|
fvgBullishPivotStyle //
|
|
);
|
|
|
|
//
|
|
// Store Object ...
|
|
mFVGBullishPivotObjects.Add(iObj);
|
|
}
|
|
|
|
//
|
|
ZeroMemory(iObj);
|
|
}
|
|
|
|
//
|
|
void DrawFVGBearishPivot(
|
|
XBoxZone &item,
|
|
datetime to = NULL //
|
|
)
|
|
{
|
|
//
|
|
bool has = drawFVGBearishPivots;
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
has = item.IsValid() &&
|
|
item.type == GetBoxType(XCA_FVG_BEAR) &&
|
|
item.dir == GetDirection(XCA_FVG_BEAR);
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
bool canUpdateTo = IsValid(to);
|
|
if (canUpdateTo)
|
|
{
|
|
item.to = to;
|
|
}
|
|
|
|
//
|
|
XCBoxObject *iObj;
|
|
has = drawer.DrawBox(
|
|
item,
|
|
iObj //
|
|
);
|
|
if (has)
|
|
{
|
|
//
|
|
// Style Object ...
|
|
ApplyPivotStyle(
|
|
iObj,
|
|
fvgBearishPivotStyle //
|
|
);
|
|
|
|
//
|
|
// Store Object ...
|
|
mFVGBearishPivotObjects.Add(iObj);
|
|
}
|
|
|
|
//
|
|
ZeroMemory(iObj);
|
|
}
|
|
|
|
//
|
|
void DrawTrendBullishPivot(
|
|
XBoxZone &item,
|
|
datetime to = NULL //
|
|
)
|
|
{
|
|
//
|
|
bool has = drawTrendBullishPivots;
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
has = item.IsValid() &&
|
|
item.type == GetBoxType(XCA_TREND_BULL) &&
|
|
item.dir == GetDirection(XCA_TREND_BULL);
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
bool canUpdateTo = IsValid(to);
|
|
if (canUpdateTo)
|
|
{
|
|
item.to = to;
|
|
}
|
|
|
|
//
|
|
XCBoxObject *iObj;
|
|
has = drawer.DrawBox(
|
|
item,
|
|
iObj //
|
|
);
|
|
if (has)
|
|
{
|
|
//
|
|
// Style Object ...
|
|
ApplyPivotStyle(
|
|
iObj,
|
|
trendBullishPivotStyle //
|
|
);
|
|
|
|
//
|
|
// Store Object ...
|
|
mTrendBullishPivotObjects.Add(iObj);
|
|
}
|
|
|
|
//
|
|
ZeroMemory(iObj);
|
|
}
|
|
|
|
//
|
|
void DrawTrendBearishPivot(
|
|
XBoxZone &item,
|
|
datetime to = NULL //
|
|
)
|
|
{
|
|
//
|
|
bool has = drawTrendBearishPivots;
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
has = item.IsValid() &&
|
|
item.type == GetBoxType(XCA_TREND_BEAR) &&
|
|
item.dir == GetDirection(XCA_TREND_BEAR);
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
bool canUpdateTo = IsValid(to);
|
|
if (canUpdateTo)
|
|
{
|
|
item.to = to;
|
|
}
|
|
|
|
//
|
|
XCBoxObject *iObj;
|
|
has = drawer.DrawBox(
|
|
item,
|
|
iObj //
|
|
);
|
|
if (has)
|
|
{
|
|
//
|
|
// Style Object ...
|
|
ApplyPivotStyle(
|
|
iObj,
|
|
trendBearishPivotStyle //
|
|
);
|
|
|
|
//
|
|
// Store Object ...
|
|
mTrendBearishPivotObjects.Add(iObj);
|
|
}
|
|
|
|
//
|
|
ZeroMemory(iObj);
|
|
}
|
|
|
|
//
|
|
// Protected ...
|
|
protected:
|
|
//
|
|
// Props ...
|
|
|
|
//
|
|
void ApplyPivotStyle(
|
|
XCBoxObject *&object,
|
|
XCAPivotStyle &style //
|
|
)
|
|
{
|
|
//
|
|
if (object == NULL)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
object.BoxColor(style.clr);
|
|
object.BoxWidth(style.width);
|
|
object.BoxStyle(style.style);
|
|
}
|
|
|
|
//
|
|
// Prrivate ...
|
|
private:
|
|
//
|
|
// Props ...
|
|
|
|
//
|
|
XCPOIDrawer *drawer;
|
|
XCXCAEAPOIDetector *detector;
|
|
|
|
//
|
|
CArrayObj mPeakPivotObjects;
|
|
CArrayObj mValePivotObjects;
|
|
|
|
//
|
|
CArrayObj mFVGBullishPivotObjects;
|
|
CArrayObj mFVGBearishPivotObjects;
|
|
|
|
//
|
|
CArrayObj mTrendBullishPivotObjects;
|
|
CArrayObj mTrendBearishPivotObjects;
|
|
|
|
//
|
|
};
|
|
|
|
// |