complete recovery senario a ...

This commit is contained in:
2024-07-28 18:59:05 +03:30
parent 97cbf77f7d
commit 901b4e7848
2 changed files with 52 additions and 23 deletions
+45 -18
View File
@@ -4742,7 +4742,7 @@ public:
if (mData[i].recoveryLevel <= 0)
{
//
if (profit > 0)
if (profit > 0 && iPosition.tp == 0)
{
//
double proftiInPoints = profit / volume;
@@ -5104,29 +5104,17 @@ public:
if (
recoveryTPPoint > 0 &&
recoverySLPoint > 0 &&
mData[i].recoveryLevel < maxAllowedRecover)
(maxAllowedRecover <= 0
? true
: mData[i].recoveryLevel < maxAllowedRecover))
{
//
// Current Profit ...
double distanceInPoints = (MathAbs(profit) / volume);
double _volumeMultiplier = ((mData[i].recoveryLevel) * recoveryVolumeMultiplier);
double _volumeMultiplier = ((mData[i].recoveryLevel + 1) * recoveryVolumeMultiplier);
double _volume = volume * (_volumeMultiplier <= 0 ? 1 : _volumeMultiplier);
string _comment = GenerateRecoveryTag(ticket);
//
// Try to Remove SL of Recovery Signals ...
if (iPosition.sl > 0 || iPosition.tp > 0)
{
//
string comment = "EQM Recover Remove TP/SL";
bool isSLRemoved = mTrader.Modify(
ticket,
0,
0,
comment //
);
}
//
if (profit < 0)
{
@@ -5180,6 +5168,9 @@ public:
//
if (isPrepared)
{
//
RemovePositionTPSL(iPosition);
//
rSignal.comment = _comment;
@@ -5202,6 +5193,9 @@ public:
mData[i].recoveryLevel / 2 == 0));
if (canRecover)
{
//
RemovePositionTPSL(iPosition);
//
ENUM_POSITION_TYPE _type =
isLong
@@ -5237,7 +5231,10 @@ public:
}
}
}
else if (profit >= 0 && mData[i].recoveryLevel > 0)
else if (profit >= 0 &&
(mData[i].recoveryLevel == 1 ||
(mData[i].recoveryLevel >= 2 &&
mData[i].recoveryLevel / 2 == 1)))
{
//
if (mRecoverBasedOnPressures)
@@ -5285,6 +5282,9 @@ public:
//
if (isPrepared)
{
//
RemovePositionTPSL(iPosition);
//
rSignal.comment = _comment;
@@ -5298,6 +5298,9 @@ public:
}
else
{
//
RemovePositionTPSL(iPosition);
//
ENUM_POSITION_TYPE _type =
isLong
@@ -5658,6 +5661,30 @@ private:
requiredProfitsForHedge -= commissions;
}
//
bool RemovePositionTPSL(XPosition &osition)
{
//
bool result = false;
//
// Try to Remove SL of Recovery Signals ...
if (osition.sl > 0 || osition.tp > 0)
{
//
string comment = "EQM Recover Remove TP/SL";
result = mTrader.Modify(
osition.ticket,
0,
0,
comment //
);
}
//
return result;
}
//
bool ExecuteRecoverySignal(XSignal &signal)
{
+7 -5
View File
@@ -114,7 +114,7 @@ int OnInit()
//
// EventSetTimer(1);
EventSetMillisecondTimer(100);
// EventSetMillisecondTimer(100);
//
// Init Succeed ...
@@ -152,7 +152,7 @@ void OnDeinit(const int reason)
delete eaTradeHandler;
//
EventKillTimer();
// EventKillTimer();
//
Clean(strategies);
@@ -162,6 +162,8 @@ void OnDeinit(const int reason)
// On Tick Handler ...
void OnTick()
{
//
HandleTradeState();
HandleStrategiesOnTick();
}
@@ -177,7 +179,7 @@ void OnTrade()
void OnTimer()
{
//
HandleTradeState();
// HandleTradeState();
// //
// if (eaTimeTracker.IsNewDay())
@@ -280,8 +282,8 @@ bool InitialEA()
//
// Configure Recovery ...
eaTradeHandler.AllowRecover(true);
eaTradeHandler.MaxAllowedRecover(2);
eaTradeHandler.RecoveryTPPoint(eaTPPoint);
eaTradeHandler.MaxAllowedRecover(0);
eaTradeHandler.RecoveryTPPoint(50);
eaTradeHandler.RecoverySLPoint(eaSLPoint);
eaTradeHandler.RecoveryVolumeMultiplier(2);
eaTradeHandler.RecoverBasedOnPressures(false);