last ...
This commit is contained in:
@@ -1238,9 +1238,9 @@ class X121SCTradeHandler : public XSCBaseAlert
|
|||||||
void ProtectionVolumeMultiplier(double value)
|
void ProtectionVolumeMultiplier(double value)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
if (value < 0)
|
if (value < 1)
|
||||||
{
|
{
|
||||||
value = 0;
|
value = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -1259,6 +1259,18 @@ class X121SCTradeHandler : public XSCBaseAlert
|
|||||||
mProtectOnConditions = value;
|
mProtectOnConditions = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool AllowDirectionProtct()
|
||||||
|
{
|
||||||
|
return mAllowDirectionProtct;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
void AllowDirectionProtct(bool value)
|
||||||
|
{
|
||||||
|
mAllowDirectionProtct = value;
|
||||||
|
}
|
||||||
|
|
||||||
// //
|
// //
|
||||||
// // Freeze ...
|
// // Freeze ...
|
||||||
// bool AllowFreeze()
|
// bool AllowFreeze()
|
||||||
@@ -2719,14 +2731,14 @@ class X121SCTradeHandler : public XSCBaseAlert
|
|||||||
bool allowProtect = AllowProtect();
|
bool allowProtect = AllowProtect();
|
||||||
bool protectOnConditions = ProtectOnConditions();
|
bool protectOnConditions = ProtectOnConditions();
|
||||||
double protectDistance = ProtectionStartDistance();
|
double protectDistance = ProtectionStartDistance();
|
||||||
|
bool allowDirectionProtect = AllowDirectionProtct();
|
||||||
double protectVolumeMultiplier = ProtectionVolumeMultiplier();
|
double protectVolumeMultiplier = ProtectionVolumeMultiplier();
|
||||||
bool canProtect =
|
bool canProtect =
|
||||||
!isInProfit &&
|
!isInProfit &&
|
||||||
allowProtect &&
|
allowProtect &&
|
||||||
supportsCount == 0 &&
|
|
||||||
protectDistance > 0 &&
|
protectDistance > 0 &&
|
||||||
protectVolumeMultiplier > 0 &&
|
protectVolumeMultiplier > 1 &&
|
||||||
MathAbs(profitInPoint) >= Mathbs(protectDistance);
|
MathAbs(profitInPoint) >= MathAbs(protectDistance);
|
||||||
|
|
||||||
//
|
//
|
||||||
// bool allowFreeze = AllowFreeze();
|
// bool allowFreeze = AllowFreeze();
|
||||||
@@ -3273,18 +3285,93 @@ class X121SCTradeHandler : public XSCBaseAlert
|
|||||||
//
|
//
|
||||||
// Protect ...
|
// Protect ...
|
||||||
bool isProtected = false;
|
bool isProtected = false;
|
||||||
if (canProtected)
|
if (canProtect)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
bool hasLongProtectConditions = isTicksBullishForLong &&
|
bool hasLongProtectConditions = isTicksBullishForLong &&
|
||||||
hasBullishConditions;
|
hasBullishConditions;
|
||||||
bool hasShortProtectConditions = isTicksBearishForShort &&
|
bool hasShortProtectConditions = isTicksBearishForShort &&
|
||||||
hasBearishConditions;
|
hasBearishConditions;
|
||||||
bool hasProtectConditions = hasLongProtectConditions ||
|
bool hasProtectConditions = !protectOnConditions
|
||||||
hasShortProtectConditions;
|
? true
|
||||||
if (hasSupportConditions) {
|
: allowDirectionProtect
|
||||||
//
|
? (hasLongProtectConditions ||
|
||||||
|
hasShortProtectConditions)
|
||||||
|
: isLong
|
||||||
|
? hasShortProtectConditions
|
||||||
|
: hasLongProtectConditions;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Protection Conditions Happens ...
|
||||||
|
if (hasProtectConditions)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool isInDirectProtection =
|
||||||
|
!protectOnConditions
|
||||||
|
? true
|
||||||
|
: isLong
|
||||||
|
? hasShortProtectConditions
|
||||||
|
: hasLongProtectConditions;
|
||||||
|
|
||||||
|
//
|
||||||
|
double sl =
|
||||||
|
!isInDirectProtection
|
||||||
|
? position.sl
|
||||||
|
: position.tp;
|
||||||
|
double tp =
|
||||||
|
!isInDirectProtection
|
||||||
|
? position.tp
|
||||||
|
: position.sl;
|
||||||
|
double volume = protectVolumeMultiplier * position.volume;
|
||||||
|
ENUM_POSITION_TYPE type =
|
||||||
|
!isInDirectProtection
|
||||||
|
? position.type
|
||||||
|
: GetOpposit(position.type);
|
||||||
|
double entry = GetEntry(
|
||||||
|
position.symbol,
|
||||||
|
type //
|
||||||
|
);
|
||||||
|
ENUM_X_ORDER_MODES mode = X_ORDER_MODE_MARKET;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare Signal ...
|
||||||
|
XSignal signal;
|
||||||
|
bool isPrepared = signal.Prepare(
|
||||||
|
position.symbol,
|
||||||
|
position.provider,
|
||||||
|
position.period,
|
||||||
|
type,
|
||||||
|
mode,
|
||||||
|
entry,
|
||||||
|
volume,
|
||||||
|
sl,
|
||||||
|
tp //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
if (isPrepared)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Generate Comment for Recover and Support ...
|
||||||
|
string comment = GenerateSupportTag(position.ticket);
|
||||||
|
|
||||||
|
//
|
||||||
|
signal.comment = comment;
|
||||||
|
|
||||||
|
//
|
||||||
|
ENUM_X_SIGNAL_EXECUTION_RESULT state;
|
||||||
|
isProtected = ExecuteSignal(
|
||||||
|
signal,
|
||||||
|
state,
|
||||||
|
true // Support Signal need to Ignore Policies ...
|
||||||
|
);
|
||||||
|
if (isProtected)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
string message = "EQM Open " + (IsLong(type) ? "Long" : "Short") + " Protect Position for (" + ToString(position.ticket) + ") ...";
|
||||||
|
Alert(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3353,6 +3440,7 @@ class X121SCTradeHandler : public XSCBaseAlert
|
|||||||
bool mAllowProtect; // Allow Proptecting
|
bool mAllowProtect; // Allow Proptecting
|
||||||
double mProtectionStartDistance; // Protection Start Drawdown in Profit
|
double mProtectionStartDistance; // Protection Start Drawdown in Profit
|
||||||
double mProtectionVolumeMultiplier; // Protection Volume Multiplier
|
double mProtectionVolumeMultiplier; // Protection Volume Multiplier
|
||||||
|
bool mAllowDirectionProtct; // Allow also Directional Protect
|
||||||
bool mProtectOnConditions; // Do Protection only when Conditions happens
|
bool mProtectOnConditions; // Do Protection only when Conditions happens
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -140,6 +140,15 @@ input group "In Drawdown Positions Protecting";
|
|||||||
// input bool eaDoSupportOnConditions = true; // Do Support on Conditions
|
// input bool eaDoSupportOnConditions = true; // Do Support on Conditions
|
||||||
// input int eaDelayBetweenTwoSupport = 60; // Delay Between To Support in Second
|
// input int eaDelayBetweenTwoSupport = 60; // Delay Between To Support in Second
|
||||||
|
|
||||||
|
//
|
||||||
|
// Protect ...
|
||||||
|
input group "Protect";
|
||||||
|
input bool eaAllowProtect = true; // Allow Proptecting
|
||||||
|
input bool eaProtectOnConditions = true; // Do Protection only when Conditions happens
|
||||||
|
input bool eaAllowDirectionProtct = false; // Allow also Directional Protect
|
||||||
|
input double eaProtectionStartDistance = 50; // Protection Start Drawdown in Profit
|
||||||
|
input double eaProtectionVolumeMultiplier = 2; // Protection Volume Multiplier
|
||||||
|
|
||||||
//
|
//
|
||||||
// Partial Close (In Drawdown) ...
|
// Partial Close (In Drawdown) ...
|
||||||
input group "Partial Close";
|
input group "Partial Close";
|
||||||
@@ -625,6 +634,14 @@ bool InitialEA()
|
|||||||
// eaTradeHandler.DoSupportOnConditions(eaDoSupportOnConditions);
|
// eaTradeHandler.DoSupportOnConditions(eaDoSupportOnConditions);
|
||||||
// eaTradeHandler.DelayBetweenTwoSupport(eaDelayBetweenTwoSupport);
|
// eaTradeHandler.DelayBetweenTwoSupport(eaDelayBetweenTwoSupport);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Protect ...
|
||||||
|
eaTradeHandler.AllowProtect(eaAllowProtect);
|
||||||
|
eaTradeHandler.ProtectOnConditions(eaProtectOnConditions);
|
||||||
|
eaTradeHandler.AllowDirectionProtct(eaAllowDirectionProtct);
|
||||||
|
eaTradeHandler.ProtectionStartDistance(eaProtectionStartDistance);
|
||||||
|
eaTradeHandler.ProtectionVolumeMultiplier(eaProtectionVolumeMultiplier);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Partial Close (In Profit) ...
|
// Partial Close (In Profit) ...
|
||||||
eaTradeHandler.PartialCloseInDrawdownDistance(eaPartialCloseInDrawdownDistance);
|
eaTradeHandler.PartialCloseInDrawdownDistance(eaPartialCloseInDrawdownDistance);
|
||||||
|
|||||||
Reference in New Issue
Block a user