775 lines
19 KiB
Plaintext
775 lines
19 KiB
Plaintext
///////////////////////////////////////////////////////
|
|
//
|
|
// SaherElm IT Center MQL5 Class
|
|
// -------------------------------------------------
|
|
// Name: XCXFIMAPoiDrawer ...
|
|
// Description: XFIMA 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 XFIMA POI Drawer Class"
|
|
#property strict
|
|
|
|
//
|
|
// Imports ...
|
|
#include "../../Classes/x-saherelm.x-poi.drawer.class.mq5"
|
|
#include "../Libraries/x-saherelm.xfima.lib.mq5"
|
|
|
|
//
|
|
// Implementation ...
|
|
class XCXFIMAPOIDrawer : public XCPOIDrawer
|
|
{
|
|
//
|
|
public:
|
|
//
|
|
|
|
//
|
|
// Get Specified Directional Arrow Anchor ...
|
|
ENUM_ARROW_ANCHOR GetArrowAnchor(ENUM_X_DIRECTION forDir)
|
|
{
|
|
//
|
|
ENUM_ARROW_ANCHOR result = ANCHOR_BOTTOM;
|
|
|
|
//
|
|
if (HasDirection(forDir))
|
|
{
|
|
//
|
|
result =
|
|
IsSpecifiedBullish(forDir)
|
|
? ANCHOR_TOP
|
|
: ANCHOR_BOTTOM;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Get Specified Directional Arrow Code ...
|
|
int GetArrowCode(ENUM_X_DIRECTION forDir)
|
|
{
|
|
//
|
|
int result = 159;
|
|
|
|
//
|
|
if (HasDirection(forDir))
|
|
{
|
|
//
|
|
result =
|
|
IsSpecifiedBullish(forDir)
|
|
? 233
|
|
: 234;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Get Specified Directional Arrow Code ...
|
|
color GetArrowColor(ENUM_X_DIRECTION forDir)
|
|
{
|
|
//
|
|
color result = clrYellow;
|
|
|
|
//
|
|
if (HasDirection(forDir))
|
|
{
|
|
//
|
|
result =
|
|
IsSpecifiedBullish(forDir)
|
|
? clrAqua
|
|
: clrMagenta;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Get Specified Directional Arrow Price Type ...
|
|
ENUM_X_PRICE GetArrowPriceType(ENUM_X_DIRECTION forDir)
|
|
{
|
|
//
|
|
ENUM_X_PRICE result = X_PRICE_CLOSE;
|
|
|
|
//
|
|
if (HasDirection(forDir))
|
|
{
|
|
//
|
|
result =
|
|
IsSpecifiedBullish(forDir)
|
|
? X_PRICE_LOW
|
|
: X_PRICE_HIGH;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Fill Arrow Based Drawing Specs ...
|
|
*
|
|
* @param forDir: Specified Direction ...
|
|
* @param arrowPriceType: ENUM_X_PRICE, refrence for Arrow Price ...
|
|
* @param arrowCode: int, reference for Arrow Code ...
|
|
* @param arrowWidth: int, reference for Arrow Width ...
|
|
* @param arrowColor: color, reference for Arrow Color ...
|
|
* @param arrowAnchor: ENUM_ARROW_ANCHOR, reference for Arrow Anchor ...
|
|
*/
|
|
void FillArrowSpecs(
|
|
ENUM_X_DIRECTION forDir,
|
|
ENUM_X_PRICE &arrowPriceType,
|
|
int &arrowCode,
|
|
int &arrowWidth,
|
|
color &arrowColor,
|
|
ENUM_ARROW_ANCHOR &arrowAnchor //
|
|
)
|
|
{
|
|
//
|
|
// Prepare ...
|
|
arrowCode = 159;
|
|
arrowWidth = 3;
|
|
arrowColor = CLR_NONE;
|
|
arrowAnchor = ANCHOR_BOTTOM;
|
|
arrowPriceType = X_PRICE_CLOSE;
|
|
|
|
//
|
|
if (HasDirection(forDir))
|
|
{
|
|
//
|
|
arrowCode = GetArrowCode(forDir);
|
|
arrowColor = GetArrowColor(forDir);
|
|
arrowAnchor = GetArrowAnchor(forDir);
|
|
arrowPriceType = GetArrowPriceType(forDir);
|
|
}
|
|
}
|
|
|
|
int DrawMarketStructure(
|
|
XFIMAMarketStructure &structure,
|
|
XFIMAMarketStructureDrawerConfig &config,
|
|
CArrayObj *&objects //
|
|
)
|
|
{
|
|
//
|
|
int result = 0;
|
|
|
|
//
|
|
// Normalize ...
|
|
if (objects == NULL)
|
|
{
|
|
objects = new CArrayObj();
|
|
}
|
|
|
|
//
|
|
// Prepare ...
|
|
objects.Clear();
|
|
|
|
//
|
|
bool has = false;
|
|
int arrowCode = -1;
|
|
int arrowWidth = 3;
|
|
string arrowName = NULL;
|
|
color arrowColor = CLR_NONE;
|
|
ENUM_X_PRICE arrowPriceType = X_PRICE_CLOSE;
|
|
ENUM_ARROW_ANCHOR arrowAnchor = ANCHOR_BOTTOM;
|
|
|
|
//
|
|
int bullArrowCode = GetArrowCode(X_DIRECTION_BULLISH);
|
|
int bearArrowCode = GetArrowCode(X_DIRECTION_BEARISH);
|
|
|
|
//
|
|
// Validate ...
|
|
has = structure.bar.IsValid();
|
|
if (!has)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Apply Drawing Methods ...
|
|
|
|
//
|
|
// OB ...
|
|
if (config.drawOB)
|
|
{
|
|
//
|
|
// Validate ...
|
|
has = structure.ob.IsValid();
|
|
if (has)
|
|
{
|
|
//
|
|
XCBoxObject *iObj;
|
|
has = DrawBox(
|
|
structure.ob,
|
|
iObj //
|
|
);
|
|
if (has)
|
|
{
|
|
objects.Add(iObj);
|
|
}
|
|
|
|
//
|
|
ZeroMemory(iObj);
|
|
}
|
|
}
|
|
|
|
//
|
|
// FVG ...
|
|
if (config.drawFVG)
|
|
{
|
|
//
|
|
// Validate ...
|
|
has = structure.fvg.IsValid();
|
|
if (has)
|
|
{
|
|
//
|
|
XCBoxObject *iObj;
|
|
has = DrawBox(
|
|
structure.fvg,
|
|
iObj //
|
|
);
|
|
if (has)
|
|
{
|
|
objects.Add(iObj);
|
|
}
|
|
|
|
//
|
|
ZeroMemory(iObj);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Support ...
|
|
if (config.drawSupports)
|
|
{
|
|
//
|
|
// Validate ...
|
|
has = structure.support.IsValid();
|
|
if (has)
|
|
{
|
|
//
|
|
XCBoxObject *iObj;
|
|
has = DrawBox(
|
|
structure.support,
|
|
iObj //
|
|
);
|
|
if (has)
|
|
{
|
|
objects.Add(iObj);
|
|
}
|
|
|
|
//
|
|
ZeroMemory(iObj);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Resistance ...
|
|
if (config.drawResistance)
|
|
{
|
|
//
|
|
// Validate ...
|
|
has = structure.resistance.IsValid();
|
|
if (has)
|
|
{
|
|
//
|
|
XCBoxObject *iObj;
|
|
has = DrawBox(
|
|
structure.resistance,
|
|
iObj //
|
|
);
|
|
if (has)
|
|
{
|
|
objects.Add(iObj);
|
|
}
|
|
|
|
//
|
|
ZeroMemory(iObj);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Swing Trend ...
|
|
if (config.drawSwingTrend)
|
|
{
|
|
//
|
|
// Validate ...
|
|
has = HasDirection(structure.trendDir) &&
|
|
HasChild(structure.trendSwings);
|
|
if (has)
|
|
{
|
|
//
|
|
CChartObjectTrend *iObj;
|
|
has = DrawSwingTrend(
|
|
structure.trendSwings,
|
|
structure.trendDir,
|
|
iObj, //
|
|
true, // Ray Right ...
|
|
false // Ray Left ...
|
|
);
|
|
if (has)
|
|
{
|
|
objects.Add(iObj);
|
|
}
|
|
|
|
//
|
|
ZeroMemory(iObj);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Start Pattern ...
|
|
if (config.drawStarPattern)
|
|
{
|
|
//
|
|
// Validate ...
|
|
has = HasDirection(structure.starPatternDir);
|
|
if (has)
|
|
{
|
|
//
|
|
FillArrowSpecs(
|
|
structure.starPatternDir,
|
|
arrowPriceType,
|
|
arrowCode,
|
|
arrowWidth,
|
|
arrowColor,
|
|
arrowAnchor //
|
|
);
|
|
XCBarArrowObject *iObj;
|
|
arrowName = "XStar_" + ToMD5(structure.bar.time);
|
|
has = DrawBarArrow(
|
|
structure.bar,
|
|
iObj,
|
|
arrowPriceType,
|
|
arrowCode,
|
|
arrowColor,
|
|
arrowWidth,
|
|
arrowAnchor,
|
|
arrowName //
|
|
);
|
|
if (has)
|
|
{
|
|
objects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Flag Pattern ...
|
|
if (config.drawFlagPattern)
|
|
{
|
|
//
|
|
// Validate ...
|
|
has = HasDirection(structure.flagPatternDir) &&
|
|
structure.flagSwing.IsValid();
|
|
if (has)
|
|
{
|
|
//
|
|
FillArrowSpecs(
|
|
structure.flagPatternDir,
|
|
arrowPriceType,
|
|
arrowCode,
|
|
arrowWidth,
|
|
arrowColor,
|
|
arrowAnchor //
|
|
);
|
|
XCBarArrowObject *iObj;
|
|
arrowName = "XFlag_" + ToMD5(structure.bar.time);
|
|
has = DrawBarArrow(
|
|
structure.bar,
|
|
iObj,
|
|
arrowPriceType,
|
|
arrowCode,
|
|
arrowColor,
|
|
arrowWidth,
|
|
arrowAnchor,
|
|
arrowName //
|
|
);
|
|
if (has)
|
|
{
|
|
objects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Rising Pattern ...
|
|
if (config.drawRisingPattern)
|
|
{
|
|
//
|
|
// Validate ...
|
|
has = HasDirection(structure.risingPatternDir);
|
|
if (has)
|
|
{
|
|
//
|
|
FillArrowSpecs(
|
|
structure.risingPatternDir,
|
|
arrowPriceType,
|
|
arrowCode,
|
|
arrowWidth,
|
|
arrowColor,
|
|
arrowAnchor //
|
|
);
|
|
XCBarArrowObject *iObj;
|
|
arrowName = "XRise_" + ToMD5(structure.bar.time);
|
|
has = DrawBarArrow(
|
|
structure.bar,
|
|
iObj,
|
|
arrowPriceType,
|
|
arrowCode,
|
|
arrowColor,
|
|
arrowWidth,
|
|
arrowAnchor,
|
|
arrowName //
|
|
);
|
|
if (has)
|
|
{
|
|
objects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Piercing Pattern ...
|
|
if (config.drawPiercingPattern)
|
|
{
|
|
//
|
|
// Validate ...
|
|
has = HasDirection(structure.piercingPatternDir);
|
|
if (has)
|
|
{
|
|
//
|
|
FillArrowSpecs(
|
|
structure.piercingPatternDir,
|
|
arrowPriceType,
|
|
arrowCode,
|
|
arrowWidth,
|
|
arrowColor,
|
|
arrowAnchor //
|
|
);
|
|
XCBarArrowObject *iObj;
|
|
arrowName = "XPiercing_" + ToMD5(structure.bar.time);
|
|
has = DrawBarArrow(
|
|
structure.bar,
|
|
iObj,
|
|
arrowPriceType,
|
|
arrowCode,
|
|
arrowColor,
|
|
arrowWidth,
|
|
arrowAnchor,
|
|
arrowName //
|
|
);
|
|
if (has)
|
|
{
|
|
objects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Signal Key Bar Pattern ...
|
|
if (config.drawSignalKeyBarPattern)
|
|
{
|
|
//
|
|
// Validate ...
|
|
has = HasDirection(structure.signalKeyBarPatternDir);
|
|
if (has)
|
|
{
|
|
//
|
|
FillArrowSpecs(
|
|
structure.signalKeyBarPatternDir,
|
|
arrowPriceType,
|
|
arrowCode,
|
|
arrowWidth,
|
|
arrowColor,
|
|
arrowAnchor //
|
|
);
|
|
XCBarArrowObject *iObj;
|
|
arrowName = "XSignalKey_" + ToMD5(structure.bar.time);
|
|
has = DrawBarArrow(
|
|
structure.bar,
|
|
iObj,
|
|
arrowPriceType,
|
|
arrowCode,
|
|
arrowColor,
|
|
arrowWidth,
|
|
arrowAnchor,
|
|
arrowName //
|
|
);
|
|
if (has)
|
|
{
|
|
objects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Pinned Bar ...
|
|
if (config.drawPinned)
|
|
{
|
|
//
|
|
// Validate ...
|
|
has = HasDirection(structure.pinnedDir);
|
|
if (has)
|
|
{
|
|
//
|
|
FillArrowSpecs(
|
|
structure.pinnedDir,
|
|
arrowPriceType,
|
|
arrowCode,
|
|
arrowWidth,
|
|
arrowColor,
|
|
arrowAnchor //
|
|
);
|
|
XCBarArrowObject *iObj;
|
|
arrowName = "XPin_" + ToMD5(structure.bar.time);
|
|
has = DrawBarArrow(
|
|
structure.bar,
|
|
iObj,
|
|
arrowPriceType,
|
|
arrowCode,
|
|
arrowColor,
|
|
arrowWidth,
|
|
arrowAnchor,
|
|
arrowName //
|
|
);
|
|
if (has)
|
|
{
|
|
objects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Momentum Bar ...
|
|
if (config.drawMomentum)
|
|
{
|
|
//
|
|
// Validate ...
|
|
has = HasDirection(structure.momentumDir);
|
|
if (has)
|
|
{
|
|
//
|
|
FillArrowSpecs(
|
|
structure.momentumDir,
|
|
arrowPriceType,
|
|
arrowCode,
|
|
arrowWidth,
|
|
arrowColor,
|
|
arrowAnchor //
|
|
);
|
|
XCBarArrowObject *iObj;
|
|
arrowName = "XMomentum_" + ToMD5(structure.bar.time);
|
|
has = DrawBarArrow(
|
|
structure.bar,
|
|
iObj,
|
|
arrowPriceType,
|
|
arrowCode,
|
|
arrowColor,
|
|
arrowWidth,
|
|
arrowAnchor,
|
|
arrowName //
|
|
);
|
|
if (has)
|
|
{
|
|
objects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Engulfed Bar ...
|
|
if (config.drawEngulfed)
|
|
{
|
|
//
|
|
// Validate ...
|
|
has = HasDirection(structure.engulfedDir);
|
|
if (has)
|
|
{
|
|
//
|
|
FillArrowSpecs(
|
|
structure.engulfedDir,
|
|
arrowPriceType,
|
|
arrowCode,
|
|
arrowWidth,
|
|
arrowColor,
|
|
arrowAnchor //
|
|
);
|
|
XCBarArrowObject *iObj;
|
|
arrowName = "XEngulf_" + ToMD5(structure.bar.time);
|
|
has = DrawBarArrow(
|
|
structure.bar,
|
|
iObj,
|
|
arrowPriceType,
|
|
arrowCode,
|
|
arrowColor,
|
|
arrowWidth,
|
|
arrowAnchor,
|
|
arrowName //
|
|
);
|
|
if (has)
|
|
{
|
|
objects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// True Gaped Bar ...
|
|
if (config.drawTrueGaped)
|
|
{
|
|
//
|
|
// Validate ...
|
|
has = HasDirection(structure.trueGapedDir);
|
|
if (has)
|
|
{
|
|
//
|
|
FillArrowSpecs(
|
|
structure.trueGapedDir,
|
|
arrowPriceType,
|
|
arrowCode,
|
|
arrowWidth,
|
|
arrowColor,
|
|
arrowAnchor //
|
|
);
|
|
XCBarArrowObject *iObj;
|
|
arrowName = "XTrueGap_" + ToMD5(structure.bar.time);
|
|
has = DrawBarArrow(
|
|
structure.bar,
|
|
iObj,
|
|
arrowPriceType,
|
|
arrowCode,
|
|
arrowColor,
|
|
arrowWidth,
|
|
arrowAnchor,
|
|
arrowName //
|
|
);
|
|
if (has)
|
|
{
|
|
objects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// XFIMA PV Analysis ...
|
|
if (config.drawFIMAPVPivotsAnalysis)
|
|
{
|
|
//
|
|
// Validate ...
|
|
has = structure.pvAnalysis.IsValid();
|
|
if (has)
|
|
{
|
|
//
|
|
XCPivotAnalysisObject *iObj;
|
|
has = DrawPivotAnalysis(
|
|
structure.pvAnalysis,
|
|
iObj,
|
|
config.drawFIMAPVPivotsAnalysisPivots,
|
|
bearArrowCode,
|
|
bullArrowCode //
|
|
);
|
|
if (has)
|
|
{
|
|
objects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// XFIMA MA Analysis ...
|
|
if (config.drawFIMAMAPivotsAnalysis)
|
|
{
|
|
//
|
|
// Validate ...
|
|
has = structure.maAnalysis.IsValid();
|
|
if (has)
|
|
{
|
|
//
|
|
XCPivotAnalysisObject *iObj;
|
|
has = DrawPivotAnalysis(
|
|
structure.pvAnalysis,
|
|
iObj,
|
|
config.drawFIMAMAPivotsAnalysisPivots,
|
|
bearArrowCode,
|
|
bullArrowCode //
|
|
);
|
|
if (has)
|
|
{
|
|
objects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// XFIMA Sar Analysis ...
|
|
if (config.drawFIMASARPivotsAnalysis)
|
|
{
|
|
//
|
|
// Validate ...
|
|
has = structure.sarAnalysis.IsValid();
|
|
if (has)
|
|
{
|
|
//
|
|
XCPivotAnalysisObject *iObj;
|
|
has = DrawPivotAnalysis(
|
|
structure.pvAnalysis,
|
|
iObj,
|
|
config.drawFIMASARPivotsAnalysisPivots,
|
|
bearArrowCode,
|
|
bullArrowCode //
|
|
);
|
|
if (has)
|
|
{
|
|
objects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// XFIMA ZigZag Analysis ...
|
|
if (config.drawFIMAZigZagPivotsAnalysis)
|
|
{
|
|
//
|
|
// Validate ...
|
|
has = structure.zigzagAnalysis.IsValid();
|
|
if (has)
|
|
{
|
|
//
|
|
XCPivotAnalysisObject *iObj;
|
|
has = DrawPivotAnalysis(
|
|
structure.pvAnalysis,
|
|
iObj,
|
|
config.drawFIMAZigZagPivotsAnalysisPivots,
|
|
bearArrowCode,
|
|
bullArrowCode //
|
|
);
|
|
if (has)
|
|
{
|
|
objects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
result = objects.Total();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
};
|
|
|
|
// |