This commit is contained in:
2025-02-24 19:15:41 +03:30
parent cee35a424b
commit 3ed72f0271
4 changed files with 634 additions and 212 deletions
+283 -92
View File
@@ -1273,42 +1273,6 @@ bool IsBoxUsed(
return result;
}
/**
* Converts a Consolidation Zone ...
*
* @param zone: XConsolidationZone instance Reference ...
* @param dest: XCZone pointer Reference ...
*
* @return ( bool )
*/
bool ToZone(
XConsolidationZone &zone,
XCZone *&dest //
)
{
//
bool result = false;
//
dest = NULL;
//
result = zone.IsValid();
if (!result)
{
return result;
}
//
dest = new XCZone();
dest.Upper(zone.upper);
dest.Lower(zone.lower);
result = dest.IsValidBoundary();
//
return result;
}
/**
* Converts to XBoxZone ...
*
@@ -1586,7 +1550,7 @@ bool ToBox(
box.upper = item.upper;
box.lower = item.lower;
box.dir = item.breakDir;
box.from = item.initTime;
box.from = item.From();
box.symbol = item.symbol;
box.period = item.period;
box.to = item.breakerBar.time;
@@ -1600,18 +1564,20 @@ bool ToBox(
}
/**
* Get Oldest Zone ...
* Converts to XBoxZone ...
*
* @return ( int )
* @return ( bool )
*/
int GetOldest(
XCZone *&source[] //
int ToBox(
XConsolidationZone &source[],
XBoxZone &dest[] //
)
{
//
int result = -1;
int result = 0;
//
Clean(dest);
int count = ArraySize(source);
if (!IsValidSize(count))
{
@@ -1619,68 +1585,36 @@ int GetOldest(
}
//
XCZone *oldest = NULL;
for (int i = 0; i < count; i++)
{
//
XCZone *iZone = source[i];
XConsolidationZone iZone = source[i];
//
bool canSet =
oldest == NULL ||
(oldest != NULL &&
oldest.From() > iZone.From());
if (canSet)
XBoxZone iBox;
bool hasBox = ToBox(
iBox,
iZone //
);
//
if (hasBox)
{
//
result = i;
oldest = iZone;
AddRef(
iBox,
dest //
);
}
}
//
return result;
}
/**
* Get Youngest Zone ...
*
* @return ( int )
*/
int GetYoungest(
XCZone *&source[] //
)
{
//
int result = -1;
//
int count = ArraySize(source);
if (!IsValidSize(count))
{
return result;
}
//
XCZone *youngest = NULL;
for (int i = 0; i < count; i++)
{
//
XCZone *iZone = source[i];
//
bool canSet =
youngest == NULL ||
(youngest != NULL &&
youngest.From() < iZone.From());
if (canSet)
{
//
result = i;
youngest = iZone;
}
iBox.Clean();
iZone.Clean();
}
//
result = ArraySize(dest);
//
return result;
}
@@ -1726,6 +1660,9 @@ int GetOldest(
}
}
//
selected.Clean();
//
return result;
}
@@ -1771,6 +1708,9 @@ int GetYoungest(
}
}
//
selected.Clean();
//
return result;
}
@@ -1816,6 +1756,9 @@ int GetHighest(
}
}
//
selected.Clean();
//
return result;
}
@@ -1868,6 +1811,254 @@ int GetLowest(
return result;
}
/**
* Get Oldest Box Index ...
*
* @param source: XBoxZone instance Reference Collection ...
*
* @return ( int )
*/
int GetOldest(
XConsolidationZone &source[] //
)
{
//
int result = -1;
//
int count = ArraySize(source);
if (!IsValidSize(count))
{
return result;
}
//
XBoxZone tmpBoxes[];
int boxesCount = ToBox(
source,
tmpBoxes //
);
if (!IsValidSize(boxesCount))
{
//
Clean(tmpBoxes);
return result;
}
//
XBoxZone selected;
for (int i = 0; i < boxesCount; i++)
{
//
XBoxZone iBox = tmpBoxes[i];
//
bool canSet =
!selected.IsValid()
? true
: selected.from > iBox.from;
if (canSet)
{
//
result = i;
selected = iBox;
}
}
//
Clean(tmpBoxes);
selected.Clean();
//
return result;
}
/**
* Get Youngest Box Index ...
*
* @param source: XBoxZone instance Reference Collection ...
*
* @return ( int )
*/
int GetYoungest(
XConsolidationZone &source[] //
)
{
//
int result = -1;
//
int count = ArraySize(source);
if (!IsValidSize(count))
{
return result;
}
//
XBoxZone tmpBoxes[];
int boxesCount = ToBox(
source,
tmpBoxes //
);
if (!IsValidSize(boxesCount))
{
//
Clean(tmpBoxes);
return result;
}
//
XBoxZone selected;
for (int i = 0; i < boxesCount; i++)
{
//
XBoxZone iBox = tmpBoxes[i];
//
bool canSet =
!selected.IsValid()
? true
: selected.from < iBox.from;
if (canSet)
{
//
result = i;
selected = iBox;
}
}
//
Clean(tmpBoxes);
selected.Clean();
//
return result;
}
/**
* Get Highest Box Index ...
*
* @param source: XBoxZone instance Reference Collection ...
*
* @return ( int )
*/
int GetHighest(
XConsolidationZone &source[] //
)
{
//
int result = -1;
//
int count = ArraySize(source);
if (!IsValidSize(count))
{
return result;
}
//
XBoxZone tmpBoxes[];
int boxesCount = ToBox(
source,
tmpBoxes //
);
if (!IsValidSize(boxesCount))
{
//
Clean(tmpBoxes);
return result;
}
//
XBoxZone selected;
for (int i = 0; i < boxesCount; i++)
{
//
XBoxZone iBox = tmpBoxes[i];
//
bool canSet =
!selected.IsValid()
? true
: selected.upper < iBox.upper;
if (canSet)
{
//
result = i;
selected = iBox;
}
}
//
Clean(tmpBoxes);
selected.Clean();
//
return result;
}
/**
* Get Lowest Box Index ...
*
* @param source: XBoxZone instance Reference Collection ...
*
* @return ( int )
*/
int GetLowest(
XConsolidationZone &source[] //
)
{
//
int result = -1;
//
int count = ArraySize(source);
if (!IsValidSize(count))
{
return result;
}
//
XBoxZone tmpBoxes[];
int boxesCount = ToBox(
source,
tmpBoxes //
);
if (!IsValidSize(boxesCount))
{
//
Clean(tmpBoxes);
return result;
}
//
XBoxZone selected;
for (int i = 0; i < boxesCount; i++)
{
//
XBoxZone iBox = tmpBoxes[i];
//
bool canSet =
!selected.IsValid()
? true
: selected.lower > iBox.lower;
if (canSet)
{
//
result = i;
selected = iBox;
}
}
//
Clean(tmpBoxes);
selected.Clean();
//
return result;
}
//
template <typename T>
void SortZones(