complete recovery senario a ...
This commit is contained in:
@@ -4742,7 +4742,7 @@ public:
|
|||||||
if (mData[i].recoveryLevel <= 0)
|
if (mData[i].recoveryLevel <= 0)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
if (profit > 0)
|
if (profit > 0 && iPosition.tp == 0)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
double proftiInPoints = profit / volume;
|
double proftiInPoints = profit / volume;
|
||||||
@@ -5104,29 +5104,17 @@ public:
|
|||||||
if (
|
if (
|
||||||
recoveryTPPoint > 0 &&
|
recoveryTPPoint > 0 &&
|
||||||
recoverySLPoint > 0 &&
|
recoverySLPoint > 0 &&
|
||||||
mData[i].recoveryLevel < maxAllowedRecover)
|
(maxAllowedRecover <= 0
|
||||||
|
? true
|
||||||
|
: mData[i].recoveryLevel < maxAllowedRecover))
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Current Profit ...
|
// Current Profit ...
|
||||||
double distanceInPoints = (MathAbs(profit) / volume);
|
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);
|
double _volume = volume * (_volumeMultiplier <= 0 ? 1 : _volumeMultiplier);
|
||||||
string _comment = GenerateRecoveryTag(ticket);
|
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)
|
if (profit < 0)
|
||||||
{
|
{
|
||||||
@@ -5180,6 +5168,9 @@ public:
|
|||||||
//
|
//
|
||||||
if (isPrepared)
|
if (isPrepared)
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
RemovePositionTPSL(iPosition);
|
||||||
|
|
||||||
//
|
//
|
||||||
rSignal.comment = _comment;
|
rSignal.comment = _comment;
|
||||||
|
|
||||||
@@ -5202,6 +5193,9 @@ public:
|
|||||||
mData[i].recoveryLevel / 2 == 0));
|
mData[i].recoveryLevel / 2 == 0));
|
||||||
if (canRecover)
|
if (canRecover)
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
RemovePositionTPSL(iPosition);
|
||||||
|
|
||||||
//
|
//
|
||||||
ENUM_POSITION_TYPE _type =
|
ENUM_POSITION_TYPE _type =
|
||||||
isLong
|
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)
|
if (mRecoverBasedOnPressures)
|
||||||
@@ -5285,6 +5282,9 @@ public:
|
|||||||
//
|
//
|
||||||
if (isPrepared)
|
if (isPrepared)
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
RemovePositionTPSL(iPosition);
|
||||||
|
|
||||||
//
|
//
|
||||||
rSignal.comment = _comment;
|
rSignal.comment = _comment;
|
||||||
|
|
||||||
@@ -5298,6 +5298,9 @@ public:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
RemovePositionTPSL(iPosition);
|
||||||
|
|
||||||
//
|
//
|
||||||
ENUM_POSITION_TYPE _type =
|
ENUM_POSITION_TYPE _type =
|
||||||
isLong
|
isLong
|
||||||
@@ -5658,6 +5661,30 @@ private:
|
|||||||
requiredProfitsForHedge -= commissions;
|
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)
|
bool ExecuteRecoverySignal(XSignal &signal)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ int OnInit()
|
|||||||
|
|
||||||
//
|
//
|
||||||
// EventSetTimer(1);
|
// EventSetTimer(1);
|
||||||
EventSetMillisecondTimer(100);
|
// EventSetMillisecondTimer(100);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Init Succeed ...
|
// Init Succeed ...
|
||||||
@@ -152,7 +152,7 @@ void OnDeinit(const int reason)
|
|||||||
delete eaTradeHandler;
|
delete eaTradeHandler;
|
||||||
|
|
||||||
//
|
//
|
||||||
EventKillTimer();
|
// EventKillTimer();
|
||||||
|
|
||||||
//
|
//
|
||||||
Clean(strategies);
|
Clean(strategies);
|
||||||
@@ -162,6 +162,8 @@ void OnDeinit(const int reason)
|
|||||||
// On Tick Handler ...
|
// On Tick Handler ...
|
||||||
void OnTick()
|
void OnTick()
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
HandleTradeState();
|
||||||
HandleStrategiesOnTick();
|
HandleStrategiesOnTick();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,7 +179,7 @@ void OnTrade()
|
|||||||
void OnTimer()
|
void OnTimer()
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
HandleTradeState();
|
// HandleTradeState();
|
||||||
|
|
||||||
// //
|
// //
|
||||||
// if (eaTimeTracker.IsNewDay())
|
// if (eaTimeTracker.IsNewDay())
|
||||||
@@ -280,8 +282,8 @@ bool InitialEA()
|
|||||||
//
|
//
|
||||||
// Configure Recovery ...
|
// Configure Recovery ...
|
||||||
eaTradeHandler.AllowRecover(true);
|
eaTradeHandler.AllowRecover(true);
|
||||||
eaTradeHandler.MaxAllowedRecover(2);
|
eaTradeHandler.MaxAllowedRecover(0);
|
||||||
eaTradeHandler.RecoveryTPPoint(eaTPPoint);
|
eaTradeHandler.RecoveryTPPoint(50);
|
||||||
eaTradeHandler.RecoverySLPoint(eaSLPoint);
|
eaTradeHandler.RecoverySLPoint(eaSLPoint);
|
||||||
eaTradeHandler.RecoveryVolumeMultiplier(2);
|
eaTradeHandler.RecoveryVolumeMultiplier(2);
|
||||||
eaTradeHandler.RecoverBasedOnPressures(false);
|
eaTradeHandler.RecoverBasedOnPressures(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user