This commit is contained in:
2025-01-23 20:52:45 +03:30
parent aa3630bc82
commit 330c70088c
10 changed files with 3085 additions and 774 deletions
+35 -706
View File
@@ -330,15 +330,10 @@ bool DetectX121SMCXSiganlSetup(
//
XOHCL zBar;
result = decisionCycleHelper.GetBar(
result = consolidationCycleHelper.GetBar(
zBar,
zIndex //
);
// zBar.Init(
// symbol,
// period,
// zIndex //
// );
if (!result)
{
return result;
@@ -346,15 +341,10 @@ bool DetectX121SMCXSiganlSetup(
//
XOHCL cBar;
result = decisionCycleHelper.GetBar(
result = consolidationCycleHelper.GetBar(
cBar,
cIndex //
);
// cBar.Init(
// symbol,
// period,
// cIndex //
// );
if (!result)
{
return result;
@@ -362,15 +352,10 @@ bool DetectX121SMCXSiganlSetup(
//
XOHCL pBar;
result = decisionCycleHelper.GetBar(
result = consolidationCycleHelper.GetBar(
pBar,
pIndex //
);
// pBar.Init(
// symbol,
// period,
// pIndex //
// );
if (!result)
{
return result;
@@ -795,659 +780,6 @@ bool DetectX121SMCXSiganlSetup(
//
;
//
// Detect Pivot ...
//
double pivotPremiumDiscount = 0;
//
bool isPivotUpperUpBreaked = false;
bool isPivotUpperDownBreaked = false;
bool isPivotUpperDownRejected = false;
//
bool isPivotLowerUpBreaked = false;
bool isPivotLowerUpRejected = false;
bool isPivotLowerDownBreaked = false;
//
bool isPriceInPivotPremium = false;
bool isPriceInPivotDiscount = false;
//
bool isPivotPremiumUpBreaked = false;
bool isPivotPremiumDownBreaked = false;
bool isPivotPremiumUpRejected = false;
bool isPivotPremiumDownRejected = false;
//
bool isPivotDiscountUpBreaked = false;
bool isPivotDiscountDownBreaked = false;
bool isPivotDiscountUpRejected = false;
bool isPivotDiscountDownRejected = false;
//
bool hasPivot = conditions.pivotZone.IsValid();
//
if (!hasPivot)
{
//
bool hasPeak = conditions.HasPeak();
bool hasVale = conditions.HasVale();
//
int higherPeakIDX = -1;
int higherPeakStartIDX = -1;
datetime higherPeakTime = NULL;
double higherPeak = decisionCycleHelper
.mX121Helper
.xpvHelper
.GetHigherPeak(
higherPeakIDX,
decisionXConditions.peaksBuffer[1] //
);
bool hasHigherPeak =
higherPeak > 0 &&
IsValidIndex(higherPeakIDX);
if (hasHigherPeak)
{
//
// Detect Higher Peak Start Index ...
int idx = higherPeakIDX;
bool canContinue = true;
while (canContinue)
{
//
double iPeak = decisionCycleHelper
.mX121Helper
.xpvHelper
.GetPeak(idx);
canContinue = iPeak == higherPeak;
if (!canContinue)
{
break;
}
//
idx++;
}
//
if (idx > higherPeakIDX)
{
higherPeakStartIDX = idx - 1;
}
}
//
int lowerValeIDX = -1;
int lowerValeStartIDX = -1;
datetime lowerValeTime = NULL;
double lowerVale = decisionCycleHelper
.mX121Helper
.xpvHelper
.GetLowerVale(
lowerValeIDX,
decisionXConditions.valesBuffer[1] //
);
bool hasLowerVale =
lowerVale > 0 &&
IsValidIndex(lowerValeIDX);
if (hasLowerVale)
{
//
// Detect Lower Vale Start Index ...
int idx = lowerValeIDX;
bool canContinue = true;
while (canContinue)
{
//
double iVale = decisionCycleHelper
.mX121Helper
.xpvHelper
.GetVale(idx);
canContinue = iVale == lowerVale;
if (!canContinue)
{
break;
}
//
idx++;
}
//
if (idx > lowerValeIDX)
{
lowerValeStartIDX = idx - 1;
}
}
//
// Now we Have to Detect Higher Peak and Lower Vale
// Zones ...
//
if (hasHigherPeak)
{
//
XOHCL higherPeakStartBar;
bool isInited = higherPeakStartBar.Init(
symbol,
period,
higherPeakStartIDX //
);
if (isInited)
{
higherPeakTime = higherPeakStartBar.time;
}
}
//
if (hasLowerVale)
{
//
XOHCL lowerValeStartBar;
bool isInited = lowerValeStartBar.Init(
symbol,
period,
lowerValeStartIDX //
);
if (isInited)
{
lowerValeTime = lowerValeStartBar.time;
}
}
//
bool isNewPeak =
!hasPeak &&
hasLowerVale &&
hasHigherPeak &&
decisionXConditions.isNewPeakUnderLast;
if (isNewPeak)
{
//
conditions.pvType = XPV_PEAK;
//
conditions.peakTime = cTime;
conditions.peak = decisionXConditions.peaksBuffer[1];
//
conditions.higherPeakTime = higherPeakTime;
conditions.higherPeak = higherPeak;
//
conditions.valeTime = cTime;
conditions.vale = decisionXConditions.valesBuffer[1];
//
conditions.lowerValeTime = lowerValeTime;
conditions.lowerVale = lowerVale;
//
hasPeak = conditions.HasPeak();
hasVale = conditions.HasVale();
}
//
bool isNewVale =
!hasVale &&
!isNewPeak &&
hasLowerVale &&
hasHigherPeak &&
decisionXConditions.isNewValeOverLast;
if (isNewVale)
{
//
conditions.pvType = XPV_PEAK;
//
conditions.peakTime = cTime;
conditions.peak = decisionXConditions.peaksBuffer[1];
//
conditions.higherPeakTime = higherPeakTime;
conditions.higherPeak = higherPeak;
//
conditions.valeTime = cTime;
conditions.vale = decisionXConditions.valesBuffer[1];
//
conditions.lowerValeTime = lowerValeTime;
conditions.lowerVale = lowerVale;
//
hasPeak = conditions.HasPeak();
hasVale = conditions.HasVale();
}
//
if (isNewPeak || isNewVale)
{
//
XPVPivot pivot;
//
pivot.symbol = symbol;
pivot.period = period;
//
pivot.repetition = MathMax(
higherPeakIDX,
lowerValeIDX //
);
pivot.type = conditions.pvType;
//
pivot.upper = higherPeak;
pivot.lower = lowerVale;
//
bool isHigherPeakOlder =
conditions.higherPeakTime < conditions.lowerValeTime;
//
pivot.to = cTime;
pivot.from =
isHigherPeakOlder
? conditions.higherPeakTime
: conditions.lowerValeTime;
//
pivot.type =
isHigherPeakOlder
? XPV_PEAK
: XPV_VALE;
//
hasPivot = pivot.IsValid();
if (hasPivot)
{
conditions.pivotZone = pivot;
}
//
}
//
// Has Pivot ...
hasPivot = conditions.pivotZone.IsValid();
}
//
if (hasPivot)
{
//
// Check Pivot Validation ...
//
bool isPivotDied =
//
(cBar.low > conditions.pivotZone.upper &&
cBar.close > conditions.pivotZone.upper)
//
||
//
(cBar.high < conditions.pivotZone.lower &&
cBar.close < conditions.pivotZone.lower)
//
;
if (isPivotDied)
{
conditions.Clean();
}
//
hasPivot = conditions.pivotZone.IsValid();
if (hasPivot)
{
//
// Detect Pivot States ...
//
XPOIState analysePivotState;
DetectPivotPOIs(
conditions.pivotZone,
analyseState,
analysePivotState //
);
//
XPOIState decisionPivotState;
DetectPivotPOIs(
conditions.pivotZone,
decisionState,
decisionPivotState //
);
//
// Combine two State ...
XPOIState combinedPivotState;
XPOIState iStates[];
// AddRef(
// analysePivotState,
// iStates //
// );
AddRef(
decisionPivotState,
iStates //
);
CombineStates(
combinedPivotState,
iStates //
);
combinedPivotState = decisionPivotState;
//
ArrayFree(iStates);
//
combinedPivotState.time = decisionPivotState.time;
combinedPivotState.symbol = decisionPivotState.symbol;
combinedPivotState.period = decisionPivotState.period;
//
// Hold Only Areas Which on Upper or Lower bondary of Pivot Zone ...
FilterPivotState(
conditions.pivotZone,
combinedPivotState //
);
//
conditions.pivotZone.state = combinedPivotState;
//
// Calculate Pivot Ticks Zone ...
//
int ticksLevels = decisionCycleHelper
.mPOIDetector
.TicksRangeZoneLevel();
int ticksRange = decisionCycleHelper
.mPOIDetector
.TicksRangeZoneRange();
//
CalculatePivotTickZone(
conditions.pivotZone,
ticksLevels,
ticksRange //
);
//
// Try to Fill up Pivot Conditions ...
//
XOHCL pivotCBar;
bool isCInited = triggerCycleHelper.GetBar(
pivotCBar,
cIndex //
);
//
XOHCL pivotPBar;
bool isPInited = triggerCycleHelper.GetBar(
pivotPBar,
pIndex //
);
//
double upper = conditions.pivotZone.upper;
double lower = conditions.pivotZone.lower;
pivotPremiumDiscount = conditions.pivotZone.CalculateMid();
//
// Pivot Upper ...
//
isPivotUpperUpBreaked =
isCInited &&
IsBarBreak(
upper,
X_DIRECTION_BULLISH,
pivotCBar //
);
//
isPivotUpperDownBreaked =
isCInited &&
IsBarBreak(
upper,
X_DIRECTION_BEARISH,
pivotCBar //
);
//
isPivotUpperDownRejected =
isCInited &&
IsBarReject(
upper,
X_DIRECTION_BEARISH,
pivotCBar //
);
//
// Pivot Lower ...
//
isPivotLowerUpBreaked =
isCInited &&
IsBarBreak(
lower,
X_DIRECTION_BULLISH,
pivotCBar //
);
//
isPivotLowerUpRejected =
isCInited &&
IsBarReject(
lower,
X_DIRECTION_BULLISH,
pivotCBar //
);
//
isPivotLowerDownBreaked =
isCInited &&
IsBarBreak(
lower,
X_DIRECTION_BEARISH,
pivotCBar //
);
//
// Pivot Premium / Discount ...
//
bool isPriceInPivotPremium =
isCInited &&
ask < upper &&
bid < upper &&
ask > pivotPremiumDiscount &&
bid > pivotPremiumDiscount;
//
bool isPriceInPivotDiscount =
isCInited &&
ask > lower &&
bid > lower &&
ask < pivotPremiumDiscount &&
bid < pivotPremiumDiscount;
//
//
//
//
isPivotPremiumUpBreaked =
isCInited &&
isPInited &&
IsBarBreak(
pivotPremiumDiscount,
X_DIRECTION_BULLISH,
pivotCBar //
) &&
pivotPBar.high > pivotPremiumDiscount;
//
isPivotPremiumDownBreaked =
isCInited &&
isPInited &&
IsBarBreak(
pivotPremiumDiscount,
X_DIRECTION_BEARISH,
pivotCBar //
) &&
pivotPBar.high > pivotPremiumDiscount;
//
isPivotPremiumUpRejected =
isCInited &&
isPInited &&
IsBarReject(
pivotPremiumDiscount,
X_DIRECTION_BULLISH,
pivotCBar //
) &&
pivotPBar.high > pivotPremiumDiscount;
//
isPivotPremiumDownRejected =
isCInited &&
isPInited &&
IsBarReject(
pivotPremiumDiscount,
X_DIRECTION_BEARISH,
pivotCBar //
) &&
pivotPBar.high > pivotPremiumDiscount;
//
//
//
//
isPivotDiscountUpBreaked =
isCInited &&
isPInited &&
IsBarBreak(
pivotPremiumDiscount,
X_DIRECTION_BULLISH,
pivotCBar //
) &&
pivotPBar.low < pivotPremiumDiscount;
//
isPivotDiscountDownBreaked =
isCInited &&
isPInited &&
IsBarBreak(
pivotPremiumDiscount,
X_DIRECTION_BEARISH,
pivotCBar //
) &&
pivotPBar.low < pivotPremiumDiscount;
//
isPivotDiscountUpRejected =
isCInited &&
isPInited &&
IsBarReject(
pivotPremiumDiscount,
X_DIRECTION_BULLISH,
pivotCBar //
) &&
pivotPBar.low < pivotPremiumDiscount;
//
isPivotDiscountDownRejected =
isCInited &&
isPInited &&
IsBarReject(
pivotPremiumDiscount,
X_DIRECTION_BEARISH,
pivotCBar //
) &&
pivotPBar.low < pivotPremiumDiscount;
//
// Detect Bar Patterns ...
//
if (isCBarBullishRejected)
{
//
int count = conditions.pivotZone.state.CountBullishRejectionBars();
isCBarBullishRejected = IsValidSize(count);
if (isCBarBullishRejected)
{
//
bool hasBar = false;
for (int i = 0; i < count; i++)
{
//
XCRejectionBar *iBar = conditions.pivotZone.state.bullishRejectionBars[i];
//
hasBar = iBar.BarTime() == cBar.time;
if (hasBar)
{
break;
}
}
//
isCBarBullishRejected = hasBar;
}
}
//
if (isCBarBearishRejected)
{
//
int count = conditions.pivotZone.state.CountBearishRejectionBars();
isCBarBearishRejected = IsValidSize(count);
if (isCBarBearishRejected)
{
//
bool hasBar = false;
for (int i = 0; i < count; i++)
{
//
XCRejectionBar *iBar = conditions.pivotZone.state.bearishRejectionBars[i];
//
hasBar = iBar.BarTime() == cBar.time;
if (hasBar)
{
break;
}
}
//
isCBarBearishRejected = hasBar;
}
}
//
// Draw Pivot ...
// XCBaseObject *drawnObjects[];
// triggerCycleHelper.mPOIDetector.mDrawer.DrawPivot(
// conditions.pivotZone,
// drawnObjects,
// true, // Draw State ...
// false, // State As Box ...
// true // Tick Zone ...
// );
}
}
//
//
//
@@ -1458,30 +790,30 @@ bool DetectX121SMCXSiganlSetup(
//
bool isCondition1Bullish =
//
hasPivot &&
// decisionXConditions.isRsiSlopeBullish &&
// analyseXConditions.isRsiSlopeBullish &&
// verificationXConditions.isRsiSlopeBullish &&
// consolidationXConditions.isRsiSlopeBullish &&
// visionXConditions.isRsiCrossedOverOverSold
//
(isCBarBullishRejected &&
pBar.open > cBar.close &&
decisionXConditions.isNewValeUnderLast &&
decisionXConditions.valesBuffer[1] > conditions.pivotZone.lower) &&
//
//
true
// cBar.IsBullish() &&
decisionXConditions.isBreakedUpPrevAtrLower // &&
// cBar.open > analyseXConditions.atrLowerBuffer[0]
//
;
//
bool isCondition1Bearish =
//
hasPivot &&
// decisionXConditions.isRsiSlopeBearish &&
// analyseXConditions.isRsiSlopeBearish &&
// verificationXConditions.isRsiSlopeBearish &&
// consolidationXConditions.isRsiSlopeBearish &&
// visionXConditions.isRsiCrossedUnderOverBought
//
(isCBarBearishRejected &&
pBar.open < cBar.close &&
decisionXConditions.isNewPeakOverLast &&
decisionXConditions.peaksBuffer[1] < conditions.pivotZone.upper) &&
//
//
true
// cBar.IsBearish() &&
decisionXConditions.isBreakedDownPrevAtrUpper // &&
// cBar.open < analyseXConditions.atrUpperBuffer[0]
//
;
@@ -1506,21 +838,16 @@ bool DetectX121SMCXSiganlSetup(
// Manipulate Conditions Point ...
//
conditions.point = pivotPremiumDiscount;
conditions.point = point;
//
// Manipulate Conditions Pivot ...
//
conditions.pivot =
isCondition1Bullish
? conditions.pivotZone.upper
: conditions.pivotZone.lower;
//
// conditions.Clean();
// isCondition1Bullish = false;
// isCondition1Bearish = false;
// conditions.pivot =
// isCondition1Bullish
// ? conditions.pivotZone.upper
// : conditions.pivotZone.lower;
}
//
@@ -1532,6 +859,7 @@ bool DetectX121SMCXSiganlSetup(
//
// false
isCondition1Bullish
// isCondition2Bullish
//
;
@@ -1540,6 +868,7 @@ bool DetectX121SMCXSiganlSetup(
//
// false
isCondition1Bearish
// isCondition2Bearish
//
;
@@ -1905,15 +1234,15 @@ bool DetectX121SMCXSiganlTrigger(
//
double point = conditions.point;
bool isPointBreaked =
isBullish
? ask > point && bid > point
: ask < point && bid < point;
// bool isPointBreaked = IsBarBreak(
// point,
// setupDir,
// cBar //
// );
// bool isPointBreaked =
// isBullish
// ? ask > point && bid > point
// : ask < point && bid < point;
bool isPointBreaked = IsBarBreak(
point,
setupDir,
cBar //
);
//
// Summary ...
File diff suppressed because it is too large Load Diff