last ...
This commit is contained in:
@@ -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
|
||||
)
|
||||
{
|
||||
//
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
//
|
||||
// Close Opposit Positions ...
|
||||
int oppositCount =
|
||||
isLong
|
||||
? 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;
|
||||
}
|
||||
|
||||
//
|
||||
// Only Accept Next Same Type when Previous in Profit ...
|
||||
if (isSignalValid)
|
||||
{
|
||||
//
|
||||
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;
|
||||
}
|
||||
|
||||
//
|
||||
// Only Accept Next Same Type when Previous in Profit ...
|
||||
bool acceptNewOnlyWhenLastInProfit = AcceptNextDirectionalSignalsWhenFirstInProfit();
|
||||
if (acceptNewOnlyWhenLastInProfit)
|
||||
{
|
||||
//
|
||||
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)
|
||||
{
|
||||
//
|
||||
XPosition iSymbolsPositions[];
|
||||
int iSymbolsPositionsCount = mTrader.GetPositions(
|
||||
iSymbolsPositions,
|
||||
iSignal.symbol,
|
||||
NULL, // Provider
|
||||
NULL, // Period
|
||||
NULL, // Type
|
||||
true //
|
||||
);
|
||||
|
||||
//
|
||||
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();
|
||||
double volumeMultiplier = IncreaseNextSignalsVolumeMultiplier();
|
||||
if (canIncreaseVolume)
|
||||
{
|
||||
//
|
||||
double volumeMultiplier = IncreaseNextSignalsVolumeMultiplier();
|
||||
iSignal.volume = iSignal.volume * (multiplier * volumeMultiplier);
|
||||
}
|
||||
double multiplier =
|
||||
(isLong
|
||||
? symbolPositions[symbolIDX].CountLongs()
|
||||
: symbolPositions[symbolIDX].CountShorts()) +
|
||||
1;
|
||||
|
||||
//
|
||||
//
|
||||
multiplier = NormalizeDouble(multiplier * volumeMultiplier, 2);
|
||||
iSignal.volume = iSignal.volume * multiplier;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -4711,6 +4719,8 @@ public:
|
||||
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)
|
||||
|
||||
@@ -1135,7 +1135,10 @@ protected:
|
||||
);
|
||||
|
||||
//
|
||||
result = profits >= requiredProfit;
|
||||
result =
|
||||
positionsCount <= 5
|
||||
? profits >= requiredProfit
|
||||
: profits >= requiredProfit * 0.6;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
|
||||
@@ -63,8 +63,8 @@ input group "Risk Management";
|
||||
input double x121EAVolume = 0.01; // Static Volume
|
||||
input double x121EATPPoint = 1000; // TP Point
|
||||
input double x121EASLPoint = 1000; // SL Point
|
||||
input bool x121EAIgnoreSL = true; // Ignore Calculated SL
|
||||
input bool x121EAIgnoreTP = true; // Ignore Calculated TP
|
||||
input bool x121EAIgnoreSL = false; // Ignore Calculated SL
|
||||
input bool x121EAIgnoreTP = false; // Ignore Calculated TP
|
||||
input bool x121EACloseOnOpposit = false; // Close all Positions on Opposit
|
||||
input int x121EAMaxAllowedTrades = 0; // Max Allowed Positions Per Symbol
|
||||
input bool x121EAUseMaxAllowedPerDirection = true; // Use Max Allowed Positions Per Direction
|
||||
|
||||
@@ -2781,21 +2781,31 @@ struct XSymbolPositions
|
||||
|
||||
//
|
||||
double profit;
|
||||
double volume;
|
||||
|
||||
//
|
||||
double longsProfit;
|
||||
double longSupportsProfit;
|
||||
|
||||
//
|
||||
double shortsProfit;
|
||||
double shortSupportsProfit;
|
||||
|
||||
//
|
||||
double volume;
|
||||
double longsVolume;
|
||||
double longSupportsVolume;
|
||||
|
||||
//
|
||||
double shortsVolume;
|
||||
double shortSupportsVolume;
|
||||
|
||||
//
|
||||
double requiredProfitForHedge;
|
||||
|
||||
//
|
||||
// TODO: Complete this ...
|
||||
XPosition longs[];
|
||||
XPosition shorts[];
|
||||
XPosition supports[];
|
||||
XPosition positions[];
|
||||
XPosition longSupports[];
|
||||
XPosition shortSupports[];
|
||||
@@ -2825,6 +2835,59 @@ struct XSymbolPositions
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XPosition _supports[];
|
||||
XPosition _positions[];
|
||||
|
||||
//
|
||||
XPosition _tmp[];
|
||||
|
||||
//
|
||||
Copy(
|
||||
positions,
|
||||
_tmp //
|
||||
);
|
||||
|
||||
//
|
||||
Clean(positions);
|
||||
|
||||
//
|
||||
int tmpsCount = ArraySize(_tmp);
|
||||
for (int i = 0; i < tmpsCount; i++)
|
||||
{
|
||||
//
|
||||
XPosition iPosition = _tmp[i];
|
||||
|
||||
//
|
||||
bool isSupport = IsSupport(iPosition.comment);
|
||||
if (!isSupport)
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
iPosition,
|
||||
_positions //
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
iPosition,
|
||||
_supports //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
Clean(_tmp);
|
||||
|
||||
//
|
||||
Copy(
|
||||
_positions,
|
||||
positions //
|
||||
);
|
||||
Clean(_positions);
|
||||
|
||||
//
|
||||
// Extract Types ...
|
||||
ExtractPositions(
|
||||
@@ -2833,6 +2896,21 @@ struct XSymbolPositions
|
||||
shorts //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
_supports,
|
||||
supports //
|
||||
);
|
||||
Clean(_supports);
|
||||
|
||||
//
|
||||
// Extract Types ...
|
||||
ExtractPositions(
|
||||
supports,
|
||||
longSupports,
|
||||
shortSupports //
|
||||
);
|
||||
|
||||
//
|
||||
int numOfLongs = 0;
|
||||
int numOfShorts = 0;
|
||||
@@ -2847,14 +2925,46 @@ struct XSymbolPositions
|
||||
);
|
||||
|
||||
//
|
||||
profit = longsProfit + shortsProfit;
|
||||
volume = longsVolume + shortsVolume;
|
||||
requiredProfitForHedge = SpecifiedCalculateRequiredProfitForHedge(
|
||||
numOfLongs = 0;
|
||||
numOfShorts = 0;
|
||||
CountPositions(
|
||||
supports,
|
||||
numOfLongs,
|
||||
longSupportsProfit,
|
||||
longSupportsVolume,
|
||||
numOfShorts,
|
||||
shortSupportsProfit,
|
||||
shortSupportsVolume //
|
||||
);
|
||||
|
||||
//
|
||||
XPosition _allPositions[];
|
||||
Copy(
|
||||
positions,
|
||||
_allPositions,
|
||||
false //
|
||||
);
|
||||
Copy(
|
||||
supports,
|
||||
_allPositions,
|
||||
false //
|
||||
);
|
||||
|
||||
//
|
||||
profit = longsProfit + shortsProfit + longSupportsProfit + shortSupportsProfit;
|
||||
volume = longsVolume + shortsVolume + longSupportsVolume + shortSupportsVolume;
|
||||
requiredProfitForHedge = SpecifiedCalculateRequiredProfitForHedge(
|
||||
_allPositions,
|
||||
mMinProfitPerTrade,
|
||||
mMinProfitPerVolumeFactor //
|
||||
);
|
||||
|
||||
//
|
||||
Clean(_allPositions);
|
||||
|
||||
//
|
||||
result = true;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
@@ -2932,6 +3042,12 @@ struct XSymbolPositions
|
||||
return ArraySize(positions);
|
||||
}
|
||||
|
||||
//
|
||||
int CountSupports()
|
||||
{
|
||||
return ArraySize(supports);
|
||||
}
|
||||
|
||||
//
|
||||
int CountLongs()
|
||||
{
|
||||
@@ -2945,83 +3061,15 @@ struct XSymbolPositions
|
||||
}
|
||||
|
||||
//
|
||||
bool HasSupport()
|
||||
int CountLongSupports()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = HasChild();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
return ArraySize(longSupports);
|
||||
}
|
||||
|
||||
//
|
||||
result = HasLongSupport() || HasShortSupport();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool HasLongSupport()
|
||||
int CountShortSupports()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
int count = CountLongs();
|
||||
result = IsValidSize(count);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XPosition iPosition = longs[i];
|
||||
result = IsSupport(iPosition.comment);
|
||||
if (result)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool HasShortSupport()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
int count = CountShorts();
|
||||
result = IsValidSize(count);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XPosition iPosition = shorts[i];
|
||||
result = IsSupport(iPosition.comment);
|
||||
if (result)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
return ArraySize(shortSupports);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -3114,7 +3162,7 @@ struct XSymbolPositions
|
||||
|
||||
//
|
||||
int GetMaxInProfit(
|
||||
XPosition _position,
|
||||
XPosition &_position,
|
||||
ENUM_POSITION_TYPE _type //
|
||||
)
|
||||
{
|
||||
@@ -3168,7 +3216,7 @@ struct XSymbolPositions
|
||||
|
||||
//
|
||||
int GetMinInProfit(
|
||||
XPosition _position,
|
||||
XPosition &_position,
|
||||
ENUM_POSITION_TYPE _type //
|
||||
)
|
||||
{
|
||||
@@ -3222,7 +3270,7 @@ struct XSymbolPositions
|
||||
|
||||
//
|
||||
int GetMaxInDrawdown(
|
||||
XPosition _position,
|
||||
XPosition &_position,
|
||||
ENUM_POSITION_TYPE _type //
|
||||
)
|
||||
{
|
||||
@@ -3276,7 +3324,7 @@ struct XSymbolPositions
|
||||
|
||||
//
|
||||
int GetMinInDrawdown(
|
||||
XPosition _position,
|
||||
XPosition &_position,
|
||||
ENUM_POSITION_TYPE _type //
|
||||
)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user