last works on implementing SMC Strategy based on POIs ...
This commit is contained in:
@@ -34,20 +34,20 @@ enum ENUM_XCHARTOBJECTS
|
||||
{
|
||||
//
|
||||
// Global ...
|
||||
X_ZONE,
|
||||
X_FROM_TO,
|
||||
X_ZONE = 7861,
|
||||
X_FROM_TO = 7862,
|
||||
//
|
||||
// Structured ...
|
||||
X_TRADE_DAY,
|
||||
X_MARKET_SESSION,
|
||||
X_SUPPORT_ZONE,
|
||||
X_RESISTANCE_ZONE,
|
||||
X_SUPPLY_ZONE,
|
||||
X_DEMAND_ZONE,
|
||||
X_BULLISH_ORDERBLOCK,
|
||||
X_BEARISH_ORDERBLOCK,
|
||||
X_BULLISH_FVG,
|
||||
X_BEARISH_FVG,
|
||||
X_TRADE_DAY = 7863,
|
||||
X_MARKET_SESSION = 7864,
|
||||
X_SUPPORT_ZONE = 7865,
|
||||
X_RESISTANCE_ZONE = 7866,
|
||||
X_SUPPLY_ZONE = 7867,
|
||||
X_DEMAND_ZONE = 7868,
|
||||
X_BULLISH_ORDERBLOCK = 7869,
|
||||
X_BEARISH_ORDERBLOCK = 78610,
|
||||
X_BULLISH_FVG = 78611,
|
||||
X_BEARISH_FVG = 78612,
|
||||
};
|
||||
|
||||
enum ENUM_X_CHART_IDS
|
||||
@@ -365,11 +365,6 @@ class XCZoneObject : public XCBaseObject
|
||||
!IsValid(objprefix)
|
||||
? ""
|
||||
: objprefix + "_";
|
||||
result = Name(prefix);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Params For Rectangle ...
|
||||
|
||||
+1438
-596
File diff suppressed because it is too large
Load Diff
+193
-127
@@ -30,11 +30,6 @@
|
||||
#include "../X121SMCEA/Classes/x-121.smc.ea.panel.class.mq5"
|
||||
#include "../X121SMCEA/Strategy/x-121.smc.strategy.class.mq5"
|
||||
|
||||
//
|
||||
// TEST ...
|
||||
#include "../Classes/x-saherelm.x-poi.class.mq5"
|
||||
XCPOI *eaPOI;
|
||||
|
||||
//
|
||||
// Inputs ...
|
||||
|
||||
@@ -51,6 +46,12 @@ input group "Symbols";
|
||||
input bool eaMultiSymbol = false; // Use Multi Symbol
|
||||
input string eaSymbols = "EURUSDb,GBPUSDb,USDJPYb,USDCHFb,DowJones30,XAUUSDb"; // Trading Symbols
|
||||
|
||||
//
|
||||
// Signalling ...
|
||||
input group "Signalling";
|
||||
input bool eaAllowLong = true; // Allow Long Signals
|
||||
input bool eaAllowShort = true; // Allow Short Signals
|
||||
|
||||
//
|
||||
// Alert ...
|
||||
// Here we Provider All Requirements for
|
||||
@@ -83,6 +84,12 @@ XSCXCCHelper *eaCCHelper; // Chart Styler Indicator Helper Class ...
|
||||
X121CAppDialog eaMainWindow; // EA Main Dialog ...
|
||||
XCX121SMCStrategy *eaStrategies[]; // Registere Strategies in EA ...
|
||||
|
||||
//
|
||||
// Signalling Controller Conditions ...
|
||||
bool eaDisableSignalling;
|
||||
bool eaAllowLongSignalling;
|
||||
bool eaAllowShortSignalling;
|
||||
|
||||
//
|
||||
// Event Handlers ...
|
||||
|
||||
@@ -105,6 +112,10 @@ int OnInit()
|
||||
return INIT_FAILED;
|
||||
}
|
||||
|
||||
//
|
||||
// Initial Controller Conditions ...
|
||||
InitControllerConditions();
|
||||
|
||||
//
|
||||
// Initialize all Requirements ...
|
||||
if (!InitEA())
|
||||
@@ -171,18 +182,7 @@ void OnTick()
|
||||
UpdateGUI();
|
||||
HandleReportTime();
|
||||
UpdatePositionsState();
|
||||
|
||||
//
|
||||
// TEST ...
|
||||
ENUM_XPOI_EVENTS states[];
|
||||
int statesCount = eaPOI.Update(states);
|
||||
if (IsValidSize(statesCount))
|
||||
{
|
||||
eaAlert.Log("POI Events Happens: " + ToString(statesCount));
|
||||
}
|
||||
|
||||
//
|
||||
// TODO: Implemetn Tick Processors Algorithm ...
|
||||
HandleStrategiesOnTick();
|
||||
}
|
||||
|
||||
//
|
||||
@@ -271,7 +271,7 @@ void OnPositionForceClosed(
|
||||
*/
|
||||
void OnSignalRecieved(
|
||||
XSignal &signal,
|
||||
XStrategyConditions &conditions //
|
||||
X121SMCStrategyConditions &conditions //
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -425,122 +425,96 @@ bool InitEA()
|
||||
eaTrader.AddOnForceClosePositionEventHandler(OnPositionForceClosed);
|
||||
|
||||
//
|
||||
// TEST ...
|
||||
eaPOI = new XCPOI(
|
||||
_Symbol,
|
||||
_Period //
|
||||
);
|
||||
eaPOI.EnableDrawPOIs();
|
||||
// eaPOI.AllowDrawSwingLows(false);
|
||||
// eaPOI.AllowDrawSwingHighs(false);
|
||||
// eaPOI.AllowDrawBullishFVGs(false);
|
||||
// eaPOI.AllowDrawBearishFVGs(false);
|
||||
// eaPOI.AllowDrawSupplyZones(false);
|
||||
// eaPOI.AllowDrawDemandZones(false);
|
||||
// eaPOI.AllowDrawMomentumBars(false);
|
||||
// eaPOI.AllowDrawSupportZones(false);
|
||||
// eaPOI.AllowDrawRejectionBars(false);
|
||||
// eaPOI.AllowDrawMarketSessions(false);
|
||||
// eaPOI.AllowDrawResistanceZones(false);
|
||||
// eaPOI.AllowDrawBullishOrderBlocks(false);
|
||||
// eaPOI.AllowDrawBearishOrderBlocks(false);
|
||||
// Symbols Parsing ...
|
||||
|
||||
//
|
||||
eaPOI.Init();
|
||||
// Parsers ...
|
||||
XSymbolParser _symbolParser;
|
||||
|
||||
// //
|
||||
// // Symbols Parsing ...
|
||||
//
|
||||
// Single Symbol ...
|
||||
if (!eaMultiSymbol)
|
||||
{
|
||||
//
|
||||
// Register Strategy ...
|
||||
|
||||
// //
|
||||
// // Parsers ...
|
||||
// XSymbolParser _symbolParser;
|
||||
//
|
||||
// Create Class Instance ...
|
||||
XCX121SMCStrategy *iX121SMCStrategy;
|
||||
iX121SMCStrategy = new XCX121SMCStrategy(
|
||||
_Symbol,
|
||||
_Period //
|
||||
);
|
||||
|
||||
// //
|
||||
// // Single Symbol ...
|
||||
// if (!eaMultiSymbol)
|
||||
// {
|
||||
//
|
||||
ConfigureStrategy(iX121SMCStrategy);
|
||||
RegisterStrategy(iX121SMCStrategy);
|
||||
}
|
||||
//
|
||||
// Multi Symbol ...
|
||||
else
|
||||
{
|
||||
//
|
||||
// Parse Symbols ...
|
||||
string symbols[];
|
||||
int symbolsCount = SplitContent(
|
||||
symbols,
|
||||
eaSymbols //
|
||||
);
|
||||
result = IsValidSize(symbolsCount);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
// //
|
||||
// // Register Strategy ...
|
||||
// }
|
||||
// //
|
||||
// // Multi Symbol ...
|
||||
// else
|
||||
// {
|
||||
// //
|
||||
// // Parse Symbols ...
|
||||
// string symbols[];
|
||||
// int symbolsCount = SplitContent(
|
||||
// symbols,
|
||||
// eaSymbols //
|
||||
// );
|
||||
// result = IsValidSize(symbolsCount);
|
||||
// if (!result)
|
||||
// {
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
for (int i = 0; i < symbolsCount; i++)
|
||||
{
|
||||
//
|
||||
// Select Symbol ...
|
||||
string iSymbol = symbols[i];
|
||||
|
||||
// //
|
||||
// for (int i = 0; i < symbolsCount; i++)
|
||||
// {
|
||||
// //
|
||||
// // Select Symbol ...
|
||||
// string iSymbol = symbols[i];
|
||||
//
|
||||
// Register Strategy Based On Symbol ...
|
||||
|
||||
// //
|
||||
// // Register Strategy Based On Symbol ...
|
||||
//
|
||||
// Parse Symbol ...
|
||||
bool isEURUSD = _symbolParser.IsEURUSD(_Symbol);
|
||||
bool isGBPUSD = _symbolParser.IsGBPUSD(_Symbol);
|
||||
bool isEURGBP = _symbolParser.IsEURGBP(_Symbol);
|
||||
bool isUSDCHF = _symbolParser.IsUSDCHF(_Symbol);
|
||||
bool isEURCHF = _symbolParser.IsEURCHF(_Symbol);
|
||||
bool isUSDJPY = _symbolParser.IsUSDJPY(_Symbol);
|
||||
bool isEURJPY = _symbolParser.IsEURJPY(_Symbol);
|
||||
bool isUSDCAD = _symbolParser.IsUSDCAD(_Symbol);
|
||||
bool isEURCAD = _symbolParser.IsEURCAD(_Symbol);
|
||||
bool isAUDUSD = _symbolParser.IsAUDUSD(_Symbol);
|
||||
bool isEURAUD = _symbolParser.IsEURAUD(_Symbol);
|
||||
bool isNZDUSD = _symbolParser.IsNZDUSD(_Symbol);
|
||||
bool isEURNZD = _symbolParser.IsEURNZD(_Symbol);
|
||||
|
||||
// //
|
||||
// // Parse Symbol ...
|
||||
// bool isEURUSD = _symbolParser.IsEURUSD(_Symbol);
|
||||
// bool isGBPUSD = _symbolParser.IsGBPUSD(_Symbol);
|
||||
// bool isEURGBP = _symbolParser.IsEURGBP(_Symbol);
|
||||
// bool isUSDCHF = _symbolParser.IsUSDCHF(_Symbol);
|
||||
// bool isEURCHF = _symbolParser.IsEURCHF(_Symbol);
|
||||
// bool isUSDJPY = _symbolParser.IsUSDJPY(_Symbol);
|
||||
// bool isEURJPY = _symbolParser.IsEURJPY(_Symbol);
|
||||
// bool isUSDCAD = _symbolParser.IsUSDCAD(_Symbol);
|
||||
// bool isEURCAD = _symbolParser.IsEURCAD(_Symbol);
|
||||
// bool isAUDUSD = _symbolParser.IsAUDUSD(_Symbol);
|
||||
// bool isEURAUD = _symbolParser.IsEURAUD(_Symbol);
|
||||
// bool isNZDUSD = _symbolParser.IsNZDUSD(_Symbol);
|
||||
// bool isEURNZD = _symbolParser.IsEURNZD(_Symbol);
|
||||
//
|
||||
// Check Symbol Can Register or not ...
|
||||
bool canRegisterStrategy = true;
|
||||
|
||||
// //
|
||||
// // Check Symbol Can Register or not ...
|
||||
// bool canRegisterStrategy = true;
|
||||
//
|
||||
if (canRegisterStrategy)
|
||||
{
|
||||
//
|
||||
// Create Class Instance ...
|
||||
XCX121SMCStrategy *iX121SMCStrategy;
|
||||
iX121SMCStrategy = new XCX121SMCStrategy(
|
||||
iSymbol,
|
||||
_Period //
|
||||
);
|
||||
|
||||
// //
|
||||
// if (canRegisterStrategy)
|
||||
// {
|
||||
// //
|
||||
// // Create Class Instance ...
|
||||
// XCX121SMCStrategy *iX121SMCStrategy;
|
||||
// iX121SMCStrategy = new XCX121SMCStrategy(
|
||||
// iSymbol,
|
||||
// _Period //
|
||||
// );
|
||||
|
||||
// //
|
||||
// // Configuere Strategy ...
|
||||
// // iX121SMCStrategy.DrawImportantAreas(false);
|
||||
// // iX121SMCStrategy.AddXSignalEventHandler(OnSignalRecieved);
|
||||
|
||||
// // //
|
||||
// // // Configure Alerts ...
|
||||
// // iX121SMCStrategy.SetAlertPrefix(eaLogTag);
|
||||
// // iX121SMCStrategy.SetAlertEnableAlerts(eAEnableAlerts);
|
||||
// // iX121SMCStrategy.SetAlertLogAlerts(eALogAlerts);
|
||||
// // iX121SMCStrategy.SetAlertMailAlerts(eAMailAlerts);
|
||||
// // iX121SMCStrategy.SetAlertPushAlerts(eAPushAlerts);
|
||||
// // iX121SMCStrategy.SetAlertTerminalAlerts(eATerminalAlerts);
|
||||
|
||||
// //
|
||||
// // Register Strategy ...
|
||||
// RegisterStrategy(iX121SMCStrategy);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Register Strategy ...
|
||||
ConfigureStrategy(iX121SMCStrategy);
|
||||
RegisterStrategy(iX121SMCStrategy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
@@ -557,10 +531,6 @@ void DestroyEA()
|
||||
|
||||
//
|
||||
delete eaAlert;
|
||||
|
||||
//
|
||||
// TEST ...
|
||||
delete eaPOI;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -724,8 +694,63 @@ void HandleReportTime()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initial EA Controller Conditions ...
|
||||
*/
|
||||
void InitControllerConditions()
|
||||
{
|
||||
//
|
||||
// Signalling Conditions ...
|
||||
eaAllowLongSignalling = eaAllowLong;
|
||||
eaAllowShortSignalling = eaAllowShort;
|
||||
|
||||
//
|
||||
eaDisableSignalling = !eaAllowLongSignalling &&
|
||||
!eaAllowShortSignalling;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
/**
|
||||
* Configure Startegy ...
|
||||
*/
|
||||
void ConfigureStrategy(XCX121SMCStrategy *&strategy)
|
||||
{
|
||||
//
|
||||
if (strategy == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Configure Alerts ...
|
||||
strategy.SetAlertPrefix(eaLogTag);
|
||||
strategy.SetAlertLogAlerts(eALogAlerts);
|
||||
strategy.SetAlertMailAlerts(eAMailAlerts);
|
||||
strategy.SetAlertPushAlerts(eAPushAlerts);
|
||||
strategy.SetAlertEnableAlerts(eAEnableAlerts);
|
||||
strategy.SetAlertTerminalAlerts(eATerminalAlerts);
|
||||
|
||||
//
|
||||
// Confiugre Signalling ...
|
||||
|
||||
//
|
||||
strategy.AllowLong(eaAllowLongSignalling);
|
||||
strategy.AllowShort(eaAllowShortSignalling);
|
||||
|
||||
//
|
||||
if (eaDisableSignalling)
|
||||
{
|
||||
strategy.Disable();
|
||||
}
|
||||
else
|
||||
{
|
||||
strategy.Enable();
|
||||
}
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an Strategy in EA ...
|
||||
*
|
||||
@@ -749,4 +774,45 @@ void RegisterStrategy(XCX121SMCStrategy *strategy)
|
||||
eaStrategies[ArraySize(eaStrategies) - 1] = strategy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Re Configure All Registered Strategies ...
|
||||
*/
|
||||
void ReConfigureAllStrategies()
|
||||
{
|
||||
//
|
||||
int count = ArraySize(eaStrategies);
|
||||
if (!IsValidSize(count))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
ConfigureStrategy(eaStrategies[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Call all Registered Strategies On Tick ...
|
||||
*/
|
||||
void HandleStrategiesOnTick()
|
||||
{
|
||||
//
|
||||
int count = ArraySize(eaStrategies);
|
||||
if (!IsValidSize(count))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
// Call Tick Handler Function ...
|
||||
eaStrategies[i].HandleTick();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -437,8 +437,7 @@ struct XZone
|
||||
string result = NULL;
|
||||
|
||||
//
|
||||
result = prefix +
|
||||
"_XZone_" +
|
||||
result = prefix + "_" +
|
||||
ToString(upper) + "_" +
|
||||
ToString(lower);
|
||||
|
||||
@@ -474,6 +473,655 @@ typedef void (*TXZoneEventHandler)(
|
||||
XZone &zone //
|
||||
);
|
||||
|
||||
//
|
||||
// Model Exists Founded POIs ...
|
||||
struct XPOIState
|
||||
{
|
||||
//
|
||||
string symbol;
|
||||
ENUM_TIMEFRAMES period;
|
||||
datetime reportedAt;
|
||||
|
||||
//
|
||||
XTradeDay tradingDays[];
|
||||
XMarketSession marketSessions[];
|
||||
|
||||
//
|
||||
XOHCL momentumBars[];
|
||||
XOHCL rejectionBars[];
|
||||
|
||||
//
|
||||
XOHCL swingHighs[];
|
||||
XOHCL swingLows[];
|
||||
|
||||
//
|
||||
XOHCL supportZones[];
|
||||
XOHCL resistanceZones[];
|
||||
|
||||
//
|
||||
XZone supplyZones[];
|
||||
XZone demandZones[];
|
||||
|
||||
//
|
||||
XZone bullishOrderBlocks[];
|
||||
XZone bearishOrderBlocks[];
|
||||
|
||||
//
|
||||
XZone bullishFVGs[];
|
||||
XZone bearishFVGs[];
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
void XPOIState()
|
||||
{
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Actions ...
|
||||
|
||||
/**
|
||||
* Cleanup all props ...
|
||||
*/
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
symbol = NULL;
|
||||
period = NULL;
|
||||
reportedAt = NULL;
|
||||
|
||||
//
|
||||
Clean(tradingDays);
|
||||
Clean(marketSessions);
|
||||
|
||||
//
|
||||
Clean(momentumBars);
|
||||
Clean(rejectionBars);
|
||||
|
||||
//
|
||||
Clean(swingHighs);
|
||||
Clean(swingLows);
|
||||
|
||||
//
|
||||
Clean(supportZones);
|
||||
Clean(resistanceZones);
|
||||
|
||||
//
|
||||
Clean(supplyZones);
|
||||
Clean(demandZones);
|
||||
|
||||
//
|
||||
Clean(bullishOrderBlocks);
|
||||
Clean(bearishOrderBlocks);
|
||||
|
||||
//
|
||||
Clean(bullishFVGs);
|
||||
Clean(bearishFVGs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill Trading Days ...
|
||||
*
|
||||
* @param source: XTradeDay instance Collection ...
|
||||
* @param forceClean: Boolean ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int FillTradingDays(
|
||||
XTradeDay &source[],
|
||||
bool forceClean = true //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
if (forceClean)
|
||||
{
|
||||
Clean(tradingDays);
|
||||
}
|
||||
|
||||
//
|
||||
int count = ArraySize(source);
|
||||
if (!IsValidSize(count))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
Copy(
|
||||
source,
|
||||
tradingDays //
|
||||
);
|
||||
result = ArraySize(tradingDays);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill Market Sessions ...
|
||||
*
|
||||
* @param source: XMarketSession instance Collection ...
|
||||
* @param forceClean: Boolean ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int FillMarketSessions(
|
||||
XMarketSession &source[],
|
||||
bool forceClean = true //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
if (forceClean)
|
||||
{
|
||||
Clean(marketSessions);
|
||||
}
|
||||
|
||||
//
|
||||
int count = ArraySize(source);
|
||||
if (!IsValidSize(count))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
Copy(
|
||||
source,
|
||||
marketSessions //
|
||||
);
|
||||
result = ArraySize(marketSessions);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill Momentum Bars ...
|
||||
*
|
||||
* @param source: XOHCL instance Collection ...
|
||||
* @param forceClean: Boolean ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int FillMomentumBars(
|
||||
XOHCL &source[],
|
||||
bool forceClean = true //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
if (forceClean)
|
||||
{
|
||||
Clean(momentumBars);
|
||||
}
|
||||
|
||||
//
|
||||
int count = ArraySize(source);
|
||||
if (!IsValidSize(count))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
Copy(
|
||||
source,
|
||||
momentumBars //
|
||||
);
|
||||
result = ArraySize(momentumBars);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill Retection Bars ...
|
||||
*
|
||||
* @param source: XOHCL instance Collection ...
|
||||
* @param forceClean: Boolean ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int FillRejectionBars(
|
||||
XOHCL &source[],
|
||||
bool forceClean = true //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
if (forceClean)
|
||||
{
|
||||
Clean(rejectionBars);
|
||||
}
|
||||
|
||||
//
|
||||
int count = ArraySize(source);
|
||||
if (!IsValidSize(count))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
Copy(
|
||||
source,
|
||||
rejectionBars //
|
||||
);
|
||||
result = ArraySize(rejectionBars);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill Swing Highs ...
|
||||
*
|
||||
* @param source: XOHCL instance Collection ...
|
||||
* @param forceClean: Boolean ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int FillSwingHighs(
|
||||
XOHCL &source[],
|
||||
bool forceClean = true //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
if (forceClean)
|
||||
{
|
||||
Clean(swingHighs);
|
||||
}
|
||||
|
||||
//
|
||||
int count = ArraySize(source);
|
||||
if (!IsValidSize(count))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
Copy(
|
||||
source,
|
||||
swingHighs //
|
||||
);
|
||||
result = ArraySize(swingHighs);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill Swing Lows ...
|
||||
*
|
||||
* @param source: XOHCL instance Collection ...
|
||||
* @param forceClean: Boolean ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int FillSwingLows(
|
||||
XOHCL &source[],
|
||||
bool forceClean = true //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
if (forceClean)
|
||||
{
|
||||
Clean(swingLows);
|
||||
}
|
||||
|
||||
//
|
||||
int count = ArraySize(source);
|
||||
if (!IsValidSize(count))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
Copy(
|
||||
source,
|
||||
swingLows //
|
||||
);
|
||||
result = ArraySize(swingLows);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill Support Zones ...
|
||||
*
|
||||
* @param source: XOHCL instance Collection ...
|
||||
* @param forceClean: Boolean ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int FillSupportZones(
|
||||
XOHCL &source[],
|
||||
bool forceClean = true //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
if (forceClean)
|
||||
{
|
||||
Clean(supportZones);
|
||||
}
|
||||
|
||||
//
|
||||
int count = ArraySize(source);
|
||||
if (!IsValidSize(count))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
Copy(
|
||||
source,
|
||||
supportZones //
|
||||
);
|
||||
result = ArraySize(supportZones);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill Resistance Zones ...
|
||||
*
|
||||
* @param source: XOHCL instance Collection ...
|
||||
* @param forceClean: Boolean ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int FillResistanceZones(
|
||||
XOHCL &source[],
|
||||
bool forceClean = true //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
if (forceClean)
|
||||
{
|
||||
Clean(resistanceZones);
|
||||
}
|
||||
|
||||
//
|
||||
int count = ArraySize(source);
|
||||
if (!IsValidSize(count))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
Copy(
|
||||
source,
|
||||
resistanceZones //
|
||||
);
|
||||
result = ArraySize(resistanceZones);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill Supply Zones ...
|
||||
*
|
||||
* @param source: XZone instance Collection ...
|
||||
* @param forceClean: Boolean ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int FillSupplyZones(
|
||||
XZone &source[],
|
||||
bool forceClean = true //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
if (forceClean)
|
||||
{
|
||||
Clean(supplyZones);
|
||||
}
|
||||
|
||||
//
|
||||
int count = ArraySize(source);
|
||||
if (!IsValidSize(count))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
Copy(
|
||||
source,
|
||||
supplyZones //
|
||||
);
|
||||
result = ArraySize(supplyZones);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill Demand Zones ...
|
||||
*
|
||||
* @param source: XZone instance Collection ...
|
||||
* @param forceClean: Boolean ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int FillDemandZones(
|
||||
XZone &source[],
|
||||
bool forceClean = true //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
if (forceClean)
|
||||
{
|
||||
Clean(demandZones);
|
||||
}
|
||||
|
||||
//
|
||||
int count = ArraySize(source);
|
||||
if (!IsValidSize(count))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
Copy(
|
||||
source,
|
||||
demandZones //
|
||||
);
|
||||
result = ArraySize(demandZones);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill Bullish Order Blockss ...
|
||||
*
|
||||
* @param source: XZone instance Collection ...
|
||||
* @param forceClean: Boolean ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int FillBullishOrderBlocks(
|
||||
XZone &source[],
|
||||
bool forceClean = true //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
if (forceClean)
|
||||
{
|
||||
Clean(bullishOrderBlocks);
|
||||
}
|
||||
|
||||
//
|
||||
int count = ArraySize(source);
|
||||
if (!IsValidSize(count))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
Copy(
|
||||
source,
|
||||
bullishOrderBlocks //
|
||||
);
|
||||
result = ArraySize(bullishOrderBlocks);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill Bearish Order Blockss ...
|
||||
*
|
||||
* @param source: XZone instance Collection ...
|
||||
* @param forceClean: Boolean ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int FillBearishOrderBlocks(
|
||||
XZone &source[],
|
||||
bool forceClean = true //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
if (forceClean)
|
||||
{
|
||||
Clean(bearishOrderBlocks);
|
||||
}
|
||||
|
||||
//
|
||||
int count = ArraySize(source);
|
||||
if (!IsValidSize(count))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
Copy(
|
||||
source,
|
||||
bearishOrderBlocks //
|
||||
);
|
||||
result = ArraySize(bearishOrderBlocks);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill Bullish FVGs ...
|
||||
*
|
||||
* @param source: XZone instance Collection ...
|
||||
* @param forceClean: Boolean ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int FillBullishFVGs(
|
||||
XZone &source[],
|
||||
bool forceClean = true //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
if (forceClean)
|
||||
{
|
||||
Clean(bullishFVGs);
|
||||
}
|
||||
|
||||
//
|
||||
int count = ArraySize(source);
|
||||
if (!IsValidSize(count))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
Copy(
|
||||
source,
|
||||
bullishFVGs //
|
||||
);
|
||||
result = ArraySize(bullishFVGs);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill Bearish FVGs ...
|
||||
*
|
||||
* @param source: XZone instance Collection ...
|
||||
* @param forceClean: Boolean ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int FillBearishFVGs(
|
||||
XZone &source[],
|
||||
bool forceClean = true //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
if (forceClean)
|
||||
{
|
||||
Clean(bearishFVGs);
|
||||
}
|
||||
|
||||
//
|
||||
int count = ArraySize(source);
|
||||
if (!IsValidSize(count))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
Copy(
|
||||
source,
|
||||
bearishFVGs //
|
||||
);
|
||||
result = ArraySize(bearishFVGs);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
//
|
||||
// Extensions ...
|
||||
|
||||
@@ -611,3 +1259,103 @@ string ToString(ENUM_XSESSION value)
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate General Event Messages ...
|
||||
*
|
||||
* @param value: ENUM_XPOI_EVENTS member ...
|
||||
*
|
||||
* @return ( string )
|
||||
*/
|
||||
string ToString(ENUM_XPOI_EVENTS value)
|
||||
{
|
||||
//
|
||||
string result = NULL;
|
||||
|
||||
//
|
||||
switch (value)
|
||||
{
|
||||
//
|
||||
case X_TRADE_DAY_FIRST_BAR:
|
||||
result = "First Bar of Day";
|
||||
break;
|
||||
|
||||
//
|
||||
case X_TRADE_DAY_LAST_BAR:
|
||||
result = "Last Bar of Day";
|
||||
break;
|
||||
|
||||
//
|
||||
case X_SESSION_FIRST_BAR:
|
||||
result = "First Bar of Session";
|
||||
break;
|
||||
|
||||
//
|
||||
case X_SESSION_LAST_BAR:
|
||||
result = "Last Bar of Session";
|
||||
break;
|
||||
|
||||
//
|
||||
case X_MOMENTUM_BAR_DETECTED:
|
||||
result = "Momentum Bar Detected";
|
||||
break;
|
||||
|
||||
//
|
||||
case X_REJECTION_BAR_DETECTED:
|
||||
result = "Rejection Bar Detected";
|
||||
break;
|
||||
|
||||
//
|
||||
case X_SWING_HIGH_DETECTED:
|
||||
result = "Swing High Detected";
|
||||
break;
|
||||
|
||||
//
|
||||
case X_SWING_LOW_DETECTED:
|
||||
result = "Swing Low Detected";
|
||||
break;
|
||||
|
||||
//
|
||||
case X_SUPPORT_ZONE_DETECTED:
|
||||
result = "Support Zone Detected";
|
||||
break;
|
||||
|
||||
//
|
||||
case X_RESISTANCE_ZONE_DETECTED:
|
||||
result = "Resistance Zone Detected";
|
||||
break;
|
||||
|
||||
//
|
||||
case X_SUPPLY_ZONE_DETECTED:
|
||||
result = "Supply Zone Detected";
|
||||
break;
|
||||
|
||||
//
|
||||
case X_DEMAND_ZONE_DETECTED:
|
||||
result = "Demand Zone Detected";
|
||||
break;
|
||||
|
||||
//
|
||||
case X_BULLISH_ORDERBLOCK_DETECTED:
|
||||
result = "Bullish Order Block Detected";
|
||||
break;
|
||||
|
||||
//
|
||||
case X_BEARISH_ORDERBLOCK_DETECTED:
|
||||
result = "Bearish Orer Block Detected";
|
||||
break;
|
||||
|
||||
//
|
||||
case X_BULLISH_FVG_DETECTED:
|
||||
result = "Bullish FVG Detected";
|
||||
break;
|
||||
|
||||
//
|
||||
case X_BEARISH_FVG_DETECTED:
|
||||
result = "Bearish FVg Detected";
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Seriallize Library
|
||||
// ---------------------------------------
|
||||
// Name: X121SMCLib
|
||||
// Description: All models related to X121SMC ...
|
||||
//
|
||||
//
|
||||
// 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
|
||||
|
||||
//
|
||||
// Imports ...
|
||||
#include "../../Classes/x-saherelm.base.class.mq5"
|
||||
#include "../../Libraries/x-saherelm.common.lib.mq5"
|
||||
#include "../../Libraries/x-saherelm.x-poi.lib.mq5"
|
||||
#include "../../Libraries/x-saherelm.xtrade.lib.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
//
|
||||
// Specific Identifier(s) of XStrategy ...
|
||||
string X121SMCStrategyToken = "X121SMC";
|
||||
|
||||
//
|
||||
// Condition Structure ...
|
||||
struct X121SMCStrategyConditions
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Common ...
|
||||
string symbol;
|
||||
ENUM_TIMEFRAMES period;
|
||||
datetime time;
|
||||
|
||||
//
|
||||
// Helper Conditions ...
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
void XStrategyConditions()
|
||||
{
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Cleanup ...
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
symbol = NULL;
|
||||
period = NULL;
|
||||
time = NULL;
|
||||
|
||||
//
|
||||
// Clean Helpers Conditions ...
|
||||
}
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
IsValid(time) &&
|
||||
IsValid(symbol) &&
|
||||
IsValid(period)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Generate Provided Scores ...
|
||||
void GenerateScore(
|
||||
double &bullishScore,
|
||||
double &bearishScore //
|
||||
)
|
||||
{
|
||||
//
|
||||
bullishScore = 0;
|
||||
bearishScore = 0;
|
||||
|
||||
//
|
||||
if (!IsValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
double bullScore = 0;
|
||||
double bearScore = 0;
|
||||
|
||||
//
|
||||
// Generate Helpers Conitions Scores ...
|
||||
}
|
||||
|
||||
//
|
||||
// Generate Summary ...
|
||||
string GenerateSummary(
|
||||
bool onlyCommons = false,
|
||||
bool onlyConditions = false,
|
||||
bool includeScores = true,
|
||||
bool ignoreFalseConditions = true,
|
||||
string separator = "\n" //
|
||||
)
|
||||
{
|
||||
//
|
||||
string result = NULL;
|
||||
|
||||
//
|
||||
double bullishScore = 0;
|
||||
double bearishScore = 0;
|
||||
GenerateScore(
|
||||
bullishScore,
|
||||
bearishScore //
|
||||
);
|
||||
|
||||
//
|
||||
string commonStr = GenerateSpecifiedCommonSummary(
|
||||
this,
|
||||
separator,
|
||||
includeScores,
|
||||
true //
|
||||
);
|
||||
|
||||
//
|
||||
// Generate Helpers Conditions Strings ...
|
||||
|
||||
//
|
||||
// Combine Helpers Conditions Strings ...
|
||||
string conditionsStr =
|
||||
//
|
||||
"" + separator +
|
||||
""
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
"[" + GetTag() + "]" + separator +
|
||||
"----------" + separator +
|
||||
(onlyConditions
|
||||
? ""
|
||||
: commonStr) +
|
||||
" " + separator +
|
||||
(onlyCommons
|
||||
? ""
|
||||
: conditionsStr) +
|
||||
""
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
string GetTag()
|
||||
{
|
||||
return X121SMCStrategyToken;
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
//
|
||||
// On Signal Event Handler ...
|
||||
typedef void (*TOnX121SMCSignal)(
|
||||
XSignal &signal,
|
||||
X121SMCStrategyConditions &conditions //
|
||||
);
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user