complete signaller trigger cond 1 and 2 and apply sorting for Tagets and etc ...

This commit is contained in:
2025-05-14 04:15:20 +03:30
parent ca28c56256
commit 4ed75abc2b
8 changed files with 670 additions and 86 deletions
+171
View File
@@ -531,6 +531,145 @@ struct XTarget
}
};
//
// Get Lowest Target index ...
int GetLowest(XTarget &targets[])
{
//
int result = -1;
//
if (!HasChild(targets))
{
return result;
}
//
XTarget iTarget;
int count = ArraySize(targets);
for (int i = 0; i < count; i++)
{
//
bool canSet =
!iTarget.IsValid()
? true
: iTarget.target > targets[i].target;
if (canSet)
{
//
result = i;
iTarget = targets[i];
}
}
//
iTarget.Clean();
//
return result;
}
//
// Get Highest Target index ...
int GetHighest(XTarget &targets[])
{
//
int result = -1;
//
if (!HasChild(targets))
{
return result;
}
//
XTarget iTarget;
int count = ArraySize(targets);
for (int i = 0; i < count; i++)
{
//
bool canSet =
!iTarget.IsValid()
? true
: iTarget.target < targets[i].target;
if (canSet)
{
//
result = i;
iTarget = targets[i];
}
}
//
iTarget.Clean();
//
return result;
}
//
// Apply Sorting on Targets ...
void ApplySortOnTargets(
ENUM_X_DIRECTION forDir, // Target Sorting Direction ...
XTarget &targets[] // Targets to Apply Sorting ...
)
{
//
bool has = HasChild(targets) &&
HasDirection(forDir);
if (!has)
{
return;
}
//
bool isBullish = IsBullish(forDir);
bool isBearish = IsBearish(forDir);
//
XTarget tmp[];
Copy(
targets,
tmp //
);
Clean(targets);
while (HasChild(tmp))
{
//
int idx = -1;
if (isBullish)
{
idx = GetLowest(tmp);
}
else if (isBearish)
{
idx = GetHighest(tmp);
}
//
has = IsValidIndex(idx);
if (!has)
{
break;
}
//
XTarget iTarget = tmp[idx];
ArrayRemove(
tmp,
idx,
1 //
);
AddRef(
iTarget,
targets //
);
}
//
Clean(tmp);
}
//
// Model an Open Position ...
struct XPosition
@@ -5740,4 +5879,36 @@ int ExtractSymbolPositions(
return result;
}
//
// Apply a Collection of Targets
// on Specified Signal ...
void ApplyTargetsOnSignal(
ENUM_X_DIRECTION sortingDir, // Target Sorting Direction ...
XTarget &targets[], // Required Targets ...
XSignal &signal // Destination Signal ...
)
{
//
bool has =
HasChild(targets) &&
HasDirection(sortingDir);
if (!has)
{
return;
}
//
// Sort Targets ...
ApplySortOnTargets(
sortingDir,
targets //
);
//
Copy(
targets,
signal.targets //
);
}
//