last ...
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user