This commit is contained in:
2024-12-19 04:20:54 +03:30
parent 2a3138402d
commit 00d93a36d6
30 changed files with 1678 additions and 56620 deletions
@@ -49,7 +49,8 @@ enum ENUM_X_CYCLE_EVENTS
PIVOT_POINT_DETECTED,
VWAP_ORDER_CHANGE_ETECTED,
VWAP_STATE_CHANGE_DETCTED,
CONSOLIDATION_BREAKED_DETECTED
CONSOLIDATION_BREAKED_DETECTED,
PIVOT_DETECTED,
};
class XC121SMCCycleHelper : public XCBase
@@ -401,6 +402,7 @@ class XC121SMCCycleHelper : public XCBase
*/
bool GetConditions(
ENUM_X_CYCLE_EVENTS &events[],
ENUM_XPOI_EVENTS &poiEvents[],
X121SMCCycleConditions &conditions,
int barIndex = 0,
int loopback = 7 //
@@ -422,6 +424,8 @@ class XC121SMCCycleHelper : public XCBase
}
//
Clean(events);
Clean(poiEvents);
conditions.Clean();
//
@@ -437,6 +441,10 @@ class XC121SMCCycleHelper : public XCBase
return result;
}
//
mPOIDetector.Update(poiEvents);
mPOIDetector.GetState(conditions.state);
//
conditions.symbol = conditions.x121Conditions.symbol;
conditions.period = conditions.x121Conditions.period;
@@ -463,6 +471,106 @@ class XC121SMCCycleHelper : public XCBase
//
// Tools ...
/**
* Get POI State of Specified Pivot ...
*
* @param pivot: XPVPivot instance Reference ...
* @param lookupSwingHighs: Boolean ...
* @param lookupSwingLows: Boolean ...
* @param lookupSupportZones: Boolean ...
* @param lookupResistanceZones: Boolean ...
* @param lookupSupplyZones: Boolean ...
* @param lookupDemandZones: Boolean ...
* @param lookupBullishOrderBlocks: Boolean ...
* @param lookupBearishOrderBlocks: Boolean ...
* @param lookupBullishFairValueGaps: Boolean ...
* @param lookupBearishFairValueGaps: Boolean ...
* @param lookupBullishRejectionBars: Boolean ...
* @param lookupBearishRejectionBars: Boolean ...
* @param lookupBullishMomentumBars: Boolean ...
* @param lookupBearishMomentumBars: Boolean ...
*
* @return ( bool )
*/
bool FillPivotState(
XPVPivot &pivot,
bool lookupSwingHighs = true,
bool lookupSwingLows = true,
bool lookupSupportZones = true,
bool lookupResistanceZones = true,
bool lookupSupplyZones = true,
bool lookupDemandZones = true,
bool lookupBullishOrderBlocks = true,
bool lookupBearishOrderBlocks = true,
bool lookupBullishFairValueGaps = true,
bool lookupBearishFairValueGaps = true,
bool lookupBullishRejectionBars = true,
bool lookupBearishRejectionBars = true,
bool lookupBullishMomentumBars = true,
bool lookupBearishMomentumBars = true //
)
{
//
bool result = false;
//
XPOIState state;
state.Clean();
//
result = pivot.IsValid();
if (!result)
{
return result;
}
//
XPOIState _state;
mPOIDetector.GetState(_state);
result = _state.IsValid() &&
_state.HasChild();
if (!result)
{
return result;
}
//
DetectPivotPOIs(
pivot,
_state,
state,
lookupSwingHighs,
lookupSwingLows,
lookupSupportZones,
lookupResistanceZones,
lookupSupplyZones,
lookupDemandZones,
lookupBullishOrderBlocks,
lookupBearishOrderBlocks,
lookupBullishFairValueGaps,
lookupBearishFairValueGaps,
lookupBullishRejectionBars,
lookupBearishRejectionBars,
lookupBullishMomentumBars,
lookupBearishMomentumBars //
);
//
result = state.IsValid() &&
state.HasChild();
if (result)
{
//
pivot.state = state;
//
CalculatePivotTickZone(pivot);
}
//
return result;
}
/**
* Detect XPV Based POI(s) ...
*
@@ -814,9 +922,9 @@ class XC121SMCCycleHelper : public XCBase
/**
* Retrieve Last Sar Changes ...
*
*
* @param change: XValueChange instance ...
*
*
* @return ( bool )
*/
bool GetLastSarChange(XValueChange &change)
@@ -873,9 +981,9 @@ class XC121SMCCycleHelper : public XCBase
/**
* Retrieve Last Peak Changes ...
*
*
* @param change: XValueChange instance ...
*
*
* @return ( bool )
*/
bool GetLastPeakChange(XValueChange &change)
@@ -932,9 +1040,9 @@ class XC121SMCCycleHelper : public XCBase
/**
* Retrieve Last Vale Changes ...
*
*
* @param change: XValueChange instance ...
*
*
* @return ( bool )
*/
bool GetLastValeChange(XValueChange &change)
@@ -991,9 +1099,9 @@ class XC121SMCCycleHelper : public XCBase
/**
* Retrieve Last VWap Order Changes ...
*
*
* @param change: XValueChange instance ...
*
*
* @return ( bool )
*/
bool GetLastVWapOrderChange(XValueChange &change)
@@ -1050,9 +1158,9 @@ class XC121SMCCycleHelper : public XCBase
/**
* Retrieve Last VWap State Changes ...
*
*
* @param change: XValueChange instance ...
*
*
* @return ( bool )
*/
bool GetLastVWapStateChange(XValueChange &change)
@@ -1109,9 +1217,9 @@ class XC121SMCCycleHelper : public XCBase
/**
* Retrieve Last Consolidation Breaks ...
*
*
* @param change: XValueChange instance ...
*
*
* @return ( bool )
*/
bool GetLastConsolidationZone(XConsolidationZone &zone)
@@ -1268,6 +1376,14 @@ class XC121SMCCycleHelper : public XCBase
return result;
}
//
void GetActivePivot(XPVPivot &pivot)
{
//
mActivePivot.to = TimeCurrent();
pivot = mActivePivot;
}
//
// Virtuals ...
@@ -1303,6 +1419,7 @@ class XC121SMCCycleHelper : public XCBase
//
string symbol = GetSymbol();
datetime cTime = TimeCurrent();
ENUM_TIMEFRAMES period = GetPeriod();
//
@@ -1778,6 +1895,107 @@ class XC121SMCCycleHelper : public XCBase
}
}
}
//
// Calculate Pivots ...
if (isNewPeak || isNewVale)
{
//
mActivePivot.symbol = symbol;
mActivePivot.period = period;
//
if (!IsValid(mActivePivot.from))
{
mActivePivot.from = cTime;
}
mActivePivot.to = cTime;
//
if (mActivePivot.upper <= 0)
{
//
if (isNewPeakUnderLast)
{
mActivePivot.upper = conditions.x121Conditions.peaksBuffer[2];
}
else
{
mActivePivot.upper = conditions.x121Conditions.peaksBuffer[1];
}
}
//
if (mActivePivot.lower <= 0)
{
//
if (isNewValeOverLast)
{
mActivePivot.lower = conditions.x121Conditions.valesBuffer[2];
}
else
{
mActivePivot.lower = conditions.x121Conditions.valesBuffer[1];
}
}
//
mActivePivot.type =
isNewPeak
? XPV_VALE
: XPV_PEAK;
mActivePivot.repetition++;
//
if (mActivePivot.to > mActivePivot.from)
{
//
FillPivotState(mActivePivot);
//
// Check Active Pivot has State and Ticks Zone ...
if (mActivePivot.state.IsValid() &&
mActivePivot.state.ticksZone != NULL &&
mActivePivot.state.ticksZone.IsValid())
{
//
// Here We Have to Calculate Ticks Level Volume and Percents ...
// Liquidity ...
//
// Select Current TickZone which Price is Inside ...
int cTZoneIDX = -1;
int count = mActivePivot.state.ticksZone.Count();
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XCTickZone *iTZ = mActivePivot.state.ticksZone.GetZone(i);
//
bool isBarInside =
changeBar.low >= iTZ.low &&
changeBar.high <= iTZ.high;
if (isBarInside)
{
//
cTZoneIDX = i;
break;
}
}
//
if (IsValidIndex(cTZoneIDX))
{
//
Print("ZoneIndex: ", cTZoneIDX);
}
}
}
}
}
}
//
@@ -1802,6 +2020,11 @@ class XC121SMCCycleHelper : public XCBase
//
XPVPivotPoint mPivotPoints[]; // Holds Pivots ...
//
XCXPVPivotObject mActivePivotObject;
XPVPivot mActivePivot;
XPVPivot mPivots[];
//
// Actions ...
@@ -1871,6 +2094,92 @@ class XC121SMCCycleHelper : public XCBase
ChartSetInteger(chartId, CHART_COLOR_VOLUME, mVolumesColor);
}
/**
* Fill Pivot Tick Zone ...
*
* @param pivot: XPVPivot instance Reference ...
*/
void CalculatePivotTickZone(
XPVPivot &pivot //
)
{
//
string symbol = GetSymbol();
ENUM_TIMEFRAMES period = GetPeriod();
//
bool isInited = false;
//
datetime from = pivot.from;
XOHCL iFromBar;
int iFromBarIndex = iBarShift(
symbol,
period,
from //
);
isInited = iFromBar.Init(
symbol,
period,
iFromBarIndex //
);
if (!isInited)
{
return;
}
//
datetime to = pivot.to;
XOHCL iToBar;
int iToBarIndex = iBarShift(
symbol,
period,
to //
);
isInited = iToBar.Init(
symbol,
period,
iToBarIndex //
);
if (!isInited)
{
return;
}
//
if (iFromBarIndex <= iToBarIndex)
{
return;
}
//
XCTicksZone *iZone;
iZone = new XCTicksZone();
//
int ticksLevels = mPOIDetector.TicksRangeZoneLevel();
int ticksRange = mPOIDetector.TicksRangeZoneRange();
isInited = ticksLevels > 0 &&
ticksRange > 0;
if (!isInited)
{
return;
}
//
isInited = iZone.Init(
iFromBar,
iToBar //
);
if (!isInited)
{
return;
}
//
pivot.state.ticksZone = iZone;
}
//
// Change Values Actions ...