This commit is contained in:
2024-07-01 00:53:55 +03:30
parent f5f358e497
commit 378f6e2bdb
5 changed files with 448 additions and 283 deletions
+112 -6
View File
@@ -2847,6 +2847,7 @@ struct X121SignalGenerator
int result = 0;
//
// 1
// XTD ...
bool isTDPassed =
//
@@ -2860,6 +2861,7 @@ struct X121SignalGenerator
}
//
// 2
// XHK ...
bool isHKPassed =
//
@@ -2878,6 +2880,7 @@ struct X121SignalGenerator
}
//
// 3
// XCHE ...
bool isCHEPassed =
//
@@ -2893,6 +2896,7 @@ struct X121SignalGenerator
}
//
// 4
// XICH ...
bool isICHPassed =
//
@@ -2920,6 +2924,7 @@ struct X121SignalGenerator
}
//
// 5
// XSTR ...
bool isSTRPassed =
//
@@ -2933,6 +2938,7 @@ struct X121SignalGenerator
}
//
// 6
// XMRB ...
bool isMRBPassed =
//
@@ -2946,6 +2952,7 @@ struct X121SignalGenerator
}
//
// 7
// XVLM ...
bool isVLMPassed =
//
@@ -2960,6 +2967,7 @@ struct X121SignalGenerator
}
//
// 8
// XSSLC ...
bool isSSLCPassed =
//
@@ -2973,6 +2981,7 @@ struct X121SignalGenerator
}
//
// 9
// XHULL ...
bool isHULLPassed =
//
@@ -2988,6 +2997,7 @@ struct X121SignalGenerator
}
//
// 10
// XADX ...
bool isADXTDPassed =
//
@@ -3002,8 +3012,9 @@ struct X121SignalGenerator
}
//
// 11
// XMC ...
bool isMATDPassed =
bool isMCPassed =
//
((conditions.mcConditions.isBullish ||
conditions.mcConditions.isSwitchedToBullish)
@@ -3024,7 +3035,49 @@ struct X121SignalGenerator
conditions.mcConditions.isSARSwitchedToBullish)
//
;
if (isMATDPassed)
if (isMCPassed)
{
result++;
}
//
// 12
// XSLN ...
bool isXSLNPassed =
//
(conditions.slnConditions.isBullish ||
conditions.slnConditions.isSwitchedToBullish)
//
;
if (isXSLNPassed)
{
result++;
}
//
// 13
// XHTD ...
bool isXHTDPassed =
//
(conditions.htdConditions.isBullish ||
conditions.htdConditions.isSwitchedToBullish)
//
;
if (isXHTDPassed)
{
result++;
}
//
// 14
// XATSL ...
bool isXATSLPassed =
//
(conditions.atslConditions.isBullish ||
conditions.atslConditions.isSwitchedToBullish)
//
;
if (isXATSLPassed)
{
result++;
}
@@ -3036,7 +3089,7 @@ struct X121SignalGenerator
//
bool IsConditionsValidForLong(
X121SetupConditions &conditions, // Conditions
int verifications = 2 // Number of Verifications
int verifications = 10 // Number of Verifications
)
{
//
@@ -3103,6 +3156,7 @@ struct X121SignalGenerator
int result = 0;
//
// 1
// XTD ...
bool isTDPassed =
//
@@ -3116,6 +3170,7 @@ struct X121SignalGenerator
}
//
// 2
// XHK ...
bool isHKPassed =
//
@@ -3134,6 +3189,7 @@ struct X121SignalGenerator
}
//
// 3
// XCHE ...
bool isCHEPassed =
//
@@ -3149,6 +3205,7 @@ struct X121SignalGenerator
}
//
// 4
// XICH ...
bool isICHPassed =
//
@@ -3176,6 +3233,7 @@ struct X121SignalGenerator
}
//
// 5
// XSTR ...
bool isSTRPassed =
//
@@ -3189,6 +3247,7 @@ struct X121SignalGenerator
}
//
// 6
// XMRB ...
bool isMRBPassed =
//
@@ -3202,6 +3261,7 @@ struct X121SignalGenerator
}
//
// 7
// XVLM ...
bool isVLMPassed =
//
@@ -3216,6 +3276,7 @@ struct X121SignalGenerator
}
//
// 8
// XSSLC ...
bool isSSLCPassed =
//
@@ -3229,6 +3290,7 @@ struct X121SignalGenerator
}
//
// 9
// XHULL ...
bool isHULLPassed =
//
@@ -3244,6 +3306,7 @@ struct X121SignalGenerator
}
//
// 10
// XADX ...
bool isADXTDPassed =
//
@@ -3258,8 +3321,9 @@ struct X121SignalGenerator
}
//
// 11
// XMC ...
bool isMATDPassed =
bool isMCPassed =
//
((conditions.mcConditions.isBearish ||
conditions.mcConditions.isSwitchedToBearish)
@@ -3280,7 +3344,49 @@ struct X121SignalGenerator
conditions.mcConditions.isSARSwitchedToBearish)
//
;
if (isMATDPassed)
if (isMCPassed)
{
result++;
}
//
// 12
// XSLN ...
bool isXSLNPassed =
//
(conditions.slnConditions.isBearish ||
conditions.slnConditions.isSwitchedToBearish)
//
;
if (isXSLNPassed)
{
result++;
}
//
// 13
// XHTD ...
bool isXHTDPassed =
//
(conditions.htdConditions.isBearish ||
conditions.htdConditions.isSwitchedToBearish)
//
;
if (isXHTDPassed)
{
result++;
}
//
// 14
// XATSL ...
bool isXATSLPassed =
//
(conditions.atslConditions.isBearish ||
conditions.atslConditions.isSwitchedToBearish)
//
;
if (isXATSLPassed)
{
result++;
}
@@ -3292,7 +3398,7 @@ struct X121SignalGenerator
//
bool IsConditionsValidForShort(
X121SetupConditions &conditions, // Conditions
int verifications = 2 // Number of Verifications
int verifications = 10 // Number of Verifications
)
{
//
+201 -193
View File
@@ -4170,6 +4170,10 @@ public:
signal = cSignal;
//
AddRef(
cConditions,
otherConditions //
);
AddRef(
sConditions,
otherConditions //
@@ -4178,6 +4182,14 @@ public:
mConditions,
otherConditions //
);
AddRef(
lConditions,
otherConditions //
);
AddRef(
hConditions,
otherConditions //
);
}
//
@@ -4192,10 +4204,22 @@ public:
cConditions,
otherConditions //
);
AddRef(
sConditions,
otherConditions //
);
AddRef(
mConditions,
otherConditions //
);
AddRef(
lConditions,
otherConditions //
);
AddRef(
hConditions,
otherConditions //
);
}
//
@@ -4206,14 +4230,26 @@ public:
signal = mSignal;
//
AddRef(
cConditions,
otherConditions //
);
AddRef(
sConditions,
otherConditions //
);
AddRef(
mConditions,
otherConditions //
);
AddRef(
lConditions,
otherConditions //
);
AddRef(
hConditions,
otherConditions //
);
}
//
@@ -4224,10 +4260,22 @@ public:
signal = lSignal;
//
AddRef(
cConditions,
otherConditions //
);
AddRef(
sConditions,
otherConditions //
);
AddRef(
mConditions,
otherConditions //
);
AddRef(
lConditions,
otherConditions //
);
AddRef(
hConditions,
otherConditions //
@@ -4408,7 +4456,7 @@ public:
//
double minProfitPerTrade = MinProfitPerTrade();
double minProfitPerTradeVolumeFactor = minProfitPerTradeVolumeFactor();
double minProfitPerTradeVolumeFactor = MinProfitPerVolumeFactor();
//
XSymbolPositions symbolPositions[];
@@ -4458,8 +4506,28 @@ public:
// Check Has Same Type Signal or not ...
hasSameTypeSignal =
isLong
? symbolPositions[symbolIDX].longs > 1
: symbolPositions[symbolIDX].shorts > 1;
? symbolPositions[symbolIDX].CountLongs() > 1
: symbolPositions[symbolIDX].CountShorts() > 1;
}
//
// New Signals Only Accepted when there is not any Support Signals
// on their types ...
if (hasSameTypeSignal)
{
//
isSignalValid =
isLong
? symbolPositions[symbolIDX].CountLongSupports() <= 0
: symbolPositions[symbolIDX].CountShortSupports() <= 0;
}
else
{
isSignalValid = true;
}
if (!isSignalValid)
{
continue;
}
//
@@ -4478,28 +4546,101 @@ public:
if (mCloseOnOpposit)
{
//
int oppositCount =
// Close Opposit Positions ...
int oppositCount =
isLong
? symbolPositions[symbolIDX].CountShorts()
: symbolPositions[symbolIDX].CountLongs();
? symbolPositions[symbolIDX].CountShorts()
: symbolPositions[symbolIDX].CountLongs();
bool hasOpposit = IsValidSize(oppositCount);
if (hasOpposit) {
if (hasOpposit)
{
//
XPosition opposit[];
if (isLong)
{
//
Copy(
symbolPositions[symbolIDX].shorts,
opposit //
);
}
else
{
//
Copy(
symbolPositions[symbolIDX].longs,
opposit //
);
}
//
string comment = "Close due Opposit ...";
//
int closeds = Close(
iPositions,
opposit,
comment //
);
if (IsValidSize(closeds))
{
//
string message = XEQMSupportToken + " Closed " + ToString(iPositionsCount) + " due Opposit Signal ...";
string message = XEQMSupportToken + " Closed " + ToString(oppositCount) + " due Opposit Signal ...";
//
Alert(message);
}
//
Clean(opposit);
}
//
// Close Opposit Supports ...
int oppositSupportCount =
isLong
? symbolPositions[symbolIDX].CountShortSupports()
: symbolPositions[symbolIDX].CountLongSupports();
bool hasOppositSupport = IsValidSize(oppositSupportCount);
if (hasOppositSupport)
{
//
XPosition opposit[];
if (isLong)
{
//
Copy(
symbolPositions[symbolIDX].shortSupports,
opposit //
);
}
else
{
//
Copy(
symbolPositions[symbolIDX].longSupports,
opposit //
);
}
//
string comment = "Close due Opposit ...";
//
int closeds = Close(
opposit,
comment //
);
if (IsValidSize(closeds))
{
//
string message = XEQMSupportToken + " Closed " + ToString(oppositCount) + " due Opposit Signal ...";
//
Alert(message);
}
//
Clean(opposit);
}
}
@@ -4508,197 +4649,64 @@ public:
if (maxAllowed > 0)
{
//
// Here we Get Opposite Signals of Same Symbol Valid ...
ENUM_X_POSITION_TYPES iType =
perDirection
? ToPositionType(iSignal.type)
: X_POSITION_TYPE_ALL;
XPosition iSymbolsPositions[];
int iSymbolsPositionsCount = mTrader.GetPositions(
iSymbolsPositions,
iSignal.symbol,
NULL, // Provider
NULL, // Period
iType, // Type
true //
);
//
int iSupportsCount = 0;
if (IsValidSize(iSymbolsPositionsCount))
{
//
// Filter Support Positions ...
XPosition iSupports[];
iSupportsCount = ExtractSupports(
iSymbolsPositions,
iSupports //
);
}
//
isFirstOfSymbol =
//
isSignalValid =
iSupportsCount <= 0
? iSymbolsPositionsCount < maxAllowed
: iSymbolsPositionsCount - iSupportsCount < maxAllowed;
if (!isSignalValid)
{
continue;
}
int usedCount =
!perDirection
? symbolPositions[symbolIDX].Count()
: isLong
? symbolPositions[symbolIDX].CountLongs()
: symbolPositions[symbolIDX].CountShorts();
isSignalValid = !IsValidSize(usedCount)
? true
: usedCount < maxAllowed;
}
else
{
isSignalValid = true;
}
if (!isSignalValid)
{
continue;
}
//
// Only Accept Next Same Type when Previous in Profit ...
if (isSignalValid)
bool acceptNewOnlyWhenLastInProfit = AcceptNextDirectionalSignalsWhenFirstInProfit();
if (acceptNewOnlyWhenLastInProfit)
{
//
ENUM_X_POSITION_TYPES iType =
ToPositionType(iSignal.type);
XPosition iSymbolsPositions[];
int iSymbolsPositionsCount = mTrader.GetPositions(
iSymbolsPositions,
iSignal.symbol,
NULL, // Provider
NULL, // Period
iType, // Type
true //
);
//
int iSupportsCount = 0;
if (IsValidSize(iSymbolsPositionsCount))
{
//
// Filter Support Positions ...
XPosition iSupports[];
iSupportsCount = ExtractSupports(
iSymbolsPositions,
iSupports //
);
//
// Filter Support Positions ...
if (IsValidSize(iSupportsCount))
{
//
XPosition tmpPositions[];
Copy(
iSymbolsPositions,
tmpPositions //
);
//
Clean(iSymbolsPositions);
//
for (int i = 0; i < iSymbolsPositionsCount; i++)
{
//
XPosition iPosition = tmpPositions[i];
//
bool isSupport = IsSupport(iPosition.comment);
if (isSupport)
{
continue;
}
//
AddRef(
iPosition,
iSymbolsPositions //
);
}
//
iSymbolsPositionsCount = ArraySize(iSymbolsPositions);
}
}
//
bool acceptNewOnlyWhenLastInProfit = AcceptNextDirectionalSignalsWhenFirstInProfit();
isSameTypeExists = IsValidSize(iSymbolsPositionsCount);
if (isSameTypeExists && acceptNewOnlyWhenLastInProfit)
{
//
XPosition youngest;
int youngestAge = GetYoungest(
youngest,
iSymbolsPositions //
);
//
isSignalValid = youngest.profit > 0.1;
}
//
if (!isSignalValid)
{
continue;
}
isSignalValid =
!hasSameTypeSignal
? true
: isLong
? symbolPositions[symbolIDX].longsProfit > 0
: symbolPositions[symbolIDX].shortsProfit > 0;
}
else
{
isSignalValid = true;
}
if (!isSignalValid)
{
continue;
}
//
// Multiply Signal Volume ...
// Create First Signal Opposit Protector ...
if (isSignalValid)
bool canIncreaseVolume = IncreaseNextSignalsVolume();
double volumeMultiplier = IncreaseNextSignalsVolumeMultiplier();
if (canIncreaseVolume)
{
//
XPosition iSymbolsPositions[];
int iSymbolsPositionsCount = mTrader.GetPositions(
iSymbolsPositions,
iSignal.symbol,
NULL, // Provider
NULL, // Period
NULL, // Type
true //
);
double multiplier =
(isLong
? symbolPositions[symbolIDX].CountLongs()
: symbolPositions[symbolIDX].CountShorts()) +
1;
//
int iSupportsCount = 0;
if (IsValidSize(iSymbolsPositionsCount))
{
//
// Filter Support Positions ...
XPosition iSupports[];
iSupportsCount = ExtractSupports(
iSymbolsPositions,
iSupports //
);
}
//
int multiplier =
iSupportsCount <= 0
? iSymbolsPositionsCount
: iSymbolsPositionsCount - iSupportsCount;
if (multiplier <= 0)
{
multiplier = 1;
}
else
{
multiplier++;
}
//
bool canIncreaseVolume = IncreaseNextSignalsVolume();
if (canIncreaseVolume)
{
//
double volumeMultiplier = IncreaseNextSignalsVolumeMultiplier();
iSignal.volume = iSignal.volume * (multiplier * volumeMultiplier);
}
//
//
multiplier = NormalizeDouble(multiplier * volumeMultiplier, 2);
iSignal.volume = iSignal.volume * multiplier;
}
//
@@ -4711,8 +4719,10 @@ public:
eSignals //
);
}
}
//
}
//
result = ArraySize(eSignals);
@@ -4721,18 +4731,16 @@ public:
if (IsValidSize(result))
{
//
Copy(
eSignals,
signals //
);
//
Clean(eSignals);
//
HandleSignals(signals);
// Execute Signals ...
HandleSignals(eSignals);
}
//
// Here we maker result to 0
// for prevent XBaseEA Calss for Executing Signal ...
result = 0;
Clean(signals);
//
return result;
}
@@ -5028,7 +5036,7 @@ protected:
XPosition youngest;
int youngestAge = positions.GetYoungest(
youngest,
iSignal.type //
signal.type //
);
result = !IsValidIndex(youngestAge);
if (result)
+4 -1
View File
@@ -1135,7 +1135,10 @@ protected:
);
//
result = profits >= requiredProfit;
result =
positionsCount <= 5
? profits >= requiredProfit
: profits >= requiredProfit * 0.6;
if (!result)
{
return result;