last ...
This commit is contained in:
@@ -67,6 +67,9 @@ string XActionToken = "A";
|
||||
string XDirectionalToken = "D";
|
||||
string XINDirectionalToken = "IND";
|
||||
|
||||
//
|
||||
string XRecoveryToken = "XRCV";
|
||||
|
||||
//
|
||||
// Available Order Modes ...
|
||||
enum ENUM_X_ORDER_MODES
|
||||
@@ -3393,12 +3396,15 @@ struct XTradeData
|
||||
ENUM_X_POSITION_TYPES type; // Position Type
|
||||
|
||||
//
|
||||
ulong ticket; // Position Ticket
|
||||
double profit; // Profit on Close
|
||||
double commission; // Commission
|
||||
double swap; // Swap
|
||||
string message; // Close Reason
|
||||
datetime endTime; // End Time
|
||||
ulong ticket; // Position Ticket
|
||||
double swap; // Swap
|
||||
double profit; // Profit on Close
|
||||
double commission; // Commission
|
||||
double maxDrawdown; // Max Position Drawdown
|
||||
string message; // Close Reason
|
||||
datetime endTime; // End Time
|
||||
|
||||
//
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
@@ -3496,6 +3502,14 @@ struct XTradeData
|
||||
profit = _position.profit;
|
||||
swap = _position.swap;
|
||||
|
||||
//
|
||||
if (profit < 0 &&
|
||||
(maxDrawdown == 0 ||
|
||||
MathAbs(profit) > MathAbs(maxDrawdown)))
|
||||
{
|
||||
profit = maxDrawdown;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
@@ -3523,9 +3537,11 @@ struct XTradeData
|
||||
profit = 0;
|
||||
volume = 0;
|
||||
commission = 0;
|
||||
maxDrawdown = 0;
|
||||
|
||||
//
|
||||
ResetTrail();
|
||||
ResetRecovery();
|
||||
}
|
||||
|
||||
//
|
||||
@@ -3722,6 +3738,7 @@ struct XTradeData
|
||||
ToString("Profit", profit) +
|
||||
ToString("Commission", commission) +
|
||||
ToString("Swap", swap) +
|
||||
ToString("Max Drawdown", maxDrawdown) +
|
||||
ToString("End Time", endTime) +
|
||||
ToString("Age", age) +
|
||||
ToString("Message", message)
|
||||
@@ -3744,7 +3761,7 @@ struct XTradeData
|
||||
// Trailing Stop ....
|
||||
|
||||
//
|
||||
bool allowTrailStop; // Specified Position Can Trail Stop or not
|
||||
bool allowTrailStop; // Specified Position Can Trail Stop or not
|
||||
bool ignoreTPOnTrail; // Ignore TP when SL Trailed
|
||||
bool trailBasedOnProfit; // Do Trail Based on Profit Points
|
||||
int trailLevel; // Last Trail Level
|
||||
@@ -3764,6 +3781,24 @@ struct XTradeData
|
||||
trailBasedOnProfit = false;
|
||||
}
|
||||
|
||||
//
|
||||
// Recovery ...
|
||||
|
||||
//
|
||||
bool allowRecover; // Allow Recover Specified Position
|
||||
double recoveryTPPoint; // Recovery TP Point
|
||||
double recoverySLPoint; // Recovery SL Point
|
||||
int maxAllowedRecover; // Max Allowed Recovery
|
||||
|
||||
//
|
||||
void ResetRecovery()
|
||||
{
|
||||
//
|
||||
allowRecover = false;
|
||||
recoveryTPPoint = 0;
|
||||
recoverySLPoint = 0;
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
@@ -5286,6 +5321,121 @@ ulong ExtractParentTicket(string value)
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// XRecovery ...
|
||||
|
||||
//
|
||||
string GenerateRecoveryTag(ulong ticket)
|
||||
{
|
||||
//
|
||||
return Surround(
|
||||
XRecoveryToken,
|
||||
ticket //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
ulong ExtractRecoveredTicket(string value)
|
||||
{
|
||||
//
|
||||
return ParseLongSurrounded(
|
||||
value,
|
||||
XRecoveryToken //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Extract Recoveries ...
|
||||
template <typename T>
|
||||
int ExtractRecoveries(
|
||||
T &source[],
|
||||
T &dest[] // Result ...
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
Clean(dest);
|
||||
|
||||
//
|
||||
int sourceCount = ArraySize(source);
|
||||
if (!IsValidSize(sourceCount))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
for (int i = 0; i < sourceCount; i++)
|
||||
{
|
||||
//
|
||||
T iSource = source[i];
|
||||
|
||||
//
|
||||
ulong isRecovery = ExtractRecoveredTicket(iSource.comment) > 0;
|
||||
if (isRecovery)
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
iSource,
|
||||
dest //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = ArraySize(dest);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Extract Specified Position's Recoveries ...
|
||||
int ExtractRecoveries(
|
||||
ulong ticket,
|
||||
XPosition &source[],
|
||||
XPosition &dest[] // Result ...
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
Clean(dest);
|
||||
|
||||
//
|
||||
int sourceCount = ArraySize(source);
|
||||
if (!IsValidSize(sourceCount))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
for (int i = 0; i < sourceCount; i++)
|
||||
{
|
||||
//
|
||||
XPosition iSource = source[i];
|
||||
|
||||
//
|
||||
ulong isRecovery = ExtractRecoveredTicket(iSource.comment) > 0;
|
||||
if (isRecovery && iSource.ticket == ticket)
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
iSource,
|
||||
dest //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = ArraySize(dest);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// SL Trails ...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user