272 lines
4.9 KiB
Plaintext
272 lines
4.9 KiB
Plaintext
///////////////////////////////////////////////////////
|
|
//
|
|
// 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;
|
|
|
|
//
|
|
// Conditions ...
|
|
|
|
//
|
|
XZone supplyZone;
|
|
|
|
//
|
|
XZone bearishOrderBlocks[];
|
|
XZone bearishFVGs[];
|
|
|
|
//
|
|
XOHCL swingHighs[];
|
|
XOHCL resistances[];
|
|
XOHCL bearishMomentumBars[];
|
|
XOHCL bearishRejectionBars[];
|
|
|
|
//
|
|
XZone demandZone;
|
|
|
|
//
|
|
XZone bullishOrderBlocks[];
|
|
XZone bullishFVGs[];
|
|
|
|
//
|
|
XOHCL supports[];
|
|
XOHCL swingLows[];
|
|
XOHCL bullishMomentumBars[];
|
|
XOHCL bullishRejectionBars[];
|
|
|
|
//
|
|
// Constructor ...
|
|
void XStrategyConditions()
|
|
{
|
|
Clean();
|
|
}
|
|
|
|
//
|
|
// Tools ...
|
|
|
|
//
|
|
// Cleanup ...
|
|
void Clean()
|
|
{
|
|
//
|
|
symbol = NULL;
|
|
period = NULL;
|
|
time = NULL;
|
|
|
|
//
|
|
supplyZone.Clean();
|
|
|
|
//
|
|
Clean(bearishFVGs);
|
|
Clean(bearishOrderBlocks);
|
|
|
|
//
|
|
demandZone.Clean();
|
|
|
|
//
|
|
Clean(bullishFVGs);
|
|
Clean(bullishOrderBlocks);
|
|
|
|
//
|
|
Clean(swingHighs);
|
|
Clean(resistances);
|
|
Clean(bearishMomentumBars);
|
|
Clean(bearishRejectionBars);
|
|
|
|
//
|
|
Clean(swingLows);
|
|
Clean(supports);
|
|
Clean(bullishMomentumBars);
|
|
Clean(bullishRejectionBars);
|
|
}
|
|
|
|
//
|
|
// 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(
|
|
bool fullTag = false //
|
|
)
|
|
{
|
|
//
|
|
string result = NULL;
|
|
|
|
//
|
|
if (!IsValid())
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
if (fullTag)
|
|
{
|
|
//
|
|
result = X121SMCStrategyToken + "_" +
|
|
"Conditions_" +
|
|
symbol + "_" +
|
|
ToString(period) + "_" +
|
|
ToFormatString(time);
|
|
}
|
|
else
|
|
{
|
|
result = X121SMCStrategyToken;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
};
|
|
|
|
//
|
|
// On Signal Event Handler ...
|
|
typedef void (*TOnX121SMCSignal)(
|
|
XSignal &signal,
|
|
X121SMCStrategyConditions &conditions //
|
|
);
|