add support for dynamic volume calculation in ea ...

This commit is contained in:
2024-08-10 16:25:34 +03:30
parent 0aafd0b14e
commit b76565f0b9
2 changed files with 115 additions and 6 deletions
+79 -1
View File
@@ -3285,6 +3285,51 @@ public:
return result;
}
//
// Prepare Dynamic Volume ...
double GetDynamicVolume(
string _symbol,
double _balanceFactor,
double _volumeStep //
)
{
//
double result = 0;
//
// Validate Inputs ...
if (!IsValid(_symbol) ||
_volumeStep <= 0 ||
_balanceFactor <= 0)
{
return result;
}
//
// Retrieve Account Balance ...
double balance = mAccount.GetBalance();
//
double bStep = balance / _balanceFactor;
bStep = MathFloor(bStep);
if (bStep == 0)
{
bStep = 1;
}
//
result = bStep * _volumeStep;
//
result = NormalizeVolume(
result,
_symbol //
);
//
return result;
}
//
// Protected ...
protected:
@@ -4939,6 +4984,39 @@ public:
GetMaxDrawdown();
}
//
void UpdateSignal(XSignal &signal)
{
//
if (!signal.IsValid())
{
return;
}
//
int count = Count();
if (!IsValidSize(count))
{
return;
}
//
for (int i = 0; i < count; i++)
{
//
bool isOwn = mData[i].IsOwn(
signal.symbol,
signal.provider,
signal.period,
ToPositionType(signal.type) //
);
if (isOwn)
{
mData[i].Fill(signal);
}
}
}
//
// Do all Protections ...
void HandleProtection()
@@ -5810,7 +5888,7 @@ protected:
bool mSaveConditions; // Save SL Conditions
//
XSymbolSessionParser mSymbolSession; // Check Symbol Session
XSymbolSessionParser mSymbolSession; // Check Symbol Session
//
bool mAllowLong; // Allow Long/Buy Trade Type