last ...
This commit is contained in:
@@ -2847,6 +2847,7 @@ struct X121SignalGenerator
|
|||||||
int result = 0;
|
int result = 0;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
// 1
|
||||||
// XTD ...
|
// XTD ...
|
||||||
bool isTDPassed =
|
bool isTDPassed =
|
||||||
//
|
//
|
||||||
@@ -2860,6 +2861,7 @@ struct X121SignalGenerator
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
// 2
|
||||||
// XHK ...
|
// XHK ...
|
||||||
bool isHKPassed =
|
bool isHKPassed =
|
||||||
//
|
//
|
||||||
@@ -2878,6 +2880,7 @@ struct X121SignalGenerator
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
// 3
|
||||||
// XCHE ...
|
// XCHE ...
|
||||||
bool isCHEPassed =
|
bool isCHEPassed =
|
||||||
//
|
//
|
||||||
@@ -2893,6 +2896,7 @@ struct X121SignalGenerator
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
// 4
|
||||||
// XICH ...
|
// XICH ...
|
||||||
bool isICHPassed =
|
bool isICHPassed =
|
||||||
//
|
//
|
||||||
@@ -2920,6 +2924,7 @@ struct X121SignalGenerator
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
// 5
|
||||||
// XSTR ...
|
// XSTR ...
|
||||||
bool isSTRPassed =
|
bool isSTRPassed =
|
||||||
//
|
//
|
||||||
@@ -2933,6 +2938,7 @@ struct X121SignalGenerator
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
// 6
|
||||||
// XMRB ...
|
// XMRB ...
|
||||||
bool isMRBPassed =
|
bool isMRBPassed =
|
||||||
//
|
//
|
||||||
@@ -2946,6 +2952,7 @@ struct X121SignalGenerator
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
// 7
|
||||||
// XVLM ...
|
// XVLM ...
|
||||||
bool isVLMPassed =
|
bool isVLMPassed =
|
||||||
//
|
//
|
||||||
@@ -2960,6 +2967,7 @@ struct X121SignalGenerator
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
// 8
|
||||||
// XSSLC ...
|
// XSSLC ...
|
||||||
bool isSSLCPassed =
|
bool isSSLCPassed =
|
||||||
//
|
//
|
||||||
@@ -2973,6 +2981,7 @@ struct X121SignalGenerator
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
// 9
|
||||||
// XHULL ...
|
// XHULL ...
|
||||||
bool isHULLPassed =
|
bool isHULLPassed =
|
||||||
//
|
//
|
||||||
@@ -2988,6 +2997,7 @@ struct X121SignalGenerator
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
// 10
|
||||||
// XADX ...
|
// XADX ...
|
||||||
bool isADXTDPassed =
|
bool isADXTDPassed =
|
||||||
//
|
//
|
||||||
@@ -3002,8 +3012,9 @@ struct X121SignalGenerator
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
// 11
|
||||||
// XMC ...
|
// XMC ...
|
||||||
bool isMATDPassed =
|
bool isMCPassed =
|
||||||
//
|
//
|
||||||
((conditions.mcConditions.isBullish ||
|
((conditions.mcConditions.isBullish ||
|
||||||
conditions.mcConditions.isSwitchedToBullish)
|
conditions.mcConditions.isSwitchedToBullish)
|
||||||
@@ -3024,7 +3035,49 @@ struct X121SignalGenerator
|
|||||||
conditions.mcConditions.isSARSwitchedToBullish)
|
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++;
|
result++;
|
||||||
}
|
}
|
||||||
@@ -3036,7 +3089,7 @@ struct X121SignalGenerator
|
|||||||
//
|
//
|
||||||
bool IsConditionsValidForLong(
|
bool IsConditionsValidForLong(
|
||||||
X121SetupConditions &conditions, // Conditions
|
X121SetupConditions &conditions, // Conditions
|
||||||
int verifications = 2 // Number of Verifications
|
int verifications = 10 // Number of Verifications
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -3103,6 +3156,7 @@ struct X121SignalGenerator
|
|||||||
int result = 0;
|
int result = 0;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
// 1
|
||||||
// XTD ...
|
// XTD ...
|
||||||
bool isTDPassed =
|
bool isTDPassed =
|
||||||
//
|
//
|
||||||
@@ -3116,6 +3170,7 @@ struct X121SignalGenerator
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
// 2
|
||||||
// XHK ...
|
// XHK ...
|
||||||
bool isHKPassed =
|
bool isHKPassed =
|
||||||
//
|
//
|
||||||
@@ -3134,6 +3189,7 @@ struct X121SignalGenerator
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
// 3
|
||||||
// XCHE ...
|
// XCHE ...
|
||||||
bool isCHEPassed =
|
bool isCHEPassed =
|
||||||
//
|
//
|
||||||
@@ -3149,6 +3205,7 @@ struct X121SignalGenerator
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
// 4
|
||||||
// XICH ...
|
// XICH ...
|
||||||
bool isICHPassed =
|
bool isICHPassed =
|
||||||
//
|
//
|
||||||
@@ -3176,6 +3233,7 @@ struct X121SignalGenerator
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
// 5
|
||||||
// XSTR ...
|
// XSTR ...
|
||||||
bool isSTRPassed =
|
bool isSTRPassed =
|
||||||
//
|
//
|
||||||
@@ -3189,6 +3247,7 @@ struct X121SignalGenerator
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
// 6
|
||||||
// XMRB ...
|
// XMRB ...
|
||||||
bool isMRBPassed =
|
bool isMRBPassed =
|
||||||
//
|
//
|
||||||
@@ -3202,6 +3261,7 @@ struct X121SignalGenerator
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
// 7
|
||||||
// XVLM ...
|
// XVLM ...
|
||||||
bool isVLMPassed =
|
bool isVLMPassed =
|
||||||
//
|
//
|
||||||
@@ -3216,6 +3276,7 @@ struct X121SignalGenerator
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
// 8
|
||||||
// XSSLC ...
|
// XSSLC ...
|
||||||
bool isSSLCPassed =
|
bool isSSLCPassed =
|
||||||
//
|
//
|
||||||
@@ -3229,6 +3290,7 @@ struct X121SignalGenerator
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
// 9
|
||||||
// XHULL ...
|
// XHULL ...
|
||||||
bool isHULLPassed =
|
bool isHULLPassed =
|
||||||
//
|
//
|
||||||
@@ -3244,6 +3306,7 @@ struct X121SignalGenerator
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
// 10
|
||||||
// XADX ...
|
// XADX ...
|
||||||
bool isADXTDPassed =
|
bool isADXTDPassed =
|
||||||
//
|
//
|
||||||
@@ -3258,8 +3321,9 @@ struct X121SignalGenerator
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
// 11
|
||||||
// XMC ...
|
// XMC ...
|
||||||
bool isMATDPassed =
|
bool isMCPassed =
|
||||||
//
|
//
|
||||||
((conditions.mcConditions.isBearish ||
|
((conditions.mcConditions.isBearish ||
|
||||||
conditions.mcConditions.isSwitchedToBearish)
|
conditions.mcConditions.isSwitchedToBearish)
|
||||||
@@ -3280,7 +3344,49 @@ struct X121SignalGenerator
|
|||||||
conditions.mcConditions.isSARSwitchedToBearish)
|
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++;
|
result++;
|
||||||
}
|
}
|
||||||
@@ -3292,7 +3398,7 @@ struct X121SignalGenerator
|
|||||||
//
|
//
|
||||||
bool IsConditionsValidForShort(
|
bool IsConditionsValidForShort(
|
||||||
X121SetupConditions &conditions, // Conditions
|
X121SetupConditions &conditions, // Conditions
|
||||||
int verifications = 2 // Number of Verifications
|
int verifications = 10 // Number of Verifications
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -4170,6 +4170,10 @@ public:
|
|||||||
signal = cSignal;
|
signal = cSignal;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
AddRef(
|
||||||
|
cConditions,
|
||||||
|
otherConditions //
|
||||||
|
);
|
||||||
AddRef(
|
AddRef(
|
||||||
sConditions,
|
sConditions,
|
||||||
otherConditions //
|
otherConditions //
|
||||||
@@ -4178,6 +4182,14 @@ public:
|
|||||||
mConditions,
|
mConditions,
|
||||||
otherConditions //
|
otherConditions //
|
||||||
);
|
);
|
||||||
|
AddRef(
|
||||||
|
lConditions,
|
||||||
|
otherConditions //
|
||||||
|
);
|
||||||
|
AddRef(
|
||||||
|
hConditions,
|
||||||
|
otherConditions //
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -4192,10 +4204,22 @@ public:
|
|||||||
cConditions,
|
cConditions,
|
||||||
otherConditions //
|
otherConditions //
|
||||||
);
|
);
|
||||||
|
AddRef(
|
||||||
|
sConditions,
|
||||||
|
otherConditions //
|
||||||
|
);
|
||||||
AddRef(
|
AddRef(
|
||||||
mConditions,
|
mConditions,
|
||||||
otherConditions //
|
otherConditions //
|
||||||
);
|
);
|
||||||
|
AddRef(
|
||||||
|
lConditions,
|
||||||
|
otherConditions //
|
||||||
|
);
|
||||||
|
AddRef(
|
||||||
|
hConditions,
|
||||||
|
otherConditions //
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -4206,14 +4230,26 @@ public:
|
|||||||
signal = mSignal;
|
signal = mSignal;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
AddRef(
|
||||||
|
cConditions,
|
||||||
|
otherConditions //
|
||||||
|
);
|
||||||
AddRef(
|
AddRef(
|
||||||
sConditions,
|
sConditions,
|
||||||
otherConditions //
|
otherConditions //
|
||||||
);
|
);
|
||||||
|
AddRef(
|
||||||
|
mConditions,
|
||||||
|
otherConditions //
|
||||||
|
);
|
||||||
AddRef(
|
AddRef(
|
||||||
lConditions,
|
lConditions,
|
||||||
otherConditions //
|
otherConditions //
|
||||||
);
|
);
|
||||||
|
AddRef(
|
||||||
|
hConditions,
|
||||||
|
otherConditions //
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -4224,10 +4260,22 @@ public:
|
|||||||
signal = lSignal;
|
signal = lSignal;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
AddRef(
|
||||||
|
cConditions,
|
||||||
|
otherConditions //
|
||||||
|
);
|
||||||
|
AddRef(
|
||||||
|
sConditions,
|
||||||
|
otherConditions //
|
||||||
|
);
|
||||||
AddRef(
|
AddRef(
|
||||||
mConditions,
|
mConditions,
|
||||||
otherConditions //
|
otherConditions //
|
||||||
);
|
);
|
||||||
|
AddRef(
|
||||||
|
lConditions,
|
||||||
|
otherConditions //
|
||||||
|
);
|
||||||
AddRef(
|
AddRef(
|
||||||
hConditions,
|
hConditions,
|
||||||
otherConditions //
|
otherConditions //
|
||||||
@@ -4408,7 +4456,7 @@ public:
|
|||||||
|
|
||||||
//
|
//
|
||||||
double minProfitPerTrade = MinProfitPerTrade();
|
double minProfitPerTrade = MinProfitPerTrade();
|
||||||
double minProfitPerTradeVolumeFactor = minProfitPerTradeVolumeFactor();
|
double minProfitPerTradeVolumeFactor = MinProfitPerVolumeFactor();
|
||||||
|
|
||||||
//
|
//
|
||||||
XSymbolPositions symbolPositions[];
|
XSymbolPositions symbolPositions[];
|
||||||
@@ -4458,8 +4506,28 @@ public:
|
|||||||
// Check Has Same Type Signal or not ...
|
// Check Has Same Type Signal or not ...
|
||||||
hasSameTypeSignal =
|
hasSameTypeSignal =
|
||||||
isLong
|
isLong
|
||||||
? symbolPositions[symbolIDX].longs > 1
|
? symbolPositions[symbolIDX].CountLongs() > 1
|
||||||
: symbolPositions[symbolIDX].shorts > 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)
|
if (mCloseOnOpposit)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
int oppositCount =
|
// Close Opposit Positions ...
|
||||||
|
int oppositCount =
|
||||||
isLong
|
isLong
|
||||||
? symbolPositions[symbolIDX].CountShorts()
|
? symbolPositions[symbolIDX].CountShorts()
|
||||||
: symbolPositions[symbolIDX].CountLongs();
|
: symbolPositions[symbolIDX].CountLongs();
|
||||||
bool hasOpposit = IsValidSize(oppositCount);
|
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 ...";
|
string comment = "Close due Opposit ...";
|
||||||
|
|
||||||
//
|
//
|
||||||
int closeds = Close(
|
int closeds = Close(
|
||||||
iPositions,
|
opposit,
|
||||||
comment //
|
comment //
|
||||||
);
|
);
|
||||||
if (IsValidSize(closeds))
|
if (IsValidSize(closeds))
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
string message = XEQMSupportToken + " Closed " + ToString(iPositionsCount) + " due Opposit Signal ...";
|
string message = XEQMSupportToken + " Closed " + ToString(oppositCount) + " due Opposit Signal ...";
|
||||||
|
|
||||||
//
|
//
|
||||||
Alert(message);
|
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)
|
if (maxAllowed > 0)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Here we Get Opposite Signals of Same Symbol Valid ...
|
int usedCount =
|
||||||
ENUM_X_POSITION_TYPES iType =
|
!perDirection
|
||||||
perDirection
|
? symbolPositions[symbolIDX].Count()
|
||||||
? ToPositionType(iSignal.type)
|
: isLong
|
||||||
: X_POSITION_TYPE_ALL;
|
? symbolPositions[symbolIDX].CountLongs()
|
||||||
XPosition iSymbolsPositions[];
|
: symbolPositions[symbolIDX].CountShorts();
|
||||||
int iSymbolsPositionsCount = mTrader.GetPositions(
|
isSignalValid = !IsValidSize(usedCount)
|
||||||
iSymbolsPositions,
|
? true
|
||||||
iSignal.symbol,
|
: usedCount < maxAllowed;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
isSignalValid = true;
|
isSignalValid = true;
|
||||||
}
|
}
|
||||||
|
if (!isSignalValid)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Only Accept Next Same Type when Previous in Profit ...
|
// Only Accept Next Same Type when Previous in Profit ...
|
||||||
if (isSignalValid)
|
bool acceptNewOnlyWhenLastInProfit = AcceptNextDirectionalSignalsWhenFirstInProfit();
|
||||||
|
if (acceptNewOnlyWhenLastInProfit)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
ENUM_X_POSITION_TYPES iType =
|
isSignalValid =
|
||||||
ToPositionType(iSignal.type);
|
!hasSameTypeSignal
|
||||||
XPosition iSymbolsPositions[];
|
? true
|
||||||
int iSymbolsPositionsCount = mTrader.GetPositions(
|
: isLong
|
||||||
iSymbolsPositions,
|
? symbolPositions[symbolIDX].longsProfit > 0
|
||||||
iSignal.symbol,
|
: symbolPositions[symbolIDX].shortsProfit > 0;
|
||||||
NULL, // Provider
|
}
|
||||||
NULL, // Period
|
else
|
||||||
iType, // Type
|
{
|
||||||
true //
|
isSignalValid = true;
|
||||||
);
|
}
|
||||||
|
if (!isSignalValid)
|
||||||
//
|
{
|
||||||
int iSupportsCount = 0;
|
continue;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Multiply Signal Volume ...
|
// Multiply Signal Volume ...
|
||||||
// Create First Signal Opposit Protector ...
|
// Create First Signal Opposit Protector ...
|
||||||
if (isSignalValid)
|
bool canIncreaseVolume = IncreaseNextSignalsVolume();
|
||||||
|
double volumeMultiplier = IncreaseNextSignalsVolumeMultiplier();
|
||||||
|
if (canIncreaseVolume)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
XPosition iSymbolsPositions[];
|
double multiplier =
|
||||||
int iSymbolsPositionsCount = mTrader.GetPositions(
|
(isLong
|
||||||
iSymbolsPositions,
|
? symbolPositions[symbolIDX].CountLongs()
|
||||||
iSignal.symbol,
|
: symbolPositions[symbolIDX].CountShorts()) +
|
||||||
NULL, // Provider
|
1;
|
||||||
NULL, // Period
|
|
||||||
NULL, // Type
|
|
||||||
true //
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
int iSupportsCount = 0;
|
multiplier = NormalizeDouble(multiplier * volumeMultiplier, 2);
|
||||||
if (IsValidSize(iSymbolsPositionsCount))
|
iSignal.volume = iSignal.volume * multiplier;
|
||||||
{
|
|
||||||
//
|
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
//
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -4711,8 +4719,10 @@ public:
|
|||||||
eSignals //
|
eSignals //
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
result = ArraySize(eSignals);
|
result = ArraySize(eSignals);
|
||||||
|
|
||||||
@@ -4721,18 +4731,16 @@ public:
|
|||||||
if (IsValidSize(result))
|
if (IsValidSize(result))
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
Copy(
|
// Execute Signals ...
|
||||||
eSignals,
|
HandleSignals(eSignals);
|
||||||
signals //
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
Clean(eSignals);
|
|
||||||
|
|
||||||
//
|
|
||||||
HandleSignals(signals);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Here we maker result to 0
|
||||||
|
// for prevent XBaseEA Calss for Executing Signal ...
|
||||||
|
result = 0;
|
||||||
|
Clean(signals);
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -5028,7 +5036,7 @@ protected:
|
|||||||
XPosition youngest;
|
XPosition youngest;
|
||||||
int youngestAge = positions.GetYoungest(
|
int youngestAge = positions.GetYoungest(
|
||||||
youngest,
|
youngest,
|
||||||
iSignal.type //
|
signal.type //
|
||||||
);
|
);
|
||||||
result = !IsValidIndex(youngestAge);
|
result = !IsValidIndex(youngestAge);
|
||||||
if (result)
|
if (result)
|
||||||
|
|||||||
@@ -1135,7 +1135,10 @@ protected:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
result = profits >= requiredProfit;
|
result =
|
||||||
|
positionsCount <= 5
|
||||||
|
? profits >= requiredProfit
|
||||||
|
: profits >= requiredProfit * 0.6;
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -63,8 +63,8 @@ input group "Risk Management";
|
|||||||
input double x121EAVolume = 0.01; // Static Volume
|
input double x121EAVolume = 0.01; // Static Volume
|
||||||
input double x121EATPPoint = 1000; // TP Point
|
input double x121EATPPoint = 1000; // TP Point
|
||||||
input double x121EASLPoint = 1000; // SL Point
|
input double x121EASLPoint = 1000; // SL Point
|
||||||
input bool x121EAIgnoreSL = true; // Ignore Calculated SL
|
input bool x121EAIgnoreSL = false; // Ignore Calculated SL
|
||||||
input bool x121EAIgnoreTP = true; // Ignore Calculated TP
|
input bool x121EAIgnoreTP = false; // Ignore Calculated TP
|
||||||
input bool x121EACloseOnOpposit = false; // Close all Positions on Opposit
|
input bool x121EACloseOnOpposit = false; // Close all Positions on Opposit
|
||||||
input int x121EAMaxAllowedTrades = 0; // Max Allowed Positions Per Symbol
|
input int x121EAMaxAllowedTrades = 0; // Max Allowed Positions Per Symbol
|
||||||
input bool x121EAUseMaxAllowedPerDirection = true; // Use Max Allowed Positions Per Direction
|
input bool x121EAUseMaxAllowedPerDirection = true; // Use Max Allowed Positions Per Direction
|
||||||
|
|||||||
@@ -2781,21 +2781,31 @@ struct XSymbolPositions
|
|||||||
|
|
||||||
//
|
//
|
||||||
double profit;
|
double profit;
|
||||||
|
double volume;
|
||||||
|
|
||||||
|
//
|
||||||
double longsProfit;
|
double longsProfit;
|
||||||
|
double longSupportsProfit;
|
||||||
|
|
||||||
|
//
|
||||||
double shortsProfit;
|
double shortsProfit;
|
||||||
|
double shortSupportsProfit;
|
||||||
|
|
||||||
//
|
//
|
||||||
double volume;
|
|
||||||
double longsVolume;
|
double longsVolume;
|
||||||
|
double longSupportsVolume;
|
||||||
|
|
||||||
|
//
|
||||||
double shortsVolume;
|
double shortsVolume;
|
||||||
|
double shortSupportsVolume;
|
||||||
|
|
||||||
//
|
//
|
||||||
double requiredProfitForHedge;
|
double requiredProfitForHedge;
|
||||||
|
|
||||||
//
|
//
|
||||||
// TODO: Complete this ...
|
|
||||||
XPosition longs[];
|
XPosition longs[];
|
||||||
XPosition shorts[];
|
XPosition shorts[];
|
||||||
|
XPosition supports[];
|
||||||
XPosition positions[];
|
XPosition positions[];
|
||||||
XPosition longSupports[];
|
XPosition longSupports[];
|
||||||
XPosition shortSupports[];
|
XPosition shortSupports[];
|
||||||
@@ -2825,6 +2835,59 @@ struct XSymbolPositions
|
|||||||
return result;
|
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 ...
|
// Extract Types ...
|
||||||
ExtractPositions(
|
ExtractPositions(
|
||||||
@@ -2833,6 +2896,21 @@ struct XSymbolPositions
|
|||||||
shorts //
|
shorts //
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
Copy(
|
||||||
|
_supports,
|
||||||
|
supports //
|
||||||
|
);
|
||||||
|
Clean(_supports);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Extract Types ...
|
||||||
|
ExtractPositions(
|
||||||
|
supports,
|
||||||
|
longSupports,
|
||||||
|
shortSupports //
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
int numOfLongs = 0;
|
int numOfLongs = 0;
|
||||||
int numOfShorts = 0;
|
int numOfShorts = 0;
|
||||||
@@ -2847,14 +2925,46 @@ struct XSymbolPositions
|
|||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
profit = longsProfit + shortsProfit;
|
numOfLongs = 0;
|
||||||
volume = longsVolume + shortsVolume;
|
numOfShorts = 0;
|
||||||
requiredProfitForHedge = SpecifiedCalculateRequiredProfitForHedge(
|
CountPositions(
|
||||||
|
supports,
|
||||||
|
numOfLongs,
|
||||||
|
longSupportsProfit,
|
||||||
|
longSupportsVolume,
|
||||||
|
numOfShorts,
|
||||||
|
shortSupportsProfit,
|
||||||
|
shortSupportsVolume //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
XPosition _allPositions[];
|
||||||
|
Copy(
|
||||||
positions,
|
positions,
|
||||||
|
_allPositions,
|
||||||
|
false //
|
||||||
|
);
|
||||||
|
Copy(
|
||||||
|
supports,
|
||||||
|
_allPositions,
|
||||||
|
false //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
profit = longsProfit + shortsProfit + longSupportsProfit + shortSupportsProfit;
|
||||||
|
volume = longsVolume + shortsVolume + longSupportsVolume + shortSupportsVolume;
|
||||||
|
requiredProfitForHedge = SpecifiedCalculateRequiredProfitForHedge(
|
||||||
|
_allPositions,
|
||||||
mMinProfitPerTrade,
|
mMinProfitPerTrade,
|
||||||
mMinProfitPerVolumeFactor //
|
mMinProfitPerVolumeFactor //
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
Clean(_allPositions);
|
||||||
|
|
||||||
|
//
|
||||||
|
result = true;
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -2932,6 +3042,12 @@ struct XSymbolPositions
|
|||||||
return ArraySize(positions);
|
return ArraySize(positions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int CountSupports()
|
||||||
|
{
|
||||||
|
return ArraySize(supports);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
int CountLongs()
|
int CountLongs()
|
||||||
{
|
{
|
||||||
@@ -2945,83 +3061,15 @@ struct XSymbolPositions
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
bool HasSupport()
|
int CountLongSupports()
|
||||||
{
|
{
|
||||||
//
|
return ArraySize(longSupports);
|
||||||
bool result = false;
|
|
||||||
|
|
||||||
//
|
|
||||||
result = HasChild();
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
result = HasLongSupport() || HasShortSupport();
|
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
bool HasLongSupport()
|
int CountShortSupports()
|
||||||
{
|
{
|
||||||
//
|
return ArraySize(shortSupports);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -3114,7 +3162,7 @@ struct XSymbolPositions
|
|||||||
|
|
||||||
//
|
//
|
||||||
int GetMaxInProfit(
|
int GetMaxInProfit(
|
||||||
XPosition _position,
|
XPosition &_position,
|
||||||
ENUM_POSITION_TYPE _type //
|
ENUM_POSITION_TYPE _type //
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -3168,7 +3216,7 @@ struct XSymbolPositions
|
|||||||
|
|
||||||
//
|
//
|
||||||
int GetMinInProfit(
|
int GetMinInProfit(
|
||||||
XPosition _position,
|
XPosition &_position,
|
||||||
ENUM_POSITION_TYPE _type //
|
ENUM_POSITION_TYPE _type //
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -3222,7 +3270,7 @@ struct XSymbolPositions
|
|||||||
|
|
||||||
//
|
//
|
||||||
int GetMaxInDrawdown(
|
int GetMaxInDrawdown(
|
||||||
XPosition _position,
|
XPosition &_position,
|
||||||
ENUM_POSITION_TYPE _type //
|
ENUM_POSITION_TYPE _type //
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -3276,7 +3324,7 @@ struct XSymbolPositions
|
|||||||
|
|
||||||
//
|
//
|
||||||
int GetMinInDrawdown(
|
int GetMinInDrawdown(
|
||||||
XPosition _position,
|
XPosition &_position,
|
||||||
ENUM_POSITION_TYPE _type //
|
ENUM_POSITION_TYPE _type //
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user