last ...
This commit is contained in:
@@ -1273,42 +1273,6 @@ bool IsBoxUsed(
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a Consolidation Zone ...
|
||||
*
|
||||
* @param zone: XConsolidationZone instance Reference ...
|
||||
* @param dest: XCZone pointer Reference ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool ToZone(
|
||||
XConsolidationZone &zone,
|
||||
XCZone *&dest //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
dest = NULL;
|
||||
|
||||
//
|
||||
result = zone.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
dest = new XCZone();
|
||||
dest.Upper(zone.upper);
|
||||
dest.Lower(zone.lower);
|
||||
result = dest.IsValidBoundary();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts to XBoxZone ...
|
||||
*
|
||||
@@ -1586,7 +1550,7 @@ bool ToBox(
|
||||
box.upper = item.upper;
|
||||
box.lower = item.lower;
|
||||
box.dir = item.breakDir;
|
||||
box.from = item.initTime;
|
||||
box.from = item.From();
|
||||
box.symbol = item.symbol;
|
||||
box.period = item.period;
|
||||
box.to = item.breakerBar.time;
|
||||
@@ -1600,18 +1564,20 @@ bool ToBox(
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Oldest Zone ...
|
||||
* Converts to XBoxZone ...
|
||||
*
|
||||
* @return ( int )
|
||||
* @return ( bool )
|
||||
*/
|
||||
int GetOldest(
|
||||
XCZone *&source[] //
|
||||
int ToBox(
|
||||
XConsolidationZone &source[],
|
||||
XBoxZone &dest[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = -1;
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
Clean(dest);
|
||||
int count = ArraySize(source);
|
||||
if (!IsValidSize(count))
|
||||
{
|
||||
@@ -1619,67 +1585,35 @@ int GetOldest(
|
||||
}
|
||||
|
||||
//
|
||||
XCZone *oldest = NULL;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XCZone *iZone = source[i];
|
||||
XConsolidationZone iZone = source[i];
|
||||
|
||||
//
|
||||
bool canSet =
|
||||
oldest == NULL ||
|
||||
(oldest != NULL &&
|
||||
oldest.From() > iZone.From());
|
||||
if (canSet)
|
||||
XBoxZone iBox;
|
||||
bool hasBox = ToBox(
|
||||
iBox,
|
||||
iZone //
|
||||
);
|
||||
|
||||
//
|
||||
if (hasBox)
|
||||
{
|
||||
//
|
||||
result = i;
|
||||
oldest = iZone;
|
||||
}
|
||||
AddRef(
|
||||
iBox,
|
||||
dest //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Youngest Zone ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int GetYoungest(
|
||||
XCZone *&source[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = -1;
|
||||
|
||||
//
|
||||
int count = ArraySize(source);
|
||||
if (!IsValidSize(count))
|
||||
{
|
||||
return result;
|
||||
iBox.Clean();
|
||||
iZone.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
XCZone *youngest = NULL;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XCZone *iZone = source[i];
|
||||
|
||||
//
|
||||
bool canSet =
|
||||
youngest == NULL ||
|
||||
(youngest != NULL &&
|
||||
youngest.From() < iZone.From());
|
||||
if (canSet)
|
||||
{
|
||||
//
|
||||
result = i;
|
||||
youngest = iZone;
|
||||
}
|
||||
}
|
||||
result = ArraySize(dest);
|
||||
|
||||
//
|
||||
return result;
|
||||
@@ -1726,6 +1660,9 @@ int GetOldest(
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
selected.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
@@ -1771,6 +1708,9 @@ int GetYoungest(
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
selected.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
@@ -1816,6 +1756,9 @@ int GetHighest(
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
selected.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
@@ -1868,6 +1811,254 @@ int GetLowest(
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Oldest Box Index ...
|
||||
*
|
||||
* @param source: XBoxZone instance Reference Collection ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int GetOldest(
|
||||
XConsolidationZone &source[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = -1;
|
||||
|
||||
//
|
||||
int count = ArraySize(source);
|
||||
if (!IsValidSize(count))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XBoxZone tmpBoxes[];
|
||||
int boxesCount = ToBox(
|
||||
source,
|
||||
tmpBoxes //
|
||||
);
|
||||
if (!IsValidSize(boxesCount))
|
||||
{
|
||||
//
|
||||
Clean(tmpBoxes);
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XBoxZone selected;
|
||||
for (int i = 0; i < boxesCount; i++)
|
||||
{
|
||||
//
|
||||
XBoxZone iBox = tmpBoxes[i];
|
||||
|
||||
//
|
||||
bool canSet =
|
||||
!selected.IsValid()
|
||||
? true
|
||||
: selected.from > iBox.from;
|
||||
if (canSet)
|
||||
{
|
||||
//
|
||||
result = i;
|
||||
selected = iBox;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
Clean(tmpBoxes);
|
||||
selected.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Youngest Box Index ...
|
||||
*
|
||||
* @param source: XBoxZone instance Reference Collection ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int GetYoungest(
|
||||
XConsolidationZone &source[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = -1;
|
||||
|
||||
//
|
||||
int count = ArraySize(source);
|
||||
if (!IsValidSize(count))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XBoxZone tmpBoxes[];
|
||||
int boxesCount = ToBox(
|
||||
source,
|
||||
tmpBoxes //
|
||||
);
|
||||
if (!IsValidSize(boxesCount))
|
||||
{
|
||||
//
|
||||
Clean(tmpBoxes);
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XBoxZone selected;
|
||||
for (int i = 0; i < boxesCount; i++)
|
||||
{
|
||||
//
|
||||
XBoxZone iBox = tmpBoxes[i];
|
||||
|
||||
//
|
||||
bool canSet =
|
||||
!selected.IsValid()
|
||||
? true
|
||||
: selected.from < iBox.from;
|
||||
if (canSet)
|
||||
{
|
||||
//
|
||||
result = i;
|
||||
selected = iBox;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
Clean(tmpBoxes);
|
||||
selected.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Highest Box Index ...
|
||||
*
|
||||
* @param source: XBoxZone instance Reference Collection ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int GetHighest(
|
||||
XConsolidationZone &source[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = -1;
|
||||
|
||||
//
|
||||
int count = ArraySize(source);
|
||||
if (!IsValidSize(count))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XBoxZone tmpBoxes[];
|
||||
int boxesCount = ToBox(
|
||||
source,
|
||||
tmpBoxes //
|
||||
);
|
||||
if (!IsValidSize(boxesCount))
|
||||
{
|
||||
//
|
||||
Clean(tmpBoxes);
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XBoxZone selected;
|
||||
for (int i = 0; i < boxesCount; i++)
|
||||
{
|
||||
//
|
||||
XBoxZone iBox = tmpBoxes[i];
|
||||
|
||||
//
|
||||
bool canSet =
|
||||
!selected.IsValid()
|
||||
? true
|
||||
: selected.upper < iBox.upper;
|
||||
if (canSet)
|
||||
{
|
||||
//
|
||||
result = i;
|
||||
selected = iBox;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
Clean(tmpBoxes);
|
||||
selected.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Lowest Box Index ...
|
||||
*
|
||||
* @param source: XBoxZone instance Reference Collection ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int GetLowest(
|
||||
XConsolidationZone &source[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = -1;
|
||||
|
||||
//
|
||||
int count = ArraySize(source);
|
||||
if (!IsValidSize(count))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XBoxZone tmpBoxes[];
|
||||
int boxesCount = ToBox(
|
||||
source,
|
||||
tmpBoxes //
|
||||
);
|
||||
if (!IsValidSize(boxesCount))
|
||||
{
|
||||
//
|
||||
Clean(tmpBoxes);
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XBoxZone selected;
|
||||
for (int i = 0; i < boxesCount; i++)
|
||||
{
|
||||
//
|
||||
XBoxZone iBox = tmpBoxes[i];
|
||||
|
||||
//
|
||||
bool canSet =
|
||||
!selected.IsValid()
|
||||
? true
|
||||
: selected.lower > iBox.lower;
|
||||
if (canSet)
|
||||
{
|
||||
//
|
||||
result = i;
|
||||
selected = iBox;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
Clean(tmpBoxes);
|
||||
selected.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
template <typename T>
|
||||
void SortZones(
|
||||
|
||||
@@ -34,6 +34,7 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
XOBFVG chochZone;
|
||||
XOBFVG targetZone;
|
||||
XOBFVG signalZone;
|
||||
XOBFVG waitingZone;
|
||||
@@ -605,6 +606,7 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
// Checking Order Flow Break ...
|
||||
int breakedIDX = -1;
|
||||
bool isOrderFlowBreaked =
|
||||
hasOrderFlow &&
|
||||
workingZone.IsOrderFlowBreaked(
|
||||
breakedIDX,
|
||||
true, // Force OB Breaked
|
||||
@@ -624,59 +626,21 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
);
|
||||
|
||||
//
|
||||
Clean(workingZone.orderFlow);
|
||||
hasOrderFlow = false;
|
||||
signalZone = workingZone.orderFlow[breakedIDX];
|
||||
provider = X121SMC_XWZ_PROVIDER_ACTIVATED_CHOCH;
|
||||
|
||||
//
|
||||
ArrayRemove(
|
||||
workingZone.orderFlow,
|
||||
breakedIDX,
|
||||
1 //
|
||||
);
|
||||
|
||||
//
|
||||
CleanupArray(
|
||||
workingZone.brokenOrderFlow,
|
||||
10 //
|
||||
);
|
||||
|
||||
//
|
||||
// TODO: Here Implement CHOCH Trading Senario ...
|
||||
|
||||
//
|
||||
}
|
||||
result = !isOrderFlowBreaked;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
Clean(visionPoiEvents);
|
||||
Clean(analysePoiEvents);
|
||||
Clean(decisionPoiEvents);
|
||||
Clean(consolidationPoiEvents);
|
||||
|
||||
//
|
||||
Clean(visionCycleEvents);
|
||||
Clean(analyseCycleEvents);
|
||||
Clean(decisionCycleEvents);
|
||||
Clean(consolidationCycleEvents);
|
||||
|
||||
//
|
||||
visionState.Clean();
|
||||
analyseState.Clean();
|
||||
decisionState.Clean();
|
||||
consolidationState.Clean();
|
||||
|
||||
//
|
||||
visionConditions.Clean();
|
||||
analyseConditions.Clean();
|
||||
decisionConditions.Clean();
|
||||
consolidationConditions.Clean();
|
||||
|
||||
//
|
||||
visionXConditions.Clean();
|
||||
analyseXConditions.Clean();
|
||||
decisionXConditions.Clean();
|
||||
consolidationXConditions.Clean();
|
||||
|
||||
//
|
||||
mConditions.Clean();
|
||||
consolidationZBar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1150,6 +1114,48 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
waitingZone.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
if (signalZone.IsValid() &&
|
||||
provider == X121SMC_XWZ_PROVIDER_ACTIVATED_CHOCH)
|
||||
{
|
||||
//
|
||||
ENUM_X_DIRECTION iForDir = Opposit(signalZone.GetDirection());
|
||||
if (hasNewAnalyseOB &&
|
||||
hasNewAnalyseFVG)
|
||||
{
|
||||
//
|
||||
bool isSameDir =
|
||||
newAnalyseOB.GetDirection() == iForDir &&
|
||||
newAnalyseFVG.GetDirection() == iForDir;
|
||||
bool isOneInsideAnoter =
|
||||
//
|
||||
(newAnalyseFVG.Upper() < newAnalyseOB.Upper() &&
|
||||
newAnalyseFVG.Upper() > newAnalyseOB.Lower())
|
||||
//
|
||||
||
|
||||
//
|
||||
(newAnalyseOB.Upper() < newAnalyseFVG.Upper() &&
|
||||
newAnalyseOB.Upper() > newAnalyseFVG.Lower())
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool isZoneDetected =
|
||||
isSameDir &&
|
||||
isOneInsideAnoter;
|
||||
if (isZoneDetected)
|
||||
{
|
||||
//
|
||||
XOBFVG iSignalZone;
|
||||
iSignalZone.ob = newAnalyseOB;
|
||||
iSignalZone.fvg = newAnalyseFVG;
|
||||
|
||||
//
|
||||
chochZone = iSignalZone;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
ZeroMemory(newOB);
|
||||
ZeroMemory(newFVG);
|
||||
@@ -1157,6 +1163,74 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
ZeroMemory(newAnalyseFVG);
|
||||
}
|
||||
|
||||
//
|
||||
bool isPriceInsideCHOCHZone = false;
|
||||
bool hasCHOCHZone = chochZone.IsValid();
|
||||
if (hasCHOCHZone)
|
||||
{
|
||||
//
|
||||
XCBaseObject *objects[];
|
||||
bool isCreated = visionCycleHelper
|
||||
.mPOIDrawer
|
||||
.DrawOBFVG(
|
||||
chochZone,
|
||||
objects //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
AddDrawnObjects(objects);
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL cBar;
|
||||
bool isInited = cBar.Init(
|
||||
symbol,
|
||||
period,
|
||||
cIndex //
|
||||
);
|
||||
|
||||
//
|
||||
isPriceInsideCHOCHZone =
|
||||
isInited &&
|
||||
cBar.low >= chochZone.fvg.Lower() &&
|
||||
cBar.high <= chochZone.fvg.Upper();
|
||||
if (isPriceInsideCHOCHZone)
|
||||
{
|
||||
//
|
||||
// Reverse Trend and ReCalculate Requirements
|
||||
// For CHOCH Tradng ...
|
||||
|
||||
//
|
||||
trend = chochZone.GetDirection();
|
||||
|
||||
//
|
||||
isBullish = IsBullish(trend);
|
||||
isBearish = IsBearish(trend);
|
||||
|
||||
//
|
||||
bool hasPriority = workingZone
|
||||
.DetectPriority(
|
||||
priority,
|
||||
trend,
|
||||
zIndex,
|
||||
period //
|
||||
);
|
||||
|
||||
//
|
||||
bool hasRewardAmount = CalculateRiskReward(
|
||||
priority,
|
||||
reward,
|
||||
amountPercent //
|
||||
);
|
||||
|
||||
//
|
||||
provider = X121SMC_XWZ_PROVIDER_ACTIVATED_CHOCH;
|
||||
}
|
||||
|
||||
//
|
||||
cBar.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Reading Trand Line Value ...
|
||||
double zValue = workingZone.GetOrderFlowTrendLinePrice(
|
||||
@@ -1264,6 +1338,44 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
signalZone.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// TODO: Implement CHOCH Trading Senario ...
|
||||
bool hasCHOCHConditions =
|
||||
hasCHOCHZone &&
|
||||
chochZone.IsValid() &&
|
||||
isPriceInsideCHOCHZone &&
|
||||
provider == X121SMC_XWZ_PROVIDER_ACTIVATED_CHOCH;
|
||||
|
||||
//
|
||||
hasChochBullishConditions =
|
||||
hasCHOCHConditions &&
|
||||
chochZone.IsBullish();
|
||||
hasChochBearishConditions =
|
||||
hasCHOCHConditions &&
|
||||
chochZone.IsBearish();
|
||||
|
||||
//
|
||||
if (hasCHOCHConditions)
|
||||
{
|
||||
//
|
||||
mConditions.signalZone = chochZone;
|
||||
mConditions.targetZone = targetZone;
|
||||
|
||||
//
|
||||
point = hasChochBullishConditions
|
||||
? chochZone.ob.Upper()
|
||||
: chochZone.ob.Lower();
|
||||
|
||||
//
|
||||
pivot = hasChochBearishConditions
|
||||
? chochZone.ob.Lower()
|
||||
: chochZone.ob.Upper();
|
||||
|
||||
//
|
||||
chochZone.Clean();
|
||||
signalZone.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// TODO: Implement Trend Line Trading Senario ...
|
||||
|
||||
@@ -1276,6 +1388,9 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
//
|
||||
// TODO: Implement Support and Resistance Trading Senario ...
|
||||
|
||||
//
|
||||
// TODO: Implement Mitigation Blocks Trading Senario ...
|
||||
|
||||
//
|
||||
// Summarize ...
|
||||
|
||||
@@ -1287,6 +1402,7 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
hasSupResBullishConditions ||
|
||||
hasTrendLineBullishConditions ||
|
||||
hasOrderFlowhBullishConditions ||
|
||||
hasInsideZoneBullishConditions ||
|
||||
hasBQuarterLineBullishConditions
|
||||
//
|
||||
;
|
||||
@@ -1299,6 +1415,7 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
hasSupResBearishConditions ||
|
||||
hasTrendLineBearishConditions ||
|
||||
hasOrderFlowhBearishConditions ||
|
||||
hasInsideZoneBearishConditions ||
|
||||
hasBQuarterLineBearishConditions
|
||||
//
|
||||
;
|
||||
@@ -1533,13 +1650,21 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
bullishScore,
|
||||
bearishScore //
|
||||
);
|
||||
bool isBullishScorePassed =
|
||||
isBullish &&
|
||||
bullishScore > (bearishScore * 1.5);
|
||||
bool isBearishScorePassed =
|
||||
isBearish &&
|
||||
bearishScore > (bullishScore * 1.5);
|
||||
bool isScorePassed = isBullishScorePassed ||
|
||||
isBearishScorePassed;
|
||||
|
||||
//
|
||||
// Base SL Used Pivot of Conditions ...
|
||||
Add(
|
||||
conditions.pivot,
|
||||
sls //
|
||||
);
|
||||
// Add(
|
||||
// conditions.pivot,
|
||||
// sls //
|
||||
// );
|
||||
|
||||
//
|
||||
int lowestSupportIDX = -1;
|
||||
@@ -1588,11 +1713,15 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
;
|
||||
|
||||
//
|
||||
if (isBullish)
|
||||
isSupportRejected =
|
||||
isBullish &&
|
||||
isSupportRejected;
|
||||
if (isSupportRejected)
|
||||
{
|
||||
//
|
||||
double vPivot = conditions.signalZone.supportZones[lowestSupportIDX].Lower();
|
||||
bool canSetPivot = conditions.pivot < vPivot;
|
||||
bool canSetPivot = vPivot > conditions.pivot &&
|
||||
vPivot < conditions.point;
|
||||
if (canSetPivot)
|
||||
{
|
||||
//
|
||||
@@ -1609,7 +1738,7 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
if (IsValidIndex(highestResistanceIDX))
|
||||
{
|
||||
//
|
||||
isSupportRejected =
|
||||
isResistanceRejected =
|
||||
//
|
||||
isBarInited &&
|
||||
(
|
||||
@@ -1627,11 +1756,15 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
;
|
||||
|
||||
//
|
||||
if (isBearish)
|
||||
isResistanceRejected =
|
||||
isBearish &&
|
||||
isResistanceRejected;
|
||||
if (isResistanceRejected)
|
||||
{
|
||||
//
|
||||
double vPivot = conditions.signalZone.resistanceZones[highestResistanceIDX].Upper();
|
||||
bool canSetPivot = conditions.pivot > vPivot;
|
||||
bool canSetPivot = vPivot < conditions.pivot &&
|
||||
vPivot > conditions.point;
|
||||
if (canSetPivot)
|
||||
{
|
||||
//
|
||||
@@ -1650,73 +1783,122 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
//
|
||||
// Consolidation Zone Detection ...
|
||||
|
||||
//
|
||||
// Detect Consolidation Zones ...
|
||||
|
||||
//
|
||||
// Bullish Consolidation Zone ...
|
||||
XConsolidationZone lastBullishConsolidationZone;
|
||||
bool hasBullishConsolidationZone = decisionCycleHelper
|
||||
.GetLastDirectionalConsolidationZone(
|
||||
XConsolidationZone bullishCZones[];
|
||||
bool hasBullishConsolidationZone = false;
|
||||
XConsolidationZone bullishConsolidationZone;
|
||||
int bullishCZonesCount = decisionCycleHelper.FillConsolidationZones(
|
||||
X_DIRECTION_BULLISH,
|
||||
lastBullishConsolidationZone //
|
||||
bullishCZones //
|
||||
);
|
||||
bool hasBullishConsolidationZones = IsValidSize(bullishCZonesCount);
|
||||
if (hasBullishConsolidationZones)
|
||||
{
|
||||
//
|
||||
int idx = -1;
|
||||
while (HasChild(bullishCZones))
|
||||
{
|
||||
//
|
||||
idx = GetYoungest(bullishCZones);
|
||||
hasBullishConsolidationZone = IsValidIndex(idx);
|
||||
if (hasBullishConsolidationZone)
|
||||
{
|
||||
//
|
||||
// Validate Consolidation Zone ...
|
||||
hasBullishConsolidationZone =
|
||||
lastBullishConsolidationZone.lower > conditions.pivot;
|
||||
bullishConsolidationZone = bullishCZones[idx];
|
||||
|
||||
//
|
||||
if (isBullish &&
|
||||
hasBullishConsolidationZone)
|
||||
ArrayRemove(
|
||||
bullishCZones,
|
||||
idx,
|
||||
1 //
|
||||
);
|
||||
|
||||
//
|
||||
// Check Zone Based On pivot, since this is the SL ...
|
||||
hasBullishConsolidationZone =
|
||||
isBullish &&
|
||||
hasBullishConsolidationZone &&
|
||||
bullishConsolidationZone.lower > conditions.pivot &&
|
||||
bullishConsolidationZone.upper <= conditions.point;
|
||||
if (hasBullishConsolidationZone)
|
||||
{
|
||||
//
|
||||
double vPivot = lastBullishConsolidationZone.lower;
|
||||
bool canSetPivot = conditions.pivot < vPivot;
|
||||
if (canSetPivot)
|
||||
XCConsolidationZoneObject *iObj;
|
||||
bool isCreated = decisionCycleHelper.mPOIDrawer.CreateConsolidationZone(
|
||||
bullishConsolidationZone,
|
||||
iObj //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
mObjects.Add(iObj);
|
||||
}
|
||||
|
||||
//
|
||||
Add(
|
||||
vPivot,
|
||||
bullishConsolidationZone.lower,
|
||||
sls //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
lastBullishConsolidationZone.Clean();
|
||||
}
|
||||
Clean(bullishCZones);
|
||||
bullishConsolidationZone.Clean();
|
||||
|
||||
//
|
||||
// Bearish Consolidation Zone ...
|
||||
XConsolidationZone lastBearishConsolidationZone;
|
||||
bool hasBearishConsolidationZone = decisionCycleHelper
|
||||
.GetLastDirectionalConsolidationZone(
|
||||
XConsolidationZone bearishCZones[];
|
||||
bool hasBearishConsolidationZone = false;
|
||||
XConsolidationZone bearishConsolidationZone;
|
||||
int bearishCZonesCount = decisionCycleHelper.FillConsolidationZones(
|
||||
X_DIRECTION_BEARISH,
|
||||
lastBearishConsolidationZone //
|
||||
bearishCZones //
|
||||
);
|
||||
bool hasBearishConsolidationZones = IsValidSize(bearishCZones);
|
||||
if (hasBearishConsolidationZones)
|
||||
{
|
||||
//
|
||||
int idx = -1;
|
||||
while (HasChild(bearishCZones))
|
||||
{
|
||||
//
|
||||
idx = GetYoungest(bearishCZones);
|
||||
hasBearishConsolidationZone = IsValidIndex(idx);
|
||||
if (hasBearishConsolidationZone)
|
||||
{
|
||||
//
|
||||
// Validate Consolidation Zone ...
|
||||
hasBearishConsolidationZone =
|
||||
lastBearishConsolidationZone.upper < conditions.pivot;
|
||||
bearishConsolidationZone = bearishCZones[idx];
|
||||
|
||||
//
|
||||
if (isBearish &&
|
||||
hasBearishConsolidationZone)
|
||||
{
|
||||
ArrayRemove(
|
||||
bearishCZones,
|
||||
idx,
|
||||
1 //
|
||||
);
|
||||
|
||||
//
|
||||
double vPivot = lastBearishConsolidationZone.upper;
|
||||
bool canSetPivot = conditions.pivot > vPivot;
|
||||
if (canSetPivot)
|
||||
hasBearishConsolidationZone =
|
||||
isBearish &&
|
||||
hasBearishConsolidationZone &&
|
||||
bearishConsolidationZone.upper < conditions.pivot &&
|
||||
bearishConsolidationZone.lower >= conditions.point;
|
||||
if (hasBearishConsolidationZone)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
vPivot,
|
||||
bearishConsolidationZone.upper,
|
||||
sls //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
lastBearishConsolidationZone.Clean();
|
||||
}
|
||||
Clean(bearishCZones);
|
||||
bearishConsolidationZone.Clean();
|
||||
|
||||
//
|
||||
// Check VWap Crossing ...
|
||||
@@ -1733,12 +1915,17 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
decisionXConditions.isVWapSwitchedToBullishOrdered)
|
||||
//
|
||||
;
|
||||
if (isBullish &&
|
||||
isVWapSwitchedToBullish)
|
||||
|
||||
//
|
||||
isVWapSwitchedToBullish =
|
||||
isBullish &&
|
||||
isVWapSwitchedToBullish;
|
||||
if (isVWapSwitchedToBullish)
|
||||
{
|
||||
//
|
||||
double vPivot = decisionXConditions.vwapMin;
|
||||
bool canSetPivot = conditions.pivot < vPivot;
|
||||
bool canSetPivot = vPivot > conditions.pivot &&
|
||||
vPivot < conditions.point;
|
||||
if (canSetPivot)
|
||||
{
|
||||
//
|
||||
@@ -1761,12 +1948,17 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
decisionXConditions.isVWapSwitchedToBearishOrdered)
|
||||
//
|
||||
;
|
||||
if (isBearish &&
|
||||
isVWapSwitchedToBearish)
|
||||
|
||||
//
|
||||
isVWapSwitchedToBearish =
|
||||
isBearish &&
|
||||
isVWapSwitchedToBearish;
|
||||
if (isVWapSwitchedToBearish)
|
||||
{
|
||||
//
|
||||
double vPivot = decisionXConditions.vwapMax;
|
||||
bool canSetPivot = conditions.pivot > vPivot;
|
||||
bool canSetPivot = vPivot < conditions.pivot &&
|
||||
vPivot > conditions.point;
|
||||
if (canSetPivot)
|
||||
{
|
||||
//
|
||||
@@ -1794,16 +1986,36 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
);
|
||||
cBar.Clean();
|
||||
|
||||
//
|
||||
bool isCommonsPassed =
|
||||
//
|
||||
(isSupportRejected ||
|
||||
isResistanceRejected ||
|
||||
isVWapSwitchedToBullish ||
|
||||
isVWapSwitchedToBearish ||
|
||||
hasBullishConsolidationZone ||
|
||||
hasBearishConsolidationZone)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
// Trigger Conditions ...
|
||||
|
||||
//
|
||||
bool canTriggerCHOCHZone =
|
||||
//
|
||||
isScorePassed &&
|
||||
isCommonsPassed &&
|
||||
conditions.provider == X121SMC_XWZ_PROVIDER_ACTIVATED_CHOCH
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool canTriggerActivatedZone =
|
||||
//
|
||||
// isPointBreaked &&
|
||||
(isSupportRejected ||
|
||||
hasBullishConsolidationZone) &&
|
||||
bullishScore > (bearishScore * 1.5) &&
|
||||
isScorePassed &&
|
||||
isCommonsPassed &&
|
||||
conditions.provider == X121SMC_XWZ_PROVIDER_ACTIVATED_ZONE
|
||||
//
|
||||
;
|
||||
@@ -1811,16 +2023,15 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
//
|
||||
bool canTriggerPriceInsideZone =
|
||||
//
|
||||
// isPointBreaked &&
|
||||
(isResistanceRejected ||
|
||||
hasBearishConsolidationZone) &&
|
||||
bearishScore > (bullishScore * 1.5) &&
|
||||
isScorePassed &&
|
||||
isCommonsPassed &&
|
||||
conditions.provider == X121SMC_XWZ_PROVIDER_PRICE_INSIDE_ZONE
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool canTrigger = (canTriggerActivatedZone ||
|
||||
bool canTrigger = (canTriggerCHOCHZone ||
|
||||
canTriggerActivatedZone ||
|
||||
canTriggerPriceInsideZone);
|
||||
|
||||
//
|
||||
@@ -1887,7 +2098,20 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
|
||||
//
|
||||
double iAtr = decisionXConditions.atrBuffer[1];
|
||||
iAtr *= 0;
|
||||
iAtr *= 1.5;
|
||||
|
||||
//
|
||||
// Since Pivot Value almost used
|
||||
// as Default SL, if there isn't any Refind SL
|
||||
// we use Default ...
|
||||
if (!HasChild(sls))
|
||||
{
|
||||
//
|
||||
Add(
|
||||
conditions.pivot,
|
||||
sls //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
double slsMin = GetMin(sls);
|
||||
@@ -1895,8 +2119,8 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
|
||||
//
|
||||
double sl = isBullish
|
||||
? slsMax - iAtr
|
||||
: slsMin + iAtr;
|
||||
? slsMin - iAtr
|
||||
: slsMax + iAtr;
|
||||
double risk = MathAbs(entry - sl);
|
||||
|
||||
//
|
||||
@@ -1953,6 +2177,9 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return false;
|
||||
|
||||
//
|
||||
result = isCycleHelpersValid;
|
||||
if (!result)
|
||||
@@ -3264,6 +3491,7 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
void DeInit()
|
||||
{
|
||||
//
|
||||
chochZone.Clean();
|
||||
signalZone.Clean();
|
||||
targetZone.Clean();
|
||||
mConditions.Clean();
|
||||
@@ -3289,7 +3517,9 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
value = NormalizeTime(value);
|
||||
|
||||
//
|
||||
chochZone.UpdateTo(value);
|
||||
targetZone.UpdateTo(value);
|
||||
signalZone.UpdateTo(value);
|
||||
workingZone.UpdateTo(value);
|
||||
mConditions.UpdateTo(value);
|
||||
waitingZone.UpdateTo(value);
|
||||
|
||||
@@ -31,6 +31,7 @@ enum ENUM_X121SMC_XWZ_PROVIDERS
|
||||
{
|
||||
X121SMC_XWZ_PROVIDER_NONE,
|
||||
X121SMC_XWZ_PROVIDER_ACTIVATED_ZONE,
|
||||
X121SMC_XWZ_PROVIDER_ACTIVATED_CHOCH,
|
||||
X121SMC_XWZ_PROVIDER_PRICE_INSIDE_ZONE,
|
||||
};
|
||||
|
||||
|
||||
@@ -371,9 +371,9 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
|
||||
//
|
||||
// Configuring Global Protector ...
|
||||
signal.trailSL = true;
|
||||
signal.trailSLStartOnReachTPLevel = 3;
|
||||
signal.fullTPLevel = signal.GetRiskRewardRatio();
|
||||
// signal.trailSL = true;
|
||||
// signal.trailSLStartOnReachTPLevel = 3;
|
||||
// signal.fullTPLevel = signal.GetRiskRewardRatio();
|
||||
|
||||
// //
|
||||
// mXSupDemOBSSignalDetector.RemoveDraws();
|
||||
|
||||
Reference in New Issue
Block a user