This commit is contained in:
2024-06-21 09:18:04 +03:30
parent a5cb716d0b
commit e54a991b6d
4 changed files with 554 additions and 335 deletions
+138 -139
View File
@@ -2810,13 +2810,13 @@ struct X121SignalGenerator
//
// Generate Support Signals ...
if (_useSupport)
{
//
GenerateSupportSignals(
signal //
);
}
// if (_useSupport)
// {
// //
// GenerateSupportSignals(
// signal //
// );
// }
//
return result;
@@ -2827,11 +2827,52 @@ struct X121SignalGenerator
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 ...
if (!signal.IsValid())
{
return;
return result;
}
//
@@ -2875,6 +2916,7 @@ struct X121SignalGenerator
);
//
Clean(pivots);
double tmpPivots[];
//
@@ -2999,27 +3041,44 @@ struct X121SignalGenerator
}
//
XSignal supports[];
int indirectionalsCount =
PrepareInDirectionalSupportSignals(
supports,
signal,
tmpPivots //
);
if (IsValidSize(indirectionalsCount))
int tmpPivotsCount = ArraySize(tmpPivots);
if (!IsValidSize(tmpPivotsCount))
{
//
Copy(
supports,
signal.supports //
);
//
Clean(supports);
return result;
}
//
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);
//
result = ArraySize(pivots);
//
return result;
}
//
@@ -3043,77 +3102,71 @@ struct X121SignalGenerator
}
//
bool isDirectional = support.provider == XEQMSupportToken + XDirectionalToken;
mResult = support.provider == XEQMSupportToken + XINDirectionalToken;
if (!mResult)
{
return mResult;
}
//
if (!isDirectional)
// Indirectional Supports Updated Using Directional ...
//
double entryPrice = GetEntry(
parent.symbol,
parent.type //
);
//
ENUM_X_ORDER_MODES rMode = X_ORDER_MODE_NOTHING;
bool isParentLong = IsLong(parent.type);
if (isParentLong)
{
//
// Indirectional Supports Updated Using Directional ...
//
double entryPrice = GetEntry(
parent.symbol,
parent.type //
);
//
ENUM_X_ORDER_MODES rMode = X_ORDER_MODE_NOTHING;
bool isParentLong = IsLong(parent.type);
if (isParentLong)
if (entryPrice < parent.entry)
{
//
if (entryPrice < parent.entry)
{
rMode = X_ORDER_MODE_STOP;
}
else if (entryPrice > parent.entry)
{
rMode = X_ORDER_MODE_LIMIT;
}
}
else
{
//
if (entryPrice < parent.entry)
{
rMode = X_ORDER_MODE_LIMIT;
}
else if (entryPrice > parent.entry)
{
rMode = X_ORDER_MODE_STOP;
}
}
//
if (rMode != X_ORDER_MODE_NOTHING)
{
//
mResult = result.Prepare(
parent.symbol,
XEQMSupportToken + XDirectionalToken,
parent.period,
parent.type,
rMode,
parent.entry,
parent.volume,
0,
0 //
);
}
//
if (mResult)
{
//
string comment = GenerateSupportTag(parent.ticket);
result.comment = comment;
rMode = X_ORDER_MODE_STOP;
}
}
else
{
//
// TODO: Implement ...
if (entryPrice > parent.entry)
{
rMode = X_ORDER_MODE_STOP;
}
}
//
mResult = rMode != X_ORDER_MODE_NOTHING;
if (!mResult)
{
return mResult;
}
//
mResult = result.Prepare(
parent.symbol,
XEQMSupportToken + XDirectionalToken,
parent.period,
parent.type,
rMode,
parent.entry,
parent.volume,
0,
0 //
);
//
if (mResult)
{
//
string comment = GenerateSupportTag(parent.ticket);
result.comment = comment;
}
else
{
result.Clean();
}
//
@@ -3232,60 +3285,6 @@ struct X121SignalGenerator
rTP = 0;
rEntry = 0;
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;
}
}
}