last works ...
This commit is contained in:
+584
-286
@@ -5010,6 +5010,43 @@ struct XBoxZone
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Box is Same as another ...
|
||||
*
|
||||
* @param box: XBoxZone instance Reference ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsSame(XBoxZone &box)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = IsValid() &&
|
||||
box.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
dir == box.dir &&
|
||||
from == box.from &&
|
||||
type == box.type &&
|
||||
upper == box.upper &&
|
||||
lower == box.lower &&
|
||||
symbol == box.symbol &&
|
||||
period == box.period
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
@@ -5404,292 +5441,6 @@ void CombineStates(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Price Above Specified Zone ...
|
||||
*
|
||||
* @param bar: XOHCL instance Reference ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsPriceAboveZone(
|
||||
XOHCL &bar,
|
||||
XCZone *zone //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
zone != NULL &&
|
||||
bar.IsValid() &&
|
||||
zone.IsValidBoundary();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
bar.low > zone.Upper()
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Price Above Specified Zone ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsPriceAboveZone(
|
||||
double price,
|
||||
XCZone *zone //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
price > 0 &&
|
||||
zone != NULL &&
|
||||
zone.IsValidBoundary();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
price > zone.Upper()
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Price Below Specified Zone ...
|
||||
*
|
||||
* @param bar: XOHCL instance Reference ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsPriceBelowZone(
|
||||
XOHCL &bar,
|
||||
XCZone *zone //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
zone != NULL &&
|
||||
bar.IsValid() &&
|
||||
zone.IsValidBoundary();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
bar.high < zone.Lower()
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Price Below Specified Zone ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsPriceBelowZone(
|
||||
double price,
|
||||
XCZone *zone //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
price > 0 &&
|
||||
zone != NULL &&
|
||||
zone.IsValidBoundary();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
price < zone.Lower()
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Price Inside Specified Zone ...
|
||||
*
|
||||
* @param bar: XOHCL instance Reference ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsPriceInsideZone(
|
||||
XOHCL &bar,
|
||||
XCZone *zone //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
zone != NULL &&
|
||||
bar.IsValid() &&
|
||||
zone.IsValidBoundary();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
bar.low <= zone.Upper()
|
||||
//
|
||||
&&
|
||||
//
|
||||
bar.low >= zone.Lower()
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
bool IsPriceInsideZone(
|
||||
XOHCL &bar,
|
||||
double upper,
|
||||
double lower //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
upper > 0 &&
|
||||
lower > 0 &&
|
||||
upper > lower &&
|
||||
bar.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
bar.low <= upper
|
||||
//
|
||||
&&
|
||||
//
|
||||
bar.low >= lower
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Price Inside Specified Zone ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsPriceInsideZone(
|
||||
double price,
|
||||
XCZone *zone //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
price > 0 &&
|
||||
zone != NULL &&
|
||||
zone.IsValidBoundary();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
price <= zone.Upper()
|
||||
//
|
||||
&&
|
||||
//
|
||||
price >= zone.Lower()
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
bool IsPriceInsideZone(
|
||||
double price,
|
||||
double upper,
|
||||
double lower //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
price > 0 &&
|
||||
upper > 0 &&
|
||||
lower > 0 &&
|
||||
upper > lower;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
price <= upper
|
||||
//
|
||||
&&
|
||||
//
|
||||
price >= lower
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool ToZone(
|
||||
T *&source[],
|
||||
@@ -5791,6 +5542,553 @@ bool ToBox(
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool IsSame(
|
||||
T *source,
|
||||
T *dest //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
XBoxZone sourceBox;
|
||||
result = ToBox(
|
||||
sourceBox,
|
||||
source //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XBoxZone destBox;
|
||||
result = ToBox(
|
||||
destBox,
|
||||
dest //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = sourceBox.IsSame(destBox);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T, typename F>
|
||||
bool IsSameDiff(
|
||||
T *source,
|
||||
F *dest //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
XBoxZone sourceBox;
|
||||
result = ToBox(
|
||||
sourceBox,
|
||||
source //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XBoxZone destBox;
|
||||
result = ToBox(
|
||||
destBox,
|
||||
dest //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = sourceBox.IsSame(destBox);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool IsBelow(
|
||||
T *source,
|
||||
T *dest,
|
||||
bool ignoreInside = false //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
XBoxZone sourceBox;
|
||||
result = ToBox(
|
||||
sourceBox,
|
||||
source //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XBoxZone destBox;
|
||||
result = ToBox(
|
||||
destBox,
|
||||
dest //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = IsBoxBelow(
|
||||
sourceBox,
|
||||
destBox,
|
||||
ignoreInside //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T, typename F>
|
||||
bool IsBelowDiff(
|
||||
T *source,
|
||||
F *dest,
|
||||
bool ignoreInside = false //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
XBoxZone sourceBox;
|
||||
result = ToBox(
|
||||
sourceBox,
|
||||
source //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XBoxZone destBox;
|
||||
result = ToBox(
|
||||
destBox,
|
||||
dest //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = IsBoxBelow(
|
||||
sourceBox,
|
||||
destBox,
|
||||
ignoreInside //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool IsAbove(
|
||||
T *source,
|
||||
T *dest,
|
||||
bool ignoreInside = false //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
XBoxZone sourceBox;
|
||||
result = ToBox(
|
||||
sourceBox,
|
||||
source //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XBoxZone destBox;
|
||||
result = ToBox(
|
||||
destBox,
|
||||
dest //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = IsBoxAbove(
|
||||
sourceBox,
|
||||
destBox,
|
||||
ignoreInside //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T, typename F>
|
||||
bool IsAboveDiff(
|
||||
T *source,
|
||||
F *dest,
|
||||
bool ignoreInside = false //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
XBoxZone sourceBox;
|
||||
result = ToBox(
|
||||
sourceBox,
|
||||
source //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XBoxZone destBox;
|
||||
result = ToBox(
|
||||
destBox,
|
||||
dest //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = IsBoxAbove(
|
||||
sourceBox,
|
||||
destBox,
|
||||
ignoreInside //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool IsInside(
|
||||
T *source,
|
||||
T *dest //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
XBoxZone sourceBox;
|
||||
result = ToBox(
|
||||
sourceBox,
|
||||
source //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XBoxZone destBox;
|
||||
result = ToBox(
|
||||
destBox,
|
||||
dest //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = IsBoxInside(
|
||||
sourceBox,
|
||||
destBox //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T, typename F>
|
||||
bool IsInsideDiff(
|
||||
T *source,
|
||||
F *dest //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
XBoxZone sourceBox;
|
||||
result = ToBox(
|
||||
sourceBox,
|
||||
source //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XBoxZone destBox;
|
||||
result = ToBox(
|
||||
destBox,
|
||||
dest //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = IsBoxInside(
|
||||
sourceBox,
|
||||
destBox //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool FindIndex(
|
||||
int &index,
|
||||
T *item,
|
||||
T *&items[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
index = -1;
|
||||
|
||||
//
|
||||
XBoxZone itemBox;
|
||||
result = ToBox(
|
||||
itemBox,
|
||||
item //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XBoxZone itemsBox[];
|
||||
result = ToBox(
|
||||
items,
|
||||
itemsBox //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = FindBoxIndex(
|
||||
index,
|
||||
itemBox,
|
||||
itemsBox //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find Specified Box Index inside a Collection of Boxes ...
|
||||
*
|
||||
* @param box: XBoxZone instance Reference ...
|
||||
* @param boxes: XBoxZone instance Reference Collection ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
bool FindBoxIndex(
|
||||
int &index,
|
||||
XBoxZone &box,
|
||||
XBoxZone &boxes[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
index = -1;
|
||||
|
||||
//
|
||||
int count = ArraySize(boxes);
|
||||
result = box.IsValid() &&
|
||||
IsValidSize(count);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XBoxZone iBox = boxes[i];
|
||||
|
||||
//
|
||||
bool isSame = box.IsSame(iBox);
|
||||
if (isSame)
|
||||
{
|
||||
//
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = IsValidIndex(index);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Source Box is Below Dest ...
|
||||
*
|
||||
* @param source: XBoxZone instance Reference ...
|
||||
* @param dest: XBoxZone instance Reference ...
|
||||
* @param ignoreInside: bool ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsBoxBelow(
|
||||
XBoxZone &source,
|
||||
XBoxZone &dest,
|
||||
bool ignoreInside = false //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = source.IsValid() &&
|
||||
dest.IsValid() &&
|
||||
!source.IsSame(dest);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
if (!ignoreInside)
|
||||
{
|
||||
result = source.upper < dest.lower;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = (source.upper < dest.lower ||
|
||||
source.upper >= dest.upper) &&
|
||||
source.lower < dest.lower;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Source Box is Above Dest ...
|
||||
*
|
||||
* @param source: XBoxZone instance Reference ...
|
||||
* @param dest: XBoxZone instance Reference ...
|
||||
* @param ignoreInside: bool ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsBoxAbove(
|
||||
XBoxZone &source,
|
||||
XBoxZone &dest,
|
||||
bool ignoreInside = false //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = source.IsValid() &&
|
||||
dest.IsValid() &&
|
||||
!source.IsSame(dest);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
if (!ignoreInside)
|
||||
{
|
||||
result = source.lower > dest.upper;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = (source.lower > dest.upper ||
|
||||
source.lower <= dest.upper) &&
|
||||
source.upper > dest.upper;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Source Box is Inside Dest ...
|
||||
*
|
||||
* @param source: XBoxZone instance Reference ...
|
||||
* @param dest: XBoxZone instance Reference ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsBoxAbove(
|
||||
XBoxZone &source,
|
||||
XBoxZone &dest //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = source.IsValid() &&
|
||||
dest.IsValid() &&
|
||||
!source.IsSame(dest);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = source.lower >= dest.lower &&
|
||||
source.upper <= dest.upper;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a Consolidation Zone ...
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user