prepare all materials for implementing new test strategy ...

This commit is contained in:
2024-12-25 00:53:38 +03:30
parent 0a4859982b
commit aa1ffb3ed9
6 changed files with 1890 additions and 1134 deletions
@@ -3015,6 +3015,22 @@ class XC121SMCTradeHandler : public XCBaseAlert
} }
} }
//
// Check Spread ...
double spread = GetSpread(signal.symbol);
double maxAllowedSpread = MaxAllowedSpread();
if (maxAllowedSpread > 0)
{
//
result = spread <= maxAllowedSpread;
if (!result)
{
//
state = X_SIGNAL_EXECUTION_FAILED_SPREAD;
return result;
}
}
// //
return result; return result;
} }
+3 -3
View File
@@ -24,7 +24,7 @@
#include "../../Classes/x-saherelm.x-expert.class.mq5" #include "../../Classes/x-saherelm.x-expert.class.mq5"
#include "../Classes/x-121.smc.x-tradehandler.class.mq5" #include "../Classes/x-121.smc.x-tradehandler.class.mq5"
#include "../Libraries/x-121.smc.lib.mq5" #include "../Libraries/x-121.smc.lib.mq5"
#include "../Strategy/x-121.smc.test.strategy.class.mq5" #include "../Strategy/x-121.smc.strategy.class.mq5"
// //
// Definitions ... // Definitions ...
@@ -1044,7 +1044,7 @@ class XC121SMCExpert : public XCBaseExpert
// //
// Create Class Instance ... // Create Class Instance ...
XCX121SMCBaseStrategy *iX121SMCStrategy; XCX121SMCBaseStrategy *iX121SMCStrategy;
iX121SMCStrategy = new XCX121SMCTestStrategy( iX121SMCStrategy = new XCX121SMCStrategy(
_Symbol, _Symbol,
_Period // _Period //
); );
@@ -1109,7 +1109,7 @@ class XC121SMCExpert : public XCBaseExpert
// //
// Create Class Instance ... // Create Class Instance ...
XCX121SMCBaseStrategy *iX121SMCStrategy; XCX121SMCBaseStrategy *iX121SMCStrategy;
iX121SMCStrategy = new XCX121SMCTestStrategy( iX121SMCStrategy = new XCX121SMCStrategy(
iSymbol, iSymbol,
_Period // _Period //
); );
+12 -23
View File
@@ -34,9 +34,8 @@
const string X121SMCStrategyToken = "X121SMC"; const string X121SMCStrategyToken = "X121SMC";
// //
const string X121SMCSMPVToken = "X121SMCSMPV"; const string X121SMCXTestToken = "X121XTest";
const string X121SMCRJBPVToken = "X121SMCRJBPV"; const string X121SMCXPVOBToken = "X121XPVOB";
const string X121SMCVWAPCToken = "X121SMCVWAPC";
// //
// X121 SMC Providers ... // X121 SMC Providers ...
@@ -44,9 +43,8 @@ enum ENUM_X_121_SMC_PROVIDERS
{ {
// //
X_121_SMC_PROVIDER_NONE, X_121_SMC_PROVIDER_NONE,
X_121_SMC_PROVIDER_SMPV, X_121_SMC_PROVIDER_XTEST,
X_121_SMC_PROVIDER_RJBPV, X_121_SMC_PROVIDER_XPVOB,
X_121_SMC_PROVIDER_VWAPC,
}; };
// //
@@ -1951,18 +1949,13 @@ string ToString(ENUM_X_121_SMC_PROVIDERS value)
switch (value) switch (value)
{ {
// //
case X_121_SMC_PROVIDER_SMPV: case X_121_SMC_PROVIDER_XTEST:
result = X121SMCSMPVToken; result = X121SMCXTestToken;
break; break;
// //
case X_121_SMC_PROVIDER_RJBPV: case X_121_SMC_PROVIDER_XPVOB:
result = X121SMCRJBPVToken; result = X121SMCXPVOBToken;
break;
//
case X_121_SMC_PROVIDER_VWAPC:
result = X121SMCVWAPCToken;
break; break;
} }
@@ -1989,17 +1982,13 @@ ENUM_X_121_SMC_PROVIDERS ParseProvider(string value)
} }
// //
if (Contains(X121SMCSMPVToken, value)) if (Contains(X121SMCXTestToken, value))
{ {
result = X_121_SMC_PROVIDER_SMPV; result = X_121_SMC_PROVIDER_XTEST;
} }
else if (Contains(X121SMCRJBPVToken, value)) else if (Contains(X121SMCXPVOBToken, value))
{ {
result = X_121_SMC_PROVIDER_RJBPV; result = X_121_SMC_PROVIDER_XPVOB;
}
else if (Contains(X121SMCVWAPCToken, value))
{
result = X_121_SMC_PROVIDER_VWAPC;
} }
// //
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -2,7 +2,7 @@
// //
// SaherElm IT Center MQL5 Class Library // SaherElm IT Center MQL5 Class Library
// -------------------------------------- // --------------------------------------
// Name: XCX121SMCTestStrategy // Name: XCX121SMCStrategy
// Description: provides all based classes for use ... // Description: provides all based classes for use ...
// //
// //
@@ -25,14 +25,17 @@
// //
#include "../Classes/x-121.smc.base.strategy.class.mq5" #include "../Classes/x-121.smc.base.strategy.class.mq5"
#include "../Classes/x-121.smc.market.cycle.helper.class.mq5" #include "../Classes/x-121.smc.market.cycle.helper.class.mq5"
//
#include "../Signals/x-121.smc.test.signal.class.mq5" #include "../Signals/x-121.smc.test.signal.class.mq5"
#include "../Signals/x-121.smc.xpvob.signal.class.mq5"
// //
// Definitions ... // Definitions ...
// //
// XStrategy Class Implementation(s) ... // XStrategy Class Implementation(s) ...
class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy class XCX121SMCStrategy : public XCX121SMCBaseStrategy
{ {
// //
// Public ... // Public ...
@@ -41,7 +44,7 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
// //
// Constructor(s) ... // Constructor(s) ...
void XCX121SMCTestStrategy( void XCX121SMCStrategy(
// //
// Base ... // Base ...
string _symbol, // Trading Symbol string _symbol, // Trading Symbol
@@ -54,7 +57,7 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
// //
// Deconstructur ... // Deconstructur ...
void ~XCX121SMCTestStrategy() void ~XCX121SMCStrategy()
{ {
} }
@@ -152,39 +155,11 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
bool hasSignal = false; bool hasSignal = false;
// //
bool hasSMPVSignal = false;
bool hasRJBPVSignal = false;
bool hasVWAPCSignal = false;
bool hasTestSignal = false; bool hasTestSignal = false;
bool hasXPVOBSignal = false;
// //
// X_121_SMC_PROVIDER_SMPV ... // Test Signal ...
if (!hasSignal)
{
//
// hasSMPVSignal = DetectSamePeaksAndValesSignal(conditions);
// hasSignal = hasSMPVSignal;
}
//
// X_121_SMC_PROVIDER_RJBPV ...
if (!hasSignal)
{
// //
// hasRJBPVSignal = DetectRJBPVSignal(conditions);
// hasSignal = hasRJBPVSignal;
}
//
// X_121_SMC_PROVIDER_VWAPC ...
if (!hasSignal)
{
// //
// hasVWAPCSignal = DetectVWAPCSignal(conditions);
// hasSignal = hasVWAPCSignal;
}
//
if (!hasSignal) if (!hasSignal)
{ {
// //
@@ -192,6 +167,15 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
hasSignal = hasTestSignal; hasSignal = hasTestSignal;
} }
//
// XPVOB Signal ...
if (!hasSignal)
{
//
// hasXPVOBSignal = DetectXPVOBSignal(conditions);
// hasSignal = hasXPVOBSignal;
}
// //
result = hasSignal; result = hasSignal;
if (!result) if (!result)
@@ -278,7 +262,8 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
signal.time = TimeCurrent(); signal.time = TimeCurrent();
// //
if (hasTestSignal) // XPVOB Signal ...
if (hasXPVOBSignal)
{ {
// //
// Add Aditionsal Info ... // Add Aditionsal Info ...
@@ -515,7 +500,7 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
// Signalling Functions ... // Signalling Functions ...
// //
// TODO: Remove this ... // Test Signal ...
X121SMCStrategyTestSignalConditions mTestConditions; X121SMCStrategyTestSignalConditions mTestConditions;
bool DetectTestSignal( bool DetectTestSignal(
X121SMCStrategyConditions &conditions // X121SMCStrategyConditions &conditions //
@@ -536,7 +521,7 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
datetime cTime = TimeCurrent(); datetime cTime = TimeCurrent();
// //
ENUM_X_121_SMC_PROVIDERS provider = X_121_SMC_PROVIDER_SMPV; ENUM_X_121_SMC_PROVIDERS provider = X_121_SMC_PROVIDER_XTEST;
string providerStr = ToString(provider); string providerStr = ToString(provider);
// //
@@ -577,39 +562,6 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
if (isSetuped) if (isSetuped)
{ {
// //
XCFVG *iFVG = mTestConditions.activeFVG;
if (iFVG != NULL && iFVG.IsValid())
{
//
ClearDraws();
iFVG.To(cTime);
if (IsBullish(setupDir) && iFVG.IsBullish())
{
//
XCBullishFairValueGapObject *iObj;
bool isCreated = mPOIDrawer.CreateBullishFairValueGap(
iFVG,
iObj //
);
if (isCreated)
{
AddObjectIfNotExists(iObj);
}
}
else if (IsBearish(setupDir) && iFVG.IsBearish())
{
//
XCBearishFairValueGapObject *iObj;
bool isCreated = mPOIDrawer.CreateBearishFairValueGap(
iFVG,
iObj //
);
if (isCreated)
{
AddObjectIfNotExists(iObj);
}
}
}
} }
// //
@@ -669,6 +621,161 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
return result; return result;
} }
//
// XPVOB Signal ...
X121SMCStrategyXPVOBSignalConditions mXPVOBConditions;
bool DetectXPVOBSignal(
X121SMCStrategyConditions &conditions //
)
{
//
bool result = false;
//
bool isBullish = false;
bool isBearish = false;
//
string symbol = GetSymbol();
ENUM_TIMEFRAMES period = GetPeriod();
//
datetime cTime = TimeCurrent();
//
ENUM_X_121_SMC_PROVIDERS provider = X_121_SMC_PROVIDER_XPVOB;
string providerStr = ToString(provider);
//
// Detect Setup Conditions ...
datetime setupTime = mXPVOBConditions.setupTime;
bool isSetuped = mXPVOBConditions.IsSetuped();
ENUM_X_DIRECTION setupDir = mXPVOBConditions.dir;
if (!isSetuped)
{
//
// Detect Signal Setup ...
isSetuped = DetectX121SMCXPVOBSiganlSetup(
symbol,
period,
mXPVOBConditions,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
//
result = isSetuped;
if (!result)
{
return result;
}
//
setupDir = mXPVOBConditions.dir;
setupTime = mXPVOBConditions.setupTime;
}
//
// Draw Conditions Active FVG ...
if (isSetuped)
{
//
XCFVG *iFVG = mXPVOBConditions.activeFVG;
if (iFVG != NULL && iFVG.IsValid())
{
//
ClearDraws();
iFVG.To(cTime);
if (IsBullish(setupDir) && iFVG.IsBullish())
{
//
XCBullishFairValueGapObject *iObj;
bool isCreated = mPOIDrawer.CreateBullishFairValueGap(
iFVG,
iObj //
);
if (isCreated)
{
AddObjectIfNotExists(iObj);
}
}
else if (IsBearish(setupDir) && iFVG.IsBearish())
{
//
XCBearishFairValueGapObject *iObj;
bool isCreated = mPOIDrawer.CreateBearishFairValueGap(
iFVG,
iObj //
);
if (isCreated)
{
AddObjectIfNotExists(iObj);
}
}
}
}
//
// Detect Trigger Conditions ...
bool canTrigger = mXPVOBConditions.CanTrigger();
datetime triggerTime = mXPVOBConditions.triggerTime;
if (!canTrigger)
{
//
// Detect Signal Trigger ...
canTrigger = DetectX121SMCXPVOBSiganlTrigger(
mXPVOBConditions,
symbol,
period,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
//
result = canTrigger;
if (!result)
{
return result;
}
//
triggerTime = mXPVOBConditions.triggerTime;
}
//
// Check Signal Direction ...
//
isBullish = IsBullish(setupDir);
isBearish = IsBearish(setupDir);
result = isBullish ||
isBearish;
if (!result)
{
return result;
}
//
// Issues Signal on Conditions ...
conditions.signalDir = setupDir;
conditions.provider = providerStr;
conditions.sl = mXPVOBConditions.sl;
//
mXPVOBConditions.Clean();
//
return result;
}
// //
// Private ... // Private ...
private: private: