This commit is contained in:
2024-06-22 08:33:18 +03:30
parent 532be35f74
commit 6063d3be61
5 changed files with 597 additions and 57 deletions
+80
View File
@@ -3266,6 +3266,46 @@ int FindMaxProfitIndex(
return result;
}
//
int FindMinProfitIndex(
XPosition &positions[] // Position Collection
)
{
//
int result = -1;
//
int positionsCount = ArraySize(positions);
if (!IsValidSize(positionsCount))
{
return result;
}
//
double min = 0;
for (int i = 0; i < positionsCount; i++)
{
//
XPosition iPosition = positions[i];
if (iPosition.profit <= 0)
{
continue;
}
//
if (min == 0 ||
min > iPosition.profit)
{
//
result = i;
min = iPosition.profit;
}
}
//
return result;
}
//
int ExtractInProfitPositions(
XPosition &positions[], // Position Collection
@@ -3324,6 +3364,46 @@ int FindMaxDrawdownIndex(
return result;
}
//
double max = 0;
for (int i = 0; i < positionsCount; i++)
{
//
XPosition iPosition = positions[i];
if (iPosition.profit >= 0)
{
continue;
}
//
if (max == 0 ||
max < iPosition.profit)
{
//
result = i;
max = iPosition.profit;
}
}
//
return result;
}
//
int FindMinDrawdownIndex(
XPosition &positions[] // Position Collection
)
{
//
int result = -1;
//
int positionsCount = ArraySize(positions);
if (!IsValidSize(positionsCount))
{
return result;
}
//
double min = 0;
for (int i = 0; i < positionsCount; i++)