last ...
This commit is contained in:
@@ -26,7 +26,6 @@
|
||||
|
||||
//
|
||||
// Extensions ...
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Oldest Detection |
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -976,6 +975,498 @@ int GetLowest(
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Box |
|
||||
//+------------------------------------------------------------------+
|
||||
int GetOldestBefore(
|
||||
datetime _time,
|
||||
XBoxZone &source[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = -1;
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool has =
|
||||
HasChild(source) &&
|
||||
IsSpecifiedValid(_time);
|
||||
if (!has)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int idx = -1;
|
||||
XBoxZone tmps[];
|
||||
int count = ArraySize(source);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
has = source[i].from < _time;
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
AddIfNotExists(
|
||||
source[i],
|
||||
tmps //
|
||||
);
|
||||
}
|
||||
}
|
||||
has = HasChild(tmps);
|
||||
if (!has)
|
||||
{
|
||||
//
|
||||
result = -1;
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
idx = GetOldest(tmps);
|
||||
has =
|
||||
IsValidIndex(idx) &&
|
||||
FindIndex(
|
||||
result,
|
||||
tmps[idx],
|
||||
source //
|
||||
);
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
SpecifiedClean(tmps);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
int GetOldestAfter(
|
||||
datetime _time,
|
||||
XBoxZone &source[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = -1;
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool has =
|
||||
HasChild(source) &&
|
||||
IsSpecifiedValid(_time);
|
||||
if (!has)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int idx = -1;
|
||||
XBoxZone tmps[];
|
||||
int count = ArraySize(source);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
has = source[i].from > _time;
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
AddIfNotExists(
|
||||
source[i],
|
||||
tmps //
|
||||
);
|
||||
}
|
||||
}
|
||||
has = HasChild(tmps);
|
||||
if (!has)
|
||||
{
|
||||
//
|
||||
result = -1;
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
idx = GetOldest(tmps);
|
||||
has =
|
||||
IsValidIndex(idx) &&
|
||||
FindIndex(
|
||||
result,
|
||||
tmps[idx],
|
||||
source //
|
||||
);
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
SpecifiedClean(tmps);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
int GetYoungestBefore(
|
||||
datetime _time,
|
||||
XBoxZone &source[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = -1;
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool has =
|
||||
HasChild(source) &&
|
||||
IsSpecifiedValid(_time);
|
||||
if (!has)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int idx = -1;
|
||||
XBoxZone tmps[];
|
||||
int count = ArraySize(source);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
has = source[i].from < _time;
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
AddIfNotExists(
|
||||
source[i],
|
||||
tmps //
|
||||
);
|
||||
}
|
||||
}
|
||||
has = HasChild(tmps);
|
||||
if (!has)
|
||||
{
|
||||
//
|
||||
result = -1;
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
idx = GetYoungest(tmps);
|
||||
has =
|
||||
IsValidIndex(idx) &&
|
||||
FindIndex(
|
||||
result,
|
||||
tmps[idx],
|
||||
source //
|
||||
);
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
SpecifiedClean(tmps);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
int GetYoungestAfter(
|
||||
datetime _time,
|
||||
XBoxZone &source[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = -1;
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool has =
|
||||
HasChild(source) &&
|
||||
IsSpecifiedValid(_time);
|
||||
if (!has)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int idx = -1;
|
||||
XBoxZone tmps[];
|
||||
int count = ArraySize(source);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
has = source[i].from > _time;
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
AddIfNotExists(
|
||||
source[i],
|
||||
tmps //
|
||||
);
|
||||
}
|
||||
}
|
||||
has = HasChild(tmps);
|
||||
if (!has)
|
||||
{
|
||||
//
|
||||
result = -1;
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
idx = GetYoungest(tmps);
|
||||
has =
|
||||
IsValidIndex(idx) &&
|
||||
FindIndex(
|
||||
result,
|
||||
tmps[idx],
|
||||
source //
|
||||
);
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
SpecifiedClean(tmps);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
int GetHighestAbove(
|
||||
double _value,
|
||||
XBoxZone &source[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = -1;
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool has =
|
||||
HasChild(source) &&
|
||||
NotEmptyZero(_value);
|
||||
if (!has)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int idx = -1;
|
||||
XBoxZone tmps[];
|
||||
int count = ArraySize(source);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
has = source[i].upper > _value;
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
AddIfNotExists(
|
||||
source[i],
|
||||
tmps //
|
||||
);
|
||||
}
|
||||
}
|
||||
has = HasChild(tmps);
|
||||
if (!has)
|
||||
{
|
||||
//
|
||||
result = -1;
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
idx = GetHighest(tmps);
|
||||
has =
|
||||
IsValidIndex(idx) &&
|
||||
FindIndex(
|
||||
result,
|
||||
tmps[idx],
|
||||
source //
|
||||
);
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
SpecifiedClean(tmps);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
int GetHighestBelow(
|
||||
double _value,
|
||||
XBoxZone &source[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = -1;
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool has =
|
||||
HasChild(source) &&
|
||||
NotEmptyZero(_value);
|
||||
if (!has)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int idx = -1;
|
||||
XBoxZone tmps[];
|
||||
int count = ArraySize(source);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
has = source[i].upper < _value;
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
AddIfNotExists(
|
||||
source[i],
|
||||
tmps //
|
||||
);
|
||||
}
|
||||
}
|
||||
has = HasChild(tmps);
|
||||
if (!has)
|
||||
{
|
||||
//
|
||||
result = -1;
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
idx = GetHighest(tmps);
|
||||
has =
|
||||
IsValidIndex(idx) &&
|
||||
FindIndex(
|
||||
result,
|
||||
tmps[idx],
|
||||
source //
|
||||
);
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
SpecifiedClean(tmps);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
int GetLowestAbove(
|
||||
double _value,
|
||||
XBoxZone &source[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = -1;
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool has =
|
||||
HasChild(source) &&
|
||||
NotEmptyZero(_value);
|
||||
if (!has)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int idx = -1;
|
||||
XBoxZone tmps[];
|
||||
int count = ArraySize(source);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
has = source[i].lower > _value;
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
AddIfNotExists(
|
||||
source[i],
|
||||
tmps //
|
||||
);
|
||||
}
|
||||
}
|
||||
has = HasChild(tmps);
|
||||
if (!has)
|
||||
{
|
||||
//
|
||||
result = -1;
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
idx = GetLowest(tmps);
|
||||
has =
|
||||
IsValidIndex(idx) &&
|
||||
FindIndex(
|
||||
result,
|
||||
tmps[idx],
|
||||
source //
|
||||
);
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
SpecifiedClean(tmps);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
int GetLowestBelow(
|
||||
double _value,
|
||||
XBoxZone &source[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = -1;
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool has =
|
||||
HasChild(source) &&
|
||||
NotEmptyZero(_value);
|
||||
if (!has)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int idx = -1;
|
||||
XBoxZone tmps[];
|
||||
int count = ArraySize(source);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
has = source[i].lower < _value;
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
AddIfNotExists(
|
||||
source[i],
|
||||
tmps //
|
||||
);
|
||||
}
|
||||
}
|
||||
has = HasChild(tmps);
|
||||
if (!has)
|
||||
{
|
||||
//
|
||||
result = -1;
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
idx = GetLowest(tmps);
|
||||
has =
|
||||
IsValidIndex(idx) &&
|
||||
FindIndex(
|
||||
result,
|
||||
tmps[idx],
|
||||
source //
|
||||
);
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
SpecifiedClean(tmps);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Sort |
|
||||
//+------------------------------------------------------------------+
|
||||
|
||||
Reference in New Issue
Block a user