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)
@@ -372,13 +372,15 @@ struct X121SMCTradeData
//
double pVolume = _position.volume;
double pSL = NormalizePrice(_position.sl, _position.symbol);
double pTP = NormalizePrice(_position.tp, _position.symbol);
double pEntry = NormalizePrice(_position.entry, _position.symbol);
//
result =
//
IsValid() &&
sl == pSL &&
(sl == pSL ||
tp == pTP) &&
entry == pEntry &&
pVolume == volume &&
_position.IsValid() &&
@@ -389,6 +391,17 @@ struct X121SMCTradeData
//
;
//
if (!result)
{
//
result =
//
IsValid() &&
_position.IsValid() &&
_position.ticket == signal.positionId;
}
//
return result;
}
@@ -3324,6 +3337,21 @@ class XC121SMCTradeHandler : public XCBaseAlert
" PC (" + ToString(closeVolume) + ") On TP Level: " +
ToString(partialCloseOnTP) + " Successfully ...";
Alert(message);
//
// Finish Position ...
if (closeVolume == mainVolume)
{
//
Finish(
iPosition.ticket,
iPosition,
comment //
);
//
break;
}
}
}
}
@@ -3419,6 +3447,19 @@ class XC121SMCTradeHandler : public XCBaseAlert
);
if (IsValidSize(closedPositionsCount))
{
//
// Finish Positions and Clear Data ...
for (int i = 0; i < ArraySize(positions); i++)
{
//
XPosition iPosition = positions[i];
Finish(
iPosition.ticket,
iPosition,
comment //
);
}
//
string message = "Hedge (" + ToString(count) + ") Positions By: " +
ToString(profitSummary) + " Successfully ...";