This commit is contained in:
2025-10-25 16:45:25 +03:30
parent 2db26ee5f6
commit 7c0c48128e
6 changed files with 1416 additions and 17 deletions
@@ -2712,6 +2712,791 @@ class XCXFIMAHelperParser : XCBase
return result;
}
//
// Boundary Tools ...
// =============================
// Boundary Includes:
// MA Band ...
// PB Band ...
// HK Band ...
// ATR Band ...
/**
* Reading Boundary Values ...
*
* @param maBandUpper: double, reference to holds MA Band Upper value ...
* @param maBandLower: double, reference to holds MA Band Lower value ...
* @param pbBandUpper: double, reference to holds PB Band Upper value ...
* @param pbBandLower: double, reference to holds PB Band Lower value ...
* @param hkBandUpper: double, reference to holds HK Band Upper value ...
* @param hkBandLower: double, reference to holds HK Band Lower value ...
* @param atrBandUpper: double, reference to holds ATR Band Upper value ...
* @param atrBandLower: double, reference to holds ATR Band Lower value ...
* @param barIndex: int, Specified Bar Index ...
*/
void GetBoundaryValues(
double &maBandUpper,
double &maBandLower,
double &pbBandUpper,
double &pbBandLower,
double &hkBandUpper,
double &hkBandLower,
double &atrBandUpper,
double &atrBandLower,
int barIndex = 0 //
)
{
//
// Normalize ...
barIndex = NormalizeBarIndex(barIndex);
//
// Prepare ...
maBandUpper = EMPTY_VALUE;
maBandLower = EMPTY_VALUE;
pbBandUpper = EMPTY_VALUE;
pbBandLower = EMPTY_VALUE;
hkBandUpper = EMPTY_VALUE;
hkBandLower = EMPTY_VALUE;
atrBandUpper = EMPTY_VALUE;
atrBandLower = EMPTY_VALUE;
//
// Validate ...
bool has = IsValid();
if (!has)
{
return;
}
//
maBandUpper = helper.GetMABandUpper(barIndex);
maBandLower = helper.GetMABandLower(barIndex);
pbBandUpper = helper.GetPBBandUpper(barIndex);
pbBandLower = helper.GetPBBandLower(barIndex);
hkBandUpper = helper.GetHKBandUpper(barIndex);
hkBandLower = helper.GetHKBandLower(barIndex);
atrBandUpper = helper.GetATRBandUpper(barIndex);
atrBandLower = helper.GetATRBandLower(barIndex);
}
/**
* Read Boundary Values and Fill as an Array ...
*
* @param values: double, collection reference to fill results ...
* @param barIndex: int, Specified Bar Index ...
*/
void GetBoundaryValuesArray(
double &values[],
int barIndex = 0 //
)
{
//
// Prepare ...
XClean(values);
//
// Normalize ...
barIndex = NormalizeBarIndex(barIndex);
//
// Validate ...
bool has = IsValid();
if (!has)
{
return;
}
//
// Reading Boundary Values ...
//
double maBandUpper = EMPTY_VALUE;
double maBandLower = EMPTY_VALUE;
double pbBandUpper = EMPTY_VALUE;
double pbBandLower = EMPTY_VALUE;
double hkBandUpper = EMPTY_VALUE;
double hkBandLower = EMPTY_VALUE;
double atrBandUpper = EMPTY_VALUE;
double atrBandLower = EMPTY_VALUE;
//
GetBoundaryValues(
maBandUpper,
maBandLower,
pbBandUpper,
pbBandLower,
hkBandUpper,
hkBandLower,
atrBandUpper,
atrBandLower,
barIndex //
);
//
// Validate ...
has =
NotEmptyZero(maBandUpper) &&
NotEmptyZero(maBandLower) &&
NotEmptyZero(pbBandUpper) &&
NotEmptyZero(pbBandLower) &&
NotEmptyZero(hkBandUpper) &&
NotEmptyZero(hkBandLower) &&
NotEmptyZero(atrBandUpper) &&
NotEmptyZero(atrBandLower);
if (!has)
{
return;
}
//
Add(maBandUpper, values);
Add(maBandLower, values);
Add(pbBandUpper, values);
Add(pbBandLower, values);
Add(hkBandUpper, values);
Add(hkBandLower, values);
Add(atrBandUpper, values);
Add(atrBandLower, values);
}
/**
* Read Boundary Min Value ...
*
* @param barIndex: int, Specified Bar Index ...
*
* @return ( double )
*/
double GetBoundaryMin(int barIndex = 0)
{
//
double result = EMPTY_VALUE;
//
// Normalize ...
barIndex = NormalizeBarIndex(barIndex);
//
// Validate ...
bool has = IsValid();
if (!has)
{
return result;
}
//
double values[];
GetBoundaryValuesArray(values, barIndex);
result = GetMax(values);
//
return result;
}
/**
* Read Boundary Max Value ...
*
* @param barIndex: int, Specified BAr Index ...
*
* @return ( double )
*/
double GetBoundaryMax(int barIndex = 0)
{
//
double result = EMPTY_VALUE;
//
// Normalize ...
barIndex = NormalizeBarIndex(barIndex);
//
// Validate ...
bool has = IsValid();
if (!has)
{
return result;
}
//
double values[];
GetBoundaryValuesArray(values, barIndex);
result = GetMin(values);
//
return result;
}
//
// Bars and Boundary ...
/**
* Check Bar's Price is Over Boundary Max or not ...
*
* @param barIndex: int, Specified Bar Index ...
* @param priceType: ENUM_X_PRICE, Specified Price Type ...
*
* @return ( bool )
*/
bool IsBarOverBoundaryMax(
int barIndex = 0,
ENUM_X_PRICE priceType = X_PRICE_HIGH //
)
{
//
bool result = false;
//
// Normalize ...
barIndex = NormalizeBarIndex(barIndex);
//
// Validate ...
result = IsValid() &&
IsXValid(priceType);
if (!result)
{
return result;
}
//
XOHCL bar;
double price = EMPTY_VALUE;
double value = GetBoundaryMax(barIndex);
result = bar.Init(symbol, period, barIndex);
if (result)
{
price = bar.GetPrice(priceType);
}
result = bar.IsValid() &&
NotEmptyZero(price) &&
NotEmptyZero(value) &&
price > value;
//
// Cleanup ...
bar.Clean();
//
return result;
}
/**
* Check Bar's Price is Over Boundary Min or not ...
*
* @param barIndex: int, Specified Bar Index ...
* @param priceType: ENUM_X_PRICE, Specified Price Type ...
*
* @return ( bool )
*/
bool IsBarOverBoundaryMin(
int barIndex = 0,
ENUM_X_PRICE priceType = X_PRICE_LOW //
)
{
//
bool result = false;
//
// Normalize ...
barIndex = NormalizeBarIndex(barIndex);
//
// Validate ...
result = IsValid() &&
IsXValid(priceType);
if (!result)
{
return result;
}
//
XOHCL bar;
double price = EMPTY_VALUE;
double value = GetBoundaryMin(barIndex);
result = bar.Init(symbol, period, barIndex);
if (result)
{
price = bar.GetPrice(priceType);
}
result = bar.IsValid() &&
NotEmptyZero(price) &&
NotEmptyZero(value) &&
price > value;
//
// Cleanup ...
bar.Clean();
//
return result;
}
/**
* Check Bar's Price is Under Boundary Max or not ...
*
* @param barIndex: int, Specified Bar Index ...
* @param priceType: ENUM_X_PRICE, Specified Price Type ...
*
* @return ( bool )
*/
bool IsBarUnderBoundaryMax(
int barIndex = 0,
ENUM_X_PRICE priceType = X_PRICE_HIGH //
)
{
//
bool result = false;
//
// Normalize ...
barIndex = NormalizeBarIndex(barIndex);
//
// Validate ...
result = IsValid() &&
IsXValid(priceType);
if (!result)
{
return result;
}
//
XOHCL bar;
double price = EMPTY_VALUE;
double value = GetBoundaryMax(barIndex);
result = bar.Init(symbol, period, barIndex);
if (result)
{
price = bar.GetPrice(priceType);
}
result = bar.IsValid() &&
NotEmptyZero(price) &&
NotEmptyZero(value) &&
price < value;
//
// Cleanup ...
bar.Clean();
//
return result;
}
/**
* Check Bar's Price is Under Boundary Min or not ...
*
* @param barIndex: int, Specified Bar Index ...
* @param priceType: ENUM_X_PRICE, Specified Price Type ...
*
* @return ( bool )
*/
bool IsBarUnderBoundaryMin(
int barIndex = 0,
ENUM_X_PRICE priceType = X_PRICE_LOW //
)
{
//
bool result = false;
//
// Normalize ...
barIndex = NormalizeBarIndex(barIndex);
//
// Validate ...
result = IsValid() &&
IsXValid(priceType);
if (!result)
{
return result;
}
//
XOHCL bar;
double price = EMPTY_VALUE;
double value = GetBoundaryMin(barIndex);
result = bar.Init(symbol, period, barIndex);
if (result)
{
price = bar.GetPrice(priceType);
}
result = bar.IsValid() &&
NotEmptyZero(price) &&
NotEmptyZero(value) &&
price < value;
//
// Cleanup ...
bar.Clean();
//
return result;
}
/**
* Check Bar's Price is Crossed Over Boundary Max or not ...
*
* @param barIndex: int, Specified Bar Index ...
* @param priceType: ENUM_X_PRICE, Specified Price Type ...
*
* @return ( bool )
*/
bool IsBarCrossedOverBoundaryMax(
int barIndex = 0,
ENUM_X_PRICE priceType = X_PRICE_HIGH //
)
{
//
bool result = false;
//
// Normalize ...
barIndex = NormalizeBarIndex(barIndex);
//
// Validate ...
result = IsValid() &&
IsXValid(priceType);
if (!result)
{
return result;
}
//
bool isC = IsBarOverBoundaryMax(barIndex, priceType);
bool isP = IsBarOverBoundaryMax(barIndex + 1, priceType);
//
result = isC && !isP;
//
return result;
}
/**
* Check Bar's Price is Crossed Over Boundary Min or not ...
*
* @param barIndex: int, Specified Bar Index ...
* @param priceType: ENUM_X_PRICE, Specified Price Type ...
*
* @return ( bool )
*/
bool IsBarCrossedOverBoundaryMin(
int barIndex = 0,
ENUM_X_PRICE priceType = X_PRICE_LOW //
)
{
//
bool result = false;
//
// Normalize ...
barIndex = NormalizeBarIndex(barIndex);
//
// Validate ...
result = IsValid() &&
IsXValid(priceType);
if (!result)
{
return result;
}
//
bool isC = IsBarOverBoundaryMin(barIndex, priceType);
bool isP = IsBarOverBoundaryMin(barIndex + 1, priceType);
//
result = isC && !isP;
//
return result;
}
/**
* Check Bar's Price is Crossed Under Boundary Max or not ...
*
* @param barIndex: int, Specified Bar Index ...
* @param priceType: ENUM_X_PRICE, Specified Price Type ...
*
* @return ( bool )
*/
bool IsBarCrossedUnderBoundaryMax(
int barIndex = 0,
ENUM_X_PRICE priceType = X_PRICE_HIGH //
)
{
//
bool result = false;
//
// Normalize ...
barIndex = NormalizeBarIndex(barIndex);
//
// Validate ...
result = IsValid() &&
IsXValid(priceType);
if (!result)
{
return result;
}
//
bool isC = IsBarUnderBoundaryMax(barIndex, priceType);
bool isP = IsBarUnderBoundaryMax(barIndex + 1, priceType);
//
result = isC && !isP;
//
return result;
}
/**
* Check Bar's Price is Crossed Under Boundary Min or not ...
*
* @param barIndex: int, Specified Bar Index ...
* @param priceType: ENUM_X_PRICE, Specified Price Type ...
*
* @return ( bool )
*/
bool IsBarCrossedUnderBoundaryMin(
int barIndex = 0,
ENUM_X_PRICE priceType = X_PRICE_LOW //
)
{
//
bool result = false;
//
// Normalize ...
barIndex = NormalizeBarIndex(barIndex);
//
// Validate ...
result = IsValid() &&
IsXValid(priceType);
if (!result)
{
return result;
}
//
bool isC = IsBarUnderBoundaryMin(barIndex, priceType);
bool isP = IsBarUnderBoundaryMin(barIndex + 1, priceType);
//
result = isC && !isP;
//
return result;
}
/**
* Count Over Boundary Max Bar's Prices ...
*
* @param barIndex: int, Specified Bar Index ...
* @param priceType: ENUM_X_PRICE, Specified Price Type ...
* @param loopback: int, Max Allowed Loopback Length ...
*
* @return ( int )
*/
int CountBarsOverBoundaryMax(
int barIndex = 0,
ENUM_X_PRICE priceType = X_PRICE_HIGH,
int loopback = 500 //
)
{
//
int result = 0;
//
// Normalize ...
loopback = NormalizeInt(loopback, 50);
barIndex = NormalizeBarIndex(barIndex);
//
// Validate ...
bool has = IsValid() &&
IsXValid(priceType);
if (!result)
{
return result;
}
//
// Do ...
int idx = barIndex;
while (idx < barIndex + loopback)
{
//
idx++;
has = IsBarOverBoundaryMax(idx);
if (!has)
{
break;
}
result++;
}
//
return result;
}
/**
* Count Over Boundary Min Bar's Prices ...
*
* @param barIndex: int, Specified Bar Index ...
* @param priceType: ENUM_X_PRICE, Specified Price Type ...
* @param loopback: int, Max Allowed Loopback Length ...
*
* @return ( int )
*/
int CountBarsOverBoundaryMin(
int barIndex = 0,
ENUM_X_PRICE priceType = X_PRICE_LOW,
int loopback = 500 //
)
{
//
int result = 0;
//
// Normalize ...
loopback = NormalizeInt(loopback, 50);
barIndex = NormalizeBarIndex(barIndex);
//
// Validate ...
bool has = IsValid() &&
IsXValid(priceType);
if (!result)
{
return result;
}
//
// Do ...
int idx = barIndex;
while (idx < barIndex + loopback)
{
//
idx++;
has = IsBarOverBoundaryMin(idx);
if (!has)
{
break;
}
result++;
}
//
return result;
}
/**
* Count Under Boundary Max Bar's Prices ...
*
* @param barIndex: int, Specified Bar Index ...
* @param priceType: ENUM_X_PRICE, Specified Price Type ...
* @param loopback: int, Max Allowed Loopback Length ...
*
* @return ( int )
*/
int CountBarsUnderBoundaryMax(
int barIndex = 0,
ENUM_X_PRICE priceType = X_PRICE_HIGH,
int loopback = 500 //
)
{
//
int result = 0;
//
// Normalize ...
loopback = NormalizeInt(loopback, 50);
barIndex = NormalizeBarIndex(barIndex);
//
// Validate ...
bool has = IsValid() &&
IsXValid(priceType);
if (!result)
{
return result;
}
//
// Do ...
int idx = barIndex;
while (idx < barIndex + loopback)
{
//
idx++;
has = IsBarUnderBoundaryMax(idx);
if (!has)
{
break;
}
result++;
}
//
return result;
}
/**
* Count Under Boundary Min Bar's Prices ...
*
* @param barIndex: int, Specified Bar Index ...
* @param priceType: ENUM_X_PRICE, Specified Price Type ...
* @param loopback: int, Max Allowed Loopback Length ...
*
* @return ( int )
*/
int CountBarsUnderBoundaryMin(
int barIndex = 0,
ENUM_X_PRICE priceType = X_PRICE_LOW,
int loopback = 500 //
)
{
//
int result = 0;
//
// Normalize ...
loopback = NormalizeInt(loopback, 50);
barIndex = NormalizeBarIndex(barIndex);
//
// Validate ...
bool has = IsValid() &&
IsXValid(priceType);
if (!result)
{
return result;
}
//
// Do ...
int idx = barIndex;
while (idx < barIndex + loopback)
{
//
idx++;
has = IsBarUnderBoundaryMin(idx);
if (!has)
{
break;
}
result++;
}
//
return result;
}
//
// Protected ...
protected:
@@ -1941,6 +1941,16 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
Print("OrderFlow ...");
}
//
XBoxZone legZone;
result = poiDetector.IsLegPattern(pBar, legZone);
if (result)
{
//
poiDrawer.DrawZone(legZone, structureDrawConfig.drawConfig);
Print("Leg Pattern Detected ...");
}
//
isBullish =
//