last worsk ...

This commit is contained in:
2024-12-25 11:54:00 +03:30
parent 43b3cdc6b9
commit f20dbaea13
11 changed files with 1662 additions and 20 deletions
@@ -881,6 +881,183 @@ class XC121SMCCycleHelper : public XCBase
return result;
}
/**
* Detect Cycle Trend Based On Pivots ...
*
* @param dir: ENUM_X_DIRECTION member Reference ...
* @param numberOfPivots: Integer ...
* @param maxAllowedLoopback: Integer ...
* @param minRequiredPivotVerification: Integer ...
*
* @return ( bool )
*/
bool DetectTrend(
ENUM_X_DIRECTION &dir,
int numberOfPivots = 3,
int maxAllowedLoopback = 576,
int minRequiredPivotVerification = 5 //
)
{
//
bool result = false;
//
dir = X_DIRECTION_NONE;
//
if (numberOfPivots < 3)
{
numberOfPivots = 3;
}
//
int index = 0;
double peaks[];
double vales[];
double peak = 0;
double vale = 0;
int peaksVerified = 0;
int valesVerified = 0;
bool canContinue = true;
while (canContinue)
{
//
// Peak ...
bool lookupPeak = ArraySize(peaks) < numberOfPivots;
if (lookupPeak)
{
//
double iPeak = mX121Helper.GetPeak(index);
if (iPeak == peak)
{
peaksVerified++;
}
else
{
//
if (peaksVerified >= minRequiredPivotVerification)
{
//
Add(
iPeak,
peaks //
);
//
peaksVerified = 0;
lookupPeak = ArraySize(peaks) < numberOfPivots;
}
else
{
peak = iPeak;
}
}
}
//
// Vale ...
bool lookupVale = ArraySize(vales) < numberOfPivots;
if (lookupVale)
{
//
double iVale = mX121Helper.GetVale(index);
if (iVale == vale)
{
valesVerified++;
}
else
{
//
if (valesVerified >= minRequiredPivotVerification)
{
//
Add(
iVale,
vales //
);
//
valesVerified = 0;
lookupVale = ArraySize(vales) < numberOfPivots;
}
else
{
vale = iVale;
}
}
}
//
canContinue = index < maxAllowedLoopback &&
(lookupPeak ||
lookupVale);
if (canContinue)
{
index++;
}
}
//
int verifications = 0;
//
// Peaks ...
int peaksCount = ArraySize(peaks);
if (!result &&
peaksCount == numberOfPivots)
{
//
verifications = 0;
for (int i = 0; i < peaksCount - 1; i++)
{
//
double iValue = peaks[i];
double nValue = peaks[i + 1];
if (iValue < nValue)
{
verifications++;
}
}
//
result = verifications == numberOfPivots - 1;
if (result)
{
dir = X_DIRECTION_BEARISH;
}
}
//
// Vales ...
int valesCount = ArraySize(vales);
if (!result &&
valesCount == numberOfPivots)
{
//
verifications = 0;
for (int i = 0; i < valesCount - 1; i++)
{
//
double iValue = vales[i];
double nValue = vales[i + 1];
if (iValue > nValue)
{
verifications++;
}
}
//
result = verifications == numberOfPivots - 1;
if (result)
{
dir = X_DIRECTION_BULLISH;
}
}
//
return result;
}
//
// Change Values Actions ...
@@ -1332,9 +1509,9 @@ class XC121SMCCycleHelper : public XCBase
/**
* Get Last Peaks Pivot Point ...
*
*
* @param pivot: XPVPivotPoint instance Reference ...
*
*
* @return ( bool )
*/
bool GetLastPeakPivotPoint(XPVPivotPoint &pivot)
@@ -1410,9 +1587,9 @@ class XC121SMCCycleHelper : public XCBase
/**
* Get Last Vale Pivot Point ...
*
*
* @param pivot: XPVPivotPoint instance Reference ...
*
*
* @return ( bool )
*/
bool GetLastValePivotPoint(XPVPivotPoint &pivot)