prepare signaller's class ...

This commit is contained in:
2024-06-04 18:34:34 +03:30
parent 87a165d4a0
commit 1637a6ba92
8 changed files with 825 additions and 3677 deletions
+5 -403
View File
@@ -40,6 +40,7 @@
#include "../Helpers/x-saherelm.xich.helper.mq5"
//
#include "../Libraries/x-saherelm.xtrade.lib.mq5"
#include "../Classes/x-saherelm.xalert.class.mq5"
//
@@ -2383,7 +2384,6 @@ public:
// Constructor ...
void XSignallerDescriptor()
{
Clean();
}
//
@@ -2607,6 +2607,10 @@ public:
{
return false;
}
//
// Protected ...
protected:
};
//
@@ -2726,62 +2730,6 @@ public:
return Init(inputs);
}
//
bool AddSignaller(
XSignallerDescriptor &signaller //
)
{
//
bool result = false;
//
// Validate Signaller ...
result = signaller.IsValid();
if (!result)
{
return result;
}
//
AddRef(
signaller,
mSignallers //
);
//
return result;
}
//
int AddSignallers(
XSignallerDescriptor &signallers[] //
)
{
//
int result = 0;
//
int count = ArraySize(signallers);
if (!IsValidSize(count))
{
return result;
}
//
for (int i = 0; i < count; i++)
{
//
bool isAdded = AddSignaller(signallers[i]);
if (isAdded)
{
result++;
}
}
//
return result;
}
//
// Tools ...
@@ -4380,279 +4328,6 @@ public:
conditions.isHCLLSwitchedToBeraish = isHCLLSwitchedToBeraish;
}
//
// Market Parse Conditions ...
bool HasConditions(
XSignal &signal, // If Any Signal provided, Filled here ...
bool &hasLong,
int &longPusher,
bool &hasShort,
int &shortPusher //
)
{
//
bool result = false;
//
longPusher = 0;
shortPusher = 0;
hasLong = false;
hasShort = false;
//
int count = CountSignallers();
if (!IsValidSize(count))
{
return result;
}
//
X121MCycleConditions conditions;
GetMarketConditions(conditions);
//
for (int i = 0; i < count; i++)
{
//
bool iHasLong = false;
bool iHasShort = false;
//
double iTP = 0;
double iTPProvided = 0;
double iSL = 0;
double iSLProvided = 0;
double iEntry = 0;
ENUM_POSITION_TYPE iType;
string iSymbol = GetSymbol();
double iR2R = mSignallers[i].r2r;
ENUM_TIMEFRAMES iPeriod = GetPeriod();
string iProvider = mSignallers[i].GetName();
//
bool iHasSignal = mSignallers[i].HasConditions(
conditions,
iHasLong,
iHasShort,
iTPProvided,
iSLProvided //
);
if (iHasSignal)
{
//
// Filling Pusher(s) ...
if (iHasLong)
{
longPusher++;
}
else if (iHasShort)
{
shortPusher++;
}
//
if (iHasLong && !hasLong)
{
//
hasLong = iHasLong;
//
// Filling Signal ...
iType = POSITION_TYPE_BUY;
//
iEntry = GetEntry(
iSymbol,
iType //
);
//
CalculateTPSL(
iSL,
iTP,
iType,
iEntry,
iR2R,
iSLProvided,
iTPProvided //
);
//
// Fill Signal Here ...
bool isSignalGenerated = mSignallers[i].GenerateMarketSignal(
signal,
iSymbol,
iPeriod,
iType,
iEntry,
iSL,
iTP //
);
}
else if (iHasShort && !hasShort)
{
//
hasShort = iHasShort;
//
// Fill Signal Here ...
iType = POSITION_TYPE_SELL;
//
iEntry = GetEntry(
iSymbol,
iType //
);
//
CalculateTPSL(
iSL,
iTP,
iType,
iEntry,
iR2R,
iSLProvided,
iTPProvided //
);
//
// Fill Signal Here ...
bool isSignalGenerated = mSignallers[i].GenerateMarketSignal(
signal,
iSymbol,
iPeriod,
iType,
iEntry,
iSL,
iTP //
);
}
}
}
//
result = hasLong || hasShort;
//
return result;
}
//
// X786 Long ...
bool HasX786LongConditions()
{
//
bool result = false;
//
X121MCycleConditions conditions;
GetMarketConditions(conditions);
//
result =
//
(conditions.isSMHKSwitchedToBullish &&
(conditions.isTDBullish &&
conditions.isCHEBullish &&
conditions.isTrendBullish))
//
||
//
(conditions.isTDSwitchedToBullish &&
(conditions.isSMHKBullish &&
conditions.isCHEBullish &&
conditions.isTrendBullish))
//
||
//
(conditions.isCHESwitchedToBullish &&
(conditions.isTDBullish &&
conditions.isSMHKBullish &&
conditions.isTrendBullish))
//
||
//
(conditions.isTrendSwitchedToBullish &&
(conditions.isTDBullish &&
conditions.isCHEBullish &&
conditions.isSMHKBullish))
//
;
//
return result;
}
//
// X786 Short ...
bool HasX786ShortConditions()
{
//
bool result = false;
//
X121MCycleConditions conditions;
GetMarketConditions(conditions);
//
result =
//
(conditions.isSMHKSwitchedToBearish &&
(conditions.isTDBearish &&
conditions.isCHEBearish &&
conditions.isTrendBearish))
//
||
//
(conditions.isTDSwitchedToBearish &&
(conditions.isSMHKBearish &&
conditions.isCHEBearish &&
conditions.isTrendBearish))
//
||
//
(conditions.isCHESwitchedToBearish &&
(conditions.isTDBearish &&
conditions.isSMHKBearish &&
conditions.isTrendBearish))
//
||
//
(conditions.isTrendSwitchedToBearish &&
(conditions.isTDBearish &&
conditions.isCHEBearish &&
conditions.isSMHKBearish))
//
;
//
return result;
}
//
// X121 Long ...
bool HasX121LongConditions()
{
//
bool result = false;
//
return result;
}
//
// X121 Short ...
bool HasX121ShortConditions()
{
//
bool result = false;
//
return result;
}
//
//
// Initial Market Cycle ...
bool Init(
@@ -5193,76 +4868,6 @@ private:
//
X121MCycleInputs mInputs;
//
// Signallers ...
//
XSignallerDescriptor mSignallers[];
//
// Count Signallers ...
int CountSignallers()
{
return ArraySize(mSignallers);
}
//
// Find Signaller Index ...
int FindSignallerIndex(ENUM_XSIGNAL_PROVIDERS signaller)
{
//
int result = -1;
//
int count = CountSignallers();
if (!IsValidSize(count))
{
return result;
}
//
for (int i = 0; i < count; i++)
{
//
XSignallerDescriptor iSignaller = mSignallers[i];
//
if (iSignaller.name == signaller)
{
//
result = i;
break;
}
}
//
return result;
}
int FindSignallerIndex(string signaller)
{
//
int result = -1;
//
if (!IsValid(signaller))
{
return result;
}
//
ENUM_XSIGNAL_PROVIDERS mSignaller = ToXSignalProvider(signaller);
if (mSignaller == PROVIDER_NONE)
{
return result;
}
//
result = FindSignallerIndex(mSignaller);
//
return result;
}
//
// Tools ...
@@ -5519,9 +5124,6 @@ struct X121MarketCycleDescriptor
//
XSCX121Market *market; // Market
//
X121MCycleConditions conditions; // Market Conditions
//
// Tools ...