This commit is contained in:
2024-06-17 14:46:04 +03:30
parent e5e743d684
commit 54f85632d2
3 changed files with 249 additions and 98 deletions
+13 -13
View File
@@ -13,19 +13,6 @@
"id": "81",
"references": [],
"title": "Fix Allow Supports ..."
},
{
"assignedTo": {
"name": "Hadi Khazaee Asl"
},
"creation_time": "2024-06-16T23:58:59.163Z",
"description": {
"content": "Fix Open Signals When Support Signals only Open\nMax Allowed Trades Handler ...",
"mime": "text/markdown"
},
"id": "79",
"references": [],
"title": "Fix Max Allowed Trade on Only SUpport Signals"
}
],
"testing": [
@@ -50,6 +37,19 @@
"id": "80",
"references": [],
"title": "Complete Signalling COntrols ..."
},
{
"assignedTo": {
"name": "Hadi Khazaee Asl"
},
"creation_time": "2024-06-16T23:58:59.163Z",
"description": {
"content": "Fix Open Signals When Support Signals only Open\nMax Allowed Trades Handler ...",
"mime": "text/markdown"
},
"id": "79",
"references": [],
"title": "Fix Max Allowed Trade on Only SUpport Signals"
}
],
"done": [
+162 -83
View File
@@ -431,13 +431,16 @@ struct XTradeInfo
// Grid System Calculations ...
//
int gLevel; // Number of Grids
double gEntry; // Represents Next Grid Signal's Entry
double gVolume; // Represent Next Grid Signal's Volume
//
void ResetGrid()
{
//
gEntry = 0;
gLevel = 0;
gVolume = 0;
}
@@ -576,6 +579,9 @@ struct XTradeInfo
distance,
volumeMultiplier //
);
//
gLevel++;
}
//
@@ -592,11 +598,13 @@ struct XTradeInfo
double rVolume; // Represent Next Recovery Signal's Volume
double rZoneUpper; // Zone Recovery Upper Bound
double rZoneLower; // Zone Recovery Lower Bound
int rLevel; // Number of Recoveries
//
void ResetRecovery()
{
//
rLevel = 0;
rVolume = 0;
rLongEntry = 0;
rZoneUpper = 0;
@@ -819,6 +827,9 @@ struct XTradeInfo
volumeMultiplier,
rType //
);
//
rLevel++;
}
//
@@ -1258,6 +1269,8 @@ public:
result =
//
AllowSupport() &&
SupportDistance() > 0 &&
MaxNumberOfSupports() >= 0 &&
SupportVolumeMultiplier() > 0
//
;
@@ -1369,6 +1382,7 @@ public:
//
AllowGrid() &&
GridDistance() > 0 &&
MaxNumberOfGrids() >= 0 &&
GridVolumeMultiplier() > 0
//
;
@@ -1480,6 +1494,7 @@ public:
//
AllowRecovery() &&
RecoveryDistance() > 0 &&
MaxNumberOfRecoveries() >= 0 &&
RecoveryVolumeMultiplier() > 0
//
;
@@ -1823,7 +1838,8 @@ public:
//
// Handle Do All Protecting ...
int DoProtect(
XSignal &signals[] // if PRotecting Generate Some Support Signals, Holds them here
XSignal &signals[], // if PRotecting Generate Some Support Signals, Holds them here
XSCX121SetupCycles *&setups[] // Number of Setups
)
{
//
@@ -1832,6 +1848,73 @@ public:
//
// Calling Protection Algorithms ...
//
// Trailling ...
if (EnableTrailling())
{
//
int traillings = HandleTrailling();
}
//
// Supporting ...
if (EnableSupport())
{
//
XSignal supports[];
int supportsCount = RequestForSupport(
supports,
setups //
);
//
if (IsValidSize(supportsCount))
{
//
Copy(
supports,
signals,
false //
);
}
}
//
// Grid ...
if (EnableGrid())
{
//
XSignal grids[];
int gridsCount = RequestForGrid(grids);
if (IsValidSize(gridsCount))
{
//
Copy(
grids,
signals,
false //
);
}
}
//
// Recovery ...
if (EnableRecovery())
{
//
XSignal recoveries[];
int recoveriesCount = RequestForRecovery(recoveries);
if (IsValidSize(recoveriesCount))
{
//
Copy(
recoveries,
signals,
false //
);
}
}
//
result = ArraySize(signals);
@@ -2056,9 +2139,7 @@ protected:
//
int RequestForSupport(
XSignal &signals[],
XSCX121SetupCycles *&setups[], // Number of Setups
double supportDistance = 50,
double volumeMultiplier = 2 //
XSCX121SetupCycles *&setups[] //
)
{
//
@@ -2102,6 +2183,12 @@ protected:
return result;
}
//
double supportDistance = SupportDistance();
int maxNUmberOfSupports = MaxNumberOfSupports();
double maxAllowedVolume = MaxAllowedSupportVolume();
double volumeMultiplier = SupportVolumeMultiplier();
//
X121SignalGenerator signalGenerator;
@@ -2164,77 +2251,8 @@ protected:
}
//
// Now We Have all required Data to Decide What Supports for
// Specified In DrawDown Position ...
//
XSignal tmpSignal;
tmpSignal.Clean();
//
double longEntry = GetEntry(
iPosition.symbol,
POSITION_TYPE_BUY //
);
double shortEntry = GetEntry(
iPosition.symbol,
POSITION_TYPE_SELL //
);
double mVolume = iPosition.volume * 2;
double mSL = 0;
double mTP = 0;
//
bool isLong = IsLong(iPosition.type);
//
// Here we Can Start a Recovery Zone ...
if (data[index].rLongEntry <= 0 &&
data[index].rShortEntry <= 0 &&
data[index].rVolume <= 0)
{
//
data[index].PrepareNextRecovery(
supportDistance,
volumeMultiplier,
iPosition.type //
);
}
else
{
//
bool hasRecovery = data[index].HasRecovery(
tmpSignal,
supportDistance,
volumeMultiplier //
);
if (hasRecovery)
{
//
// tmpSignal.sl = 0;
// tmpSignal.tp = 0;
string comment = GenerateEQMSupportTag(iPosition.ticket);
tmpSignal.comment = comment;
//
AddRef(
tmpSignal,
signals //
);
}
else if (priceDiffPoints >= supportDistance)
{
//
// Reset
if (longEntry > data[index].rZoneUpper || shortEntry < data[index].rZoneLower)
{
//
// data[index].ResetRecovery();
//
}
}
}
// Check Support COunts and etc ...
// implementing supporting mechanis ...
//
}
@@ -2261,6 +2279,10 @@ protected:
return result;
}
//
int maxAllowed = MaxNumberOfGrids();
double maxAllowedVolume = MaxAllowedGridVolume();
//
int count = Count();
if (!IsValidSize(count))
@@ -2271,6 +2293,17 @@ protected:
//
for (int i = 0; i < count; i++)
{
//
// Check Count ...
bool isMaxPassed =
maxAllowed <= 0
? true
: data[i].gLevel < maxAllowed;
if (!isMaxPassed)
{
continue;
}
//
XSignal iSignal;
bool hasGrid = data[i].HasGrid(
@@ -2282,6 +2315,13 @@ protected:
//
if (hasGrid)
{
//
// Check Max Volume ...
iSignal.volume =
maxAllowedVolume <= 0
? iSignal.volume
: MathMin(iSignal.volume, maxAllowedVolume);
//
AddRef(
iSignal,
@@ -2312,6 +2352,10 @@ protected:
return result;
}
//
int maxAllowed = MaxNumberOfRecoveries();
double maxAllowedVolume = MaxAllowedRecoveryVolume();
//
int count = Count();
if (!IsValidSize(count))
@@ -2322,6 +2366,17 @@ protected:
//
for (int i = 0; i < count; i++)
{
//
// Check Count ...
bool isMaxPassed =
maxAllowed <= 0
? true
: data[i].rLevel < maxAllowed;
if (!isMaxPassed)
{
continue;
}
//
XSignal iSignal;
bool hasRecovery = data[i].HasRecovery(
@@ -2333,6 +2388,13 @@ protected:
//
if (hasRecovery)
{
//
// Check Max Volume ...
iSignal.volume =
maxAllowedVolume <= 0
? iSignal.volume
: MathMin(iSignal.volume, maxAllowedVolume);
//
AddRef(
iSignal,
@@ -3025,8 +3087,7 @@ public:
// filters theme here and passed them
// for Executing ...
int RequestForSignal(
XSignal &signals[], // Holds Signals ...
bool force = false //
XSignal &signals[] // Holds Signals ...
) override
{
//
@@ -3035,15 +3096,11 @@ public:
//
Clean(signals);
//
if (!force)
{
//
if (!IsEnable())
{
return result;
}
}
//
// IMPLEMENT ...
@@ -3750,6 +3807,7 @@ public:
// Filter Signals Based On Max Allowed ...
if (maxAllowed > 0)
{
//
XPosition iSymbolsPositions[];
int iSymbolsPositionsCount = mTrader.GetPositions(
iSymbolsPositions,
@@ -3759,7 +3817,25 @@ public:
NULL,
true //
);
isSignalValid = iSymbolsPositionsCount < maxAllowed;
//
int iSupportsCount = 0;
if (IsValidSize(iSymbolsPositionsCount))
{
//
// Filter Support Positions ...
XPosition iSupports[];
iSupportsCount = ExtractSupports(
iSymbolsPositions,
iSupports //
);
}
//
isSignalValid =
iSupportsCount <= 0
? iSymbolsPositionsCount < maxAllowed
: iSymbolsPositionsCount - iSupportsCount < maxAllowed;
if (!isSignalValid)
{
continue;
@@ -4217,7 +4293,10 @@ private:
{
//
XSignal supports[];
int supportsCount = mTradeHandler.DoProtect(supports);
int supportsCount = mTradeHandler.DoProtect(
supports,
mSetups //
);
//
if (IsValidSize(supportsCount))
+72
View File
@@ -1337,3 +1337,75 @@
Alert(message);
}
}
/////////////////////////////////////////////////////////
// //
// XSignal tmpSignal;
// tmpSignal.Clean();
// //
// double longEntry = GetEntry(
// iPosition.symbol,
// POSITION_TYPE_BUY //
// );
// double shortEntry = GetEntry(
// iPosition.symbol,
// POSITION_TYPE_SELL //
// );
// double mVolume = iPosition.volume * 2;
// double mSL = 0;
// double mTP = 0;
// //
// bool isLong = IsLong(iPosition.type);
// //
// // Here we Can Start a Recovery Zone ...
// if (data[index].rLongEntry <= 0 &&
// data[index].rShortEntry <= 0 &&
// data[index].rVolume <= 0)
// {
// //
// data[index].PrepareNextRecovery(
// supportDistance,
// volumeMultiplier,
// iPosition.type //
// );
// }
// else
// {
// //
// bool hasRecovery = data[index].HasRecovery(
// tmpSignal,
// supportDistance,
// volumeMultiplier //
// );
// if (hasRecovery)
// {
// //
// // tmpSignal.sl = 0;
// // tmpSignal.tp = 0;
// string comment = GenerateEQMSupportTag(iPosition.ticket);
// tmpSignal.comment = comment;
// //
// AddRef(
// tmpSignal,
// signals //
// );
// }
// else if (priceDiffPoints >= supportDistance)
// {
// //
// // Reset
// if (longEntry > data[index].rZoneUpper || shortEntry < data[index].rZoneLower)
// {
// //
// // data[index].ResetRecovery();
// //
// }
// }
// }