This commit is contained in:
2024-07-01 00:53:55 +03:30
parent f5f358e497
commit 378f6e2bdb
5 changed files with 448 additions and 283 deletions
+129 -81
View File
@@ -2781,21 +2781,31 @@ struct XSymbolPositions
//
double profit;
double volume;
//
double longsProfit;
double longSupportsProfit;
//
double shortsProfit;
double shortSupportsProfit;
//
double volume;
double longsVolume;
double longSupportsVolume;
//
double shortsVolume;
double shortSupportsVolume;
//
double requiredProfitForHedge;
//
// TODO: Complete this ...
XPosition longs[];
XPosition shorts[];
XPosition supports[];
XPosition positions[];
XPosition longSupports[];
XPosition shortSupports[];
@@ -2825,6 +2835,59 @@ struct XSymbolPositions
return result;
}
//
XPosition _supports[];
XPosition _positions[];
//
XPosition _tmp[];
//
Copy(
positions,
_tmp //
);
//
Clean(positions);
//
int tmpsCount = ArraySize(_tmp);
for (int i = 0; i < tmpsCount; i++)
{
//
XPosition iPosition = _tmp[i];
//
bool isSupport = IsSupport(iPosition.comment);
if (!isSupport)
{
//
AddRef(
iPosition,
_positions //
);
}
else
{
//
AddRef(
iPosition,
_supports //
);
}
}
//
Clean(_tmp);
//
Copy(
_positions,
positions //
);
Clean(_positions);
//
// Extract Types ...
ExtractPositions(
@@ -2833,6 +2896,21 @@ struct XSymbolPositions
shorts //
);
//
Copy(
_supports,
supports //
);
Clean(_supports);
//
// Extract Types ...
ExtractPositions(
supports,
longSupports,
shortSupports //
);
//
int numOfLongs = 0;
int numOfShorts = 0;
@@ -2847,14 +2925,46 @@ struct XSymbolPositions
);
//
profit = longsProfit + shortsProfit;
volume = longsVolume + shortsVolume;
requiredProfitForHedge = SpecifiedCalculateRequiredProfitForHedge(
numOfLongs = 0;
numOfShorts = 0;
CountPositions(
supports,
numOfLongs,
longSupportsProfit,
longSupportsVolume,
numOfShorts,
shortSupportsProfit,
shortSupportsVolume //
);
//
XPosition _allPositions[];
Copy(
positions,
_allPositions,
false //
);
Copy(
supports,
_allPositions,
false //
);
//
profit = longsProfit + shortsProfit + longSupportsProfit + shortSupportsProfit;
volume = longsVolume + shortsVolume + longSupportsVolume + shortSupportsVolume;
requiredProfitForHedge = SpecifiedCalculateRequiredProfitForHedge(
_allPositions,
mMinProfitPerTrade,
mMinProfitPerVolumeFactor //
);
//
Clean(_allPositions);
//
result = true;
//
return result;
}
@@ -2932,6 +3042,12 @@ struct XSymbolPositions
return ArraySize(positions);
}
//
int CountSupports()
{
return ArraySize(supports);
}
//
int CountLongs()
{
@@ -2945,83 +3061,15 @@ struct XSymbolPositions
}
//
bool HasSupport()
int CountLongSupports()
{
//
bool result = false;
//
result = HasChild();
if (!result)
{
return result;
}
//
result = HasLongSupport() || HasShortSupport();
//
return result;
return ArraySize(longSupports);
}
//
bool HasLongSupport()
int CountShortSupports()
{
//
bool result = false;
//
int count = CountLongs();
result = IsValidSize(count);
if (!result)
{
return result;
}
//
for (int i = 0; i < count; i++)
{
//
XPosition iPosition = longs[i];
result = IsSupport(iPosition.comment);
if (result)
{
break;
}
}
//
return result;
}
//
bool HasShortSupport()
{
//
bool result = false;
//
int count = CountShorts();
result = IsValidSize(count);
if (!result)
{
return result;
}
//
for (int i = 0; i < count; i++)
{
//
XPosition iPosition = shorts[i];
result = IsSupport(iPosition.comment);
if (result)
{
break;
}
}
//
return result;
return ArraySize(shortSupports);
}
//
@@ -3114,7 +3162,7 @@ struct XSymbolPositions
//
int GetMaxInProfit(
XPosition _position,
XPosition &_position,
ENUM_POSITION_TYPE _type //
)
{
@@ -3168,7 +3216,7 @@ struct XSymbolPositions
//
int GetMinInProfit(
XPosition _position,
XPosition &_position,
ENUM_POSITION_TYPE _type //
)
{
@@ -3222,7 +3270,7 @@ struct XSymbolPositions
//
int GetMaxInDrawdown(
XPosition _position,
XPosition &_position,
ENUM_POSITION_TYPE _type //
)
{
@@ -3276,7 +3324,7 @@ struct XSymbolPositions
//
int GetMinInDrawdown(
XPosition _position,
XPosition &_position,
ENUM_POSITION_TYPE _type //
)
{