last works on recovery ...

This commit is contained in:
2024-07-28 19:40:33 +03:30
parent 901b4e7848
commit efaa6dfbbe
3 changed files with 139 additions and 267 deletions
+34 -163
View File
@@ -4286,18 +4286,6 @@ public:
mRecoverySLPoint = value; mRecoverySLPoint = value;
} }
//
bool RecoverBasedOnPressures()
{
return mRecoverBasedOnPressures;
}
//
void RecoverBasedOnPressures(bool value)
{
mRecoverBasedOnPressures = value;
}
// //
int MaxAllowedRecover() int MaxAllowedRecover()
{ {
@@ -4466,6 +4454,17 @@ public:
item.recoverySLPoint = mRecoverySLPoint; item.recoverySLPoint = mRecoverySLPoint;
item.maxAllowedRecover = mMaxAllowedRecover; item.maxAllowedRecover = mMaxAllowedRecover;
item.recoveryVolumeMultiplier = mRecoveryVolumeMultiplier; item.recoveryVolumeMultiplier = mRecoveryVolumeMultiplier;
//
ENUM_POSITION_TYPE _type;
bool isConverted = ToPositionType(
_type,
item.type //
);
if (isConverted)
{
item.recoveryLookingType = GetOppositPositionType(_type);
}
} }
// //
@@ -4734,6 +4733,29 @@ public:
continue; continue;
} }
//
// Try to Detect Recovered Positions ...
//
XPosition positions[];
XPosition recoveries[];
int recoveriesCount = 0;
int positionsCount = mTrader.GetPositions(
positions,
symbol,
provider,
period //
);
if (positionsCount > 0)
{
//
recoveriesCount = ExtractRecoveries(
ticket,
positions,
recoveries //
);
}
// //
// Handle Recovery Break Event ... // Handle Recovery Break Event ...
if (mData[i].allowRecover) if (mData[i].allowRecover)
@@ -4767,24 +4789,6 @@ public:
} }
else else
{ {
//
XPosition positions[];
int positionsCount = mTrader.GetPositions(
positions,
symbol,
provider,
period //
);
if (positionsCount > 0)
{
//
XPosition recoveries[];
int recoveriesCount = ExtractRecoveries(
ticket,
positions,
recoveries //
);
// //
if (recoveriesCount > 0) if (recoveriesCount > 0)
{ {
@@ -4861,7 +4865,6 @@ public:
} }
} }
} }
}
// //
// Retriece CIndex Bar ... // Retriece CIndex Bar ...
@@ -5117,73 +5120,6 @@ public:
// //
if (profit < 0) if (profit < 0)
{
//
if (mRecoverBasedOnPressures)
{
//
bool canRecover = distanceInPoints >= recoverySLPoint * 0.75;
if (canRecover)
{
//
XSignal rSignal;
bool isPrepared = false;
double longEntry = GetEntry(symbol, POSITION_TYPE_BUY);
double shortEntry = GetEntry(symbol, POSITION_TYPE_SELL);
//
if (isBullishSigns)
{
//
rSignal.Clean();
isPrepared = rSignal.Prepare(
symbol,
provider,
period,
POSITION_TYPE_BUY,
X_ORDER_MODE_MARKET,
longEntry,
_volume,
0,
0 //
);
}
else if (isBearishSigns)
{
//
rSignal.Clean();
isPrepared = rSignal.Prepare(
symbol,
provider,
period,
POSITION_TYPE_SELL,
X_ORDER_MODE_MARKET,
shortEntry,
_volume,
0,
0 //
);
}
//
if (isPrepared)
{
//
RemovePositionTPSL(iPosition);
//
rSignal.comment = _comment;
//
bool isExecuted = ExecuteRecoverySignal(rSignal);
if (isExecuted)
{
mData[i].recoveryLevel++;
}
}
}
}
else
{ {
// //
bool canRecover = bool canRecover =
@@ -5230,73 +5166,10 @@ public:
} }
} }
} }
}
else if (profit >= 0 && else if (profit >= 0 &&
(mData[i].recoveryLevel == 1 || (mData[i].recoveryLevel == 1 ||
(mData[i].recoveryLevel >= 2 && (mData[i].recoveryLevel >= 2 &&
mData[i].recoveryLevel / 2 == 1))) mData[i].recoveryLevel / 2 == 1)))
{
//
if (mRecoverBasedOnPressures)
{
//
XSignal rSignal;
bool isPrepared = false;
double longEntry = GetEntry(symbol, POSITION_TYPE_BUY);
double shortEntry = GetEntry(symbol, POSITION_TYPE_SELL);
//
if (isBullishSigns)
{
//
rSignal.Clean();
isPrepared = rSignal.Prepare(
symbol,
provider,
period,
POSITION_TYPE_BUY,
X_ORDER_MODE_MARKET,
longEntry,
_volume,
0,
0 //
);
}
else if (isBearishSigns)
{
//
rSignal.Clean();
isPrepared = rSignal.Prepare(
symbol,
provider,
period,
POSITION_TYPE_SELL,
X_ORDER_MODE_MARKET,
shortEntry,
_volume,
0,
0 //
);
}
//
if (isPrepared)
{
//
RemovePositionTPSL(iPosition);
//
rSignal.comment = _comment;
//
bool isExecuted = ExecuteRecoverySignal(rSignal);
if (isExecuted)
{
mData[i].recoveryLevel++;
}
}
}
else
{ {
// //
RemovePositionTPSL(iPosition); RemovePositionTPSL(iPosition);
@@ -5338,7 +5211,6 @@ public:
} }
} }
} }
}
// //
// Validate Signal For Execution ... // Validate Signal For Execution ...
@@ -5393,7 +5265,6 @@ protected:
int mMaxAllowedRecover; // Max Allowed Recovery int mMaxAllowedRecover; // Max Allowed Recovery
double mRecoveryTPPoint; // Recovery TP in Points double mRecoveryTPPoint; // Recovery TP in Points
double mRecoverySLPoint; // Recovery SL in Points double mRecoverySLPoint; // Recovery SL in Points
bool mRecoverBasedOnPressures; // Do Recovery based on Market Pressures
double mRecoveryVolumeMultiplier; // Recovery Volume Multiplier double mRecoveryVolumeMultiplier; // Recovery Volume Multiplier
// //
-1
View File
@@ -286,7 +286,6 @@ bool InitialEA()
eaTradeHandler.RecoveryTPPoint(50); eaTradeHandler.RecoveryTPPoint(50);
eaTradeHandler.RecoverySLPoint(eaSLPoint); eaTradeHandler.RecoverySLPoint(eaSLPoint);
eaTradeHandler.RecoveryVolumeMultiplier(2); eaTradeHandler.RecoveryVolumeMultiplier(2);
eaTradeHandler.RecoverBasedOnPressures(false);
// //
XSymbolParser symbolParser; XSymbolParser symbolParser;
+2
View File
@@ -3791,6 +3791,7 @@ struct XTradeData
int maxAllowedRecover; // Max Allowed Recovery int maxAllowedRecover; // Max Allowed Recovery
int recoveryLevel; // Number of Recovery Signals int recoveryLevel; // Number of Recovery Signals
double recoveryVolumeMultiplier; // Recovery Volume Multiplier double recoveryVolumeMultiplier; // Recovery Volume Multiplier
ENUM_X_POSITION_TYPES recoveryLookingType; // Looking for Next Recovery Type
// //
void ResetRecovery() void ResetRecovery()
@@ -3801,6 +3802,7 @@ struct XTradeData
recoveryTPPoint = 0; recoveryTPPoint = 0;
recoverySLPoint = 0; recoverySLPoint = 0;
recoveryVolumeMultiplier = 0; recoveryVolumeMultiplier = 0;
recoveryLookingType = X_POSITION_TYPE_NONE;
} }
// //