This commit is contained in:
2025-04-25 02:04:21 +03:30
parent aa648284cf
commit e1bcf58bc8
4 changed files with 384 additions and 13 deletions
@@ -617,6 +617,12 @@ class XCXCAEAPOIDetector : public XCBase
double ticksDividerInPoints; // Ticks and Volume Detection Divider in Point ...
ENUM_TIMEFRAMES ticksDetectionPerid; // Ticks and Volume Detection Loopback ...
//
// TREND ...
XBoxZone trendPivotP; // Prev Pivot of Market Trend ...
XBoxZone trendPivotC; // Current Pivot of Market Trend ...
ENUM_X_DIRECTION trendDir; // Trend Direction ...
//
// TICK Pivots ...
@@ -744,6 +750,11 @@ class XCXCAEAPOIDetector : public XCBase
valeSupSWLPivot.Clean();
peakResSWHPivot.Clean();
//
trendPivotP.Clean();
trendPivotC.Clean();
trendDir = X_DIRECTION_NONE;
//
CleanPivots();
@@ -784,6 +795,7 @@ class XCXCAEAPOIDetector : public XCBase
detectPVFVGBearishPivots = true;
//
trendDir = X_DIRECTION_NONE;
}
//
@@ -1900,6 +1912,8 @@ class XCXCAEAPOIDetector : public XCBase
}
//
// Detect Market Trend ...
DetectMarketTrend();
}
//
@@ -2517,6 +2531,8 @@ class XCXCAEAPOIDetector : public XCBase
ReversePivots();
//
// Detect Market Trend ...
DetectMarketTrend();
}
//
@@ -2674,6 +2690,24 @@ class XCXCAEAPOIDetector : public XCBase
return result;
}
//
bool MarketTrend(ENUM_X_DIRECTION &trend)
{
//
bool result = false;
//
// Update Market Trend ...
DetectMarketTrend();
//
trend = trendDir;
result = HasDirection(trend);
//
return result;
}
//
// Counters ...
@@ -3318,6 +3352,141 @@ class XCXCAEAPOIDetector : public XCBase
return result;
}
//
void DetectMarketTrend()
{
//
int idx = -1;
int count = 0;
bool has = false;
//
XBoxZone tmp[];
count = FillPivots(tmp);
has = HasChild(tmp);
if (!has)
{
return;
}
//
XBoxZone cPivot;
XBoxZone pPivot;
ENUM_X_DIRECTION dir = X_DIRECTION_NONE;
while (HasChild(tmp))
{
//
XBoxZone iPivot;
idx = GetYoungest(tmp);
has = IsValidIndex(idx);
if (!has)
{
//
iPivot.Clean();
break;
}
//
ArrayRemove(
tmp,
idx,
1 //
);
//
// Check Pivot Type is Peak or Vale ...
has =
Contains(
"XCA_PEAKSWHRES",
iPivot.type //
) ||
Contains(
"XCA_VALESWLSUP",
iPivot.type //
);
if (!has)
{
//
iPivot.Clean();
break;
}
//
// Check Can Set CPivot ...
bool canSetCPivot =
!cPivot.IsValid()
? true
: cPivot.from < iPivot.from;
if (canSetCPivot)
{
//
if (cPivot.IsValid())
{
pPivot = cPivot;
}
//
cPivot = iPivot;
}
//
// Check Can Set PPivot ...
bool canSetPPivot =
!cPivot.IsValid()
? false
: iPivot.from < cPivot.from
? !pPivot.IsValid()
? true
: cPivot.from < iPivot.from
: false;
if (canSetPPivot)
{
pPivot = iPivot;
}
//
has = cPivot.IsValid() &&
pPivot.IsValid();
if (has)
{
//
iPivot.Clean();
break;
}
//
iPivot.Clean();
}
//
// Check Resources for Detecting Conditions ...
bool hasTrend =
//
cPivot.IsValid() &&
pPivot.IsValid() &&
cPivot.dir == pPivot.dir &&
cPivot.from > pPivot.from &&
(IsBullish(cPivot.dir)
? cPivot.lower > pPivot.lower
: cPivot.upper < pPivot.upper);
//
;
if (hasTrend)
{
//
trendPivotC = cPivot;
trendPivotP = pPivot;
trendDir = cPivot.dir;
}
//
Clean(tmp);
cPivot.Clean();
pPivot.Clean();
//
}
//
};