last works ...

This commit is contained in:
2024-11-24 13:48:12 +03:30
parent 0e2e474d46
commit 042fa88d3a
6 changed files with 701 additions and 203 deletions
@@ -58,6 +58,7 @@ struct X121SMCTradeData
string conditions; // Signal Conditions
//
bool forceTrail; // Force Trail
int trailStep; // Trail Step
bool partiallyClosed; // Partially Closed or not
datetime lastProtectedOn; // Last Protected On
@@ -200,6 +201,7 @@ struct X121SMCTradeData
//
trailStep = 0;
forceTrail = false;
lastProtectedOn = NULL;
partiallyClosed = false;
@@ -1948,8 +1950,11 @@ class XC121SMCTradeHandler : public XCBaseAlert
// First Step of Trade Handling ...
// Since Must Call when a Signal Executed ...
void AddData(
XSignal &signal, // Executed Signal
double commission = 0 // Commission
XSignal &signal, // Executed Signal
double commission = 0, // Commission
//
// Force Protections ...
bool forceTrail = false // Force Trail Stops ...
)
{
//
@@ -1975,6 +1980,27 @@ class XC121SMCTradeHandler : public XCBaseAlert
//
item.commission = commission;
//
// Checking Trailling Configs ...
double trailStep = TrailStep();
double trailStartDistance = TrailStartDistance();
bool enableTrail =
trailStep > 0 &&
trailStartDistance > 0;
//
bool onlyTrailUnprotecteds = OnlyTrailUnprotected();
bool canCheck =
(onlyTrailUnprotecteds
? !isSupport &&
!isRecovery
: true) &&
enableTrail;
if (canCheck)
{
item.forceTrail = forceTrail;
}
//
Add(item);
@@ -2326,6 +2352,71 @@ class XC121SMCTradeHandler : public XCBaseAlert
);
}
/**
* Retrieve Specified Symbols Info ...
*
* @param symbol: String ...
* @param info: X121SMCSymbolPositionInfo instance ...
*
* @return ( bool )
*/
bool GetSymbolInfo(
string symbol,
X121SMCSymbolPositionInfo &info //
)
{
//
bool result = false;
//
info.Clean();
//
int symbolIDX = -1;
result = HasSymbol(
symbol,
symbolIDX //
);
if (!result)
{
return result;
}
//
info = mSymbolInfos[symbolIDX];
//
return result;
}
/**
* Reset Specified Symbol Info ...
*
* @param symbol: String ...
*/
void ResetSymbolInfo(string symbol)
{
//
if (!IsValid(symbol))
{
return;
}
//
int symbolIDX = -1;
bool hasSymbol = HasSymbol(
symbol,
symbolIDX //
);
if (!hasSymbol)
{
return;
}
//
mSymbolInfos[symbolIDX].Reset();
}
//
// Position Execute and Sync Functions ...
@@ -2430,7 +2521,10 @@ class XC121SMCTradeHandler : public XCBaseAlert
bool ExecuteSignal(
XSignal &signal, // Signal for Execution
ENUM_X_SIGNAL_EXECUTION_RESULT &state, // Execution State
bool ignorePolicies = false // Ignore Execution Policies
bool ignorePolicies = false, // Ignore Execution Policies
//
// Force Protections ...
bool forceTrail = false // Force Trail Position
)
{
//
@@ -2614,7 +2708,8 @@ class XC121SMCTradeHandler : public XCBaseAlert
// Add Signal to Trade Handler ...
AddData(
signal,
commission //
commission,
forceTrail //
);
//
@@ -3046,7 +3141,7 @@ class XC121SMCTradeHandler : public XCBaseAlert
//
// Reading Requirements for Trailling Stops ...
bool allowTrail = AllowTrail();
bool allowTrail = AllowTrail() || mData[iDX].forceTrail;
double trailStep = TrailStep();
double trailStartDistance = TrailStartDistance();
bool allowOnlyUnprotecteds = OnlyTrailUnprotected();