This commit is contained in:
2024-11-02 18:52:49 +03:30
parent 37d13fe757
commit 39de34195d
6 changed files with 2504 additions and 22 deletions
+17 -16
View File
@@ -28,7 +28,8 @@
#include "../Helpers/x-saherelm.xcc.helper.mq5"
#include "../Helpers/x-saherelm.xct.helper.mq5"
#include "../X121SMCEA/Classes/x-121.smc.ea.panel.class.mq5"
#include "../X121SMCEA/Strategy/x-121.smc.strategy.class.mq5"
#include "../X121SMCEA/Strategy/x-121.smc.ob.strategy.class.mq5"
#include "../X121SMCEA/Strategy/x-121.smc.supdem.strategy.class.mq5"
//
// Inputs ...
@@ -75,14 +76,14 @@ input bool eaReportNewHours = false; // Report New Hours
// Define Local Variables ...
//
string eaLogTag; // EA Log Prefix ...
XSCAlert *eaAlert; // Alert Provider for Expert Adviser ...
XSCTrade *eaTrader; // Trader of Expert Adviser ...
XTimeTracker eaTimeTracker; // Time Tracker for Providing Reports ...
XSCXCTHelper *eaCTHelper; // Bar Timer Indicator Helper class ...
XSCXCCHelper *eaCCHelper; // Chart Styler Indicator Helper Class ...
X121CAppDialog eaMainWindow; // EA Main Dialog ...
XCX121SMCStrategy *eaStrategies[]; // Registere Strategies in EA ...
string eaLogTag; // EA Log Prefix ...
XSCAlert *eaAlert; // Alert Provider for Expert Adviser ...
XSCTrade *eaTrader; // Trader of Expert Adviser ...
XTimeTracker eaTimeTracker; // Time Tracker for Providing Reports ...
XSCXCTHelper *eaCTHelper; // Bar Timer Indicator Helper class ...
XSCXCCHelper *eaCCHelper; // Chart Styler Indicator Helper Class ...
X121CAppDialog eaMainWindow; // EA Main Dialog ...
XCX121SMCBaseStrategy *eaStrategies[]; // Registere Strategies in EA ...
//
// Signalling Controller Conditions ...
@@ -447,8 +448,8 @@ bool InitEA()
//
// Create Class Instance ...
XCX121SMCStrategy *iX121SMCStrategy;
iX121SMCStrategy = new XCX121SMCStrategy(
XCX121SMCBaseStrategy *iX121SMCStrategy;
iX121SMCStrategy = new XCX121SMCOBStrategy(
_Symbol,
_Period //
);
@@ -512,8 +513,8 @@ bool InitEA()
{
//
// Create Class Instance ...
XCX121SMCStrategy *iX121SMCStrategy;
iX121SMCStrategy = new XCX121SMCStrategy(
XCX121SMCBaseStrategy *iX121SMCStrategy;
iX121SMCStrategy = new XCX121SMCOBStrategy(
iSymbol,
_Period //
);
@@ -727,7 +728,7 @@ void InitControllerConditions()
/**
* Configure Startegy ...
*/
void ConfigureStrategy(XCX121SMCStrategy *&strategy)
void ConfigureStrategy(XCX121SMCBaseStrategy *&strategy)
{
//
if (strategy == NULL)
@@ -767,9 +768,9 @@ void ConfigureStrategy(XCX121SMCStrategy *&strategy)
/**
* Register an Strategy in EA ...
*
* @param strategy: XCX121SMCStrategy instance ...
* @param strategy: XCX121SMCBaseStrategy instance ...
*/
void RegisterStrategy(XCX121SMCStrategy *strategy)
void RegisterStrategy(XCX121SMCBaseStrategy *strategy)
{
//
if (strategy == NULL)
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,991 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Class Library
// --------------------------------------
// Name: XChartObjects
// Description: provides all require Chart Objects ...
//
//
// Maintainer:
// ------------
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
//
//////////////////////////////////////////////////////
//
// Global Properties ...
#property library
#property copyright "Copyright 2023, SaherElm IT Center"
#property link "https://www.saherelm.ir"
#property version "1.00"
#property strict
//
#include "../../Classes/x-saherelm.x-chart-objects.class.mq5"
#include "../../Classes/x-saherelm.x-poi.drawer.class.mq5"
#include "../../Libraries/x-saherelm.x-poi.lib.mq5"
#include "../Libraries/x-121.smc.lib.mq5"
//
#include <Arrays/ArrayObj.mqh>
//
// Definitions ...
enum ENUM_X121SMC_CHARTOBJECTS
{
//
// Global ...
X_121SMC_CONDITIONS_OBJ = 110121,
X_121SMC_MARKET_STRUCTURE_OBJ = 110122,
};
//
// Implementations ...
//
// Market Conditions ...
class XC121SMCConditionsObject : public XCBaseObject
{
//
public:
//
//
// Constructor ...
void XC121SMCConditionsObject(XCPOIDrawer *_poiDrawer)
{
mPOIDrawer = _poiDrawer;
}
//
// Deconstructor ...
void ~XC121SMCConditionsObject()
{
}
/**
* Create a Conditions Object on Chart ...
*
* @param chart_id: Long ...
* @param name: String ...
* @param window: Integer ...
* @param conditions: X121SMCStrategyConditions instance ...
*
* @return ( bool )
*/
bool CreateByConditions(
long chart_id,
const string name,
const int window,
X121SMCStrategyConditions &conditions //
)
{
//
bool result = false;
//
result = IsValid(name);
if (!result)
{
return result;
}
//
string nameMD5 = ToMD5(name);
string suffix = "_" + nameMD5;
//
// Supply Zone ...
bool isCreated = mPOIDrawer.CreateSupplyZone(
conditions.supplyZone,
mSupplyZoneObj //
);
//
// Demnd Zone ...
isCreated = mPOIDrawer.CreateDemandZone(
conditions.demandZone,
mDemandZoneObj //
);
//
// Bullish Order Block ...
isCreated = mPOIDrawer.CreateBullishOrderBlock(
conditions.bullishOrderBlock,
mBullishOBObj //
);
//
// Bearish Order Block ...
isCreated = mPOIDrawer.CreateBearishOrderBlock(
conditions.bearishOrderBlock,
mBearishOBObj //
);
//
// Collections ...
//
// Order Blocks ...
//
// Bullish ...
int count = ArraySize(conditions.bullishOrderBlocks);
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XZone iZone = conditions.bullishOrderBlocks[i];
//
XCBullishOrderBlockObject *iObj;
bool isCreated = mPOIDrawer.CreateBullishOrderBlock(
iZone,
iObj //
);
//
if (isCreated)
{
mBullishOBObjs.Add(iObj);
}
}
}
//
// Bearish ...
count = ArraySize(conditions.bearishOrderBlocks);
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XZone iZone = conditions.bearishOrderBlocks[i];
//
XCBearishOrderBlockObject *iObj;
bool isCreated = mPOIDrawer.CreateBearishOrderBlock(
iZone,
iObj //
);
//
if (isCreated)
{
mBearishOBObjs.Add(iObj);
}
}
}
//
// Fair Value Gaps ...
//
// Bullish ...
count = ArraySize(conditions.bullishFVGs);
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XZone iZone = conditions.bullishFVGs[i];
//
XCBullishFVGObject *iObj;
bool isCreated = mPOIDrawer.CreateBullishFVG(
iZone,
iObj //
);
//
if (isCreated)
{
mBullishFVGObjs.Add(iObj);
}
}
}
//
// Bearish ...
count = ArraySize(conditions.bearishFVGs);
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XZone iZone = conditions.bearishFVGs[i];
//
XCBearishFVGObject *iObj;
bool isCreated = mPOIDrawer.CreateBearishFVG(
iZone,
iObj //
);
//
if (isCreated)
{
mBearishFVGObjs.Add(iObj);
}
}
}
//
// Support and Resistance Zones ...
//
// Supports ...
count = ArraySize(conditions.supports);
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XOHCL iBar = conditions.supports[i];
//
XCSupportZoneObject *iObj;
bool isCreated = mPOIDrawer.CreateSupportZone(
iBar,
iObj //
);
//
if (isCreated)
{
mSupportZoneObjs.Add(iObj);
}
}
}
//
// Resistances ...
count = ArraySize(conditions.resistances);
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XOHCL iBar = conditions.resistances[i];
//
XCResistanceZoneObject *iObj;
bool isCreated = mPOIDrawer.CreateResistanceZone(
iBar,
iObj //
);
//
if (isCreated)
{
mResistanceZoneObjs.Add(iObj);
}
}
}
//
// Swings ...
//
// High ...
count = ArraySize(conditions.swingHighs);
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XOHCL iBar = conditions.swingHighs[i];
//
XCSwingHighObject *iObj;
bool isCreated = mPOIDrawer.CreateSwingHigh(
iBar,
iObj //
);
//
if (isCreated)
{
mSwingHighObjs.Add(iObj);
}
}
}
//
// Low ...
count = ArraySize(conditions.swingLows);
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XOHCL iBar = conditions.swingLows[i];
//
XCSwingLowObject *iObj;
bool isCreated = mPOIDrawer.CreateSwingLow(
iBar,
iObj //
);
//
if (isCreated)
{
mSwingLowObjs.Add(iObj);
}
}
}
//
// Momentum Bars ...
//
// Bullish ...
count = ArraySize(conditions.bullishMomentumBars);
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XOHCL iBar = conditions.bullishMomentumBars[i];
//
XCBullishMomentumBarObject *iObj;
bool isCreated = mPOIDrawer.CreateBullishMomentumBar(
iBar,
iObj //
);
//
if (isCreated)
{
mBullishMomentumBarObjs.Add(iObj);
}
}
}
//
// Bearish ...
count = ArraySize(conditions.bearishMomentumBars);
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XOHCL iBar = conditions.bearishMomentumBars[i];
//
XCBearishMomentumBarObject *iObj;
bool isCreated = mPOIDrawer.CreateBearishMomentumBar(
iBar,
iObj //
);
//
if (isCreated)
{
mBearishMomentumBarObjs.Add(iObj);
}
}
}
//
// Rejection Bars ...
//
// Bullish ...
count = ArraySize(conditions.bullishRejectionBars);
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XOHCL iBar = conditions.bullishRejectionBars[i];
//
XCBullishRejectionBarObject *iObj;
bool isCreated = mPOIDrawer.CreateBullishRejectionBar(
iBar,
iObj //
);
//
if (isCreated)
{
mBullishRejectionBarObjs.Add(iObj);
}
}
}
//
// Bearish ...
count = ArraySize(conditions.bearishRejectionBars);
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XOHCL iBar = conditions.bearishRejectionBars[i];
//
XCBearishRejectionBarObject *iObj;
bool isCreated = mPOIDrawer.CreateBearishRejectionBar(
iBar,
iObj //
);
//
if (isCreated)
{
mBearishRejectionBarObjs.Add(iObj);
}
}
}
//
if (result)
{
ObjName(name);
}
//
return result;
}
/**
* Retrieve Object Type ...
*
* @return ( ENUM_X121SMC_CHARTOBJECTS )
*/
virtual ENUM_X121SMC_CHARTOBJECTS Type()
{
return X_121SMC_CONDITIONS_OBJ;
}
//
private:
//
XCPOIDrawer *mPOIDrawer;
//
XCSupplyZoneObject *mSupplyZoneObj;
XCDemandZoneObject *mDemandZoneObj;
//
XCBullishOrderBlockObject *mBullishOBObj;
XCBearishOrderBlockObject *mBearishOBObj;
//
CArrayObj mBullishOBObjs;
CArrayObj mBearishOBObjs;
//
CArrayObj mBullishFVGObjs;
CArrayObj mBearishFVGObjs;
//
CArrayObj mSupportZoneObjs;
CArrayObj mResistanceZoneObjs;
//
CArrayObj mSwingHighObjs;
CArrayObj mSwingLowObjs;
//
CArrayObj mBullishMomentumBarObjs;
CArrayObj mBearishMomentumBarObjs;
//
CArrayObj mBullishRejectionBarObjs;
CArrayObj mBearishRejectionBarObjs;
//
};
//
// Market Structure ...
class XC121SMCMarketStructureObject : public XCBaseObject
{
//
public:
//
//
// Constructor ...
void XC121SMCMarketStructureObject(XCPOIDrawer *_poiDrawer)
{
mPOIDrawer = _poiDrawer;
}
//
// Deconstructor ...
void ~XC121SMCMarketStructureObject()
{
}
/**
* Create a Conditions Object on Chart ...
*
* @param chart_id: Long ...
* @param name: String ...
* @param window: Integer ...
* @param conditions: X121SMCStrategyConditions instance ...
*
* @return ( bool )
*/
bool CreateByStructure(
long chart_id,
const string name,
const int window,
X121SMCMarketStructure &structure //
)
{
//
bool result = false;
//
result = IsValid(name);
if (!result)
{
return result;
}
//
string nameMD5 = ToMD5(name);
string suffix = "_" + nameMD5;
//
// Supply Zone ...
bool isCreated = mPOIDrawer.CreateSupplyZone(
structure.supplyZone,
mSupplyZoneObj //
);
//
// Demnd Zone ...
isCreated = mPOIDrawer.CreateDemandZone(
structure.demandZone,
mDemandZoneObj //
);
//
// Bullish Order Block ...
isCreated = mPOIDrawer.CreateBullishOrderBlock(
structure.bullishOrderBlock,
mBullishOBObj //
);
//
// Bearish Order Block ...
isCreated = mPOIDrawer.CreateBearishOrderBlock(
structure.bearishOrderBlock,
mBearishOBObj //
);
//
// Collections ...
//
// Order Blocks ...
//
// Bullish ...
int count = ArraySize(structure.bullishOrderBlocks);
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XZone iZone = structure.bullishOrderBlocks[i];
//
XCBullishOrderBlockObject *iObj;
bool isCreated = mPOIDrawer.CreateBullishOrderBlock(
iZone,
iObj //
);
//
if (isCreated)
{
mBullishOBObjs.Add(iObj);
}
}
}
//
// Bearish ...
count = ArraySize(structure.bearishOrderBlocks);
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XZone iZone = structure.bearishOrderBlocks[i];
//
XCBearishOrderBlockObject *iObj;
bool isCreated = mPOIDrawer.CreateBearishOrderBlock(
iZone,
iObj //
);
//
if (isCreated)
{
mBearishOBObjs.Add(iObj);
}
}
}
//
// Fair Value Gaps ...
//
// Bullish ...
count = ArraySize(structure.bullishFVGs);
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XZone iZone = structure.bullishFVGs[i];
//
XCBullishFVGObject *iObj;
bool isCreated = mPOIDrawer.CreateBullishFVG(
iZone,
iObj //
);
//
if (isCreated)
{
mBullishFVGObjs.Add(iObj);
}
}
}
//
// Bearish ...
count = ArraySize(structure.bearishFVGs);
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XZone iZone = structure.bearishFVGs[i];
//
XCBearishFVGObject *iObj;
bool isCreated = mPOIDrawer.CreateBearishFVG(
iZone,
iObj //
);
//
if (isCreated)
{
mBearishFVGObjs.Add(iObj);
}
}
}
//
// Support and Resistance Zones ...
//
// Supports ...
count = ArraySize(structure.supports);
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XOHCL iBar = structure.supports[i];
//
XCSupportZoneObject *iObj;
bool isCreated = mPOIDrawer.CreateSupportZone(
iBar,
iObj //
);
//
if (isCreated)
{
mSupportZoneObjs.Add(iObj);
}
}
}
//
// Resistances ...
count = ArraySize(structure.resistances);
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XOHCL iBar = structure.resistances[i];
//
XCResistanceZoneObject *iObj;
bool isCreated = mPOIDrawer.CreateResistanceZone(
iBar,
iObj //
);
//
if (isCreated)
{
mResistanceZoneObjs.Add(iObj);
}
}
}
//
// Swings ...
//
// High ...
count = ArraySize(structure.swingHighs);
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XOHCL iBar = structure.swingHighs[i];
//
XCSwingHighObject *iObj;
bool isCreated = mPOIDrawer.CreateSwingHigh(
iBar,
iObj //
);
//
if (isCreated)
{
mSwingHighObjs.Add(iObj);
}
}
}
//
// Low ...
count = ArraySize(structure.swingLows);
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XOHCL iBar = structure.swingLows[i];
//
XCSwingLowObject *iObj;
bool isCreated = mPOIDrawer.CreateSwingLow(
iBar,
iObj //
);
//
if (isCreated)
{
mSwingLowObjs.Add(iObj);
}
}
}
//
// Momentum Bars ...
//
// Bullish ...
count = ArraySize(structure.bullishMomentumBars);
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XOHCL iBar = structure.bullishMomentumBars[i];
//
XCBullishMomentumBarObject *iObj;
bool isCreated = mPOIDrawer.CreateBullishMomentumBar(
iBar,
iObj //
);
//
if (isCreated)
{
mBullishMomentumBarObjs.Add(iObj);
}
}
}
//
// Bearish ...
count = ArraySize(structure.bearishMomentumBars);
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XOHCL iBar = structure.bearishMomentumBars[i];
//
XCBearishMomentumBarObject *iObj;
bool isCreated = mPOIDrawer.CreateBearishMomentumBar(
iBar,
iObj //
);
//
if (isCreated)
{
mBearishMomentumBarObjs.Add(iObj);
}
}
}
//
// Rejection Bars ...
//
// Bullish ...
count = ArraySize(structure.bullishRejectionBars);
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XOHCL iBar = structure.bullishRejectionBars[i];
//
XCBullishRejectionBarObject *iObj;
bool isCreated = mPOIDrawer.CreateBullishRejectionBar(
iBar,
iObj //
);
//
if (isCreated)
{
mBullishRejectionBarObjs.Add(iObj);
}
}
}
//
// Bearish ...
count = ArraySize(structure.bearishRejectionBars);
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XOHCL iBar = structure.bearishRejectionBars[i];
//
XCBearishRejectionBarObject *iObj;
bool isCreated = mPOIDrawer.CreateBearishRejectionBar(
iBar,
iObj //
);
//
if (isCreated)
{
mBearishRejectionBarObjs.Add(iObj);
}
}
}
//
if (result)
{
ObjName(name);
}
//
return result;
}
/**
* Retrieve Object Type ...
*
* @return ( ENUM_X121SMC_CHARTOBJECTS )
*/
virtual ENUM_X121SMC_CHARTOBJECTS Type()
{
return X_121SMC_MARKET_STRUCTURE_OBJ;
}
//
private:
//
XCPOIDrawer *mPOIDrawer;
//
XCSupplyZoneObject *mSupplyZoneObj;
XCDemandZoneObject *mDemandZoneObj;
//
XCBullishOrderBlockObject *mBullishOBObj;
XCBearishOrderBlockObject *mBearishOBObj;
//
CArrayObj mBullishOBObjs;
CArrayObj mBearishOBObjs;
//
CArrayObj mBullishFVGObjs;
CArrayObj mBearishFVGObjs;
//
CArrayObj mSupportZoneObjs;
CArrayObj mResistanceZoneObjs;
//
CArrayObj mSwingHighObjs;
CArrayObj mSwingLowObjs;
//
CArrayObj mBullishMomentumBarObjs;
CArrayObj mBearishMomentumBarObjs;
//
CArrayObj mBullishRejectionBarObjs;
CArrayObj mBearishRejectionBarObjs;
//
};
//
+50 -6
View File
@@ -32,6 +32,10 @@
//
// Specific Identifier(s) of XStrategy ...
string X121SMCStrategyToken = "X121SMC";
string X121SMCOBStrategyToken = "X121SMCOB";
string X121SMCSUPDEMStrategyToken = "X121SMCSUPDEM";
string X121SMCConditionsToken = "X121SMCConditions";
string X121SMCMarketStructureToken = "X121SMCMarketStructure";
//
// Condition Structure ...
@@ -51,6 +55,7 @@ struct X121SMCStrategyConditions
//
XZone supplyZone;
XZone bearishOrderBlock;
//
XZone bearishOrderBlocks[];
@@ -64,6 +69,7 @@ struct X121SMCStrategyConditions
//
XZone demandZone;
XZone bullishOrderBlock;
//
XZone bullishOrderBlocks[];
@@ -96,6 +102,7 @@ struct X121SMCStrategyConditions
//
supplyZone.Clean();
bearishOrderBlock.Clean();
//
Clean(bearishFVGs);
@@ -103,6 +110,7 @@ struct X121SMCStrategyConditions
//
demandZone.Clean();
bearishOrderBlock.Clean();
//
Clean(bullishFVGs);
@@ -125,6 +133,7 @@ struct X121SMCStrategyConditions
{
//
demandZone.Clean();
bullishOrderBlock.Clean();
//
Clean(supports);
@@ -139,6 +148,7 @@ struct X121SMCStrategyConditions
{
//
supplyZone.Clean();
bearishOrderBlock.Clean();
//
Clean(swingHighs);
@@ -273,15 +283,24 @@ struct X121SMCStrategyConditions
if (fullTag)
{
//
result = X121SMCStrategyToken + "_" +
"Conditions_" +
symbol + "_" +
ToString(period) + "_" +
ToFormatString(time);
result =
//
symbol + "," +
ToString(period) + "," +
ToFormatString(time) + "_" +
demandZone.GetTag() + "," +
supplyZone.GetTag() + "_" +
bullishOrderBlock.GetTag() + "," +
bearishOrderBlock.GetTag()
//
;
//
result = X121SMCConditionsToken + "_" + ToMD5(result);
}
else
{
result = X121SMCStrategyToken;
result = X121SMCConditionsToken;
}
//
@@ -299,6 +318,10 @@ struct X121SMCMarketStructure
XZone demandZone;
XZone supplyZone;
//
XZone bullishOrderBlock;
XZone bearishOrderBlock;
//
XZone demandZones[];
XZone supplyZones[];
@@ -346,6 +369,27 @@ struct X121SMCMarketStructure
Clean(bullishMomentumBars);
Clean(bullishRejectionBars);
}
//
string GetTag()
{
//
string result = NULL;
//
result =
//
demandZone.GetTag() + "," +
supplyZone.GetTag() + "_" +
bullishOrderBlock.GetTag() + "," +
bearishOrderBlock.GetTag()
//
;
result = X121SMCMarketStructureToken + "_" + ToMD5(X121SMCMarketStructureToken);
//
return result;
}
};
//
Binary file not shown.