last works on GUI and also Comment Freezing and Supporting Properties and Functionality ...

This commit is contained in:
2024-09-25 15:57:27 +03:30
parent 6b00990c8d
commit 9e772c8192
5 changed files with 770 additions and 430 deletions
+366 -364
View File
@@ -1194,176 +1194,176 @@ class X121SCTradeHandler : public XSCBaseAlert
//
// In Drawdown Positions Protecting ...
//
// Freeze ...
bool AllowFreeze()
{
return mAllowFreeze;
}
// //
// // Freeze ...
// bool AllowFreeze()
// {
// return mAllowFreeze;
// }
//
void AllowFreeze(bool value)
{
mAllowFreeze = value;
}
// //
// void AllowFreeze(bool value)
// {
// mAllowFreeze = value;
// }
//
double FreezeDistance()
{
return mFreezeDistance;
}
// //
// double FreezeDistance()
// {
// return mFreezeDistance;
// }
//
void FreezeDistance(double value)
{
//
if (value < 0)
{
value = 0;
}
// //
// void FreezeDistance(double value)
// {
// //
// if (value < 0)
// {
// value = 0;
// }
//
mFreezeDistance = value;
}
// //
// mFreezeDistance = value;
// }
//
bool RemoveFreezedPositionTPSL()
{
return mRemoveFreezedPositionTPSL;
}
// //
// bool RemoveFreezedPositionTPSL()
// {
// return mRemoveFreezedPositionTPSL;
// }
//
void RemoveFreezedPositionTPSL(bool value)
{
mRemoveFreezedPositionTPSL = value;
}
// //
// void RemoveFreezedPositionTPSL(bool value)
// {
// mRemoveFreezedPositionTPSL = value;
// }
//
bool DisableTrailWhenFreezedPosition()
{
return mDisableTrailWhenFreezedPosition;
}
// //
// bool DisableTrailWhenFreezedPosition()
// {
// return mDisableTrailWhenFreezedPosition;
// }
//
void DisableTrailWhenFreezedPosition(bool value)
{
mDisableTrailWhenFreezedPosition = value;
}
// //
// void DisableTrailWhenFreezedPosition(bool value)
// {
// mDisableTrailWhenFreezedPosition = value;
// }
//
// Support ...
//
bool AllowSupport()
{
return mAllowSupport;
}
// //
// bool AllowSupport()
// {
// return mAllowSupport;
// }
//
void AllowSupport(bool value)
{
mAllowSupport = value;
}
// //
// void AllowSupport(bool value)
// {
// mAllowSupport = value;
// }
//
double SupportStartDistance()
{
return mSupportStartDistance;
}
// //
// double SupportStartDistance()
// {
// return mSupportStartDistance;
// }
//
void SupportStartDistance(double value)
{
//
if (value < 0)
{
value = 0;
}
// //
// void SupportStartDistance(double value)
// {
// //
// if (value < 0)
// {
// value = 0;
// }
//
mSupportStartDistance = value;
}
// //
// mSupportStartDistance = value;
// }
//
int MaxAllowedSupport()
{
return mMaxAllowedSupport;
}
// //
// int MaxAllowedSupport()
// {
// return mMaxAllowedSupport;
// }
//
void MaxAllowedSupport(int value)
{
//
if (value < 0)
{
value = 0;
}
// //
// void MaxAllowedSupport(int value)
// {
// //
// if (value < 0)
// {
// value = 0;
// }
//
mMaxAllowedSupport = value;
}
// //
// mMaxAllowedSupport = value;
// }
//
double SupportVolumeMultiplier()
{
return mSupportVolumeMultiplier;
}
// //
// double SupportVolumeMultiplier()
// {
// return mSupportVolumeMultiplier;
// }
//
void SupportVolumeMultiplier(double value)
{
//
if (value < 0)
{
value = 0;
}
// //
// void SupportVolumeMultiplier(double value)
// {
// //
// if (value < 0)
// {
// value = 0;
// }
//
mSupportVolumeMultiplier = value;
}
// //
// mSupportVolumeMultiplier = value;
// }
//
bool MultiplySupportLevelOnVolume()
{
return mMultiplySupportLevelOnVolume;
}
// //
// bool MultiplySupportLevelOnVolume()
// {
// return mMultiplySupportLevelOnVolume;
// }
//
void MultiplySupportLevelOnVolume(bool value)
{
mMultiplySupportLevelOnVolume = value;
}
// //
// void MultiplySupportLevelOnVolume(bool value)
// {
// mMultiplySupportLevelOnVolume = value;
// }
//
bool DoSupportOnConditions()
{
return mDoSupportOnConditions;
}
// //
// bool DoSupportOnConditions()
// {
// return mDoSupportOnConditions;
// }
//
void DoSupportOnConditions(bool value)
{
mDoSupportOnConditions = value;
}
// //
// void DoSupportOnConditions(bool value)
// {
// mDoSupportOnConditions = value;
// }
//
int DelayBetweenTwoSupport()
{
return mDelayBetweenTwoSupport;
}
// //
// int DelayBetweenTwoSupport()
// {
// return mDelayBetweenTwoSupport;
// }
//
void DelayBetweenTwoSupport(int value)
{
//
if (value < 0)
{
value = 0;
}
// //
// void DelayBetweenTwoSupport(int value)
// {
// //
// if (value < 0)
// {
// value = 0;
// }
//
mDelayBetweenTwoSupport = value;
}
// //
// mDelayBetweenTwoSupport = value;
// }
//
// Partial Close (In Drawdown) ...
@@ -2649,42 +2649,44 @@ class X121SCTradeHandler : public XSCBaseAlert
// Reading Requirement for Freezing Positions ...
//
bool allowFreeze = AllowFreeze();
double freezeDistance = FreezeDistance();
bool removeFreezedPositionTPSL = RemoveFreezedPositionTPSL();
bool canFreeze = allowFreeze &&
!isInProfit &&
profitInPoint < 0 &&
freezeDistance > 0 &&
!mData[iDX].freezed &&
MathAbs(profitInPoint) >= freezeDistance;
// bool allowFreeze = AllowFreeze();
// double freezeDistance = FreezeDistance();
// bool removeFreezedPositionTPSL = RemoveFreezedPositionTPSL();
// bool canFreeze = allowFreeze &&
// !isInProfit &&
// profitInPoint < 0 &&
// freezeDistance > 0 &&
// !mData[iDX].freezed &&
// MathAbs(profitInPoint) >= freezeDistance;
bool canFreeze = false;
//
// Reading Requirement for Support Positions ...
bool allowSupport = AllowSupport();
double supportStartDistance = SupportStartDistance();
int maxAllowedSupport = MaxAllowedSupport();
int delayBetweenTwoSupport = DelayBetweenTwoSupport();
double supportVolumeMultiplier = SupportVolumeMultiplier();
bool multiplySupportLevelOnVolume = MultiplySupportLevelOnVolume();
bool doSupportOnConditions = DoSupportOnConditions();
bool canSupport = allowSupport &&
(!isInProfit ||
(isInProfit && supportsCount > 0)) &&
maxAllowedSupport >= 0 &&
supportStartDistance >= 0 &&
supportVolumeMultiplier > 0 &&
MathAbs(profitInPoint) >= supportStartDistance &&
//
// Check Max Allowed Support ...
(maxAllowedSupport == 0
? true
: supportsCount < maxAllowedSupport) &&
//
// Check Delay ...
(!IsValid(mData[iDX].lastSupportedOn)
? true
: (TimeToSeconds(currentTime) - TimeToSeconds(mData[iDX].lastSupportedOn)) >= ulong(delayBetweenTwoSupport));
// bool allowSupport = AllowSupport();
// double supportStartDistance = SupportStartDistance();
// int maxAllowedSupport = MaxAllowedSupport();
// int delayBetweenTwoSupport = DelayBetweenTwoSupport();
// double supportVolumeMultiplier = SupportVolumeMultiplier();
// bool multiplySupportLevelOnVolume = MultiplySupportLevelOnVolume();
// bool doSupportOnConditions = DoSupportOnConditions();
// bool canSupport = allowSupport &&
// (!isInProfit ||
// (isInProfit && supportsCount > 0)) &&
// maxAllowedSupport >= 0 &&
// supportStartDistance >= 0 &&
// supportVolumeMultiplier > 0 &&
// MathAbs(profitInPoint) >= supportStartDistance &&
// //
// // Check Max Allowed Support ...
// (maxAllowedSupport == 0
// ? true
// : supportsCount < maxAllowedSupport) &&
// //
// // Check Delay ...
// (!IsValid(mData[iDX].lastSupportedOn)
// ? true
// : (TimeToSeconds(currentTime) - TimeToSeconds(mData[iDX].lastSupportedOn)) >= ulong(delayBetweenTwoSupport));
bool canSupport = false;
//
result =
@@ -2988,204 +2990,204 @@ class X121SCTradeHandler : public XSCBaseAlert
//
// Freeze ...
bool isFreezed = false;
if (canFreeze)
{
//
// Temparory Requirement for Recover Signal ...
double sl = removeFreezedPositionTPSL ? 0 : position.tp;
double tp = removeFreezedPositionTPSL ? 0 : position.sl;
ENUM_POSITION_TYPE type = isLong
? POSITION_TYPE_SELL
: POSITION_TYPE_BUY;
double entry = GetEntry(
position.symbol,
type //
);
ENUM_X_ORDER_MODES mode = X_ORDER_MODE_MARKET;
// if (canFreeze)
// {
// //
// // Temparory Requirement for Recover Signal ...
// double sl = removeFreezedPositionTPSL ? 0 : position.tp;
// double tp = removeFreezedPositionTPSL ? 0 : position.sl;
// ENUM_POSITION_TYPE type = isLong
// ? POSITION_TYPE_SELL
// : POSITION_TYPE_BUY;
// 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,
position.volume,
sl,
tp //
);
// //
// // Prepare Signal ...
// XSignal signal;
// bool isPrepared = signal.Prepare(
// position.symbol,
// position.provider,
// position.period,
// type,
// mode,
// entry,
// position.volume,
// sl,
// tp //
// );
//
if (isPrepared)
{
//
// Generate Comment for Recover and Support ...
string comment = GenerateSupportTag(position.ticket);
// //
// if (isPrepared)
// {
// //
// // Generate Comment for Recover and Support ...
// string comment = GenerateSupportTag(position.ticket);
//
signal.comment = comment;
// //
// signal.comment = comment;
//
ENUM_X_SIGNAL_EXECUTION_RESULT state;
bool isFreezed = ExecuteSignal(
signal,
state,
true // Support Signal need to Ignore Policies ...
);
if (isFreezed)
{
//
mData[iDX].freezed = true;
// //
// ENUM_X_SIGNAL_EXECUTION_RESULT state;
// bool isFreezed = ExecuteSignal(
// signal,
// state,
// true // Support Signal need to Ignore Policies ...
// );
// if (isFreezed)
// {
// //
// mData[iDX].freezed = true;
//
string message = "EQM Open " + (IsLong(type) ? "Long" : "Short") + " Freeze Position for (" + ToString(position.ticket) + ") ...";
Alert(message);
// //
// string message = "EQM Open " + (IsLong(type) ? "Long" : "Short") + " Freeze Position for (" + ToString(position.ticket) + ") ...";
// Alert(message);
//
if (removeFreezedPositionTPSL)
{
//
string comment = "EQM Removes Freezed TP/SL ...";
bool isModified = mTrader.Modify(
position.ticket,
0,
0,
comment //
);
// //
// if (removeFreezedPositionTPSL)
// {
// //
// string comment = "EQM Removes Freezed TP/SL ...";
// bool isModified = mTrader.Modify(
// position.ticket,
// 0,
// 0,
// comment //
// );
//
if (isModified)
{
//
string message = "EQM Remove Freezed Position (" + ToString(position.ticket) + ") TP/SL ...";
Alert(message);
}
}
}
}
}
// //
// if (isModified)
// {
// //
// string message = "EQM Remove Freezed Position (" + ToString(position.ticket) + ") TP/SL ...";
// Alert(message);
// }
// }
// }
// }
// }
//
// Support ...
bool isSupported = false;
if (canSupport)
{
//
// supportsCount
// bool isDistancePassed =
// supportStartDistance <= 0
// ? true
// : mData[iDX].lastSupportDistance < 0
// ? profitInPoint < 0 && (true)
// : profitInPoint > 0 && (true);
// if (canSupport)
// {
// //
// // supportsCount
// // bool isDistancePassed =
// // supportStartDistance <= 0
// // ? true
// // : mData[iDX].lastSupportDistance < 0
// // ? profitInPoint < 0 && (true)
// // : profitInPoint > 0 && (true);
//
bool hasLongSupportCondition = !doSupportOnConditions
? true
: (isTicksBullishForLong &&
hasBullishConditions);
// //
// bool hasLongSupportCondition = !doSupportOnConditions
// ? true
// : (isTicksBullishForLong &&
// hasBullishConditions);
//
bool hasShortSupportConditions = !doSupportOnConditions
? true
: (isTicksBearishForShort &&
hasBearishConditions);
// //
// bool hasShortSupportConditions = !doSupportOnConditions
// ? true
// : (isTicksBearishForShort &&
// hasBearishConditions);
//
bool hasSupportConditions =
!doSupportOnConditions
? true
: (hasLongSupportCondition ||
hasShortSupportConditions);
if (hasSupportConditions)
{
//
// Temparory Requirement for Recover Signal ...
double sl =
isLong
? hasLongSupportCondition
? position.sl
: position.tp
: hasLongSupportCondition
? position.tp
: position.sl;
double tp =
isLong
? hasLongSupportCondition
? position.tp
: position.sl
: hasLongSupportCondition
? position.sl
: position.tp;
ENUM_POSITION_TYPE type =
hasLongSupportCondition
? POSITION_TYPE_BUY
: POSITION_TYPE_SELL;
double entry = GetEntry(
position.symbol,
type //
);
ENUM_X_ORDER_MODES mode = X_ORDER_MODE_MARKET;
double volume = position.volume * supportVolumeMultiplier;
if (multiplySupportLevelOnVolume)
{
//
volume = supportsCount <= 0
? position.volume * supportVolumeMultiplier
: position.volume * ((supportsCount + 1) * supportVolumeMultiplier);
}
// //
// bool hasSupportConditions =
// !doSupportOnConditions
// ? true
// : (hasLongSupportCondition ||
// hasShortSupportConditions);
// if (hasSupportConditions)
// {
// //
// // Temparory Requirement for Recover Signal ...
// double sl =
// isLong
// ? hasLongSupportCondition
// ? position.sl
// : position.tp
// : hasLongSupportCondition
// ? position.tp
// : position.sl;
// double tp =
// isLong
// ? hasLongSupportCondition
// ? position.tp
// : position.sl
// : hasLongSupportCondition
// ? position.sl
// : position.tp;
// ENUM_POSITION_TYPE type =
// hasLongSupportCondition
// ? POSITION_TYPE_BUY
// : POSITION_TYPE_SELL;
// double entry = GetEntry(
// position.symbol,
// type //
// );
// ENUM_X_ORDER_MODES mode = X_ORDER_MODE_MARKET;
// double volume = position.volume * supportVolumeMultiplier;
// if (multiplySupportLevelOnVolume)
// {
// //
// volume = supportsCount <= 0
// ? position.volume * supportVolumeMultiplier
// : position.volume * ((supportsCount + 1) * supportVolumeMultiplier);
// }
//
// Prepare Signal ...
XSignal signal;
bool isPrepared = signal.Prepare(
position.symbol,
position.provider,
position.period,
type,
mode,
entry,
volume,
sl,
tp //
);
// //
// // 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);
// //
// if (isPrepared)
// {
// //
// // Generate Comment for Recover and Support ...
// string comment = GenerateSupportTag(position.ticket);
//
signal.comment = comment;
// //
// signal.comment = comment;
//
ENUM_X_SIGNAL_EXECUTION_RESULT state;
bool isSupported = ExecuteSignal(
signal,
state,
true // Support Signal need to Ignore Policies ...
);
if (isSupported)
{
//
mData[iDX].supportLevel++;
mData[iDX].lastSupportedOn = currentTime;
mData[iDX].lastSupportDistance = profitInPoint;
// //
// ENUM_X_SIGNAL_EXECUTION_RESULT state;
// bool isSupported = ExecuteSignal(
// signal,
// state,
// true // Support Signal need to Ignore Policies ...
// );
// if (isSupported)
// {
// //
// mData[iDX].supportLevel++;
// mData[iDX].lastSupportedOn = currentTime;
// mData[iDX].lastSupportDistance = profitInPoint;
//
string message = "EQM Open " + (IsLong(type) ? "Long" : "Short") + " Support Position in Level: " +
ToString(mData[iDX].supportLevel) +
" for (" + ToString(position.ticket) + ") ...";
Alert(message);
}
}
}
}
// //
// string message = "EQM Open " + (IsLong(type) ? "Long" : "Short") + " Support Position in Level: " +
// ToString(mData[iDX].supportLevel) +
// " for (" + ToString(position.ticket) + ") ...";
// Alert(message);
// }
// }
// }
// }
//
result =
@@ -3248,20 +3250,20 @@ class X121SCTradeHandler : public XSCBaseAlert
//
// Freeze ...
bool mAllowFreeze; // Allow Freezing
double mFreezeDistance; // Specify Freeze Start Drawdown in Point
bool mRemoveFreezedPositionTPSL; // Remove Freezed Positions TPSL
bool mDisableTrailWhenFreezedPosition; // Disable Trail when has Freezed Position
// bool mAllowFreeze; // Allow Freezing
// double mFreezeDistance; // Specify Freeze Start Drawdown in Point
// bool mRemoveFreezedPositionTPSL; // Remove Freezed Positions TPSL
// bool mDisableTrailWhenFreezedPosition; // Disable Trail when has Freezed Position
//
// Support ...
bool mAllowSupport; // Allow Support
double mSupportStartDistance; // Specify Start Support Drawdown in Point
int mMaxAllowedSupport; // Max Allowed Number of Support Position
double mSupportVolumeMultiplier; // Specify Support Volume Multiplier
bool mMultiplySupportLevelOnVolume; // Multiply Support Level on Volume Multiplier
bool mDoSupportOnConditions; // Do Support on Conditions
int mDelayBetweenTwoSupport; // Delay Between To Support in Second
// bool mAllowSupport; // Allow Support
// double mSupportStartDistance; // Specify Start Support Drawdown in Point
// int mMaxAllowedSupport; // Max Allowed Number of Support Position
// double mSupportVolumeMultiplier; // Specify Support Volume Multiplier
// bool mMultiplySupportLevelOnVolume; // Multiply Support Level on Volume Multiplier
// bool mDoSupportOnConditions; // Do Support on Conditions
// int mDelayBetweenTwoSupport; // Delay Between To Support in Second
//
// Partial Close (In Drawdown) ...