last ...
This commit is contained in:
@@ -2181,7 +2181,7 @@ template <typename T>
|
||||
void Sort(
|
||||
T &source[],
|
||||
ENUM_X_SORT_BY sortBy = X_SORT_BY_DATE,
|
||||
ENUM_X_DIRECTION sortDir = X_DIRECTION_BULLISH,
|
||||
ENUM_X_DIRECTION sortDir = X_DIRECTION_BEARISH,
|
||||
int maxAllowed = 0 //
|
||||
)
|
||||
{
|
||||
@@ -3866,6 +3866,129 @@ void UpdateToTime(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove Breaked Zones from a Collection ...
|
||||
*
|
||||
* @param source: XBoxZone, reference to Specified Collection ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int RemoveBreakedZones(
|
||||
XBoxZone &source[],
|
||||
bool forceBreak = false //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool has = HasChild(source);
|
||||
if (!has)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XBoxZone iZone;
|
||||
XBoxZone tmps[];
|
||||
Copy(
|
||||
source,
|
||||
tmps //
|
||||
);
|
||||
XClean(source);
|
||||
XOHCL tmpBars[];
|
||||
int breakerBars = 0;
|
||||
while (HasChild(tmps))
|
||||
{
|
||||
//
|
||||
iZone.Clean();
|
||||
iZone = tmps[0];
|
||||
ArrayRemove(tmps, 0, 1);
|
||||
has = IsXValid(iZone.breakAt);
|
||||
if (has)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
if (forceBreak)
|
||||
{
|
||||
//
|
||||
breakerBars = GetBreakerBars(iZone, tmpBars);
|
||||
has = IsValidSize(breakerBars);
|
||||
}
|
||||
if (has)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
AddIfNotExists(
|
||||
iZone,
|
||||
source //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
result = ArraySize(source);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove Filled Zones ...
|
||||
*
|
||||
* @param source: XBoxZone, collection reference to Provide Data Source ...
|
||||
* @param zoneRangeFilledFactor: double, Filling Factor ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int RemoveFilledZones(
|
||||
XBoxZone &source[],
|
||||
double zoneRangeFilledFactor = 0.8 //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool has = HasChild(source);
|
||||
if (!has)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XBoxZone iTMP;
|
||||
XBoxZone tmp[];
|
||||
Copy(source, tmp);
|
||||
XClean(source);
|
||||
while (HasChild(tmp))
|
||||
{
|
||||
//
|
||||
iTMP.Clean();
|
||||
iTMP = tmp[0];
|
||||
ArrayRemove(tmp, 0, 1);
|
||||
|
||||
//
|
||||
has = IsFilled(iTMP, zoneRangeFilledFactor);
|
||||
if (!has)
|
||||
{
|
||||
AddIfNotExists(iTMP, source);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = ArraySize(source);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
// #region Zone Converters ...
|
||||
/**
|
||||
* Converts a Bar to Pivot ...
|
||||
*
|
||||
@@ -5076,7 +5199,6 @@ bool ToResistanceBox(
|
||||
box.lower = bar.GetUp();
|
||||
box.dir = X_DIRECTION_BEARISH;
|
||||
box.type = ToXString(X_BAR_PATTERN_RESISTANCE);
|
||||
;
|
||||
|
||||
//
|
||||
result = box.IsValid();
|
||||
@@ -5088,129 +5210,9 @@ bool ToResistanceBox(
|
||||
//
|
||||
return result;
|
||||
}
|
||||
// #endregion
|
||||
|
||||
/**
|
||||
* Remove Breaked Zones from a Collection ...
|
||||
*
|
||||
* @param source: XBoxZone, reference to Specified Collection ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int RemoveBreakedZones(
|
||||
XBoxZone &source[],
|
||||
bool forceBreak = false //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool has = HasChild(source);
|
||||
if (!has)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XBoxZone iZone;
|
||||
XBoxZone tmps[];
|
||||
Copy(
|
||||
source,
|
||||
tmps //
|
||||
);
|
||||
XClean(source);
|
||||
XOHCL tmpBars[];
|
||||
int breakerBars = 0;
|
||||
while (HasChild(tmps))
|
||||
{
|
||||
//
|
||||
iZone.Clean();
|
||||
iZone = tmps[0];
|
||||
ArrayRemove(tmps, 0, 1);
|
||||
has = IsXValid(iZone.breakAt);
|
||||
if (has)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
if (forceBreak)
|
||||
{
|
||||
//
|
||||
breakerBars = GetBreakerBars(iZone, tmpBars);
|
||||
has = IsValidSize(breakerBars);
|
||||
}
|
||||
if (has)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
AddIfNotExists(
|
||||
iZone,
|
||||
source //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
result = ArraySize(source);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove Filled Zones ...
|
||||
*
|
||||
* @param source: XBoxZone, collection reference to Provide Data Source ...
|
||||
* @param zoneRangeFilledFactor: double, Filling Factor ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int RemoveFilledZones(
|
||||
XBoxZone &source[],
|
||||
double zoneRangeFilledFactor = 0.8 //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool has = HasChild(source);
|
||||
if (!has)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XBoxZone iTMP;
|
||||
XBoxZone tmp[];
|
||||
Copy(source, tmp);
|
||||
XClean(source);
|
||||
while (HasChild(tmp))
|
||||
{
|
||||
//
|
||||
iTMP.Clean();
|
||||
iTMP = tmp[0];
|
||||
ArrayRemove(tmp, 0, 1);
|
||||
|
||||
//
|
||||
has = IsFilled(iTMP, zoneRangeFilledFactor);
|
||||
if (!has)
|
||||
{
|
||||
AddIfNotExists(iTMP, source);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = ArraySize(source);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
// #region Zone Checkers ...
|
||||
/**
|
||||
* Check a Zone is Filled or Not ...
|
||||
*
|
||||
@@ -5349,8 +5351,46 @@ bool IsTested(
|
||||
// Check Test ...
|
||||
result =
|
||||
zone.IsBullish()
|
||||
? bar.low < zone.upper
|
||||
: bar.high > zone.lower;
|
||||
? bar.low < zone.upper && bar.low > zone.lower
|
||||
: bar.high > zone.lower &&
|
||||
bar.high < zone.upper;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Specified Zone is Rejected by Specified Bar or not ...
|
||||
*
|
||||
* @param bar: Specified Bar ...
|
||||
* @param zone: Specified Zone ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsRejected(
|
||||
XOHCL &bar,
|
||||
XBoxZone &zone //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = bar.IsValid() &&
|
||||
zone.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Test ...
|
||||
result =
|
||||
IsTested(bar, zone) &&
|
||||
(zone.IsBullish()
|
||||
? bar.GetDown() >= zone.upper
|
||||
: bar.GetUp() <= zone.lower);
|
||||
|
||||
//
|
||||
return result;
|
||||
@@ -5461,6 +5501,72 @@ bool IsActed(
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Specified Zone is Breaked or not ...
|
||||
*
|
||||
* @param zone: XBoxZone, reference to Specified Zone ...
|
||||
* @param priceType: ENUM_X_PRICE, Specified Price Type for Zone Break Detection ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsBreaked(
|
||||
XBoxZone &zone,
|
||||
ENUM_X_PRICE priceType = X_PRICE_CLOSE //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = zone.IsValid() &&
|
||||
IsXValid(priceType);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
result = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL iBar;
|
||||
double iPrice;
|
||||
bool isBullish;
|
||||
int start = zone.ToIndex();
|
||||
int end = zone.FromIndex();
|
||||
for (int i = start; i < end; i++)
|
||||
{
|
||||
//
|
||||
// Initialize Indexed Bar ...
|
||||
iBar.Clean();
|
||||
result = iBar.Init(zone.symbol, zone.period, i);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
isBullish = zone.IsBullish();
|
||||
iPrice = iBar.GetPrice(priceType);
|
||||
result = isBullish
|
||||
? iPrice < zone.lower
|
||||
: iPrice > zone.upper;
|
||||
if (result)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup ...
|
||||
iBar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Specified Bar is Acted On Specified Zone or not ...
|
||||
*
|
||||
@@ -5607,64 +5713,12 @@ bool IsFakeBreaked(
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check a Bar is Inside a Zone or not ...
|
||||
*
|
||||
* @param index: int, reference to holds detected index ...
|
||||
* @param bar: reference to Specified Bar ...
|
||||
* @param source: reference collection to provide source ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool HasInside(
|
||||
int &index,
|
||||
XOHCL &bar,
|
||||
XBoxZone &source[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Prepare ...
|
||||
index = -1;
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = bar.IsValid() &&
|
||||
HasChild(source);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int count = ArraySize(source);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
result = IsInside(
|
||||
bar,
|
||||
source[i] //
|
||||
);
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Specified ZOne is Affected by Specified Bar or not ...
|
||||
*
|
||||
*
|
||||
* @param bar: XOHCL, reference to Specified Bar ...
|
||||
* @param zone: XBoxZone, reference to Specified Zone ...
|
||||
*
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsZoneAffected(
|
||||
@@ -5697,7 +5751,155 @@ bool IsZoneAffected(
|
||||
//
|
||||
return result;
|
||||
}
|
||||
// #endregion
|
||||
|
||||
// #region Zones Hasers ...
|
||||
/**
|
||||
* Check a Bar is Inside a Zone or not ...
|
||||
*
|
||||
* @param index: int, reference to holds detected index ...
|
||||
* @param bar: reference to Specified Bar ...
|
||||
* @param source: reference collection to provide source ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool HasInside(
|
||||
int &index,
|
||||
XOHCL &bar,
|
||||
XBoxZone &source[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
XBoxZone selected[];
|
||||
int count = ExtractInsides(bar, selected, source);
|
||||
bool result = IsValidSize(count);
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
index = GetYoungest(selected);
|
||||
if (IsValidIndex(index))
|
||||
{
|
||||
result = FindIndex(index, selected[index], source);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
XClean(selected);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check a Bar is Reject a Zone or not ...
|
||||
*
|
||||
* @param index: int, reference to holds detected index ...
|
||||
* @param bar: reference to Specified Bar ...
|
||||
* @param source: reference collection to provide source ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool HasRejected(
|
||||
int &index,
|
||||
XOHCL &bar,
|
||||
XBoxZone &source[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
XBoxZone selected[];
|
||||
int count = ExtractRejecteds(bar, selected, source);
|
||||
bool result = IsValidSize(count);
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
index = GetYoungest(selected);
|
||||
if (IsValidIndex(index))
|
||||
{
|
||||
result = FindIndex(index, selected[index], source);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
XClean(selected);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check a Bar is Break a Zone or not ...
|
||||
*
|
||||
* @param index: int, reference to holds detected index ...
|
||||
* @param bar: reference to Specified Bar ...
|
||||
* @param source: reference collection to provide source ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool HasBreaked(
|
||||
int &index,
|
||||
XOHCL &bar,
|
||||
XBoxZone &source[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
XBoxZone selected[];
|
||||
int count = ExtractBreakeds(bar, selected, source);
|
||||
bool result = IsValidSize(count);
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
index = GetYoungest(selected);
|
||||
if (IsValidIndex(index))
|
||||
{
|
||||
result = FindIndex(index, selected[index], source);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
XClean(selected);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check a Bar is Act a Zone or not ...
|
||||
*
|
||||
* @param index: int, reference to holds detected index ...
|
||||
* @param bar: reference to Specified Bar ...
|
||||
* @param source: reference collection to provide source ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool HasActed(
|
||||
int &index,
|
||||
XOHCL &bar,
|
||||
XBoxZone &source[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
XBoxZone selected[];
|
||||
int count = ExtractActeds(bar, selected, source);
|
||||
bool result = IsValidSize(count);
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
index = GetYoungest(selected);
|
||||
if (IsValidIndex(index))
|
||||
{
|
||||
result = FindIndex(index, selected[index], source);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
XClean(selected);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
// #endregion
|
||||
|
||||
// #region Zone Extractors ...
|
||||
/**
|
||||
* Extract Affected Zones for Specified Bar ...
|
||||
*
|
||||
@@ -5804,7 +6006,7 @@ int ExtractInsides(
|
||||
// Validate ...
|
||||
bool has = bar.IsValid() &&
|
||||
HasChild(source);
|
||||
if (!result)
|
||||
if (!has)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
@@ -5861,7 +6063,7 @@ int ExtractActeds(
|
||||
// Validate ...
|
||||
bool has = bar.IsValid() &&
|
||||
HasChild(source);
|
||||
if (!result)
|
||||
if (!has)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
@@ -5918,7 +6120,7 @@ int ExtractBreakeds(
|
||||
// Validate ...
|
||||
bool has = bar.IsValid() &&
|
||||
HasChild(source);
|
||||
if (!result)
|
||||
if (!has)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
@@ -5949,6 +6151,63 @@ int ExtractBreakeds(
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract all Items which Specified Bar is Rejected them ...
|
||||
*
|
||||
* @param bar: reference to Specified Bar ...
|
||||
* @param dest: reference to result ...
|
||||
* @param source: reference collection to provide source ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int ExtractRejecteds(
|
||||
XOHCL &bar,
|
||||
XBoxZone &dest[],
|
||||
XBoxZone &source[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
// Prepare ...
|
||||
SpecifiedClean(dest);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool has = bar.IsValid() &&
|
||||
HasChild(source);
|
||||
if (!has)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int count = ArraySize(source);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
has = IsRejected(
|
||||
bar,
|
||||
source[i] //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
AddIfNotExists(
|
||||
source[i],
|
||||
dest //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = ArraySize(dest);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Collect all Bars which Breakes Specified Zone ...
|
||||
*
|
||||
@@ -6175,72 +6434,6 @@ int GetTesterBars(
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Specified Zone is Breaked or not ...
|
||||
*
|
||||
* @param zone: XBoxZone, reference to Specified Zone ...
|
||||
* @param priceType: ENUM_X_PRICE, Specified Price Type for Zone Break Detection ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsBreaked(
|
||||
XBoxZone &zone,
|
||||
ENUM_X_PRICE priceType = X_PRICE_CLOSE //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = zone.IsValid() &&
|
||||
IsXValid(priceType);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
result = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL iBar;
|
||||
double iPrice;
|
||||
bool isBullish;
|
||||
int start = zone.ToIndex();
|
||||
int end = zone.FromIndex();
|
||||
for (int i = start; i < end; i++)
|
||||
{
|
||||
//
|
||||
// Initialize Indexed Bar ...
|
||||
iBar.Clean();
|
||||
result = iBar.Init(zone.symbol, zone.period, i);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
isBullish = zone.IsBullish();
|
||||
iPrice = iBar.GetPrice(priceType);
|
||||
result = isBullish
|
||||
? iPrice < zone.lower
|
||||
: iPrice > zone.upper;
|
||||
if (result)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup ...
|
||||
iBar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate Zones Range ...
|
||||
*
|
||||
@@ -6301,10 +6494,10 @@ int ValidateZonesRange(
|
||||
|
||||
/**
|
||||
* Remove Breaked Zones ...
|
||||
*
|
||||
*
|
||||
* @param source: XBoxZone, collection reference to Remove Breaked Zones ...
|
||||
* @param priceType: ENUM_X_PRICE, Specified Price type of Break Detection ...
|
||||
*
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int RemoveBreakedZones(
|
||||
@@ -6355,6 +6548,7 @@ int RemoveBreakedZones(
|
||||
//
|
||||
return result;
|
||||
}
|
||||
// #endregion
|
||||
//+------------------------------------------------------------------+
|
||||
|
||||
//
|
||||
Reference in New Issue
Block a user