last ...
This commit is contained in:
@@ -3571,6 +3571,107 @@ int FindIndex(
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// Calculate Positions Profit Summary ...
|
||||
double SpecifiedCalculatePositionsProfit(
|
||||
XPosition &positions[] // Source
|
||||
)
|
||||
{
|
||||
//
|
||||
double result = 0;
|
||||
|
||||
//
|
||||
int positionsCount = ArraySize(positions);
|
||||
if (positionsCount <= 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
for (int i = 0; i < positionsCount; i++)
|
||||
{
|
||||
//
|
||||
XPosition iPosition = positions[i];
|
||||
|
||||
//
|
||||
result += iPosition.profit;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Calculate Required Profit for Hedging ...
|
||||
double SpecifiedCalculateRequiredProfitForHedge(
|
||||
XPosition &positions[], // Source
|
||||
double mMinProfitPerTrade,
|
||||
double mMinProfitPerVolumeFactor //
|
||||
)
|
||||
{
|
||||
//
|
||||
double result = 0;
|
||||
|
||||
//
|
||||
int positionsCount = ArraySize(positions);
|
||||
if (positionsCount <= 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool isHedgingEnable = mMinProfitPerTrade > 0 && mMinProfitPerVolumeFactor > 0;
|
||||
if (!isHedgingEnable)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
for (int i = 0; i < positionsCount; i++)
|
||||
{
|
||||
//
|
||||
XPosition iPosition = positions[i];
|
||||
|
||||
//
|
||||
if (mMinProfitPerTrade > 0 && mMinProfitPerVolumeFactor > 0)
|
||||
{
|
||||
//
|
||||
result +=
|
||||
((iPosition.volume / mMinProfitPerVolumeFactor) *
|
||||
mMinProfitPerTrade) +
|
||||
(-1 * iPosition.swap);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool SpecifiedIsPositionsReadyForHedge(
|
||||
XPosition &positions[], // Source
|
||||
double mMinProfitPerTrade,
|
||||
double mMinProfitPerVolumeFactor //
|
||||
)
|
||||
{
|
||||
//
|
||||
double profit = SpecifiedCalculatePositionsProfit(positions);
|
||||
double requiredProfit = SpecifiedCalculateRequiredProfitForHedge(
|
||||
positions,
|
||||
mMinProfitPerTrade,
|
||||
mMinProfitPerVolumeFactor //
|
||||
);
|
||||
|
||||
//
|
||||
bool result = requiredProfit > 0
|
||||
? profit >= requiredProfit
|
||||
: profit > requiredProfit;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve String Representation ...
|
||||
string ToString(ENUM_X_SIGNAL_EXECUTION_RESULT value)
|
||||
|
||||
Reference in New Issue
Block a user