add support of Consolidation Zone ibside XPOIDetector and XPOIState ...

This commit is contained in:
2025-02-26 22:34:40 +03:30
parent 476bcaece8
commit af9c398338
14 changed files with 1993 additions and 1986 deletions
+185
View File
@@ -447,6 +447,191 @@ class XCBarAnalyser : public XCBase
return result;
}
bool HasConsolidationZone(
XOHCL &bar,
XConsolidationZone &zone,
int minLoopback = 3,
double range = 50,
ENUM_APPLIED_PRICE upperAppliedTo = PRICE_HIGH,
ENUM_APPLIED_PRICE lowerAppliedTo = PRICE_LOW //
)
{
//
bool result = false;
//
zone.Clean();
//
result = bar.IsValid() &&
minLoopback > 0 &&
range > 0;
if (!result)
{
return result;
}
//
double points = GetPoints(bar.symbol);
int index = bar.Index() + 1;
int length = minLoopback;
//
double upperPrice[];
int upperPriceCount = FillPrice(
upperPrice,
upperAppliedTo,
bar.symbol,
bar.period,
index,
length //
);
//
double lowerPrice[];
int lowerPriceCount = FillPrice(
lowerPrice,
lowerAppliedTo,
bar.symbol,
bar.period,
index,
length //
);
//
result = upperPriceCount == lowerPriceCount &&
lowerPriceCount == length;
if (!result)
{
//
Clean(upperPrice);
Clean(lowerPrice);
//
return result;
}
//
double upper = upperPrice[ArrayMaximum(upperPrice)];
double lower = lowerPrice[ArrayMinimum(lowerPrice)];
//
bool isBullishBreake =
bar.low > lower &&
bar.high > upper &&
bar.GetUp() > upper;
bool isBearishBreake =
bar.high < upper &&
bar.low < lower &&
bar.GetDown() < lower;
result = isBullishBreake ||
isBearishBreake;
if (!result)
{
//
Clean(upperPrice);
Clean(lowerPrice);
//
return result;
}
//
double delta = upper - lower;
result = delta <= range * points;
if (!result)
{
//
Clean(upperPrice);
Clean(lowerPrice);
//
return result;
}
//
while (delta <= range * points)
{
//
length++;
//
upperPriceCount = FillPrice(
upperPrice,
upperAppliedTo,
bar.symbol,
bar.period,
index,
length //
);
//
lowerPriceCount = FillPrice(
lowerPrice,
lowerAppliedTo,
bar.symbol,
bar.period,
index,
length //
);
//
bool isValid = upperPriceCount == lowerPriceCount &&
lowerPriceCount == length;
if (!isValid)
{
break;
}
//
double iUpper = upperPrice[ArrayMaximum(upperPrice)];
double iLower = lowerPrice[ArrayMinimum(lowerPrice)];
//
delta = iUpper - iLower;
if (delta <= range * points)
{
//
upper = iUpper;
lower = iLower;
}
}
//
Clean(upperPrice);
Clean(lowerPrice);
//
// Filling Zone ...
zone.upper = upper;
zone.lower = lower;
zone.symbol = bar.symbol;
zone.period = bar.period;
zone.to = iTime(
bar.symbol,
bar.period,
bar.Index() + 1 //
);
zone.from = iTime(
bar.symbol,
bar.period,
bar.Index() + length //
);
zone.dir = isBullishBreake
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
//
result = zone.IsValid();
if (!result)
{
zone.Clean();
}
//
return result;
}
/**
* Check Bar Has Bullish Trend or not ...
*
+2 -2
View File
@@ -1594,9 +1594,9 @@ class XCConsolidationZoneObject : public XCBaseObject
chart_id,
name,
window,
zone.From(),
zone.from,
zone.upper,
TimeCurrent(),
zone.to,
zone.lower //
);
+351 -25
View File
@@ -405,6 +405,100 @@ class XCPOIDetector : public XCBaseAlert
mFairValueGapSameBars = value;
}
/**
* Get Minimum Length of Cnsolidation Zone ...
*
* @return ( int )
*/
int ConsolidationZoneMinLoopback()
{
return mConsolidationZoneMinLoopback;
}
/**
* Set Minimum Length of Cnsolidation Zone ...
*
* @param value: int ...
*/
void ConsolidationZoneMinLoopback(int value)
{
//
if (value < 1)
{
value = 1;
}
//
mConsolidationZoneMinLoopback = value;
}
/**
* Get Consolidation Zone Range in Point ...
*
* @return ( double )
*/
double ConsolidationZoneRangeInPoint()
{
return mConsolidationZoneRangeInPoint;
}
/**
* Set Consolidation Zone Range in Point ...
*
* @param value: double
*/
void ConsolidationZoneRangeInPoint(double value)
{
//
if (value < 50)
{
value = 50;
}
//
mConsolidationZoneRangeInPoint = value;
}
/**
* Get Consolidation Zone Upper Applied To ...
*
* @return ( ENUM_APPLIED_PRICE )
*/
ENUM_APPLIED_PRICE ConsolidationZonesLowerAppliedTo()
{
return mConsolidationZonesLowerAppliedTo;
}
/**
* Set Consolidation Zone Upper Applied To ...
*
* @param value: ENUM_APPLIED_PRICE
*/
void ConsolidationZonesLowerAppliedTo(ENUM_APPLIED_PRICE value = PRICE_LOW)
{
mConsolidationZonesLowerAppliedTo = value;
}
/**
* Get Consolidation Zone Lower Applied To ...
*
* @return ( ENUM_APPLIED_PRICE )
*/
ENUM_APPLIED_PRICE ConsolidationZonesUpperAppliedTo()
{
return mConsolidationZonesUpperAppliedTo;
}
/**
* Set Consolidation Zone Lower Applied To ...
*
* @param value: ENUM_APPLIED_PRICE
*/
void ConsolidationZonesUpperAppliedTo(ENUM_APPLIED_PRICE value = PRICE_HIGH)
{
mConsolidationZonesUpperAppliedTo = value;
}
//
// Actions ...
@@ -426,6 +520,10 @@ class XCPOIDetector : public XCBaseAlert
SupResRangeAsStart(true);
RejectionShadowPercent(70);
MaxAllowedLoopbackForInit(578);
ConsolidationZoneMinLoopback(5);
ConsolidationZoneRangeInPoint(50);
ConsolidationZonesLowerAppliedTo(PRICE_LOW);
ConsolidationZonesUpperAppliedTo(PRICE_HIGH);
}
/**
@@ -560,6 +658,14 @@ class XCPOIDetector : public XCBaseAlert
false //
);
//
// Consolidation Zone ...
DetectConsolidationZone(
iBar,
iEvent,
false //
);
//
canContinue =
has &&
@@ -1027,6 +1133,20 @@ class XCPOIDetector : public XCBaseAlert
}
}
//
has = DetectConsolidationZone(
iBar,
iEvent //
);
if (has)
{
//
Add(
iEvent,
events //
);
}
//
iBar.Clean();
mLock = false;
@@ -1169,6 +1289,24 @@ class XCPOIDetector : public XCBaseAlert
state.bearishFairValueGaps //
);
//
Copy(
mConsolidationZones,
state.consolidationZones //
);
//
Copy(
mBullishConsolidationZones,
state.bullishConsolidationZones //
);
//
Copy(
mBearishConsolidationZones,
state.bearishConsolidationZones //
);
//
}
@@ -1193,51 +1331,58 @@ class XCPOIDetector : public XCBaseAlert
void CleanCollections()
{
//
Clean(mEventListeners);
Clean(mSwings);
Clean(mSwingLows);
Clean(mSwingHighs);
Clean(mMomentumBars);
Clean(mBullishMomentumBars);
Clean(mBearishMomentumBars);
Clean(mRejectionBars);
Clean(mBullishRejectionBars);
Clean(mBearishRejectionBars);
Clean(mSupportZones);
Clean(mDemandZones);
Clean(mSupplyZones);
Clean(mResistanceZones);
Clean(mFairValueGaps);
Clean(mBullishFairValueGaps);
Clean(mBearishFairValueGaps);
Clean(mOrderBlocks);
Clean(mMomentumBars);
Clean(mSupportZones);
Clean(mRejectionBars);
Clean(mFairValueGaps);
Clean(mEventListeners);
Clean(mResistanceZones);
Clean(mBullishOrderBlocks);
Clean(mBearishOrderBlocks);
Clean(mConsolidationZones);
Clean(mBullishMomentumBars);
Clean(mBearishMomentumBars);
Clean(mBullishRejectionBars);
Clean(mBearishRejectionBars);
Clean(mBullishFairValueGaps);
Clean(mBearishFairValueGaps);
Clean(mBullishConsolidationZones);
Clean(mBearishConsolidationZones);
}
//
void ReverseCollections() {
void ReverseCollections()
{
//
ArrayReverse(mEventListeners);
ArrayReverse(mSwings);
ArrayReverse(mSwingLows);
ArrayReverse(mSwingHighs);
ArrayReverse(mMomentumBars);
ArrayReverse(mBullishMomentumBars);
ArrayReverse(mBearishMomentumBars);
ArrayReverse(mRejectionBars);
ArrayReverse(mBullishRejectionBars);
ArrayReverse(mBearishRejectionBars);
ArrayReverse(mSupportZones);
ArrayReverse(mDemandZones);
ArrayReverse(mSupplyZones);
ArrayReverse(mResistanceZones);
ArrayReverse(mFairValueGaps);
ArrayReverse(mBullishFairValueGaps);
ArrayReverse(mBearishFairValueGaps);
ArrayReverse(mOrderBlocks);
ArrayReverse(mMomentumBars);
ArrayReverse(mSupportZones);
ArrayReverse(mRejectionBars);
ArrayReverse(mFairValueGaps);
ArrayReverse(mEventListeners);
ArrayReverse(mResistanceZones);
ArrayReverse(mBullishOrderBlocks);
ArrayReverse(mBearishOrderBlocks);
ArrayReverse(mConsolidationZones);
ArrayReverse(mBullishMomentumBars);
ArrayReverse(mBearishMomentumBars);
ArrayReverse(mBullishRejectionBars);
ArrayReverse(mBearishRejectionBars);
ArrayReverse(mBullishFairValueGaps);
ArrayReverse(mBearishFairValueGaps);
ArrayReverse(mBullishConsolidationZones);
ArrayReverse(mBearishConsolidationZones);
}
//
@@ -1374,6 +1519,24 @@ class XCPOIDetector : public XCBaseAlert
maxAllowed //
);
//
CleanupArray(
mConsolidationZones,
maxAllowed //
);
//
CleanupArray(
mBullishConsolidationZones,
maxAllowed //
);
//
CleanupArray(
mBearishConsolidationZones,
maxAllowed //
);
//
}
@@ -2928,6 +3091,160 @@ class XCPOIDetector : public XCBaseAlert
return result;
}
/**
* Detect Consolidation Zones ...
*
* @param bar: XOHCL instance ...
* @param reversal: boolean reversal add to collection ...
*
* @return ( bool )
*/
bool DetectConsolidationZone(
XOHCL &bar,
ENUM_XPOI_EVENTS &state,
bool reversal = false //
)
{
//
bool result = false;
//
state = X_POI_EVENT_NONE;
//
XConsolidationZone cZone;
result = mBarAnalyser.HasConsolidationZone(
bar,
cZone,
mConsolidationZoneMinLoopback,
mConsolidationZoneRangeInPoint,
mConsolidationZonesUpperAppliedTo,
mConsolidationZonesLowerAppliedTo //
);
if (!result)
{
//
cZone.Clean();
//
return result;
}
//
// Add ...
//
bool isBullish = IsBullish(cZone.dir);
bool isBearish = IsBearish(cZone.dir);
//
int idx = FindIndex(
cZone,
mConsolidationZones //
);
result = !IsValidIndex(idx);
if (!result)
{
//
cZone.Clean();
//
return result;
}
//
if (reversal)
{
//
ArrayReverse(mConsolidationZones);
//
AddRef(
cZone,
mConsolidationZones //
);
//
ArrayReverse(mConsolidationZones);
}
else
{
//
AddRef(
cZone,
mConsolidationZones //
);
}
//
if (isBullish)
{
//
// Add Swings ...
if (reversal)
{
//
ArrayReverse(mBullishConsolidationZones);
//
AddRef(
cZone,
mBullishConsolidationZones //
);
//
ArrayReverse(mBullishConsolidationZones);
}
else
{
//
AddRef(
cZone,
mBullishConsolidationZones //
);
}
}
else if (isBearish)
{
//
// Add Swings ...
if (reversal)
{
//
ArrayReverse(mBearishConsolidationZones);
//
AddRef(
cZone,
mBearishConsolidationZones //
);
//
ArrayReverse(mBearishConsolidationZones);
}
else
{
//
AddRef(
cZone,
mBearishConsolidationZones //
);
}
}
//
state =
IsBullish(cZone.dir)
? X_BULLISH_CONSOLIDATION_ZONE_DETECTED
: X_BEARISH_CONSOLIDATION_ZONE_DETECTED;
//
cZone.Clean();
//
return result;
}
//
private:
//
@@ -2991,6 +3308,15 @@ class XCPOIDetector : public XCBaseAlert
XCOrderBlock *mBearishOrderBlocks[]; // Holds Founded Bearish OrderBlocks ...
int mOrderBlockSameBars; // OrderBlock Detection Same Bars ...
//
int mConsolidationZoneMinLoopback; // Minimum Length of Cnsolidation Zone ...
double mConsolidationZoneRangeInPoint; // Consolidation Zone Range in Point ...
XConsolidationZone mConsolidationZones[]; // Holds Founded Consolidation Zones ...
XConsolidationZone mBullishConsolidationZones[]; // Holds Founded Bullish Consolidation Zones ...
XConsolidationZone mBearishConsolidationZones[]; // Holds Founded Bearish Consolidation Zones ...
ENUM_APPLIED_PRICE mConsolidationZonesLowerAppliedTo; // Consolidation Zone Upper Applied To ...
ENUM_APPLIED_PRICE mConsolidationZonesUpperAppliedTo; // Consolidation Zone Lower Applied To ...
//
};
+62 -2
View File
@@ -2964,7 +2964,7 @@ class XCPOIDrawer : public XCBase
int window = SubWindowIdentification();
//
color czColor = IsBullish(zone.breakDir)
color czColor = IsBullish(zone.dir)
? BarBullishColor()
: BarBearishColor();
@@ -3460,7 +3460,9 @@ class XCPOIDrawer : public XCBase
bool ignoreBullishRejectionBars = false,
bool ignoreBearishRejectionBars = false,
bool ignoreBullishMomentumBars = false,
bool ignoreBearishMomentumBars = false //
bool ignoreBearishMomentumBars = false,
bool ignoreBullishConsolidationZones = false,
bool ignoreBearishConsolidationZones = false //
)
{
//
@@ -3924,6 +3926,64 @@ class XCPOIDrawer : public XCBase
}
}
//
// Bullish Consolidation Zones ...
if (!ignoreBullishConsolidationZones)
{
//
int count = state.CountBullishConsolidationZones();
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XCConsolidationZoneObject *iObj;
bool isCreated = CreateConsolidationZone(
state.bullishConsolidationZones[i],
iObj //
);
if (isCreated)
{
//
Add(
(XCBaseObject *)iObj,
drawnObjects //
);
}
}
}
}
//
// Bearish Consolidation Zones ...
if (!ignoreBearishConsolidationZones)
{
//
int count = state.CountBearishConsolidationZones();
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XCConsolidationZoneObject *iObj;
bool isCreated = CreateConsolidationZone(
state.bearishConsolidationZones[i],
iObj //
);
if (isCreated)
{
//
Add(
(XCBaseObject *)iObj,
drawnObjects //
);
}
}
}
}
//
result = ArraySize(drawnObjects);
+25 -1
View File
@@ -212,4 +212,28 @@
// }
//
XCBaseObject *stateObjects[];
int stateObjectsCount = drawer.DrawState(
decisionState,
stateObjects,
false, //
true, // ignoreSwingHighs
true, // ignoreSwingLows
true, // ignoreSupportZones
true, // ignoreResistanceZones
true, // ignoreSupplyZones
true, // ignoreDemandZones
true, // ignoreBullishOrderBlocks
true, // ignoreBearishOrderBlocks
true, // ignoreBullishFairValueGaps
true, // ignoreBearishFairValueGaps
true, // ignoreBullishRejectionBars
true, // ignoreBearishRejectionBars
true, // ignoreBullishMomentumBars
true, // ignoreBearishMomentumBars
false, // ignoreBullishConsolidationZones
false // ignoreBearishConsolidationZones
);
+1
View File
@@ -90,6 +90,7 @@ struct X121Inputs
xstrInputs.Default();
xcheInputs.Default();
xdonInputs.Default();
x3maInputs.Default();
xvwapInputs.Default();
xtrendInputs.Default();
}
+128 -2
View File
@@ -3754,6 +3754,132 @@ int ExtractSwings(
return result;
}
//
// Consolidation Zone ...
struct XConsolidationZone
{
//
// Props ...
//
string symbol; // Symbol ...
ENUM_TIMEFRAMES period; // Period ...
//
double upper; // Upper ...
double lower; // Lower ...
//
datetime from; // Start Date
datetime to; // Breake Date
//
ENUM_X_DIRECTION dir; // Break Direction ...
//
// Constructor ...
XConsolidationZone()
{
Clean();
}
//
// Tools ...
/**
* Cleanup ...
*/
void Clean()
{
//
upper = 0;
lower = 0;
//
to = NULL;
from = NULL;
symbol = NULL;
period = NULL;
dir = X_DIRECTION_NONE;
//
ZeroMemory(this);
}
/**
* Validate ...
*
* @return ( bool )
*/
bool IsValid()
{
//
bool result = false;
//
result =
//
upper > 0 &&
lower > 0 &&
IsValid(to) &&
IsValid(from) &&
IsValid(symbol) &&
IsValid(period) &&
HasDirection(dir)
//
;
//
return result;
}
bool IsSameAs(
XConsolidationZone &item //
)
{
//
bool result = false;
//
result = IsValid() &&
item.IsValid() &&
dir == item.dir &&
from == item.from &&
upper == item.upper &&
lower == item.lower &&
symbol == item.symbol &&
period == item.period;
//
return result;
}
/**
* Retrieve Unique Identifier ...
*
* @return ( string )
*/
string GetTag()
{
//
string result =
//
"XCZONE" + "_" +
ToString(dir) + "_" +
symbol + "_" +
ToString(period) + "_" +
ToString(upper) + "_" +
ToString(lower)
//
;
//
return result;
}
//
};
//
// Functions ...
@@ -5255,9 +5381,9 @@ int FillPrice(
}
//
if (_mLoopback < 7)
if (_mLoopback < 1)
{
_mLoopback = 7;
_mLoopback = 1;
}
//
File diff suppressed because it is too large Load Diff
+15 -421
View File
@@ -67,6 +67,9 @@ enum ENUM_XPOIS
// Fair Value Gaps ...
X_POI_BULLISH_FVG, // Bullish Order Block ...
X_POI_BEARISH_FVG, // Bearish Order Block ...
//
X_BULLISH_CONSOLIDATION_ZONE,
X_BEARISH_CONSOLIDATION_ZONE,
};
//
@@ -111,6 +114,8 @@ enum ENUM_XPOI_EVENTS
// Fair Value Gaps ...
X_BULLISH_FVG_DETECTED, // Bullish Fair Value Gapّ ...
X_BEARISH_FVG_DETECTED, // Bearish Fair Value Gapّ ...
X_BULLISH_CONSOLIDATION_ZONE_DETECTED,
X_BEARISH_CONSOLIDATION_ZONE_DETECTED,
};
//
@@ -222,6 +227,16 @@ string ToString(ENUM_XPOIS value)
case X_POI_TICKS_ZONES:
result = "XTKSZ";
break;
//
case X_BULLISH_CONSOLIDATION_ZONE:
result = "XBULLCZ";
break;
//
case X_BEARISH_CONSOLIDATION_ZONE:
result = "XBEARCZ";
break;
}
//
@@ -5175,427 +5190,6 @@ class XCSession : public XCFromToZone
//
};
//
// Consolidation Zone ...
struct XConsolidationZone
{
//
// Props ...
//
string symbol; // Symbol ...
ENUM_TIMEFRAMES period; // Period ...
//
double upper; // Upper ...
double lower; // Lower ...
//
datetime initTime;
int loopback; // Loopback ...
//
ENUM_X_DIRECTION breakDir; // Break Direction ...
XOHCL breakerBar; // Breaker Bar ...
//
// Constructor ...
XConsolidationZone()
{
Clean();
}
//
// Tools ...
/**
* Initialize Zone ...
*
* @param _symbol: String ...
* @param _period: ENUM_TIMEFRAMES member ...
* @param _upper: Double ...
* @param _lower: Double ...
* @param _loopback: Integer ...
*
* @return ( bool )
*/
bool Init(
string _symbol,
ENUM_TIMEFRAMES _period,
double _upper,
double _lower,
int _loopback //
)
{
//
bool result = false;
//
_symbol = NormalizeSymbol(_symbol);
_period = NormalizePeriod(_period);
//
result =
//
_upper > 0 &&
_lower > 0 &&
_loopback > 0
//
;
if (!result)
{
return result;
}
//
upper = _upper;
lower = _lower;
symbol = _symbol;
period = _period;
loopback = _loopback;
//
result = IsValid();
if (result)
{
initTime = TimeCurrent();
}
//
return result;
}
/**
* Update Breaked State ...
*/
void Update()
{
//
if (!IsValid())
{
return;
}
//
if (IsBreaked())
{
return;
}
//
XOHCL cBar;
bool isInited = cBar.Init(
symbol,
period,
0 //
);
if (!isInited)
{
return;
}
//
XOHCL pBar;
isInited = cBar.GetPreviousBar(pBar);
if (!isInited)
{
return;
}
//
// Check Consolidation Hounts ...
bool isHountTop = cBar.high > upper &&
cBar.low < upper &&
cBar.GetUp() < upper;
bool isHountBottom = cBar.low < lower &&
cBar.high > lower &&
cBar.GetDown() > lower;
bool isHounted = isHountTop ||
isHountBottom;
if (isHounted)
{
//
if (isHountTop)
{
upper = cBar.high;
}
//
if (isHountBottom)
{
lower = cBar.low;
}
//
return;
}
//
// Check Consolidation Breaks ...
bool isBreakTop = (cBar.GetUp() > upper &&
cBar.GetDown() < upper) ||
(cBar.low > upper &&
cBar.high > upper);
bool isBreakBottom = (cBar.GetDown() < lower &&
cBar.GetUp() > lower) ||
(cBar.high < lower &&
cBar.low < lower);
bool isBreaked = isBreakTop ||
isBreakBottom;
if (!isBreaked)
{
return;
}
//
// Calculate Break Direction ...
breakerBar = cBar;
breakDir = isBreakTop
? X_DIRECTION_BULLISH
: isBreakBottom
? X_DIRECTION_BEARISH
: X_DIRECTION_NONE;
}
/**
* Cleanup ...
*/
void Clean()
{
//
upper = 0;
lower = 0;
loopback = 0;
symbol = NULL;
period = NULL;
initTime = NULL;
breakerBar.Clean();
breakDir = X_DIRECTION_NONE;
//
ZeroMemory(this);
}
/**
* Validate ...
*
* @return ( bool )
*/
bool IsValid()
{
//
bool result = false;
//
result =
//
IsValid(symbol) &&
IsValid(period) &&
upper > 0 &&
lower > 0 &&
loopback > 0
//
;
//
return result;
}
/**
* Check Zone is Breaked or not ...
*
* @return ( bool )
*/
bool IsBreaked()
{
//
bool result = false;
//
result = breakerBar.IsValid() &&
HasDirection(breakDir);
//
return result;
}
/**
* Detect Supply Zone if Exists ...
*
* @return ( bool )
*/
bool HasSupplyZone(
XCSupplyZone *&zone //
)
{
//
bool result = false;
//
result = IsBreaked() &&
breakDir == X_DIRECTION_BEARISH;
if (!result)
{
return result;
}
//
// Implment Zone Finding ...
int index = breakerBar.Index();
int hhIDX = iHighest(
symbol,
period,
MODE_HIGH,
loopback,
index //
);
result = IsValidIndex(hhIDX);
if (!result)
{
return result;
}
//
XOHCL hhBar;
result = hhBar.Init(
symbol,
period,
hhIDX //
);
if (!result)
{
return result;
}
//
zone = new XCSupplyZone();
result = zone.Init(
hhBar,
loopback //
);
//
return result;
}
/**
* Detect Demand Zone if Exists ...
*
* @return ( bool )
*/
bool HasDemandZone(
XCDemandZone *&zone //
)
{
//
bool result = false;
//
result = IsBreaked() &&
breakDir == X_DIRECTION_BULLISH;
if (!result)
{
return result;
}
//
// Implment Zone Finding ...
int index = breakerBar.Index();
int llIDX = iLowest(
symbol,
period,
MODE_LOW,
loopback,
index //
);
result = IsValidIndex(llIDX);
if (!result)
{
return result;
}
//
XOHCL llBar;
result = llBar.Init(
symbol,
period,
llIDX //
);
if (!result)
{
return result;
}
//
zone = new XCDemandZone();
result = zone.Init(
llBar,
loopback //
);
//
return result;
}
/**
* Retrieve Start Time ...
*
* @return ( datetime )
*/
datetime From()
{
//
datetime result = NULL;
//
if (!IsValid())
{
return result;
}
//
int startIndex = iBarShift(
symbol,
period,
initTime //
);
//
result = iTime(
symbol,
period,
loopback + startIndex //
);
//
return result;
}
/**
* Retrieve Unique Identifier ...
*
* @return ( string )
*/
string GetTag()
{
//
string result =
//
"ConsolidationZone" + "_" +
symbol + "_" +
ToString(period) + "_" +
ToString(upper) + "_" +
ToString(lower)
//
;
//
return result;
}
//
};
//
struct XBoxZone
{
+62 -109
View File
@@ -384,6 +384,11 @@ struct XPOIState
XCFVG *bullishFairValueGaps[]; // Holds Founded Bullish Fair Value Gaps ...
XCFVG *bearishFairValueGaps[]; // Holds Founded Bearish Fair Value Gaps ...
//
XConsolidationZone consolidationZones[]; // Holds Founded Consolidation Zones ...
XConsolidationZone bullishConsolidationZones[]; // Holds Founded Bullish Consolidation Zones ...
XConsolidationZone bearishConsolidationZones[]; // Holds Founded Bearih Consolidation Zones ...
//
// Constructor ...
void XPOIState()
@@ -437,6 +442,11 @@ struct XPOIState
Clean(bullishFairValueGaps);
Clean(bearishFairValueGaps);
//
Clean(consolidationZones);
Clean(bullishConsolidationZones);
Clean(bearishConsolidationZones);
//
ZeroMemory(this);
}
@@ -474,20 +484,22 @@ struct XPOIState
//
result =
//
IsValidSize(CountSwingHighs()) ||
IsValidSize(CountSwingLows()) ||
IsValidSize(CountBullishMomentumBars()) ||
IsValidSize(CountBearishMomentumBars()) ||
IsValidSize(CountBullishRejectionBars()) ||
IsValidSize(CountBearishRejectionBars()) ||
IsValidSize(CountSupportZones()) ||
IsValidSize(CountResistanceZones()) ||
IsValidSize(CountSupplyZones()) ||
IsValidSize(CountDemandZones()) ||
IsValidSize(CountBullishOrderBlocks()) ||
IsValidSize(CountBearishOrderBlocks()) ||
IsValidSize(CountBullishFairValueGaps()) ||
IsValidSize(CountBearishFairValueGaps())
HasSwingLows() ||
HasSwingHighs() ||
HasSupplyZones() ||
HasDemandZones() ||
HasSupportZones() ||
HasResistanceZones() ||
HasBullishOrderBlocks() ||
HasBearishOrderBlocks() ||
HasBullishMomentumBars() ||
HasBearishMomentumBars() ||
HasBullishRejectionBars() ||
HasBearishRejectionBars() ||
HasBullishFairValueGaps() ||
HasBearishFairValueGaps() ||
HasBullishConsolidationZones() ||
HasBearishConsolidationZones()
//
;
@@ -495,101 +507,6 @@ struct XPOIState
return result;
}
/**
* Fill Dest State by Current State's Data ...
*
* @param dest: XPOIState instance, reference to specified dest ...
*
*/
void Fill(XPOIState &dest)
{
//
if (!IsValid() ||
!HasChild())
{
return;
}
//
dest.symbol = symbol;
dest.period = period;
dest.time = time;
//
Copy(
swingHighs,
dest.swingHighs,
false //
);
Copy(
swingLows,
dest.swingLows,
false //
);
Copy(
bullishMomentumBars,
dest.bullishMomentumBars,
false //
);
Copy(
bearishMomentumBars,
dest.bearishMomentumBars,
false //
);
Copy(
bullishRejectionBars,
dest.bullishRejectionBars,
false //
);
Copy(
bearishRejectionBars,
dest.bearishRejectionBars,
false //
);
Copy(
supportZones,
dest.supportZones,
false //
);
Copy(
resistanceZones,
dest.resistanceZones,
false //
);
Copy(
supplyZones,
dest.supplyZones,
false //
);
Copy(
demandZones,
dest.demandZones,
false //
);
Copy(
bullishOrderBlocks,
dest.bullishOrderBlocks,
false //
);
Copy(
bearishOrderBlocks,
dest.bearishOrderBlocks,
false //
);
Copy(
bullishFairValueGaps,
dest.bullishFairValueGaps,
false //
);
Copy(
bearishFairValueGaps,
dest.bearishFairValueGaps,
false //
);
//
}
//
// Counters ...
@@ -1068,6 +985,42 @@ struct XPOIState
return IsValidSize(CountBearishFairValueGaps());
}
//
bool HasConsolidationZones()
{
return HasChild(consolidationZones);
}
//
int CountConsolidationZones()
{
return ArraySize(consolidationZones);
}
//
bool HasBullishConsolidationZones()
{
return HasChild(bullishConsolidationZones);
}
//
int CountBullishConsolidationZones()
{
return ArraySize(bullishConsolidationZones);
}
//
bool HasBearishConsolidationZones()
{
return HasChild(bearishConsolidationZones);
}
//
int CountBearishConsolidationZones()
{
return ArraySize(bearishConsolidationZones);
}
//
void UpdateTo(datetime value = NULL)
{
@@ -106,183 +106,6 @@ class XC121SMCCycleHelper : public XCBase
//
// Getter/Setter(s) ...
//
int CountConsolidationZones()
{
return ArraySize(mConsolidationZones);
}
//
bool HasConsolidationZones()
{
return HasChild(mConsolidationZones);
}
//
bool GetConsolidationZone(
int idx,
XConsolidationZone &zone //
)
{
//
bool result = false;
//
zone.Clean();
//
result = HasConsolidationZones();
if (!result)
{
return result;
}
//
int count = CountConsolidationZones();
result = idx >= 0 &&
idx < count;
if (!result)
{
return result;
}
//
zone = mConsolidationZones[idx];
result = zone.IsValid();
//
return result;
}
//
bool GetLastDirectionalConsolidationZone(
ENUM_X_DIRECTION forDir,
XConsolidationZone &zone //
)
{
//
bool result = false;
//
zone.Clean();
//
result = HasDirection(forDir);
if (!result)
{
return result;
}
//
bool hasZones = HasConsolidationZones();
int zonesCount = CountConsolidationZones();
result = hasZones;
if (!result)
{
return result;
}
//
for (int i = zonesCount - 1; i >= 0; i--)
{
//
XConsolidationZone iZone = mConsolidationZones[i];
//
if (!iZone.IsBreaked())
{
continue;
}
//
if (!HasDirection(iZone.breakDir))
{
continue;
}
//
if (iZone.breakDir != forDir)
{
continue;
}
//
zone = iZone;
break;
}
//
result = zone.IsValid();
//
return result;
}
//
bool GetActiveConsolidationZone(
XConsolidationZone &zone //
)
{
//
bool result = false;
//
zone = mActiveConsolidationZone;
result = zone.IsValid();
//
return result;
}
//
int FillConsolidationZones(
ENUM_X_DIRECTION forDir,
XConsolidationZone &zones[] //
)
{
//
int result = 0;
//
Clean(zones);
//
bool hasZones = HasConsolidationZones();
if (!hasZones)
{
return result;
}
//
int count = CountConsolidationZones();
for (int i = 0; i < count; i++)
{
//
XConsolidationZone iZone = mConsolidationZones[i];
//
bool isDirPassed =
(forDir == X_DIRECTION_ALL ||
forDir == X_DIRECTION_NONE)
? true
: forDir == iZone.breakDir;
if (isDirPassed)
{
//
AddRef(
iZone,
zones //
);
}
}
//
result = ArraySize(zones);
//
return result;
}
//
// Actions ...
@@ -618,7 +441,7 @@ class XC121SMCCycleHelper : public XCBase
conditions.time = TimeCurrent();
//
Update();
// Update();
//
result = conditions.IsValid();
@@ -627,87 +450,6 @@ class XC121SMCCycleHelper : public XCBase
return result;
}
//
// Tools ...
void Update()
{
//
int czRange = 50; // Consolidation min Range Points ...
int czLoopback = 5;
int maxAllowed = 20;
bool isActiveConsolidationZoneBreaked = false;
bool hasActiveConsolidationZone = mActiveConsolidationZone.IsValid();
//
if (hasActiveConsolidationZone)
{
//
isActiveConsolidationZoneBreaked = mActiveConsolidationZone.IsBreaked();
//
if (isActiveConsolidationZoneBreaked)
{
//
AddRef(
mActiveConsolidationZone,
mConsolidationZones //
);
//
CleanupArray(
mConsolidationZones,
maxAllowed //
);
//
mActiveConsolidationZone.Clean();
}
else
{
mActiveConsolidationZone.Update();
}
}
else
{
//
XOHCL mBar;
bool hasBar = GetBar(
mBar,
0 //
);
if (hasBar)
{
//
double upper = 0;
double lower = 0;
bool hasConsolidationZone =
mBarAnalyser.IsConsolidate(
mBar,
upper,
lower,
czLoopback,
czRange //
);
//
if (hasConsolidationZone)
{
//
mActiveConsolidationZone.Init(
GetSymbol(),
GetPeriod(),
upper,
lower,
czLoopback //
);
}
}
//
mBar.Clean();
}
}
//
// Virtuals ...
@@ -729,11 +471,6 @@ class XC121SMCCycleHelper : public XCBase
string mSymbol;
ENUM_TIMEFRAMES mPeriod;
//
// CArrayObj mConsolidationObjects;
XConsolidationZone mActiveConsolidationZone;
XConsolidationZone mConsolidationZones[];
//
// Actions ...
@@ -751,10 +488,6 @@ class XC121SMCCycleHelper : public XCBase
delete mX121Helper;
delete mPOIDetector;
delete mBarAnalyser;
//
Clean(mConsolidationZones);
mActiveConsolidationZone.Clean();
}
/**
+223 -223
View File
@@ -489,172 +489,172 @@ bool DetectX121SMCGuards(
//
//
//
// Detect Consolidation Zone ...
// //
// // Detect Consolidation Zone ...
//
// Detect Consolidation Zones ...
// //
// // Detect Consolidation Zones ...
//
XBoxZone lastBullishBox;
XBoxZone prevLastBullishBox;
bool hasLastBullishBox = false;
bool hasPrevLastBullishBox = false;
XConsolidationZone lastBullishZone;
bool isLastBullishAbovePrev = false;
bool isLastBullishBelowPrev = false;
XConsolidationZone prevLastBullishZone;
// //
// XBoxZone lastBullishBox;
// XBoxZone prevLastBullishBox;
// bool hasLastBullishBox = false;
// bool hasPrevLastBullishBox = false;
// XConsolidationZone lastBullishZone;
// bool isLastBullishAbovePrev = false;
// bool isLastBullishBelowPrev = false;
// XConsolidationZone prevLastBullishZone;
//
XBoxZone lastBearishBox;
XBoxZone prevLastBearishBox;
bool hasLastBearishBox = false;
bool hasPrevLastBearishBox = false;
XConsolidationZone lastBearishZone;
bool isLastBearishAbovePrev = false;
bool isLastBearishBelowPrev = false;
XConsolidationZone prevLastBearishZone;
// //
// XBoxZone lastBearishBox;
// XBoxZone prevLastBearishBox;
// bool hasLastBearishBox = false;
// bool hasPrevLastBearishBox = false;
// XConsolidationZone lastBearishZone;
// bool isLastBearishAbovePrev = false;
// bool isLastBearishBelowPrev = false;
// XConsolidationZone prevLastBearishZone;
//
int bullishConsolidationZonesCount = 0;
int bearishConsolidationZonesCount = 0;
bool hasBullishConsolidationZones = false;
bool hasBearishConsolidationZones = false;
XConsolidationZone bullishConsolidationZones[];
XConsolidationZone bearishConsolidationZones[];
bool hasConsolidationZones = decisionCycleHelper.HasConsolidationZones();
int consolidationZonesCount = decisionCycleHelper.CountConsolidationZones();
if (hasConsolidationZones)
{
//
bullishConsolidationZonesCount = decisionCycleHelper
.FillConsolidationZones(
X_DIRECTION_BULLISH,
bullishConsolidationZones //
);
hasBullishConsolidationZones = IsValidSize(bullishConsolidationZonesCount);
// //
// int bullishConsolidationZonesCount = 0;
// int bearishConsolidationZonesCount = 0;
// bool hasBullishConsolidationZones = false;
// bool hasBearishConsolidationZones = false;
// XConsolidationZone bullishConsolidationZones[];
// XConsolidationZone bearishConsolidationZones[];
// bool hasConsolidationZones = decisionCycleHelper.HasConsolidationZones();
// int consolidationZonesCount = decisionCycleHelper.CountConsolidationZones();
// if (hasConsolidationZones)
// {
// //
// bullishConsolidationZonesCount = decisionCycleHelper
// .FillConsolidationZones(
// X_DIRECTION_BULLISH,
// bullishConsolidationZones //
// );
// hasBullishConsolidationZones = IsValidSize(bullishConsolidationZonesCount);
//
bearishConsolidationZonesCount = decisionCycleHelper
.FillConsolidationZones(
X_DIRECTION_BEARISH,
bearishConsolidationZones //
);
hasBearishConsolidationZones = IsValidSize(bearishConsolidationZonesCount);
// //
// bearishConsolidationZonesCount = decisionCycleHelper
// .FillConsolidationZones(
// X_DIRECTION_BEARISH,
// bearishConsolidationZones //
// );
// hasBearishConsolidationZones = IsValidSize(bearishConsolidationZonesCount);
//
//
//
// //
// //
// //
//
if (hasBullishConsolidationZones &&
bullishConsolidationZonesCount >= 2)
{
//
lastBullishZone = bullishConsolidationZones[bullishConsolidationZonesCount - 1];
prevLastBullishZone = bullishConsolidationZones[bullishConsolidationZonesCount - 2];
// //
// if (hasBullishConsolidationZones &&
// bullishConsolidationZonesCount >= 2)
// {
// //
// lastBullishZone = bullishConsolidationZones[bullishConsolidationZonesCount - 1];
// prevLastBullishZone = bullishConsolidationZones[bullishConsolidationZonesCount - 2];
//
hasLastBullishBox = ToBox(
lastBullishBox,
lastBullishZone //
);
hasPrevLastBullishBox = ToBox(
prevLastBullishBox,
prevLastBullishZone //
);
// //
// hasLastBullishBox = ToBox(
// lastBullishBox,
// lastBullishZone //
// );
// hasPrevLastBullishBox = ToBox(
// prevLastBullishBox,
// prevLastBullishZone //
// );
//
isLastBullishAbovePrev = hasLastBullishBox &&
hasPrevLastBullishBox &&
IsBoxAbove(
lastBullishBox,
prevLastBullishBox //
);
// //
// isLastBullishAbovePrev = hasLastBullishBox &&
// hasPrevLastBullishBox &&
// IsBoxAbove(
// lastBullishBox,
// prevLastBullishBox //
// );
//
isLastBullishBelowPrev = hasLastBullishBox &&
hasPrevLastBullishBox &&
IsBoxBelow(
lastBullishBox,
prevLastBullishBox //
);
}
// //
// isLastBullishBelowPrev = hasLastBullishBox &&
// hasPrevLastBullishBox &&
// IsBoxBelow(
// lastBullishBox,
// prevLastBullishBox //
// );
// }
//
if (hasBearishConsolidationZones &&
bearishConsolidationZonesCount >= 2)
{
//
lastBearishZone = bearishConsolidationZones[bearishConsolidationZonesCount - 1];
prevLastBearishZone = bearishConsolidationZones[bearishConsolidationZonesCount - 2];
// //
// if (hasBearishConsolidationZones &&
// bearishConsolidationZonesCount >= 2)
// {
// //
// lastBearishZone = bearishConsolidationZones[bearishConsolidationZonesCount - 1];
// prevLastBearishZone = bearishConsolidationZones[bearishConsolidationZonesCount - 2];
//
hasLastBearishBox = ToBox(
lastBearishBox,
lastBearishZone //
);
hasPrevLastBearishBox = ToBox(
prevLastBearishBox,
prevLastBearishZone //
);
// //
// hasLastBearishBox = ToBox(
// lastBearishBox,
// lastBearishZone //
// );
// hasPrevLastBearishBox = ToBox(
// prevLastBearishBox,
// prevLastBearishZone //
// );
//
isLastBearishAbovePrev = hasLastBearishBox &&
hasPrevLastBearishBox &&
IsBoxAbove(
lastBearishBox,
prevLastBearishBox //
);
// //
// isLastBearishAbovePrev = hasLastBearishBox &&
// hasPrevLastBearishBox &&
// IsBoxAbove(
// lastBearishBox,
// prevLastBearishBox //
// );
//
isLastBearishBelowPrev = hasLastBearishBox &&
hasPrevLastBearishBox &&
IsBoxBelow(
lastBearishBox,
prevLastBearishBox //
);
}
// //
// isLastBearishBelowPrev = hasLastBearishBox &&
// hasPrevLastBearishBox &&
// IsBoxBelow(
// lastBearishBox,
// prevLastBearishBox //
// );
// }
//
}
// //
// }
//
// Detect High Probability Swings ...
bool isSwingLow =
//
cBar.low > pBar.low &&
ppBar.low > pBar.low &&
//
zBar.low > pBar.low
//
;
bool isSwingHigh =
//
cBar.high < pBar.high &&
ppBar.high < pBar.high &&
//
zBar.high < pBar.high
//
;
bool isStrongSwingLow =
pBar.IsBullish() &&
pBar.GetLowShadow() >= pBar.GetBody() * 2;
bool isStrongSwingHigh =
pBar.IsBearish() &&
pBar.GetHighShadow() >= pBar.GetBody() * 2;
// bool isSwingLow =
// //
// cBar.low > pBar.low &&
// ppBar.low > pBar.low &&
// //
// zBar.low > pBar.low
// //
// ;
// bool isSwingHigh =
// //
// cBar.high < pBar.high &&
// ppBar.high < pBar.high &&
// //
// zBar.high < pBar.high
// //
// ;
// bool isStrongSwingLow =
// pBar.IsBullish() &&
// pBar.GetLowShadow() >= pBar.GetBody() * 2;
// bool isStrongSwingHigh =
// pBar.IsBearish() &&
// pBar.GetHighShadow() >= pBar.GetBody() * 2;
//
bool isStrongSwingLowAboveLastBullishBox =
isStrongSwingLow &&
hasLastBullishBox &&
pBar.low > lastBullishBox.upper;
// //
// bool isStrongSwingLowAboveLastBullishBox =
// isStrongSwingLow &&
// hasLastBullishBox &&
// pBar.low > lastBullishBox.upper;
//
bool isStrongSwingHighBelowLastBearishBox =
isStrongSwingHigh &&
hasLastBearishBox &&
pBar.high < lastBearishBox.lower;
// //
// bool isStrongSwingHighBelowLastBearishBox =
// isStrongSwingHigh &&
// hasLastBearishBox &&
// pBar.high < lastBearishBox.lower;
//
// Here We Have all Requirements for Guarding Positions ...
@@ -822,82 +822,82 @@ bool DetectX121SMCGuards(
// - occures two same type consolidation zones in order of positions type;
// - occures a swing in order of consolidation zones ...
//
bool canTrailBasedOnTwoZone =
isLong
? isLastBullishAbovePrev
: isLastBearishBelowPrev;
if (canTrailBasedOnTwoZone)
{
//
trailedStop =
isLong
? prevLastBullishBox.lower
: prevLastBearishBox.upper;
}
// //
// bool canTrailBasedOnTwoZone =
// isLong
// ? isLastBullishAbovePrev
// : isLastBearishBelowPrev;
// if (canTrailBasedOnTwoZone)
// {
// //
// trailedStop =
// isLong
// ? prevLastBullishBox.lower
// : prevLastBearishBox.upper;
// }
//
bool canTrailBasedOnZoneSwing =
trailedStop <= 0 &&
(isLong
? isStrongSwingLowAboveLastBullishBox
: isStrongSwingHighBelowLastBearishBox);
if (canTrailBasedOnZoneSwing)
{
//
trailedStop =
isLong
? pBar.low
: pBar.high;
}
// //
// bool canTrailBasedOnZoneSwing =
// trailedStop <= 0 &&
// (isLong
// ? isStrongSwingLowAboveLastBullishBox
// : isStrongSwingHighBelowLastBearishBox);
// if (canTrailBasedOnZoneSwing)
// {
// //
// trailedStop =
// isLong
// ? pBar.low
// : pBar.high;
// }
//
bool canDoTrailStop =
trailedStop > 0 &&
(
//
iPosition.sl == 0
? (isLong
? trailedStop > iPosition.entry &&
trailedStop < iPosition.price
: trailedStop < iPosition.entry &&
trailedStop > iPosition.price)
: (isLong
? trailedStop > iPosition.sl &&
trailedStop > iPosition.entry &&
trailedStop < iPosition.price
: trailedStop < iPosition.sl &&
trailedStop < iPosition.entry &&
trailedStop > iPosition.price)
//
)
//
;
// //
// bool canDoTrailStop =
// trailedStop > 0 &&
// (
// //
// iPosition.sl == 0
// ? (isLong
// ? trailedStop > iPosition.entry &&
// trailedStop < iPosition.price
// : trailedStop < iPosition.entry &&
// trailedStop > iPosition.price)
// : (isLong
// ? trailedStop > iPosition.sl &&
// trailedStop > iPosition.entry &&
// trailedStop < iPosition.price
// : trailedStop < iPosition.sl &&
// trailedStop < iPosition.entry &&
// trailedStop > iPosition.price)
// //
// )
// //
// ;
//
if (canDoTrailStop)
{
//
X121SMCGuard iGuard;
// //
// if (canDoTrailStop)
// {
// //
// X121SMCGuard iGuard;
//
iGuard.time = cTime;
iGuard.symbol = symbol;
iGuard.provider = provider;
iGuard.action = X_121_SMC_GUARD_ACTION_TRAIL_STOP;
// //
// iGuard.time = cTime;
// iGuard.symbol = symbol;
// iGuard.provider = provider;
// iGuard.action = X_121_SMC_GUARD_ACTION_TRAIL_STOP;
//
iGuard.ticket = iPosition.ticket;
// //
// iGuard.ticket = iPosition.ticket;
//
iGuard.sl = trailedStop;
// //
// iGuard.sl = trailedStop;
//
AddGuard(
iGuard,
guards //
);
}
// //
// AddGuard(
// iGuard,
// guards //
// );
// }
}
}
@@ -956,14 +956,14 @@ bool DetectX121SMCGuards(
consolidationXConditions.Clean();
//
lastBullishBox.Clean();
lastBearishBox.Clean();
lastBullishZone.Clean();
lastBearishZone.Clean();
prevLastBullishBox.Clean();
prevLastBearishBox.Clean();
prevLastBullishZone.Clean();
prevLastBearishZone.Clean();
// lastBullishBox.Clean();
// lastBearishBox.Clean();
// lastBullishZone.Clean();
// lastBearishZone.Clean();
// prevLastBullishBox.Clean();
// prevLastBearishBox.Clean();
// prevLastBullishZone.Clean();
// prevLastBearishZone.Clean();
//
count = ArraySize(guards);
+114 -114
View File
@@ -1082,26 +1082,26 @@ class XCX121SMCXWZSignalDetector : public XCBase
//
//
//
// Detect Consolidation Zone ...
// //
// // Detect Consolidation Zone ...
//
// Bullish ...
XConsolidationZone bullishConsolidationZone;
bool hasBullishConsolidationZone = decisionCycleHelper
.GetLastDirectionalConsolidationZone(
X_DIRECTION_BULLISH,
bullishConsolidationZone //
);
// //
// // Bullish ...
// XConsolidationZone bullishConsolidationZone;
// bool hasBullishConsolidationZone = decisionCycleHelper
// .GetLastDirectionalConsolidationZone(
// X_DIRECTION_BULLISH,
// bullishConsolidationZone //
// );
//
// Bearish ...
XConsolidationZone bearishConsolidationZone;
bool hasBearishConsolidationZone = decisionCycleHelper
.GetLastDirectionalConsolidationZone(
X_DIRECTION_BEARISH,
bearishConsolidationZone //
);
// //
// // Bearish ...
// XConsolidationZone bearishConsolidationZone;
// bool hasBearishConsolidationZone = decisionCycleHelper
// .GetLastDirectionalConsolidationZone(
// X_DIRECTION_BEARISH,
// bearishConsolidationZone //
// );
//
// Detect High Probability Swings ...
@@ -1179,114 +1179,114 @@ class XCX121SMCXWZSignalDetector : public XCBase
double sl = iPosition.sl;
double tp = iPosition.tp;
//
// Trail Stops Using Consolidation Zones ...
bool canTraiLonglUsingCZone =
//
(isLong &&
isInProfit &&
hasBullishConsolidationZone &&
bullishConsolidationZone.lower > iPosition.sl &&
bullishConsolidationZone.lower > iPosition.entry)
//
;
if (canTraiLonglUsingCZone)
{
sl = bullishConsolidationZone.lower;
}
// //
// // Trail Stops Using Consolidation Zones ...
// bool canTraiLonglUsingCZone =
// //
// (isLong &&
// isInProfit &&
// hasBullishConsolidationZone &&
// bullishConsolidationZone.lower > iPosition.sl &&
// bullishConsolidationZone.lower > iPosition.entry)
// //
// ;
// if (canTraiLonglUsingCZone)
// {
// sl = bullishConsolidationZone.lower;
// }
//
bool canTraiShortlUsingCZone =
//
(!isLong &&
isInProfit &&
hasBearishConsolidationZone &&
bearishConsolidationZone.upper < iPosition.sl &&
bearishConsolidationZone.upper < iPosition.entry)
//
;
if (canTraiShortlUsingCZone)
{
sl = bearishConsolidationZone.upper;
}
// //
// bool canTraiShortlUsingCZone =
// //
// (!isLong &&
// isInProfit &&
// hasBearishConsolidationZone &&
// bearishConsolidationZone.upper < iPosition.sl &&
// bearishConsolidationZone.upper < iPosition.entry)
// //
// ;
// if (canTraiShortlUsingCZone)
// {
// sl = bearishConsolidationZone.upper;
// }
//
bool canTrailUsingCZone =
canTraiLonglUsingCZone ||
canTraiShortlUsingCZone;
// //
// bool canTrailUsingCZone =
// canTraiLonglUsingCZone ||
// canTraiShortlUsingCZone;
//
// Trail Stops Using Swings ...
// //
// // Trail Stops Using Swings ...
//
bool canTrailLongUsingSwings =
//
isLong &&
isInProfit &&
(isSwingLow ||
isStrongSwingLow) &&
pBar.low > iPosition.sl &&
pBar.low > iPosition.entry
//
;
if (canTrailLongUsingSwings)
{
sl = pBar.low;
}
// //
// bool canTrailLongUsingSwings =
// //
// isLong &&
// isInProfit &&
// (isSwingLow ||
// isStrongSwingLow) &&
// pBar.low > iPosition.sl &&
// pBar.low > iPosition.entry
// //
// ;
// if (canTrailLongUsingSwings)
// {
// sl = pBar.low;
// }
//
bool canTraiShortlUsingSwings =
//
!isLong &&
isInProfit &&
(isSwingHigh ||
isStrongSwingHigh) &&
pBar.high < iPosition.sl &&
pBar.high < iPosition.entry
//
;
if (canTraiShortlUsingSwings)
{
sl = pBar.high;
}
// //
// bool canTraiShortlUsingSwings =
// //
// !isLong &&
// isInProfit &&
// (isSwingHigh ||
// isStrongSwingHigh) &&
// pBar.high < iPosition.sl &&
// pBar.high < iPosition.entry
// //
// ;
// if (canTraiShortlUsingSwings)
// {
// sl = pBar.high;
// }
//
bool canTrailUsingSwings =
canTrailLongUsingSwings ||
canTraiShortlUsingSwings;
// //
// bool canTrailUsingSwings =
// canTrailLongUsingSwings ||
// canTraiShortlUsingSwings;
//
//
//
// //
// //
// //
//
bool canTrail =
sl != iPosition.sl &&
(canTrailUsingCZone ||
canTrailUsingSwings);
if (canTrail)
{
//
X121SMCGuard iGuard;
// //
// bool canTrail =
// sl != iPosition.sl &&
// (canTrailUsingCZone ||
// canTrailUsingSwings);
// if (canTrail)
// {
// //
// X121SMCGuard iGuard;
//
iGuard.time = cTime;
iGuard.symbol = symbol;
iGuard.provider = provider;
iGuard.action = X_121_SMC_GUARD_ACTION_TRAIL_STOP;
// //
// iGuard.time = cTime;
// iGuard.symbol = symbol;
// iGuard.provider = provider;
// iGuard.action = X_121_SMC_GUARD_ACTION_TRAIL_STOP;
//
iGuard.ticket = iPosition.ticket;
// //
// iGuard.ticket = iPosition.ticket;
//
iGuard.sl = sl;
// //
// iGuard.sl = sl;
//
AddGuard(
iGuard,
guards //
);
}
// //
// AddGuard(
// iGuard,
// guards //
// );
// }
}
//
@@ -451,9 +451,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
*/
void DoUnwaitedTicksWork() override
{
//
// Decision ...
mDecisionCycleHelper.Update();
}
/**
@@ -814,6 +811,12 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
x121Inputs.xvwapInputs.showVWapMedium = showAll || true;
x121Inputs.xvwapInputs.showVWapSlow = showAll || true;
//
// X3MA ...
x121Inputs.x3maInputs.showX3MaFast = showAll || true;
x121Inputs.x3maInputs.showX3MaMid = showAll || true;
x121Inputs.x3maInputs.showX3MaSlow = showAll || true;
//
// Initialize Cycle Helpers ...