- Expert Class; - Class Based EA; - Signaller(s); - Multi Symbol; - Multi Session; - ...
604 lines
11 KiB
Plaintext
604 lines
11 KiB
Plaintext
///////////////////////////////////////////////////////
|
|
//
|
|
// SaherElm IT Center MQL5 Class
|
|
// -------------------------------------------------
|
|
// Name: XCXCATBEAPOIDrawer ...
|
|
// Description: XCATBEA POI Drawer Class
|
|
//
|
|
//
|
|
// 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 XCATBEA POI Drawer Class"
|
|
#property strict
|
|
|
|
//
|
|
// Imports ...
|
|
#include "../../Classes/x-saherelm.x-poi.drawer.class.mq5"
|
|
#include "../Classes/xcatbea.x-poi.detector.class.mq5"
|
|
|
|
//
|
|
// Definitions ...
|
|
struct XCATBPivotStyle
|
|
{
|
|
//
|
|
// Properties ...
|
|
int width;
|
|
color clr;
|
|
ENUM_LINE_STYLE style;
|
|
|
|
//
|
|
// Constructor ...
|
|
XCATBPivotStyle()
|
|
{
|
|
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 XCXCATBEAPOIDrawer : public XCBase
|
|
{
|
|
//
|
|
// Public ...
|
|
public:
|
|
//
|
|
// Props ...
|
|
XCPOIDrawer *drawer;
|
|
|
|
//
|
|
// Drawers ...
|
|
bool drawPeakPivots;
|
|
bool drawValePivots;
|
|
|
|
//
|
|
// Styling ...
|
|
|
|
//
|
|
XCATBPivotStyle defaultBullishStyle;
|
|
XCATBPivotStyle defaultBearishStyle;
|
|
|
|
//
|
|
XCATBPivotStyle peakPivotStyle;
|
|
XCATBPivotStyle valePivotStyle;
|
|
|
|
//
|
|
// Constructors ...
|
|
XCXCATBEAPOIDrawer(
|
|
XCXCATBEAPOIDetector *_detector //
|
|
)
|
|
{
|
|
//
|
|
detector = _detector;
|
|
drawer = new XCPOIDrawer();
|
|
|
|
//
|
|
Default();
|
|
}
|
|
|
|
//
|
|
// De Constructors ...
|
|
~XCXCATBEAPOIDrawer()
|
|
{
|
|
//
|
|
Clear();
|
|
|
|
//
|
|
delete drawer;
|
|
ZeroMemory(drawer);
|
|
|
|
//
|
|
ZeroMemory(detector);
|
|
}
|
|
|
|
//
|
|
// Properties ...
|
|
|
|
//
|
|
// Tools ...
|
|
|
|
//
|
|
virtual void Default()
|
|
{
|
|
//
|
|
// Drawing ...
|
|
drawPeakPivots = false;
|
|
drawValePivots = 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;
|
|
}
|
|
|
|
//
|
|
void Draw(datetime to = NULL)
|
|
{
|
|
//
|
|
// PV ...
|
|
DrawPeakPivots(to);
|
|
DrawValePivots(to);
|
|
}
|
|
|
|
//
|
|
void DrawPivot(
|
|
XBoxZone &pivot,
|
|
datetime to = NULL //
|
|
)
|
|
{
|
|
//
|
|
DrawBox(
|
|
pivot,
|
|
to,
|
|
false,
|
|
false //
|
|
);
|
|
}
|
|
|
|
//
|
|
void DrawBox(
|
|
XBoxZone &box,
|
|
datetime to = NULL,
|
|
bool drawMiddle = false,
|
|
bool ignoreType = false //
|
|
)
|
|
{
|
|
//
|
|
bool has = box.IsValid();
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
bool canUpdateTo = IsValid(to);
|
|
if (canUpdateTo)
|
|
{
|
|
box.to = to;
|
|
}
|
|
|
|
//
|
|
// Draw Box as POI ...
|
|
if (!ignoreType)
|
|
{
|
|
//
|
|
// Detect Pivot Type ...
|
|
ENUM_XCATB_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;
|
|
}
|
|
}
|
|
//
|
|
// Draw Regular Box ...
|
|
else
|
|
{
|
|
//
|
|
// Select Styling Config ...
|
|
XCATBPivotStyle style;
|
|
|
|
//
|
|
if (box.IsBullish())
|
|
{
|
|
style = defaultBullishStyle;
|
|
}
|
|
else
|
|
{
|
|
style = defaultBearishStyle;
|
|
}
|
|
|
|
//
|
|
// Draw Box itself ...
|
|
XCBoxObject *iBoxObj;
|
|
has = drawer.DrawBox(
|
|
box,
|
|
iBoxObj //
|
|
);
|
|
if (has)
|
|
{
|
|
//
|
|
// Style Object ...
|
|
ApplyPivotStyle(
|
|
iBoxObj,
|
|
style //
|
|
);
|
|
|
|
//
|
|
// Store Object ...
|
|
mObjects.Add(iBoxObj);
|
|
}
|
|
|
|
//
|
|
// Draw Box Middle Range ...
|
|
if (drawMiddle)
|
|
{
|
|
//
|
|
double middle = box.GetMid();
|
|
string middleName = box.GetMiddleTag();
|
|
|
|
//
|
|
CChartObjectTrend *iMidObj;
|
|
iMidObj = new CChartObjectTrend();
|
|
has = iMidObj.Create(
|
|
drawer.ChartIdentification(),
|
|
middleName,
|
|
drawer.SubWindowIdentification(),
|
|
box.from,
|
|
middle,
|
|
box.to,
|
|
middle //
|
|
);
|
|
if (has)
|
|
{
|
|
//
|
|
// Styling Object ...
|
|
iMidObj.Color(style.clr);
|
|
iMidObj.Width(style.width);
|
|
iMidObj.Style(style.style);
|
|
|
|
//
|
|
// Store Object ...
|
|
mObjects.Add(iMidObj);
|
|
}
|
|
}
|
|
|
|
//
|
|
style.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
void DrawBoxes(
|
|
XBoxZone &boxes[],
|
|
datetime to = NULL,
|
|
bool drawMiddle = false,
|
|
bool ignoreType = false //
|
|
)
|
|
{
|
|
//
|
|
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,
|
|
drawMiddle,
|
|
ignoreType //
|
|
);
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
void Clear()
|
|
{
|
|
//
|
|
// Cleanup Models ...
|
|
defaultBullishStyle.Clean();
|
|
defaultBearishStyle.Clean();
|
|
|
|
//
|
|
// Cleanup Styles ...
|
|
peakPivotStyle.Clean();
|
|
valePivotStyle.Clean();
|
|
|
|
//
|
|
// Cleanup Pivot Objects Holder ...
|
|
mObjects.Clear();
|
|
mPeakPivotObjects.Clear();
|
|
mValePivotObjects.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();
|
|
}
|
|
}
|
|
|
|
//
|
|
// 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);
|
|
}
|
|
|
|
//
|
|
// Protected ...
|
|
protected:
|
|
//
|
|
// Props ...
|
|
|
|
//
|
|
void ApplyPivotStyle(
|
|
XCBoxObject *&object,
|
|
XCATBPivotStyle &style //
|
|
)
|
|
{
|
|
//
|
|
if (object == NULL)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
object.BoxColor(style.clr);
|
|
object.BoxWidth(style.width);
|
|
object.BoxStyle(style.style);
|
|
}
|
|
|
|
//
|
|
// Prrivate ...
|
|
private:
|
|
//
|
|
// Props ...
|
|
XCXCATBEAPOIDetector *detector;
|
|
|
|
//
|
|
CArrayObj mObjects;
|
|
|
|
//
|
|
CArrayObj mPeakPivotObjects;
|
|
CArrayObj mValePivotObjects;
|
|
|
|
//
|
|
};
|
|
|
|
// |