last ...
This commit is contained in:
@@ -1504,6 +1504,86 @@ struct XOHCL
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Same Checkers ...
|
||||
|
||||
//
|
||||
bool IsSameAs(XOHCL &item)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = IsValid() &&
|
||||
item.IsValid() &&
|
||||
IsSameTime(item) &&
|
||||
IsSameMarket(item);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool IsSameTime(XOHCL &item)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = IsValid() &&
|
||||
item.IsValid() &&
|
||||
time == item.time;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool IsSameSymbol(XOHCL &item)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = IsValid() &&
|
||||
item.IsValid() &&
|
||||
symbol == item.symbol;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool IsSamePeriod(XOHCL &item)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = IsValid() &&
|
||||
item.IsValid() &&
|
||||
period == item.period;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool IsSameMarket(XOHCL &item)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = IsValid() &&
|
||||
item.IsValid() &&
|
||||
IsSameSymbol(item) &&
|
||||
IsSamePeriod(item);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Other ...
|
||||
string GetTag(string prefix = "")
|
||||
|
||||
@@ -2596,6 +2596,56 @@ bool ExtractResistances(
|
||||
//+------------------------------------------------------------------+
|
||||
//| Find Index |
|
||||
//+------------------------------------------------------------------+
|
||||
/**
|
||||
* Find Specified Item index in a Collection ...
|
||||
*
|
||||
* @param index: int, reference to Hold Index if Exists ...
|
||||
* @param item: Specified item to Detect ...
|
||||
* @param source: Collection to Search for item ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool FindIndex(
|
||||
int &index,
|
||||
XOHCL &item,
|
||||
XOHCL &source[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
index = -1;
|
||||
|
||||
//
|
||||
int count = ArraySize(source);
|
||||
result = item.IsValid() &&
|
||||
IsValidSize(count);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
bool isSame = item.IsSameAs(source[i]);
|
||||
if (isSame)
|
||||
{
|
||||
//
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = IsValidIndex(index);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find Specified Item index in a Collection ...
|
||||
*
|
||||
@@ -2750,6 +2800,54 @@ bool FindIndex(
|
||||
//+------------------------------------------------------------------+
|
||||
//| Remove |
|
||||
//+------------------------------------------------------------------+
|
||||
/**
|
||||
* Remove Specified Item from a Collection ...
|
||||
*
|
||||
* @param item: Specified Item ...
|
||||
* @param source: Specified Collection for Remove item from it ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool Remove(
|
||||
XOHCL &item,
|
||||
XOHCL &source[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
item.IsValid() &&
|
||||
HasChild(source);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int idx = -1;
|
||||
result = FindIndex(
|
||||
idx,
|
||||
item,
|
||||
source //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = ArrayRemove(
|
||||
source,
|
||||
idx,
|
||||
1 //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove Specified Item from a Collection ...
|
||||
*
|
||||
@@ -2894,6 +2992,67 @@ bool Remove(
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove Specified items from a Collection ...
|
||||
*
|
||||
* @param items: Specified Items to Remove ...
|
||||
* @param sources: Sepcified Collection for Removing items from it ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int Removes(
|
||||
XOHCL &items[],
|
||||
XOHCL &sources[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
bool has = HasChild(items) &&
|
||||
HasChild(sources);
|
||||
if (!has)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int idx = -1;
|
||||
has = false;
|
||||
int count = ArraySize(items);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
// Detect Item Index in Collection ...
|
||||
has = FindIndex(
|
||||
idx,
|
||||
items[i],
|
||||
sources //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
// Remove Detected Index from Collection ...
|
||||
has = ArrayRemove(
|
||||
sources,
|
||||
idx,
|
||||
1 //
|
||||
);
|
||||
|
||||
//
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
// Count Removed Items ...
|
||||
result++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove Specified items from a Collection ...
|
||||
*
|
||||
@@ -3081,6 +3240,69 @@ int Removes(
|
||||
//+------------------------------------------------------------------+
|
||||
//| Add If Not Exists |
|
||||
//+------------------------------------------------------------------+
|
||||
/**
|
||||
* Add Specified Item to Specified Collection, if not Exists ...
|
||||
*
|
||||
* @param item: Item to Add ...
|
||||
* @param sources: Collection to Add item ...
|
||||
* @param maxAllowed: int, Max Allowed Collection Size ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool AddIfNotExists(
|
||||
XOHCL &item,
|
||||
XOHCL &sources[],
|
||||
int maxAllowed = 0 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Validate Args ...
|
||||
result = item.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Item Exists or not ...
|
||||
int idx = -1;
|
||||
bool isExists = FindIndex(
|
||||
idx,
|
||||
item,
|
||||
sources //
|
||||
);
|
||||
result = !isExists;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
AddRef(
|
||||
item,
|
||||
sources //
|
||||
);
|
||||
|
||||
//
|
||||
// Handle Cleanup Collection
|
||||
// if Max Reached ...
|
||||
if (result &&
|
||||
maxAllowed > 0)
|
||||
{
|
||||
//
|
||||
CleanupArray(
|
||||
sources,
|
||||
maxAllowed //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Specified Item to Specified Collection, if not Exists ...
|
||||
*
|
||||
@@ -3674,7 +3896,7 @@ bool ToResistanceBox(
|
||||
* @param bar: Specified Bar ...
|
||||
* @param zone: Specified Zone ...
|
||||
* @param forceBarEdge: bool, flag to Check Breaktion by high ot low ...
|
||||
*
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsBreaked(
|
||||
@@ -3717,6 +3939,118 @@ bool IsBreaked(
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Specified Zone is Tested by Specified Bar or not ...
|
||||
*
|
||||
* @param bar: Specified Bar ...
|
||||
* @param zone: Specified Zone ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsTested(
|
||||
XOHCL &bar,
|
||||
XBoxZone &zone //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = bar.IsValid() &&
|
||||
zone.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Break ...
|
||||
result =
|
||||
zone.IsBullish()
|
||||
? bar.low < zone.upper
|
||||
: bar.high > zone.lower;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Collect all Bars which Breakes Specified Zone ...
|
||||
*
|
||||
* @param zone: reference to Specified Zone ...
|
||||
* @param dest: reference Collection to hold result ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int GetBreakerBars(
|
||||
XBoxZone &zone,
|
||||
XOHCL &dest[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool has = zone.IsValid();
|
||||
if (!has)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Prepare ...
|
||||
SpecifiedClean(dest);
|
||||
|
||||
//
|
||||
// Do Action ...
|
||||
XOHCL iBar;
|
||||
int start = zone.ToIndex();
|
||||
int end = zone.FromIndex();
|
||||
for (int i = start; i < end; i++)
|
||||
{
|
||||
//
|
||||
// Initialize indexed Bar ...
|
||||
has = iBar.Init(
|
||||
zone.symbol,
|
||||
zone.period,
|
||||
i //
|
||||
);
|
||||
if (!has)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
has = IsBreaked(
|
||||
iBar,
|
||||
zone,
|
||||
false // Breakes by Close ...
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
AddIfNotExists(
|
||||
iBar,
|
||||
dest //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
iBar.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
result = ArraySize(dest);
|
||||
|
||||
//
|
||||
iBar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
|
||||
//
|
||||
Reference in New Issue
Block a user