add POI Detector and Drawer for XCATB classes ...
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Indicator
|
||||
// SaherElm IT Center MQL5 Class
|
||||
// -------------------------------------------------
|
||||
// Name: XCXCATBEASignaller ...
|
||||
// Description: Class for XCATBEA Signaller ...
|
||||
@@ -17,16 +17,22 @@
|
||||
#property copyright "Copyright 2023, SaherElm IT Center"
|
||||
#property link "https://saherelm.ir"
|
||||
#property version "1.00"
|
||||
#property description "SaherElm Class for XCATBEA Signaller"
|
||||
#property description "SaherElm XCXCATBEASignaller Class"
|
||||
#property strict
|
||||
|
||||
//
|
||||
// Imports ...
|
||||
#include "../../Classes/x-saherelm.x-alert.class.mq5"
|
||||
#include "../../Classes/x-saherelm.x-bar.analyser.class.mq5"
|
||||
#include "../../Helpers/x-saherelm.x121.xcatb.helper.mq5";
|
||||
#include "../Classes/xcatbea.x-poi.detector.class.mq5";
|
||||
#include "../Classes/xcatbea.x-poi.drawer.class.mq5";
|
||||
#include "../Libraries/xcatbea.lib.mq5";
|
||||
#include "../Libraries/xcatbea.signaller.lib.mq5";
|
||||
#include "../Libraries/xcatbea.x-poi.extensions.lib.mq5";
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
class XCXCATBEASignaller : XCBase
|
||||
class XCXCATBEASignaller : XCBaseAlert
|
||||
{
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,604 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 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 XCXCATBEAPOIDrawer : public XCBase
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
XCPOIDrawer *drawer;
|
||||
|
||||
//
|
||||
// Drawers ...
|
||||
bool drawPeakPivots;
|
||||
bool drawValePivots;
|
||||
|
||||
//
|
||||
// Styling ...
|
||||
|
||||
//
|
||||
XCAPivotStyle defaultBullishStyle;
|
||||
XCAPivotStyle defaultBearishStyle;
|
||||
|
||||
//
|
||||
XCAPivotStyle peakPivotStyle;
|
||||
XCAPivotStyle 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 ...
|
||||
XCAPivotStyle 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,
|
||||
XCAPivotStyle &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;
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
//
|
||||
Reference in New Issue
Block a user