Files
MQL5Data/X121XKIEA/Classes/x-saherelm.x121.xki.x-poi.drawer.class.mq5
T
2025-12-30 21:38:58 +03:30

707 lines
14 KiB
Plaintext

///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Class
// -------------------------------------------------
// Name: XCX121XKIPoiDrawer ...
// Description: X121XKI 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 X121XKI POI Drawer Class"
#property strict
//
// Imports ...
#include "../../Classes/x-saherelm.x-poi.drawer.class.mq5"
//
// Implementation ...
class XCX121XKIPOIDrawer : public XCPOIDrawer
{
//
public:
//
// Props ...
//
// Tested Zones ...
color testedBullishColor;
color testedBearishColor;
//
// Breaked Zones ...
color breakedBullishColor;
color breakedBearishColor;
//
// FakeBreaked Zones ...
color fakeBreakedBullishColor;
color fakeBreakedBearishColor;
//
// Constructor ...
XCX121XKIPOIDrawer() : XCPOIDrawer()
{
Default();
}
//
// Deconstructor ...
~XCX121XKIPOIDrawer()
{
}
//
// Overrides ...
/**
* Do additional Configurations for Child Classes ...
*/
void virtual Default() override
{
//
// Apply Default Props ...
//
Prefix(NULL);
ChartIdentification(0);
SubWindowIdentification(0);
//
defaultBullishStyle.width = 1;
defaultBullishStyle.clr = clrAqua;
defaultBullishStyle.style = STYLE_SOLID;
//
defaultBearishStyle.width = 1;
defaultBearishStyle.clr = clrMagenta;
defaultBearishStyle.style = STYLE_SOLID;
//
boxBullishStyle = defaultBullishStyle;
boxBearishStyle = defaultBearishStyle;
//
testedBullishColor = clrLime;
breakedBullishColor = clrGreen;
fakeBreakedBullishColor = clrYellow;
//
testedBearishColor = clrRed;
breakedBearishColor = clrDarkRed;
fakeBreakedBearishColor = clrDarkOrange;
}
//
// 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;
}
/**
* Get Tested Zone Style ...
*
* @param style: reference to hold result ...
* @param zone: Specified Zone ...
*
* @return ( bool )
*/
bool GetTestedStyle(
XPOIStyle &style,
XBoxZone &zone //
)
{
//
bool result = false;
//
style.Clean();
//
result = zone.IsValid();
if (!result)
{
return result;
}
//
GetBoxStyle(
style,
zone.dir //
);
//
style.width = 3;
style.clr =
zone.IsBullish()
? testedBullishColor
: testedBearishColor;
//
return result;
}
/**
* Get Patterns Zone Style ...
*
* @param style: reference to hold result ...
* @param zone: Specified Zone ...
*
* @return ( bool )
*/
bool GetPatternStyle(
XPOIStyle &style,
XBoxZone &zone //
)
{
//
bool result = false;
//
style.Clean();
//
result = zone.IsValid();
if (!result)
{
return result;
}
//
GetPatternStyle(
style,
zone.dir //
);
//
return result;
}
/**
* Get Patterns Zone Style ...
*
* @param style: reference to hold result ...
* @param forDir: Specified Direction ...
*
* @return ( bool )
*/
bool GetPatternStyle(
XPOIStyle &style,
ENUM_X_DIRECTION forDir //
)
{
//
bool result = false;
//
style.Clean();
//
result = HasDirection(forDir);
if (!result)
{
return result;
}
//
GetBoxStyle(
style,
forDir //
);
//
style.width = 2;
style.style = STYLE_DASH;
//
return result;
}
/**
* Get Breaked Zone Style ...
*
* @param style: reference to hold result ...
* @param zone: Specified Zone ...
*
* @return ( bool )
*/
bool GetBreakedStyle(
XPOIStyle &style,
XBoxZone &zone //
)
{
//
bool result = false;
//
style.Clean();
//
result = zone.IsValid();
if (!result)
{
return result;
}
//
GetBoxStyle(
style,
zone.dir //
);
//
style.width = 3;
style.clr =
zone.IsBullish()
? breakedBullishColor
: breakedBearishColor;
//
return result;
}
/**
* Get Fake Breaked Zone Style ...
*
* @param style: reference to hold result ...
* @param zone: Specified Zone ...
*
* @return ( bool )
*/
bool GetFakeBreakedStyle(
XPOIStyle &style,
XBoxZone &zone //
)
{
//
bool result = false;
//
style.Clean();
//
result = zone.IsValid();
if (!result)
{
return result;
}
//
GetBoxStyle(
style,
zone.dir //
);
//
style.width = 3;
style.clr =
zone.IsBullish()
? fakeBreakedBullishColor
: fakeBreakedBearishColor;
//
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 = 2;
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);
}
}
/**
* Apply Tested Style ...
*
* @param object: reference pointer to Object ...
* @param zone: reference to Zone ...
*/
void ApplyTestedStyle(
XCBoxObject *&object,
XBoxZone &zone //
)
{
//
if (!zone.IsValid() ||
object == NULL)
{
return;
}
//
XPOIStyle style;
if (!GetTestedStyle(style, zone))
{
return;
}
//
ApplyBoxStyle(
object,
style //
);
}
/**
* Apply Breaked Style ...
*
* @param object: reference pointer to Object ...
* @param zone: reference to Zone ...
*/
void ApplyBreakedStyle(
XCBoxObject *&object,
XBoxZone &zone //
)
{
//
if (!zone.IsValid() ||
object == NULL)
{
return;
}
//
XPOIStyle style;
if (!GetBreakedStyle(style, zone))
{
return;
}
//
ApplyBoxStyle(
object,
style //
);
}
/**
* Apply Tested Style ...
*
* @param object: reference pointer to Object ...
* @param zone: reference to Zone ...
*/
void ApplyFakeBreakStyle(
XCBoxObject *&object,
XBoxZone &zone //
)
{
//
if (!zone.IsValid() ||
object == NULL)
{
return;
}
//
XPOIStyle style;
if (!GetFakeBreakedStyle(style, zone))
{
return;
}
//
ApplyBoxStyle(
object,
style //
);
}
/**
* Apply Pattern Style ...
*
* @param object: reference pointer to Object ...
* @param zone: reference to Zone ...
*/
void ApplyPatternStyle(
XCBoxObject *&object,
XBoxZone &zone //
)
{
//
if (!zone.IsValid() ||
object == NULL)
{
return;
}
//
XPOIStyle style;
if (!GetPatternStyle(style, zone))
{
return;
}
//
ApplyBoxStyle(
object,
style //
);
}
/**
* Apply Patterns Style ...
*
* @param object: reference pointer to Object ...
*/
void ApplyPatternsStyle(
CArrayObj *&objects //
)
{
//
if (objects == NULL ||
objects.Total() == 0)
{
return;
}
//
bool has = false;
XPOIStyle iStyle;
string iName = NULL;
XCBoxObject *iBoxObj = NULL;
ENUM_X_DIRECTION iDir = X_DIRECTION_NONE;
for (int i = 0; i < objects.Total(); i++)
{
//
iBoxObj = (XCBoxObject *)objects.At(i);
iName = iBoxObj.ObjName();
//
iDir =
IsSpecifiedValid(iName) &&
Contains(
"BULL",
iName //
)
? X_DIRECTION_BULLISH
: IsSpecifiedValid(iName) &&
Contains(
"BEAR",
iName //
)
? X_DIRECTION_BEARISH
: X_DIRECTION_NONE;
//
has = GetPatternStyle(iStyle, iDir);
if (has)
{
//
ApplyBoxStyle(
iBoxObj,
iStyle //
);
}
//
iStyle.Clean();
ZeroMemory(iBoxObj);
}
}
/**
* Apply Style to Specified Pivot Object ...
*
* @param object: reference pointer to Object ...
* @param zone: reference to Zone ...
*/
void ApplyPivotStyle(
XCBarArrowObject *&object,
XPOIStyle &style //
)
{
//
if (object == NULL)
{
return;
}
//
object.ArrowColor(style.clr);
object.ArrowWidth(style.width);
}
/**
* Apply Patterns Style ...
*
* @param object: reference pointer to Object ...
*/
void ApplyPivotsStyle(
CArrayObj *&objects //
)
{
//
if (objects == NULL ||
objects.Total() == 0)
{
return;
}
//
bool has = false;
XPOIStyle iStyle;
string iName = NULL;
XCBarArrowObject *iObj = NULL;
ENUM_X_DIRECTION iDir = X_DIRECTION_NONE;
for (int i = 0; i < objects.Total(); i++)
{
//
iObj = (XCBarArrowObject *)objects.At(i);
iName = iObj.ObjName();
//
iDir =
IsSpecifiedValid(iName) &&
Contains(
"BULL",
iName //
)
? X_DIRECTION_BULLISH
: IsSpecifiedValid(iName) &&
Contains(
"BEAR",
iName //
)
? X_DIRECTION_BEARISH
: X_DIRECTION_NONE;
//
has = GetPatternStyle(iStyle, iDir);
if (has)
{
//
ApplyPivotStyle(
iObj,
iStyle //
);
}
//
iStyle.Clean();
ZeroMemory(iObj);
}
}
//
};
//