This commit is contained in:
2025-10-30 00:07:23 +03:30
parent 90988de7bf
commit 574c79afcc
6 changed files with 2209 additions and 961 deletions
+668 -114
View File
@@ -3335,6 +3335,82 @@ class XCXFIMAHelperParser : XCBase
//
// XATR ...
bool GetATRBox(
XBoxZone &zone,
int barIndex = 0,
int loopback = 3 //
)
{
//
bool result = false;
//
// Prepare ...
zone.Clean();
//
// Normalize ...
loopback = NormalizeInt(loopback, 1);
barIndex = NormalizeBarIndex(barIndex);
//
// Validate ...
result = IsValid();
if (!result)
{
return result;
}
//
double lowers[];
double uppers[];
double iUpper = EMPTY_VALUE;
double iLower = EMPTY_VALUE;
double upper = helper.GetATRRawBandUpper(barIndex);
double lower = helper.GetATRRawBandLower(barIndex);
int idx = barIndex;
while (idx <= barIndex + loopback)
{
//
idx++;
iUpper = helper.GetATRRawBandUpper(idx);
iLower = helper.GetATRRawBandLower(idx);
Add(iUpper, uppers);
Add(iLower, lowers);
}
//
zone.symbol = symbol;
zone.period = period;
zone.upper = GetMax(uppers);
zone.lower = GetMin(lowers);
zone.dir =
(upper > zone.upper ||
lower > zone.lower)
? X_DIRECTION_BULLISH
: (upper < zone.upper ||
lower < zone.lower)
? X_DIRECTION_BEARISH
: X_DIRECTION_NONE;
zone.type = ToXString(XFIMA_PIVOT_ATR);
zone.to = GetBarTime(symbol, period, barIndex);
zone.at = zone.to;
zone.from = GetBarTime(symbol, period, barIndex + loopback);
//
result = zone.IsValid();
//
// Cleanup ...
if (!result)
{
zone.Clean();
}
//
return result;
}
/**
* Check Price is Over ATR Band Lower ...
*
@@ -3533,10 +3609,10 @@ class XCXFIMAHelperParser : XCBase
/**
* Check Price is Crossed Over ATR Band Lower ...
*
*
* @param barIndex: int, Specified Bar Index ...
* @param priceType: ENUM_X_PRICE, Specified Price Type ...
*
*
* @return ( bool )
*/
bool IsCrossedOverATRBandLower(
@@ -3572,10 +3648,10 @@ class XCXFIMAHelperParser : XCBase
/**
* Check Price is Crossed Under ATR Band Lower ...
*
*
* @param barIndex: int, Specified Bar Index ...
* @param priceType: ENUM_X_PRICE, Specified Price Type ...
*
*
* @return ( bool )
*/
bool IsCrossedUnderATRBandLower(
@@ -3611,10 +3687,10 @@ class XCXFIMAHelperParser : XCBase
/**
* Check Price is Crossed Over ATR Band Upper ...
*
*
* @param barIndex: int, Specified Bar Index ...
* @param priceType: ENUM_X_PRICE, Specified Price Type ...
*
*
* @return ( bool )
*/
bool IsCrossedOverATRBandUpper(
@@ -3650,10 +3726,10 @@ class XCXFIMAHelperParser : XCBase
/**
* Check Price is Crossed Under ATR Band Upper ...
*
*
* @param barIndex: int, Specified Bar Index ...
* @param priceType: ENUM_X_PRICE, Specified Price Type ...
*
*
* @return ( bool )
*/
bool IsCrossedUnderATRBandUpper(
@@ -4047,6 +4123,152 @@ class XCXFIMAHelperParser : XCBase
return result;
}
/**
* Check Cycle MA Happens Over Last ...
*
* @param barIndex: int, Specified Bar Index ...
*
* @return ( bool )
*/
bool IsSCMAOverLast(int barIndex = 0)
{
//
bool result = false;
//
// Normalize ...
barIndex = NormalizeBarIndex(barIndex);
//
// Validate ...
result = IsValid();
if (!result)
{
return result;
}
//
double cValue = helper.GetSCMA(barIndex);
double pValue = helper.GetSCMA(barIndex + 1);
//
result =
NotEmptyZero(cValue) &&
NotEmptyZero(pValue) &&
cValue > pValue;
//
return result;
}
/**
* Check Cycle MA Happens Under Last ...
*
* @param barIndex: int, Specified Bar Index ...
*
* @return ( bool )
*/
bool IsSCMAUnderLast(int barIndex = 0)
{
//
bool result = false;
//
// Normalize ...
barIndex = NormalizeBarIndex(barIndex);
//
// Validate ...
result = IsValid();
if (!result)
{
return result;
}
//
double cValue = helper.GetSCMA(barIndex);
double pValue = helper.GetSCMA(barIndex + 1);
//
result =
NotEmptyZero(cValue) &&
NotEmptyZero(pValue) &&
cValue < pValue;
//
return result;
}
/**
* Check Cycle MA Crossed Over Last ...
*
* @param barIndex: int, Specified Bar Index ...
*
* @return ( bool )
*/
bool IsSCMACrossedOverLast(int barIndex = 0)
{
//
bool result = false;
//
// Normalize ...
barIndex = NormalizeBarIndex(barIndex);
//
// Validate ...
result = IsValid();
if (!result)
{
return result;
}
//
bool isC = IsSCMAOverLast(barIndex);
bool isP = IsSCMAOverLast(barIndex + 1);
//
result = isC && !isP;
//
return result;
}
/**
* Check Cycle MA Crossed Under Last ...
*
* @param barIndex: int, Specified Bar Index ...
*
* @return ( bool )
*/
bool IsSCMACrossedUnderLast(int barIndex = 0)
{
//
bool result = false;
//
// Normalize ...
barIndex = NormalizeBarIndex(barIndex);
//
// Validate ...
result = IsValid();
if (!result)
{
return result;
}
//
bool isC = IsSCMAUnderLast(barIndex);
bool isP = IsSCMAUnderLast(barIndex + 1);
//
result = isC && !isP;
//
return result;
}
/**
* Check Cycle Lows is Same ...
*
@@ -5166,6 +5388,152 @@ class XCXFIMAHelperParser : XCBase
return result;
}
/**
* Check Cycle MA Happens Over Last ...
*
* @param barIndex: int, Specified Bar Index ...
*
* @return ( bool )
*/
bool IsMCMAOverLast(int barIndex = 0)
{
//
bool result = false;
//
// Normalize ...
barIndex = NormalizeBarIndex(barIndex);
//
// Validate ...
result = IsValid();
if (!result)
{
return result;
}
//
double cValue = helper.GetMCMA(barIndex);
double pValue = helper.GetMCMA(barIndex + 1);
//
result =
NotEmptyZero(cValue) &&
NotEmptyZero(pValue) &&
cValue > pValue;
//
return result;
}
/**
* Check Cycle MA Happens Under Last ...
*
* @param barIndex: int, Specified Bar Index ...
*
* @return ( bool )
*/
bool IsMCMAUnderLast(int barIndex = 0)
{
//
bool result = false;
//
// Normalize ...
barIndex = NormalizeBarIndex(barIndex);
//
// Validate ...
result = IsValid();
if (!result)
{
return result;
}
//
double cValue = helper.GetMCMA(barIndex);
double pValue = helper.GetMCMA(barIndex + 1);
//
result =
NotEmptyZero(cValue) &&
NotEmptyZero(pValue) &&
cValue < pValue;
//
return result;
}
/**
* Check Cycle MA Crossed Over Last ...
*
* @param barIndex: int, Specified Bar Index ...
*
* @return ( bool )
*/
bool IsMCMACrossedOverLast(int barIndex = 0)
{
//
bool result = false;
//
// Normalize ...
barIndex = NormalizeBarIndex(barIndex);
//
// Validate ...
result = IsValid();
if (!result)
{
return result;
}
//
bool isC = IsMCMAOverLast(barIndex);
bool isP = IsMCMAOverLast(barIndex + 1);
//
result = isC && !isP;
//
return result;
}
/**
* Check Cycle MA Crossed Under Last ...
*
* @param barIndex: int, Specified Bar Index ...
*
* @return ( bool )
*/
bool IsMCMACrossedUnderLast(int barIndex = 0)
{
//
bool result = false;
//
// Normalize ...
barIndex = NormalizeBarIndex(barIndex);
//
// Validate ...
result = IsValid();
if (!result)
{
return result;
}
//
bool isC = IsMCMAUnderLast(barIndex);
bool isP = IsMCMAUnderLast(barIndex + 1);
//
result = isC && !isP;
//
return result;
}
/**
* Check Cycle Lows is Same ...
*
@@ -6285,6 +6653,152 @@ class XCXFIMAHelperParser : XCBase
return result;
}
/**
* Check Cycle MA Happens Over Last ...
*
* @param barIndex: int, Specified Bar Index ...
*
* @return ( bool )
*/
bool IsLCMAOverLast(int barIndex = 0)
{
//
bool result = false;
//
// Normalize ...
barIndex = NormalizeBarIndex(barIndex);
//
// Validate ...
result = IsValid();
if (!result)
{
return result;
}
//
double cValue = helper.GetLCMA(barIndex);
double pValue = helper.GetLCMA(barIndex + 1);
//
result =
NotEmptyZero(cValue) &&
NotEmptyZero(pValue) &&
cValue > pValue;
//
return result;
}
/**
* Check Cycle MA Happens Under Last ...
*
* @param barIndex: int, Specified Bar Index ...
*
* @return ( bool )
*/
bool IsLCMAUnderLast(int barIndex = 0)
{
//
bool result = false;
//
// Normalize ...
barIndex = NormalizeBarIndex(barIndex);
//
// Validate ...
result = IsValid();
if (!result)
{
return result;
}
//
double cValue = helper.GetLCMA(barIndex);
double pValue = helper.GetLCMA(barIndex + 1);
//
result =
NotEmptyZero(cValue) &&
NotEmptyZero(pValue) &&
cValue < pValue;
//
return result;
}
/**
* Check Cycle MA Crossed Over Last ...
*
* @param barIndex: int, Specified Bar Index ...
*
* @return ( bool )
*/
bool IsLCMACrossedOverLast(int barIndex = 0)
{
//
bool result = false;
//
// Normalize ...
barIndex = NormalizeBarIndex(barIndex);
//
// Validate ...
result = IsValid();
if (!result)
{
return result;
}
//
bool isC = IsLCMAOverLast(barIndex);
bool isP = IsLCMAOverLast(barIndex + 1);
//
result = isC && !isP;
//
return result;
}
/**
* Check Cycle MA Crossed Under Last ...
*
* @param barIndex: int, Specified Bar Index ...
*
* @return ( bool )
*/
bool IsLCMACrossedUnderLast(int barIndex = 0)
{
//
bool result = false;
//
// Normalize ...
barIndex = NormalizeBarIndex(barIndex);
//
// Validate ...
result = IsValid();
if (!result)
{
return result;
}
//
bool isC = IsLCMAUnderLast(barIndex);
bool isP = IsLCMAUnderLast(barIndex + 1);
//
result = isC && !isP;
//
return result;
}
/**
* Check Cycle Lows is Same ...
*
@@ -7404,6 +7918,152 @@ class XCXFIMAHelperParser : XCBase
return result;
}
/**
* Check Cycle MA Happens Over Last ...
*
* @param barIndex: int, Specified Bar Index ...
*
* @return ( bool )
*/
bool IsHCMAOverLast(int barIndex = 0)
{
//
bool result = false;
//
// Normalize ...
barIndex = NormalizeBarIndex(barIndex);
//
// Validate ...
result = IsValid();
if (!result)
{
return result;
}
//
double cValue = helper.GetHCMA(barIndex);
double pValue = helper.GetHCMA(barIndex + 1);
//
result =
NotEmptyZero(cValue) &&
NotEmptyZero(pValue) &&
cValue > pValue;
//
return result;
}
/**
* Check Cycle MA Happens Under Last ...
*
* @param barIndex: int, Specified Bar Index ...
*
* @return ( bool )
*/
bool IsHCMAUnderLast(int barIndex = 0)
{
//
bool result = false;
//
// Normalize ...
barIndex = NormalizeBarIndex(barIndex);
//
// Validate ...
result = IsValid();
if (!result)
{
return result;
}
//
double cValue = helper.GetHCMA(barIndex);
double pValue = helper.GetHCMA(barIndex + 1);
//
result =
NotEmptyZero(cValue) &&
NotEmptyZero(pValue) &&
cValue < pValue;
//
return result;
}
/**
* Check Cycle MA Crossed Over Last ...
*
* @param barIndex: int, Specified Bar Index ...
*
* @return ( bool )
*/
bool IsHCMACrossedOverLast(int barIndex = 0)
{
//
bool result = false;
//
// Normalize ...
barIndex = NormalizeBarIndex(barIndex);
//
// Validate ...
result = IsValid();
if (!result)
{
return result;
}
//
bool isC = IsHCMAOverLast(barIndex);
bool isP = IsHCMAOverLast(barIndex + 1);
//
result = isC && !isP;
//
return result;
}
/**
* Check Cycle MA Crossed Under Last ...
*
* @param barIndex: int, Specified Bar Index ...
*
* @return ( bool )
*/
bool IsHCMACrossedUnderLast(int barIndex = 0)
{
//
bool result = false;
//
// Normalize ...
barIndex = NormalizeBarIndex(barIndex);
//
// Validate ...
result = IsValid();
if (!result)
{
return result;
}
//
bool isC = IsHCMAUnderLast(barIndex);
bool isP = IsHCMAUnderLast(barIndex + 1);
//
result = isC && !isP;
//
return result;
}
/**
* Check Cycle Lows is Same ...
*
@@ -9209,112 +9869,6 @@ class XCXFIMAHelperParser : XCBase
//
// Other Tools ...
int CollectPivots(
XPivot &pivots[],
int barIndex = 0,
int loopback = 500 //
)
{
//
int result = 0;
//
// Prepare ...
XClean(pivots);
//
// Normalize ...
loopback = NormalizeInt(loopback, 50);
barIndex = NormalizeBarIndex(barIndex);
//
// Validate ...
bool has = IsValid();
if (!has)
{
return result;
}
//
has = false;
XOHCL tmpBar;
XPivot tmpPivot;
double tmpValue;
datetime tmpTime;
bool isBullish = false;
bool isBearish = false;
string tmpSymbol = symbol;
ENUM_TIMEFRAMES tmpPeriod = period;
ENUM_X_DIRECTION tmpDir = X_DIRECTION_NONE;
for (int i = barIndex; i < barIndex + loopback; i++)
{
//
tmpBar.Clean();
tmpPivot.Clean();
//
has = tmpBar.Init(tmpSymbol, tmpPeriod, i);
if (!has)
{
continue;
}
//
// XSAR ...
isBullish = IsSARSwitchedToBullish(i);
isBearish = IsSARSwitchedToBearish(i);
has = isBullish || isBearish;
if (has)
{
}
//
// XMA Fast / Slow ...
//
// States ...
isBullish = IsMASlowSwitchedToBullish(i);
isBearish = IsMASlowSwitchedToBearish(i);
has = isBullish || isBearish;
if (has)
{
}
//
// Crossed Fast Slow ...
isBullish = IsMAFastCrossedOverSlow(i);
isBearish = IsMAFastCrossedUnderSlow(i);
has = isBullish || isBearish;
if (has)
{
}
//
// Crossed Last ...
isBullish = IsMASlowCrossedOverLast(i);
isBearish = IsMASlowCrossedUnderLast(i);
has = isBullish || isBearish;
if (has)
{
}
//
// XHK ...
isBullish = IsHKSwitchedToBullish(i);
isBearish = IsHKSwitchedToBearish(i);
has = isBullish || isBearish;
if (has)
{
}
}
//
result = ArraySize(pivots);
//
return result;
}
//
// Protected ...
protected: