last ...
This commit is contained in:
@@ -2810,13 +2810,13 @@ struct X121SignalGenerator
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Generate Support Signals ...
|
// Generate Support Signals ...
|
||||||
if (_useSupport)
|
// if (_useSupport)
|
||||||
{
|
// {
|
||||||
//
|
// //
|
||||||
GenerateSupportSignals(
|
// GenerateSupportSignals(
|
||||||
signal //
|
// signal //
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
@@ -2827,11 +2827,52 @@ struct X121SignalGenerator
|
|||||||
XSignal &signal // Source Signal for Support Generating ...
|
XSignal &signal // Source Signal for Support Generating ...
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
double pivots[];
|
||||||
|
int pivotsCount = GenerateSupportPivots(
|
||||||
|
signal,
|
||||||
|
pivots //
|
||||||
|
);
|
||||||
|
if (!IsValidSize(pivotsCount))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XSignal supports[];
|
||||||
|
int indirectionalsCount =
|
||||||
|
PrepareInDirectionalSupportSignals(
|
||||||
|
supports,
|
||||||
|
signal,
|
||||||
|
pivots //
|
||||||
|
);
|
||||||
|
if (IsValidSize(indirectionalsCount))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Copy(
|
||||||
|
supports,
|
||||||
|
signal.supports //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
Clean(supports);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int GenerateSupportPivots(
|
||||||
|
XSignal &signal, // Source Signal for Support Generating ...
|
||||||
|
double &pivots[] //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Validate Signal ...
|
// Validate Signal ...
|
||||||
if (!signal.IsValid())
|
if (!signal.IsValid())
|
||||||
{
|
{
|
||||||
return;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -2875,6 +2916,7 @@ struct X121SignalGenerator
|
|||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
|
Clean(pivots);
|
||||||
double tmpPivots[];
|
double tmpPivots[];
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -2999,27 +3041,44 @@ struct X121SignalGenerator
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
XSignal supports[];
|
int tmpPivotsCount = ArraySize(tmpPivots);
|
||||||
int indirectionalsCount =
|
if (!IsValidSize(tmpPivotsCount))
|
||||||
PrepareInDirectionalSupportSignals(
|
|
||||||
supports,
|
|
||||||
signal,
|
|
||||||
tmpPivots //
|
|
||||||
);
|
|
||||||
if (IsValidSize(indirectionalsCount))
|
|
||||||
{
|
{
|
||||||
//
|
return result;
|
||||||
Copy(
|
|
||||||
supports,
|
|
||||||
signal.supports //
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
Clean(supports);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
for (int i = 0; i < tmpPivotsCount; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double iPivot = tmpPivots[i];
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isValidPivot =
|
||||||
|
isLong
|
||||||
|
? signal.entry > iPivot
|
||||||
|
: signal.entry < iPivot;
|
||||||
|
if (isValidPivot)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
iPivot,
|
||||||
|
pivots //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
ArrayFree(tmpPivots);
|
||||||
|
|
||||||
//
|
//
|
||||||
RemoveDraws(entryLineName);
|
RemoveDraws(entryLineName);
|
||||||
|
|
||||||
|
//
|
||||||
|
result = ArraySize(pivots);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -3043,11 +3102,12 @@ struct X121SignalGenerator
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
bool isDirectional = support.provider == XEQMSupportToken + XDirectionalToken;
|
mResult = support.provider == XEQMSupportToken + XINDirectionalToken;
|
||||||
|
if (!mResult)
|
||||||
//
|
|
||||||
if (!isDirectional)
|
|
||||||
{
|
{
|
||||||
|
return mResult;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Indirectional Supports Updated Using Directional ...
|
// Indirectional Supports Updated Using Directional ...
|
||||||
|
|
||||||
@@ -3067,27 +3127,23 @@ struct X121SignalGenerator
|
|||||||
{
|
{
|
||||||
rMode = X_ORDER_MODE_STOP;
|
rMode = X_ORDER_MODE_STOP;
|
||||||
}
|
}
|
||||||
else if (entryPrice > parent.entry)
|
|
||||||
{
|
|
||||||
rMode = X_ORDER_MODE_LIMIT;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
if (entryPrice < parent.entry)
|
if (entryPrice > parent.entry)
|
||||||
{
|
|
||||||
rMode = X_ORDER_MODE_LIMIT;
|
|
||||||
}
|
|
||||||
else if (entryPrice > parent.entry)
|
|
||||||
{
|
{
|
||||||
rMode = X_ORDER_MODE_STOP;
|
rMode = X_ORDER_MODE_STOP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
if (rMode != X_ORDER_MODE_NOTHING)
|
mResult = rMode != X_ORDER_MODE_NOTHING;
|
||||||
|
if (!mResult)
|
||||||
{
|
{
|
||||||
|
return mResult;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
mResult = result.Prepare(
|
mResult = result.Prepare(
|
||||||
parent.symbol,
|
parent.symbol,
|
||||||
@@ -3100,7 +3156,6 @@ struct X121SignalGenerator
|
|||||||
0,
|
0,
|
||||||
0 //
|
0 //
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
if (mResult)
|
if (mResult)
|
||||||
@@ -3109,11 +3164,9 @@ struct X121SignalGenerator
|
|||||||
string comment = GenerateSupportTag(parent.ticket);
|
string comment = GenerateSupportTag(parent.ticket);
|
||||||
result.comment = comment;
|
result.comment = comment;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//
|
result.Clean();
|
||||||
// TODO: Implement ...
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -3232,60 +3285,6 @@ struct X121SignalGenerator
|
|||||||
rTP = 0;
|
rTP = 0;
|
||||||
rEntry = 0;
|
rEntry = 0;
|
||||||
isSignalPrepared = false;
|
isSignalPrepared = false;
|
||||||
|
|
||||||
//
|
|
||||||
// Here we Create Related Directional Order ...
|
|
||||||
|
|
||||||
//
|
|
||||||
// Directional ...
|
|
||||||
if (isLong)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
rType = POSITION_TYPE_BUY;
|
|
||||||
rMode = X_ORDER_MODE_LIMIT;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//
|
|
||||||
rType = POSITION_TYPE_SELL;
|
|
||||||
rMode = X_ORDER_MODE_LIMIT;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
rEntry = source.entry;
|
|
||||||
rVolume = source.volume;
|
|
||||||
|
|
||||||
//
|
|
||||||
isSignalPrepared = rSignal.Prepare(
|
|
||||||
source.symbol,
|
|
||||||
XEQMSupportToken + XDirectionalToken,
|
|
||||||
source.period,
|
|
||||||
rType,
|
|
||||||
rMode,
|
|
||||||
rEntry,
|
|
||||||
rVolume,
|
|
||||||
rSL,
|
|
||||||
rTP //
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
if (isSignalPrepared)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
AddRef(
|
|
||||||
rSignal,
|
|
||||||
supports //
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
rSignal.Clean();
|
|
||||||
|
|
||||||
//
|
|
||||||
rSL = 0;
|
|
||||||
rTP = 0;
|
|
||||||
rEntry = 0;
|
|
||||||
isSignalPrepared = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -116,6 +116,7 @@ struct XTradeInfo
|
|||||||
|
|
||||||
//
|
//
|
||||||
ResetGrid();
|
ResetGrid();
|
||||||
|
ResetSupport();
|
||||||
ResetRecovery();
|
ResetRecovery();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,6 +182,15 @@ struct XTradeInfo
|
|||||||
bullishScore = _bullishScore;
|
bullishScore = _bullishScore;
|
||||||
bearishScore = _bearishScore;
|
bearishScore = _bearishScore;
|
||||||
|
|
||||||
|
//
|
||||||
|
X121SignalGenerator generator;
|
||||||
|
XSignal tSignal = _signal;
|
||||||
|
generator.GenerateSupportPivots(
|
||||||
|
tSignal,
|
||||||
|
pivots //
|
||||||
|
);
|
||||||
|
tSignal.Clean();
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -427,6 +437,183 @@ struct XTradeInfo
|
|||||||
// These are Some Helpers for Trading Controls and do not relate to Main
|
// These are Some Helpers for Trading Controls and do not relate to Main
|
||||||
// purpose of Trade Handler ...
|
// purpose of Trade Handler ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Supporting ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double pivots[];
|
||||||
|
|
||||||
|
//
|
||||||
|
void ResetSupport()
|
||||||
|
{
|
||||||
|
Clean(pivots);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Retrieve Support Signal ...
|
||||||
|
bool HasSupport(
|
||||||
|
XSignal &support //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = IsValid();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int pivotsCount = ArraySize(pivots);
|
||||||
|
result = IsValidSize(pivotsCount);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
support.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
ENUM_POSITION_TYPE sType =
|
||||||
|
type == X_POSITION_TYPE_LONG
|
||||||
|
? POSITION_TYPE_BUY
|
||||||
|
: POSITION_TYPE_SELL;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isLong = IsLong(type);
|
||||||
|
|
||||||
|
//
|
||||||
|
ENUM_POSITION_TYPE cType = GetOpposit(sType);
|
||||||
|
double cEntry = GetEntry(
|
||||||
|
symbol,
|
||||||
|
cType //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
double pivot = 0;
|
||||||
|
int pivotIndex = -1;
|
||||||
|
for (int i = 0; i < pivotsCount; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double iPivot = pivots[i];
|
||||||
|
if (iPivot <= 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
isLong
|
||||||
|
? cEntry < entry && cEntry <= iPivot
|
||||||
|
: cEntry > entry && cEntry >= iPivot;
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
pivot = iPivot;
|
||||||
|
pivotIndex = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result = support.Prepare(
|
||||||
|
symbol,
|
||||||
|
XEQMSupportToken + XINDirectionalToken,
|
||||||
|
period,
|
||||||
|
cType,
|
||||||
|
X_ORDER_MODE_MARKET,
|
||||||
|
cEntry,
|
||||||
|
volume * 2,
|
||||||
|
0,
|
||||||
|
0 //
|
||||||
|
);
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
string comment = GenerateSupportTag(ticket);
|
||||||
|
support.comment = comment;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare Directional Support ...
|
||||||
|
XSignal mSup;
|
||||||
|
result = mSup.Prepare(
|
||||||
|
symbol,
|
||||||
|
XEQMSupportToken + XDirectionalToken,
|
||||||
|
period,
|
||||||
|
sType,
|
||||||
|
X_ORDER_MODE_STOP,
|
||||||
|
entry,
|
||||||
|
volume,
|
||||||
|
0,
|
||||||
|
0 //
|
||||||
|
);
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
string comment = GenerateSupportTag(ticket);
|
||||||
|
mSup.comment = comment;
|
||||||
|
|
||||||
|
//
|
||||||
|
AddRef(
|
||||||
|
mSup,
|
||||||
|
support.supports //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
result = ArrayRemove(
|
||||||
|
pivots,
|
||||||
|
pivotIndex,
|
||||||
|
1 //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
support.Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool RemovePivot(
|
||||||
|
double pivot,
|
||||||
|
int index //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = IsValid() &&
|
||||||
|
IsValidIndex(index) &&
|
||||||
|
ArraySize(pivots) > index;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = ArrayRemove(
|
||||||
|
pivots,
|
||||||
|
index,
|
||||||
|
1 //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Grid System Calculations ...
|
// Grid System Calculations ...
|
||||||
|
|
||||||
@@ -1860,8 +2047,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Supporting ...
|
if (AllowSupport())
|
||||||
if (EnableSupport())
|
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
XSignal supports[];
|
XSignal supports[];
|
||||||
@@ -2148,10 +2334,6 @@ protected:
|
|||||||
//
|
//
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
|
||||||
//
|
|
||||||
// TODO: Complete this Later ...
|
|
||||||
return result;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
Clean(signals);
|
Clean(signals);
|
||||||
|
|
||||||
@@ -2165,104 +2347,137 @@ protected:
|
|||||||
Sync();
|
Sync();
|
||||||
|
|
||||||
//
|
//
|
||||||
// Validate Setups Count ...
|
int count = Count();
|
||||||
int setupsCount = ArraySize(setups);
|
if (!IsValidSize(count))
|
||||||
if (!IsValidSize(setupsCount))
|
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Implement Supporting Mechanism ...
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
//
|
//
|
||||||
// Extracting In Drawdown Positions ...
|
XSignal iSupport;
|
||||||
XPosition positions[];
|
double iPivot = -1;
|
||||||
int positionsCount = mTrader.GetInDrawdownPositions(
|
int iPivotIDX = -1;
|
||||||
positions //
|
bool hasSupport = data[i].HasSupport(
|
||||||
|
iSupport //
|
||||||
);
|
);
|
||||||
if (!IsValidSize(positionsCount))
|
if (hasSupport)
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
double supportDistance = SupportDistance();
|
|
||||||
int maxNUmberOfSupports = MaxNumberOfSupports();
|
|
||||||
double maxAllowedVolume = MaxAllowedSupportVolume();
|
|
||||||
double volumeMultiplier = SupportVolumeMultiplier();
|
|
||||||
|
|
||||||
//
|
|
||||||
X121SignalGenerator signalGenerator;
|
|
||||||
|
|
||||||
//
|
|
||||||
for (int i = 0; i < positionsCount; i++)
|
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
XPosition iPosition = positions[i];
|
AddRef(
|
||||||
|
iSupport,
|
||||||
//
|
signals //
|
||||||
// Check Position is not Support Position ...
|
|
||||||
bool isSupport = IsSupport(iPosition.comment);
|
|
||||||
if (isSupport)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Find Related Setp ...
|
|
||||||
int idx = FindSetupIndex(
|
|
||||||
iPosition.symbol,
|
|
||||||
setups //
|
|
||||||
);
|
);
|
||||||
if (!IsValidIndex(idx))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
int index = FindIndex(iPosition.ticket);
|
|
||||||
if (!IsValidIndex(index))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Check Position must atleast 20 Point in drawdown ...
|
|
||||||
|
|
||||||
//
|
|
||||||
double onePointPrice = PointToPrice(
|
|
||||||
1,
|
|
||||||
iPosition.symbol //
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
double iExitPrice = GetExit(
|
|
||||||
iPosition.symbol,
|
|
||||||
iPosition.type //
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
double priceDiff = MathAbs(iPosition.entry - iExitPrice);
|
|
||||||
double priceDiffPoints = priceDiff / onePointPrice;
|
|
||||||
|
|
||||||
//
|
|
||||||
bool isFarEnough = priceDiffPoints >= (supportDistance / 2);
|
|
||||||
if (!isFarEnough)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Check Support COunts and etc ...
|
|
||||||
// implementing supporting mechanis ...
|
|
||||||
|
|
||||||
//
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
result = ArraySize(signals);
|
result = ArraySize(signals);
|
||||||
|
|
||||||
|
//
|
||||||
|
// TODO: Complete this Later ...
|
||||||
|
return result;
|
||||||
|
//
|
||||||
|
// Validate Setups Count ...
|
||||||
|
// int setupsCount = ArraySize(setups);
|
||||||
|
// if (!IsValidSize(setupsCount))
|
||||||
|
// {
|
||||||
|
// return result;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Implement Supporting Mechanism ...
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Extracting In Drawdown Positions ...
|
||||||
|
// XPosition positions[];
|
||||||
|
// int positionsCount = mTrader.GetInDrawdownPositions(
|
||||||
|
// positions //
|
||||||
|
// );
|
||||||
|
// if (!IsValidSize(positionsCount))
|
||||||
|
// {
|
||||||
|
// return result;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// double supportDistance = SupportDistance();
|
||||||
|
// int maxNUmberOfSupports = MaxNumberOfSupports();
|
||||||
|
// double maxAllowedVolume = MaxAllowedSupportVolume();
|
||||||
|
// double volumeMultiplier = SupportVolumeMultiplier();
|
||||||
|
|
||||||
|
// //
|
||||||
|
// X121SignalGenerator signalGenerator;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// for (int i = 0; i < positionsCount; i++)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// XPosition iPosition = positions[i];
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Check Position is not Support Position ...
|
||||||
|
// bool isSupport = IsSupport(iPosition.comment);
|
||||||
|
// if (isSupport)
|
||||||
|
// {
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Find Related Setp ...
|
||||||
|
// int idx = FindSetupIndex(
|
||||||
|
// iPosition.symbol,
|
||||||
|
// setups //
|
||||||
|
// );
|
||||||
|
// if (!IsValidIndex(idx))
|
||||||
|
// {
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// int index = FindIndex(iPosition.ticket);
|
||||||
|
// if (!IsValidIndex(index))
|
||||||
|
// {
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Check Position must atleast 20 Point in drawdown ...
|
||||||
|
|
||||||
|
// //
|
||||||
|
// double onePointPrice = PointToPrice(
|
||||||
|
// 1,
|
||||||
|
// iPosition.symbol //
|
||||||
|
// );
|
||||||
|
|
||||||
|
// //
|
||||||
|
// double iExitPrice = GetExit(
|
||||||
|
// iPosition.symbol,
|
||||||
|
// iPosition.type //
|
||||||
|
// );
|
||||||
|
|
||||||
|
// //
|
||||||
|
// double priceDiff = MathAbs(iPosition.entry - iExitPrice);
|
||||||
|
// double priceDiffPoints = priceDiff / onePointPrice;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// bool isFarEnough = priceDiffPoints >= (supportDistance / 2);
|
||||||
|
// if (!isFarEnough)
|
||||||
|
// {
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Check Support COunts and etc ...
|
||||||
|
// // implementing supporting mechanis ...
|
||||||
|
|
||||||
|
// //
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// result = ArraySize(signals);
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -4029,10 +4244,10 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Handle Support of Supports here ...
|
// Orders Changed ...
|
||||||
void OnPositionsChangedHandler(int count) override
|
void OnOrdersChangedHandler(int count) override
|
||||||
{
|
{
|
||||||
// EQMHandleSupportProtection(count);
|
EQMHandleSupportProtection(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -4756,98 +4971,103 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
void EQMHandleSupportProtection(int positionsCount)
|
void EQMHandleSupportProtection(int count)
|
||||||
{
|
{
|
||||||
//
|
// //
|
||||||
if (!IsValidSize(positionsCount))
|
// if (IsValidSize(count))
|
||||||
{
|
// {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
//
|
// //
|
||||||
ulong ticket = mTrader.GetLastOpenPositionTicket();
|
// // This means on order Executed ...
|
||||||
XPosition position;
|
// ulong ticket = mTrader.GetLastOpenPositionTicket();
|
||||||
bool hasPosition = mTrader.GetPosition(
|
|
||||||
ticket,
|
|
||||||
position //
|
|
||||||
);
|
|
||||||
if (!hasPosition)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
// //
|
||||||
bool isSupport = IsSupport(position.comment);
|
// XPosition position;
|
||||||
if (!isSupport)
|
// bool hasPosition = mTrader.GetPosition(
|
||||||
{
|
// ticket,
|
||||||
return;
|
// position //
|
||||||
}
|
// );
|
||||||
|
// if (!hasPosition)
|
||||||
|
// {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
//
|
// //
|
||||||
bool isINDIRSupport = position.provider == XEQMSupportToken + XINDirectionalToken;
|
// bool isSupport = IsSupport(position.comment);
|
||||||
if (!isINDIRSupport)
|
// if (!isSupport)
|
||||||
{
|
// {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
//
|
// //
|
||||||
ulong parentTicket = ExtractParentTicket(position.comment);
|
// bool isInDirectional = position.provider == XEQMSupportToken + XINDirectionalToken;
|
||||||
XPosition parent;
|
// if (!isInDirectional)
|
||||||
bool hasParent = mTrader.GetPosition(
|
// {
|
||||||
parentTicket,
|
// return;
|
||||||
parent //
|
// }
|
||||||
);
|
|
||||||
if (!hasParent)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
// //
|
||||||
// Remove Parent TP SL ...
|
// XPosition parent;
|
||||||
if (parent.tp > 0 || parent.sl > 0)
|
// ulong parentTicket = ExtractParentTicket(position.comment);
|
||||||
{
|
// bool hasParent = mTrader.GetPosition(
|
||||||
//
|
// parentTicket,
|
||||||
string comment = XEQMSupportToken + "Remoove TPSL due Protect ...";
|
// parent //
|
||||||
bool isModeified = mTrader.Modify(
|
// );
|
||||||
parentTicket,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
comment //
|
|
||||||
);
|
|
||||||
if (isModeified)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
string message = XEQMSupportToken + " Removes Position (" + ToString(parentTicket) + ")' TP/SL Due Start Supporting ...";
|
|
||||||
|
|
||||||
//
|
// //
|
||||||
Alert(message);
|
// if (!hasParent)
|
||||||
}
|
// {
|
||||||
}
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
//
|
// //
|
||||||
XSignal signal;
|
// // Remove Parent TP SL ...
|
||||||
X121SignalGenerator signalGenerator;
|
// if (parent.tp > 0 || parent.sl > 0)
|
||||||
bool hasSupport = signalGenerator.PrepareDirectionalSupportSignals(
|
// {
|
||||||
position,
|
// //
|
||||||
parent,
|
// string comment = XEQMSupportToken + " Remoove TP/SL due Protect ...";
|
||||||
signal //
|
// bool isModeified = mTrader.Modify(
|
||||||
);
|
// parentTicket,
|
||||||
if (!hasSupport)
|
// 0,
|
||||||
{
|
// 0,
|
||||||
return;
|
// comment //
|
||||||
}
|
// );
|
||||||
|
// if (isModeified)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// string message = XEQMSupportToken + " Removes Position (" + ToString(parentTicket) + ")' TP/SL Due Start Supporting ...";
|
||||||
|
|
||||||
//
|
// //
|
||||||
XSignal signals[];
|
// Alert(message);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
//
|
// //
|
||||||
AddRef(
|
// XSignal signal;
|
||||||
signal,
|
// X121SignalGenerator signalGenerator;
|
||||||
signals //
|
// bool hasSupport = signalGenerator.PrepareDirectionalSupportSignals(
|
||||||
);
|
// position,
|
||||||
|
// parent,
|
||||||
|
// signal //
|
||||||
|
// );
|
||||||
|
// if (!hasSupport)
|
||||||
|
// {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
//
|
// //
|
||||||
EQMExecuteSignals(signals);
|
// XSignal signals[];
|
||||||
|
|
||||||
|
// //
|
||||||
|
// AddRef(
|
||||||
|
// signal,
|
||||||
|
// signals //
|
||||||
|
// );
|
||||||
|
|
||||||
|
// //
|
||||||
|
// EQMExecuteSignals(signals);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -1091,7 +1091,7 @@ protected:
|
|||||||
//
|
//
|
||||||
XPosition positions[];
|
XPosition positions[];
|
||||||
int positionsCount = mTrader.GetPositions(positions);
|
int positionsCount = mTrader.GetPositions(positions);
|
||||||
result = IsValidSize(positions);
|
result = positionsCount > 1;
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ bool IsLong(ENUM_X_POSITION_TYPES value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
bool ToPositinType(
|
bool ToPositionType(
|
||||||
ENUM_POSITION_TYPE &dest,
|
ENUM_POSITION_TYPE &dest,
|
||||||
ENUM_X_POSITION_TYPES source //
|
ENUM_X_POSITION_TYPES source //
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user