This commit is contained in:
2025-01-15 22:09:21 +03:30
parent 341992374c
commit 9b307ae6e6
12 changed files with 3448 additions and 671 deletions
+151 -17
View File
@@ -36,8 +36,7 @@ const string X121SMCStrategyToken = "X121SMC";
//
const string X121SMCXTestToken = "X121XTest";
const string X121SMCXOBGPVToken = "X121XOBGPV";
const string X121SMCXOBSPVToken = "X121XOBSPV";
const string X121SMCXPZToken = "X121XPZ";
const string X121SMCXSTRPVToken = "X121XSTRPV";
//
@@ -47,11 +46,25 @@ enum ENUM_X_121_SMC_PROVIDERS
//
X_121_SMC_PROVIDER_NONE,
X_121_SMC_PROVIDER_XTEST,
X_121_SMC_PROVIDER_XOBGPV,
X_121_SMC_PROVIDER_XOBSPV,
X_121_SMC_PROVIDER_XPZ,
X_121_SMC_PROVIDER_XSTRPV,
};
//
// Guard Actions ...
enum ENUM_X_121_SMC_GUARD_ACTIONS
{
X_121_SMC_GUARD_ACTION_NONE, // Nothing to Do
X_121_SMC_GUARD_ACTION_CLOSE, // Close Specified Position
X_121_SMC_GUARD_ACTION_CLOSE_ALL, // Close All Positions
X_121_SMC_GUARD_ACTION_CLOSE_LONGS, // Close All Long Positions
X_121_SMC_GUARD_ACTION_CLOSE_SHORTS, // Close All Short Position
X_121_SMC_GUARD_ACTION_PARTIAL_CLOSE, // Partial Close Specified Position
X_121_SMC_GUARD_ACTION_TRAIL_STOP, // Trail Stop of Specified Position
X_121_SMC_GUARD_ACTION_TRAIL_TARGET, // Trail Target of Specified Position
X_121_SMC_GUARD_ACTION_HEDGE, // Hedge Specified Positions
};
//
// Each Market Cycle (Time Frame) Conditions
// Model as this Structure ...
@@ -506,6 +519,136 @@ struct X121SMCStrategyConditions
//
};
//
// Model a Guard Action ...
struct X121SMCGuard
{
//
// Props ...
ENUM_X_121_SMC_GUARD_ACTIONS action;
datetime time;
//
string symbol;
string provider;
//
// Specified Position ...
ulong ticket;
//
// Partial Close ...
double volumeMultiplier;
//
// SL Trial ...
double sl;
//
// TP Trial ...
double tp;
//
// Constructor ...
X121SMCGuard()
{
Clean();
}
//
// Tools ...
/**
* Cleanup ...
*/
void Clean()
{
//
time = NULL;
action = X_121_SMC_GUARD_ACTION_NONE;
//
symbol = NULL;
provider = NULL;
//
ticket = 0;
//
volumeMultiplier = 0;
//
sl = 0;
tp = 0;
}
/**
* Validate ...
*
* @return ( bool )
*/
bool IsValid()
{
//
bool result = false;
//
result =
//
IsValid(time) &&
IsValid(symbol) &&
IsValid(provider) &&
action != X_121_SMC_GUARD_ACTION_NONE
//
;
if (!result)
{
return result;
}
//
// Validate Model Based On Specified Guard Actions ...
//
return result;
}
};
/**
* Add Guard to Collection ...
*
* @param guard: X121SMCGuard instance ...
* @param guards: X121SMCGuard instance Collection ...
*
* @return ( int )
*/
int AddGuard(
X121SMCGuard &guard,
X121SMCGuard &guards[] //
)
{
//
int result = 0;
//
if (!guard.IsValid())
{
return result;
}
//
AddRef(
guard,
guards //
);
//
result = ArraySize(guards);
//
return result;
}
/**
* Draw X121 SMC Conditions ...
*
@@ -678,13 +821,8 @@ string ToString(ENUM_X_121_SMC_PROVIDERS value)
break;
//
case X_121_SMC_PROVIDER_XOBGPV:
result = X121SMCXOBGPVToken;
break;
//
case X_121_SMC_PROVIDER_XOBSPV:
result = X121SMCXOBSPVToken;
case X_121_SMC_PROVIDER_XPZ:
result = X121SMCXPZToken;
break;
//
@@ -720,13 +858,9 @@ ENUM_X_121_SMC_PROVIDERS ParseProvider(string value)
{
result = X_121_SMC_PROVIDER_XTEST;
}
else if (Contains(X121SMCXOBGPVToken, value))
else if (Contains(X121SMCXPZToken, value))
{
result = X_121_SMC_PROVIDER_XOBGPV;
}
else if (Contains(X121SMCXOBSPVToken, value))
{
result = X_121_SMC_PROVIDER_XOBSPV;
result = X_121_SMC_PROVIDER_XPZ;
}
else if (Contains(X121SMCXSTRPVToken, value))
{