229 lines
4.5 KiB
Plaintext
229 lines
4.5 KiB
Plaintext
///////////////////////////////////////////////////////
|
|
//
|
|
// SaherElm IT Center MQL5 Common Library
|
|
// --------------------------------------
|
|
// Name: X121SMCLib
|
|
// Description: provide all commonly used functions ...
|
|
//
|
|
//
|
|
// 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.x-trade.lib.mq5"
|
|
|
|
//
|
|
// Definitions ...
|
|
|
|
const string X121SMCStrategyToken = "X121SMC";
|
|
|
|
struct X121SMCStrategyConditions
|
|
{
|
|
//
|
|
string symbol;
|
|
ENUM_TIMEFRAMES period;
|
|
datetime time;
|
|
|
|
//
|
|
void X121SMCStrategyConditions()
|
|
{
|
|
Clean();
|
|
}
|
|
|
|
//
|
|
// Tools ...
|
|
|
|
/**
|
|
* Cleanup ...
|
|
*/
|
|
void Clean()
|
|
{
|
|
//
|
|
symbol = NULL;
|
|
period = NULL;
|
|
time = NULL;
|
|
}
|
|
|
|
/**
|
|
* Validate ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool IsValid()
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result = IsSpecifiedValid(symbol) &&
|
|
IsSpecifiedValid(period) &&
|
|
IsSpecifiedValid(time);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Generate Provided Scores ...
|
|
*
|
|
* @param bullishScore: Integer, reference ...
|
|
* @param bearishScore: Integer, referenceF ...
|
|
*/
|
|
void GenerateScore(
|
|
double &bullishScore,
|
|
double &bearishScore //
|
|
)
|
|
{
|
|
//
|
|
bullishScore = 0;
|
|
bearishScore = 0;
|
|
|
|
//
|
|
if (!IsValid())
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
double bullScore = 0;
|
|
double bearScore = 0;
|
|
|
|
// //
|
|
// // XPV ...
|
|
// pvConditions.GenerateScore(
|
|
// bullScore,
|
|
// bearScore //
|
|
// );
|
|
// bullishScore += bullScore;
|
|
// bearishScore += bearScore;
|
|
}
|
|
|
|
/**
|
|
* Generate Summary ...
|
|
*
|
|
* @param onlyCommons: Boolean ...
|
|
* @param onlyConditions: Boolean ...
|
|
* @param includeScores: Boolean ...
|
|
* @param ignoreFalseConditions: Boolean ...
|
|
* @param separator: String ...
|
|
*
|
|
* @return ( string )
|
|
*/
|
|
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 //
|
|
);
|
|
|
|
// //
|
|
// // XPV ...
|
|
// string pvStr = pvConditions.GenerateSummary(
|
|
// false,
|
|
// true,
|
|
// false,
|
|
// ignoreFalseConditions //
|
|
// );
|
|
|
|
//
|
|
string conditionsStr =
|
|
//
|
|
// pvStr + separator +
|
|
""
|
|
//
|
|
;
|
|
|
|
//
|
|
result =
|
|
//
|
|
"[" + GetTag() + "]" + separator +
|
|
"----------" + separator +
|
|
(onlyConditions
|
|
? ""
|
|
: commonStr) +
|
|
" " + separator +
|
|
(onlyCommons
|
|
? ""
|
|
: conditionsStr) +
|
|
""
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Get Unique Identifier ...
|
|
*
|
|
* @param forObject: Boolean ...
|
|
*
|
|
* @return ( string )
|
|
*/
|
|
string GetTag(
|
|
bool forObject = false //
|
|
)
|
|
{
|
|
//
|
|
string result = NULL;
|
|
|
|
//
|
|
if (!forObject)
|
|
{
|
|
result = X121SMCStrategyToken;
|
|
}
|
|
else
|
|
{
|
|
//
|
|
result = X121SMCStrategyToken + "_" +
|
|
symbol + "_" + ToString(period) + "_" +
|
|
ToMD5(time);
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
};
|
|
|
|
typedef void (*TOnX121SMCSignal)(
|
|
XSignal &signal,
|
|
X121SMCStrategyConditions &conditions //
|
|
);
|
|
|
|
// |