last ...
This commit is contained in:
@@ -910,6 +910,40 @@ bool FindBoxIndex(
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check a BaxHas Valid Place for Specified Bar ...
|
||||
*
|
||||
* @param bar: XOHCL instance reference, Specified Bar ...
|
||||
* #param box: XBoxZone instance reference, Specified Box ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsBoxPlaceValidForBar(
|
||||
XOHCL &bar,
|
||||
XBoxZone &box //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = bar.IsValid() &&
|
||||
box.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
box.IsBullish()
|
||||
? bar.low > box.upper
|
||||
: bar.high < box.upper;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Source Box is Below Dest ...
|
||||
*
|
||||
@@ -2054,6 +2088,70 @@ int GetOldest(
|
||||
result = i;
|
||||
selected = iBox;
|
||||
}
|
||||
|
||||
//
|
||||
iBox.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
selected.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
int GetOldest(
|
||||
XOHCL &bar,
|
||||
XBoxZone &source[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = -1;
|
||||
|
||||
//
|
||||
if (!bar.IsValid())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int count = ArraySize(source);
|
||||
if (!IsValidSize(count))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XBoxZone selected;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XBoxZone iBox = source[i];
|
||||
|
||||
//
|
||||
bool isBoxValidForBar = IsBoxPlaceValidForBar(bar, iBox);
|
||||
if (!isBoxValidForBar)
|
||||
{
|
||||
//
|
||||
iBox.Clean();
|
||||
|
||||
//
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
bool canSet =
|
||||
!selected.IsValid()
|
||||
? true
|
||||
: selected.from > iBox.from;
|
||||
if (canSet)
|
||||
{
|
||||
//
|
||||
result = i;
|
||||
selected = iBox;
|
||||
}
|
||||
|
||||
//
|
||||
iBox.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
@@ -2102,6 +2200,70 @@ int GetYoungest(
|
||||
result = i;
|
||||
selected = iBox;
|
||||
}
|
||||
|
||||
//
|
||||
iBox.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
selected.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
int GetYoungest(
|
||||
XOHCL &bar,
|
||||
XBoxZone &source[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = -1;
|
||||
|
||||
//
|
||||
if (!bar.IsValid())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int count = ArraySize(source);
|
||||
if (!IsValidSize(count))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XBoxZone selected;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XBoxZone iBox = source[i];
|
||||
|
||||
//
|
||||
bool isBoxValidForBar = IsBoxPlaceValidForBar(bar, iBox);
|
||||
if (!isBoxValidForBar)
|
||||
{
|
||||
//
|
||||
iBox.Clean();
|
||||
|
||||
//
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
bool canSet =
|
||||
!selected.IsValid()
|
||||
? true
|
||||
: selected.from < iBox.from;
|
||||
if (canSet)
|
||||
{
|
||||
//
|
||||
result = i;
|
||||
selected = iBox;
|
||||
}
|
||||
|
||||
//
|
||||
iBox.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
@@ -2150,6 +2312,70 @@ int GetHighest(
|
||||
result = i;
|
||||
selected = iBox;
|
||||
}
|
||||
|
||||
//
|
||||
iBox.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
selected.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
int GetHighest(
|
||||
XOHCL &bar,
|
||||
XBoxZone &source[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = -1;
|
||||
|
||||
//
|
||||
if (!bar.IsValid())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int count = ArraySize(source);
|
||||
if (!IsValidSize(count))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XBoxZone selected;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XBoxZone iBox = source[i];
|
||||
|
||||
//
|
||||
bool isBoxValidForBar = IsBoxPlaceValidForBar(bar, iBox);
|
||||
if (!isBoxValidForBar)
|
||||
{
|
||||
//
|
||||
iBox.Clean();
|
||||
|
||||
//
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
bool canSet =
|
||||
!selected.IsValid()
|
||||
? true
|
||||
: selected.upper < iBox.upper;
|
||||
if (canSet)
|
||||
{
|
||||
//
|
||||
result = i;
|
||||
selected = iBox;
|
||||
}
|
||||
|
||||
//
|
||||
iBox.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
@@ -2198,6 +2424,70 @@ int GetLowest(
|
||||
result = i;
|
||||
selected = iBox;
|
||||
}
|
||||
|
||||
//
|
||||
iBox.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
selected.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
int GetLowest(
|
||||
XOHCL &bar,
|
||||
XBoxZone &source[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = -1;
|
||||
|
||||
//
|
||||
if (!bar.IsValid())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int count = ArraySize(source);
|
||||
if (!IsValidSize(count))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XBoxZone selected;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XBoxZone iBox = source[i];
|
||||
|
||||
//
|
||||
bool isBoxValidForBar = IsBoxPlaceValidForBar(bar, iBox);
|
||||
if (!isBoxValidForBar)
|
||||
{
|
||||
//
|
||||
iBox.Clean();
|
||||
|
||||
//
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
bool canSet =
|
||||
!selected.IsValid()
|
||||
? true
|
||||
: selected.lower > iBox.lower;
|
||||
if (canSet)
|
||||
{
|
||||
//
|
||||
result = i;
|
||||
selected = iBox;
|
||||
}
|
||||
|
||||
//
|
||||
iBox.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user