last works on XCATB V1.0 ...
This commit is contained in:
@@ -474,108 +474,6 @@ int GetLowest(
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate Boxes ...
|
||||
* @param box: XBoxZone instance reference for Validate ...
|
||||
* @param barIndex: int, Bar Index ...
|
||||
* @param barsLength: int, Bars Length for Validation ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsBoxValid(
|
||||
XBoxZone &box,
|
||||
int barIndex = 0,
|
||||
int barsLength = 3 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize Bar Index ...
|
||||
barIndex = NormalizeInt(barIndex, 0);
|
||||
barsLength = NormalizeInt(barsLength, 1);
|
||||
|
||||
//
|
||||
// Ceck Input Box is Valid ...
|
||||
result = box.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Input Box is Breaked or not ...
|
||||
// Breaktion Found using Counting Over/Under Close Bars ...
|
||||
bool isBullish = box.IsBullish();
|
||||
double appliedPrice = box.GetInDirectionalPrice();
|
||||
result = NotEmptyZero(appliedPrice);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int toIDX = box.ToIndex();
|
||||
|
||||
//
|
||||
XOHCL iBar;
|
||||
int edgeBreakes = 0;
|
||||
for (int i = barIndex; i <= toIDX; i++)
|
||||
{
|
||||
//
|
||||
// Initialize Indexed Bar ...
|
||||
result = iBar.Init(
|
||||
box.symbol,
|
||||
box.period,
|
||||
i //
|
||||
);
|
||||
|
||||
//
|
||||
// Checking Price ...
|
||||
result =
|
||||
//
|
||||
// Checking Bar Validation ...
|
||||
result &&
|
||||
//
|
||||
// Checking Price Breaked or not ...
|
||||
(isBullish
|
||||
? iBar.close < box.lower
|
||||
: iBar.close > box.upper);
|
||||
if (result)
|
||||
{
|
||||
edgeBreakes++;
|
||||
}
|
||||
else
|
||||
{
|
||||
edgeBreakes = 0;
|
||||
}
|
||||
|
||||
//
|
||||
result = edgeBreakes >= barsLength;
|
||||
if (result)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
iBar.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
iBar.Clean();
|
||||
|
||||
//
|
||||
// return true;
|
||||
|
||||
//
|
||||
result =
|
||||
edgeBreakes < barsLength;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find Specified Box Index inside a Collection of Boxes ...
|
||||
*
|
||||
@@ -856,12 +754,14 @@ int Removes(
|
||||
*
|
||||
* @param item: XBoxZone instance Reference, Specified Item to Add ...
|
||||
* @param sources: XBoxZone instance Reference Collection, Source Items Collection ...
|
||||
* @param maxAllowed: int, Max Allowed Collection Size ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool AddIfNotExists(
|
||||
XBoxZone &item,
|
||||
XBoxZone &sources[] //
|
||||
XBoxZone &sources[],
|
||||
int maxAllowed = 50 //
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -895,12 +795,24 @@ bool AddIfNotExists(
|
||||
sources //;
|
||||
);
|
||||
|
||||
//
|
||||
if (result &&
|
||||
maxAllowed > 0)
|
||||
{
|
||||
//
|
||||
CleanupArray(
|
||||
sources,
|
||||
maxAllowed //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
bool AddIfNotExists(
|
||||
XDirectionShift &item,
|
||||
XDirectionShift &sources[] //
|
||||
XDirectionShift &sources[],
|
||||
int maxAllowed = 50 //
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -934,6 +846,17 @@ bool AddIfNotExists(
|
||||
sources //;
|
||||
);
|
||||
|
||||
//
|
||||
if (result &&
|
||||
maxAllowed > 0)
|
||||
{
|
||||
//
|
||||
CleanupArray(
|
||||
sources,
|
||||
maxAllowed //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
@@ -943,12 +866,14 @@ bool AddIfNotExists(
|
||||
*
|
||||
* @param items: XBoxZone instance Reference Collection, Specified Items to Add ...
|
||||
* @param sources: XBoxZone instance Reference Collection, Source Items Collection ...
|
||||
* @param maxAllowed: int, Max Allowed Collection Size ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int AddIfNotExists(
|
||||
XBoxZone &items[],
|
||||
XBoxZone &sources[] //
|
||||
XBoxZone &sources[],
|
||||
int maxAllowed = 50 //
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -980,13 +905,23 @@ int AddIfNotExists(
|
||||
|
||||
//
|
||||
result = after > before;
|
||||
if (result &&
|
||||
maxAllowed > 0)
|
||||
{
|
||||
//
|
||||
CleanupArray(
|
||||
sources,
|
||||
maxAllowed //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
int AddIfNotExists(
|
||||
XDirectionShift &items[],
|
||||
XDirectionShift &sources[] //
|
||||
XDirectionShift &sources[],
|
||||
int maxAllowed = 50 //
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -1018,6 +953,15 @@ int AddIfNotExists(
|
||||
|
||||
//
|
||||
result = after > before;
|
||||
if (result &&
|
||||
maxAllowed > 0)
|
||||
{
|
||||
//
|
||||
CleanupArray(
|
||||
sources,
|
||||
maxAllowed //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
@@ -1027,6 +971,108 @@ int AddIfNotExists(
|
||||
//
|
||||
//
|
||||
|
||||
/**
|
||||
* Validate Boxes ...
|
||||
* @param box: XBoxZone instance reference for Validate ...
|
||||
* @param barIndex: int, Bar Index ...
|
||||
* @param barsLength: int, Bars Length for Validation ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsBoxValid(
|
||||
XBoxZone &box,
|
||||
int barIndex = 0,
|
||||
int barsLength = 3 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize Bar Index ...
|
||||
barIndex = NormalizeInt(barIndex, 0);
|
||||
barsLength = NormalizeInt(barsLength, 1);
|
||||
|
||||
//
|
||||
// Ceck Input Box is Valid ...
|
||||
result = box.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Input Box is Breaked or not ...
|
||||
// Breaktion Found using Counting Over/Under Close Bars ...
|
||||
bool isBullish = box.IsBullish();
|
||||
double appliedPrice = box.GetInDirectionalPrice();
|
||||
result = NotEmptyZero(appliedPrice);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int toIDX = box.ToIndex();
|
||||
|
||||
//
|
||||
XOHCL iBar;
|
||||
int edgeBreakes = 0;
|
||||
for (int i = barIndex; i <= toIDX; i++)
|
||||
{
|
||||
//
|
||||
// Initialize Indexed Bar ...
|
||||
result = iBar.Init(
|
||||
box.symbol,
|
||||
box.period,
|
||||
i //
|
||||
);
|
||||
|
||||
//
|
||||
// Checking Price ...
|
||||
result =
|
||||
//
|
||||
// Checking Bar Validation ...
|
||||
result &&
|
||||
//
|
||||
// Checking Price Breaked or not ...
|
||||
(isBullish
|
||||
? iBar.close < box.lower
|
||||
: iBar.close > box.upper);
|
||||
if (result)
|
||||
{
|
||||
edgeBreakes++;
|
||||
}
|
||||
else
|
||||
{
|
||||
edgeBreakes = 0;
|
||||
}
|
||||
|
||||
//
|
||||
result = edgeBreakes >= barsLength;
|
||||
if (result)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
iBar.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
iBar.Clean();
|
||||
|
||||
//
|
||||
// return true;
|
||||
|
||||
//
|
||||
result =
|
||||
edgeBreakes < barsLength;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
void SortBoxes(
|
||||
XBoxZone &items[],
|
||||
|
||||
Reference in New Issue
Block a user