last backup ...
This commit is contained in:
@@ -0,0 +1,117 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Class
|
||||
// -------------------------------------------------
|
||||
// Name: XCXFIMAExpret ...
|
||||
// Description: XFIMA Expert 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 Expert Class"
|
||||
#property strict
|
||||
|
||||
//
|
||||
// Imports ...
|
||||
#include "../../Classes/x-saherelm.x-expert.class.mq5"
|
||||
#include "../Classes/x-saherelm.xfima.signaller.class.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
//
|
||||
// Implementation ...
|
||||
class XCXFIMAExpret : public XCBaseExpert
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
|
||||
//
|
||||
// Overrides ...
|
||||
|
||||
/**
|
||||
* Prepare Signallers per Symbol Config ...
|
||||
*
|
||||
* @param symbolConfig: XSymbolTradeConfig, Symbol Trade Configurations ...
|
||||
*/
|
||||
void PrepareSignallers(XSymbolTradeConfig &symbolConfig) override
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
if (!symbolConfig.IsValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Instantiate Signaller ...
|
||||
|
||||
//
|
||||
// XFIMA Inputs ...
|
||||
|
||||
//
|
||||
XFIMAInputs fimaInputs;
|
||||
fimaInputs.Default();
|
||||
fimaInputs.Hide();
|
||||
|
||||
//
|
||||
// Instantiate Signaller Class ...
|
||||
XCXFIMAStrategy1Signaller *fima1Signaller = new XCXFIMAStrategy1Signaller(
|
||||
symbolConfig.symbol,
|
||||
symbolConfig.period,
|
||||
fimaInputs,
|
||||
false // Process All Ticks ...
|
||||
);
|
||||
if (!fima1Signaller.IsValid())
|
||||
{
|
||||
//
|
||||
fima1Signaller.Destroy();
|
||||
delete fima1Signaller;
|
||||
ZeroMemory(fima1Signaller);
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Register Signaller ...
|
||||
RegisterSignaller((XCBaseSignaller *)fima1Signaller);
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
fimaInputs.Clean();
|
||||
ZeroMemory(fima1Signaller);
|
||||
}
|
||||
|
||||
/**
|
||||
* Additional On Tick Processing if Required ...
|
||||
*
|
||||
* @param barIndex: int, Specified Bar Index ...
|
||||
*/
|
||||
void virtual HandleOnTickAdditional(int barIndex = 0)
|
||||
{
|
||||
//
|
||||
// Implement this if required ...
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
};
|
||||
|
||||
//
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,708 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// 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:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Tested Zones ...
|
||||
color testedBullishColor;
|
||||
color testedBearishColor;
|
||||
|
||||
//
|
||||
// Breaked Zones ...
|
||||
color breakedBullishColor;
|
||||
color breakedBearishColor;
|
||||
|
||||
//
|
||||
// FakeBreaked Zones ...
|
||||
color fakeBreakedBullishColor;
|
||||
color fakeBreakedBearishColor;
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
XCXFIMAPOIDrawer() : XCPOIDrawer()
|
||||
{
|
||||
Default();
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
~XCXFIMAPOIDrawer()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
//
|
||||
@@ -0,0 +1,590 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Library
|
||||
// -------------------------------------------------
|
||||
// Name: XCXFIMAEALib ...
|
||||
// Description: XFIMAEA Library ...
|
||||
//
|
||||
//
|
||||
// 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 XFIMAEA Library"
|
||||
#property strict
|
||||
|
||||
//
|
||||
// Imports ...
|
||||
#include "../../Classes/x-saherelm.x-cobject.class.mq5"
|
||||
#include "../../Helpers/x-saherelm.xfima.helper.mq5"
|
||||
#include "../../Libraries/x-saherelm.x-pivot.analysis.lib.mq5"
|
||||
#include "../Classes/x-saherelm.xfima.parser.class.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
/**
|
||||
* XFIMA Base Market Structure ...
|
||||
* AnalyseMarket result ...
|
||||
**/
|
||||
struct XFIMAMarketStructure
|
||||
{
|
||||
//
|
||||
XOHCL bar; // Spacified Start Bar for Analysing ...
|
||||
XPatternAnalysis barAnalysis; // Structure Bar Pattern Analysis ...
|
||||
|
||||
//
|
||||
XBoxZone orderFlow[]; // Specified Order Flow Zones ...
|
||||
ENUM_X_DIRECTION orderFlowDir; // Specified Order Flow Direction ...
|
||||
|
||||
//
|
||||
XPivot pvPivots[]; // XPV Pivots ...
|
||||
XPivot zgPivots[]; // XZG Pivots ...
|
||||
XPivot maPivots[]; // XMA Pivots ...
|
||||
XPivot hkPivots[]; // XHK Pivots ...
|
||||
XPivot sarPivots[]; // XSAR Pivots ...
|
||||
|
||||
//
|
||||
XPivotAnalysis pvAnalysis; // XPV Pivot Analysis Result ...
|
||||
XPivotAnalysis zgAnalysis; // XZG Pivot Analysis Result ...
|
||||
XPivotAnalysis maAnalysis; // XMA Pivot Analysis Result ...
|
||||
XPivotAnalysis hkAnalysis; // XHK Pivot Analysis Result ...
|
||||
XPivotAnalysis sarAnalysis; // XSAR Pivot Analysis Result ...
|
||||
|
||||
//
|
||||
XPatternAnalysis barsAnalysis[]; // Anaysed Bars ...
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
XFIMAMarketStructure()
|
||||
{
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
/**
|
||||
* Cleanup ...
|
||||
*/
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
bar.Clean();
|
||||
barAnalysis.Clean();
|
||||
|
||||
//
|
||||
XClean(pvPivots);
|
||||
XClean(zgPivots);
|
||||
XClean(maPivots);
|
||||
XClean(hkPivots);
|
||||
XClean(sarPivots);
|
||||
|
||||
//
|
||||
pvAnalysis.Clean();
|
||||
zgAnalysis.Clean();
|
||||
maAnalysis.Clean();
|
||||
hkAnalysis.Clean();
|
||||
sarAnalysis.Clean();
|
||||
|
||||
//
|
||||
XClean(barsAnalysis);
|
||||
|
||||
//
|
||||
XClean(orderFlow);
|
||||
orderFlowDir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
ZeroMemory(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = bar.IsValid() &&
|
||||
barAnalysis.IsValid();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Checkers ...
|
||||
|
||||
/**
|
||||
* Check Market Strucutre Has Order Flow or not ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool HasOrderFlow()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = IsValid() &&
|
||||
HasChild(orderFlow) &&
|
||||
HasDirection(orderFlowDir);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Market Structure Has Bullish Order Flow or not ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool HasBullishOrderFlow()
|
||||
{
|
||||
return HasOrderFlow() &&
|
||||
IsXBullish(orderFlowDir);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Market Structure Has Bearish Order Flow or not ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool HasBearishOrderFlow()
|
||||
{
|
||||
return HasOrderFlow() &&
|
||||
IsXBearish(orderFlowDir);
|
||||
}
|
||||
|
||||
//
|
||||
// Collectors ...
|
||||
|
||||
/**
|
||||
* Collect all Pivots ...
|
||||
*
|
||||
* @param dest: XPivot, collection reference to holds result ...
|
||||
* @param containsPatterns: bool, Specified to Add Pivots Bar Directionl Patterns ...
|
||||
* @param forDir: ENUM_X_DIRECTION, Specified Extraction Direction ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int CollectPivots(
|
||||
XPivot &dest[],
|
||||
bool containsPatterns = false,
|
||||
ENUM_X_DIRECTION forDir = X_DIRECTION_NONE //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
// Prepare ...
|
||||
XClean(dest);
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
bool has = IsValid();
|
||||
if (!has)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Do ...
|
||||
|
||||
//
|
||||
Copy(pvPivots, dest, false);
|
||||
Copy(hkPivots, dest, false);
|
||||
Copy(maPivots, dest, false);
|
||||
Copy(zgPivots, dest, false);
|
||||
Copy(sarPivots, dest, false);
|
||||
|
||||
//
|
||||
// Apply Direction Filtering ...
|
||||
if (HasDirection(forDir))
|
||||
{
|
||||
//
|
||||
XPivot tmps[];
|
||||
ExtractByDirection(
|
||||
tmps,
|
||||
dest,
|
||||
forDir //
|
||||
);
|
||||
XClean(dest);
|
||||
Copy(tmps, dest);
|
||||
XClean(tmps);
|
||||
}
|
||||
|
||||
//
|
||||
// Contains Pattern Pivots ...
|
||||
if (containsPatterns && HasChild(dest) && HasChild(barsAnalysis))
|
||||
{
|
||||
//
|
||||
XPivot tmp;
|
||||
int idx = -1;
|
||||
XPivot tmps[];
|
||||
XPivot sames[];
|
||||
XPivot patterns[];
|
||||
Copy(dest, tmps);
|
||||
XClean(dest);
|
||||
|
||||
//
|
||||
while (HasChild(tmps))
|
||||
{
|
||||
//
|
||||
tmp.Clean();
|
||||
tmp = tmps[0];
|
||||
ArrayRemove(tmps, 0, 1);
|
||||
|
||||
//
|
||||
XClean(sames);
|
||||
ExtractSameTimePivots(tmp, sames, tmps);
|
||||
if (HasChild(sames))
|
||||
{
|
||||
//
|
||||
has = FindByTime(idx, tmp.time, barsAnalysis);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
barsAnalysis[idx].GetPatterns(patterns, sames[0].dir);
|
||||
Copy(patterns, dest, false);
|
||||
}
|
||||
|
||||
//
|
||||
Copy(sames, dest, false);
|
||||
Removes(sames, tmps);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
XClean(tmps);
|
||||
XClean(sames);
|
||||
XClean(patterns);
|
||||
}
|
||||
|
||||
//
|
||||
result = ArraySize(dest);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
/**
|
||||
* Configure How to Detect Market Structure ...
|
||||
**/
|
||||
struct XFIMAMarketStructureConfig
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Detector Flags ...
|
||||
|
||||
//
|
||||
bool analysePVPivots; // Analyse PV Pivots ...
|
||||
bool analyseZGPivots; // Analyse ZG Pivots ...
|
||||
bool analyseHKPivots; // Analyse HK Pivots ...
|
||||
bool analyseMAPivots; // Analyse MA Pivots ...
|
||||
bool analyseSARPivots; // Analyse SAR Pivots ...
|
||||
|
||||
//
|
||||
bool analyseBarPatterns; // Analyse Bar Patterns ...
|
||||
|
||||
//
|
||||
bool detectOrderFlow; // Detect Order Flow ...
|
||||
|
||||
//
|
||||
// Detector Configs ...
|
||||
|
||||
//
|
||||
int loopback; // Max Allowed Looping Back Length ...
|
||||
int requiredPivots; // Required Extracted Pivots for Analysis ...
|
||||
|
||||
//
|
||||
int orderFlowValidation; // Order Flow Sequential Validation ...
|
||||
bool orderFlowUseOB; // Order Flow Use Order Blocks ...
|
||||
bool orderFlowUseFVG; // Order Flow Use Fair Value Gaps ...
|
||||
bool orderFlowUseSupportAndResistance; // Order Flow Use Support and Resistance (s) ...
|
||||
|
||||
//
|
||||
XPatternAnalysisConfig barsAnalysisConfig; // Bars Analyser Config ...
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
XFIMAMarketStructureConfig()
|
||||
{
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
/**
|
||||
* This function fulfills the will of the developer
|
||||
*/
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
// Detector Flags ...
|
||||
detectOrderFlow = false;
|
||||
analysePVPivots = false;
|
||||
analyseZGPivots = false;
|
||||
analyseHKPivots = false;
|
||||
analyseMAPivots = false;
|
||||
analyseSARPivots = false;
|
||||
analyseBarPatterns = false;
|
||||
|
||||
//
|
||||
// Configure Detectors ...
|
||||
loopback = 0;
|
||||
requiredPivots = 0;
|
||||
|
||||
//
|
||||
orderFlowValidation = 0;
|
||||
orderFlowUseOB = false;
|
||||
orderFlowUseFVG = false;
|
||||
orderFlowUseSupportAndResistance = false;
|
||||
|
||||
//
|
||||
barsAnalysisConfig.Clean();
|
||||
|
||||
//
|
||||
ZeroMemory(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Default Configurations ...
|
||||
*/
|
||||
void Default()
|
||||
{
|
||||
//
|
||||
// Detector Flags ...
|
||||
detectOrderFlow = true;
|
||||
analysePVPivots = true;
|
||||
analyseZGPivots = true;
|
||||
analyseHKPivots = true;
|
||||
analyseMAPivots = true;
|
||||
analyseSARPivots = true;
|
||||
analyseBarPatterns = true;
|
||||
|
||||
//
|
||||
// Configure Detectors ...
|
||||
loopback = 200;
|
||||
requiredPivots = 10;
|
||||
|
||||
//
|
||||
orderFlowValidation = 2;
|
||||
orderFlowUseOB = false;
|
||||
orderFlowUseFVG = true;
|
||||
orderFlowUseSupportAndResistance = false;
|
||||
|
||||
//
|
||||
barsAnalysisConfig.Default();
|
||||
barsAnalysisConfig.FullPattern();
|
||||
|
||||
//
|
||||
barsAnalysisConfig.supportAndResistanceLoopbackLength = 5;
|
||||
barsAnalysisConfig.supportAndResistanceValidationLength = 11;
|
||||
}
|
||||
|
||||
/**
|
||||
* No Draw Abilioty ...
|
||||
*/
|
||||
void Off()
|
||||
{
|
||||
//
|
||||
// Detector Flags ...
|
||||
detectOrderFlow = false;
|
||||
analysePVPivots = false;
|
||||
analyseZGPivots = false;
|
||||
analyseHKPivots = false;
|
||||
analyseMAPivots = false;
|
||||
analyseSARPivots = false;
|
||||
analyseBarPatterns = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Full Draw Abilioty ...
|
||||
*/
|
||||
void Full()
|
||||
{
|
||||
//
|
||||
// Detector Flags ...
|
||||
detectOrderFlow = true;
|
||||
analysePVPivots = true;
|
||||
analyseZGPivots = true;
|
||||
analyseHKPivots = true;
|
||||
analyseMAPivots = true;
|
||||
analyseSARPivots = true;
|
||||
analyseBarPatterns = true;
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
/**
|
||||
* Configure Market Structure Drawer ...
|
||||
**/
|
||||
struct XFIMAMarketStructureDrawerConfig
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
bool drawPVAnalysis;
|
||||
bool drawZGAnalysis;
|
||||
bool drawMAAnalysis;
|
||||
bool drawHKAnalysis;
|
||||
bool drawSARAnalysis;
|
||||
bool drawBarsAnalysis;
|
||||
|
||||
//
|
||||
XPOIDrawConfig drawConfig;
|
||||
XPivotAnalysisDrawConfig pivotAnalysisDrawConfig;
|
||||
XPatternAnalysisDrawConfig barAnalysisDrawConfig;
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
XFIMAMarketStructureDrawerConfig()
|
||||
{
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
/**
|
||||
* This function fulfills the will of the developer
|
||||
*/
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
// Drawing Flags ...
|
||||
|
||||
//
|
||||
drawPVAnalysis = false;
|
||||
drawZGAnalysis = false;
|
||||
drawMAAnalysis = false;
|
||||
drawHKAnalysis = false;
|
||||
drawSARAnalysis = false;
|
||||
drawBarsAnalysis = false;
|
||||
|
||||
//
|
||||
// Drawing Configs ...
|
||||
drawConfig.Clean();
|
||||
barAnalysisDrawConfig.Clean();
|
||||
pivotAnalysisDrawConfig.Clean();
|
||||
|
||||
//
|
||||
ZeroMemory(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Default Configurations ...
|
||||
*/
|
||||
void Default()
|
||||
{
|
||||
//
|
||||
// Drawing Flags ...
|
||||
|
||||
//
|
||||
drawPVAnalysis = true;
|
||||
drawZGAnalysis = true;
|
||||
drawMAAnalysis = true;
|
||||
drawHKAnalysis = true;
|
||||
drawSARAnalysis = true;
|
||||
drawBarsAnalysis = true;
|
||||
|
||||
//
|
||||
// Drawing Configs ...
|
||||
drawConfig.Default();
|
||||
pivotAnalysisDrawConfig.Default();
|
||||
|
||||
//
|
||||
barAnalysisDrawConfig.Default();
|
||||
barAnalysisDrawConfig.Full();
|
||||
XClean(barAnalysisDrawConfig.allowedDrawZones);
|
||||
Add(
|
||||
X_BAR_PATTERN_SUPPORT,
|
||||
barAnalysisDrawConfig.allowedDrawZones);
|
||||
Add(
|
||||
X_BAR_PATTERN_RESISTANCE,
|
||||
barAnalysisDrawConfig.allowedDrawZones);
|
||||
}
|
||||
|
||||
/**
|
||||
* No Draw Abilioty ...
|
||||
*/
|
||||
void Off()
|
||||
{
|
||||
//
|
||||
// Drawing Flags ...
|
||||
|
||||
//
|
||||
drawPVAnalysis = false;
|
||||
drawZGAnalysis = false;
|
||||
drawMAAnalysis = false;
|
||||
drawHKAnalysis = false;
|
||||
drawSARAnalysis = false;
|
||||
drawBarsAnalysis = false;
|
||||
|
||||
//
|
||||
// Drawing Configs ...
|
||||
barAnalysisDrawConfig.Off();
|
||||
pivotAnalysisDrawConfig.Off();
|
||||
}
|
||||
|
||||
/**
|
||||
* Full Draw Abilioty ...
|
||||
*/
|
||||
void Full()
|
||||
{
|
||||
//
|
||||
// Drawing Flags ...
|
||||
|
||||
//
|
||||
drawPVAnalysis = true;
|
||||
drawZGAnalysis = true;
|
||||
drawMAAnalysis = true;
|
||||
drawHKAnalysis = true;
|
||||
drawSARAnalysis = true;
|
||||
drawBarsAnalysis = true;
|
||||
|
||||
//
|
||||
// Drawing Configs ...
|
||||
barAnalysisDrawConfig.Full();
|
||||
pivotAnalysisDrawConfig.Full();
|
||||
}
|
||||
|
||||
void ApplyDrawConfig()
|
||||
{
|
||||
//
|
||||
barAnalysisDrawConfig.drawConfig = drawConfig;
|
||||
pivotAnalysisDrawConfig.drawConfig = drawConfig;
|
||||
}
|
||||
|
||||
void ApplyDrawConfig(XPOIDrawConfig &_drawConfig)
|
||||
{
|
||||
//
|
||||
drawConfig = _drawConfig;
|
||||
ApplyDrawConfig();
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
//
|
||||
Reference in New Issue
Block a user