last ...
This commit is contained in:
+75
-1
@@ -159,4 +159,78 @@
|
||||
//
|
||||
;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//
|
||||
iBox.to = TimeCurrent();
|
||||
XCBoxObject *iObj;
|
||||
has = helper.poiDrawer.DrawBox(
|
||||
iBox,
|
||||
iObj //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
iObj.BoxWidth(2);
|
||||
|
||||
//
|
||||
color iCLR =
|
||||
iBox.IsBullish()
|
||||
? clrAqua
|
||||
: clrMagenta;
|
||||
iObj.BoxColor(iCLR);
|
||||
iObj.BoxStyle(STYLE_SOLID);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//
|
||||
// COMPLEX ...
|
||||
|
||||
//
|
||||
double iKTIRNDs[] = {
|
||||
cKI,
|
||||
cTKI,
|
||||
cTrend //
|
||||
};
|
||||
|
||||
//
|
||||
double iKTIRNDMax = GetMax(iKTIRNDs);
|
||||
double iKTIRNDMin = GetMin(iKTIRNDs);
|
||||
|
||||
//
|
||||
// Conditions Preparing ...
|
||||
|
||||
//
|
||||
bool isTKITRNDBullish =
|
||||
cKIState > 0 &&
|
||||
cTKIState > 0 &&
|
||||
ctrendState > 0;
|
||||
|
||||
//
|
||||
bool isTKITRNDBullishPrev =
|
||||
pKIState > 0 &&
|
||||
pTKIState > 0 &&
|
||||
ptrendState > 0;
|
||||
|
||||
//
|
||||
bool isTKITRNDBearish =
|
||||
cKIState < 0 &&
|
||||
cTKIState < 0 &&
|
||||
ctrendState < 0;
|
||||
|
||||
//
|
||||
bool isTKITRNDBearishPrev =
|
||||
pKIState < 0 &&
|
||||
pTKIState < 0 &&
|
||||
ptrendState < 0;
|
||||
|
||||
//
|
||||
bool isTKITRNDSwitchedToBullish =
|
||||
isTKITRNDBullish &&
|
||||
!isTKITRNDBullishPrev;
|
||||
|
||||
//
|
||||
bool isTKITRNDSwitchedToBearish =
|
||||
isTKITRNDBearish &&
|
||||
!isTKITRNDBearishPrev;
|
||||
|
||||
@@ -674,6 +674,7 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
virtual void Default()
|
||||
{
|
||||
//
|
||||
@@ -3376,6 +3377,7 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
|
||||
//
|
||||
void Validate(
|
||||
XBoxZone &unAvailableBoxes[],
|
||||
int barIndex = 0 //
|
||||
)
|
||||
{
|
||||
@@ -3424,6 +3426,7 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
//
|
||||
has = IsPivotBreaked(
|
||||
iPivot,
|
||||
unAvailableBoxes,
|
||||
barIndex //
|
||||
);
|
||||
if (!has)
|
||||
@@ -3461,6 +3464,7 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
//
|
||||
has = IsPivotBreaked(
|
||||
iPivot,
|
||||
unAvailableBoxes,
|
||||
barIndex //
|
||||
);
|
||||
if (!has)
|
||||
@@ -3498,6 +3502,7 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
//
|
||||
has = IsPivotBreaked(
|
||||
iPivot,
|
||||
unAvailableBoxes,
|
||||
barIndex //
|
||||
);
|
||||
if (!has)
|
||||
@@ -3535,6 +3540,7 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
//
|
||||
has = IsPivotBreaked(
|
||||
iPivot,
|
||||
unAvailableBoxes,
|
||||
barIndex //
|
||||
);
|
||||
if (!has)
|
||||
@@ -3572,6 +3578,7 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
//
|
||||
has = IsPivotBreaked(
|
||||
iPivot,
|
||||
unAvailableBoxes,
|
||||
barIndex //
|
||||
);
|
||||
if (!has)
|
||||
@@ -3609,6 +3616,7 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
//
|
||||
has = IsPivotBreaked(
|
||||
iPivot,
|
||||
unAvailableBoxes,
|
||||
barIndex //
|
||||
);
|
||||
if (!has)
|
||||
@@ -3646,6 +3654,7 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
//
|
||||
has = IsPivotBreaked(
|
||||
iPivot,
|
||||
unAvailableBoxes,
|
||||
barIndex //
|
||||
);
|
||||
if (!has)
|
||||
@@ -3683,6 +3692,7 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
//
|
||||
has = IsPivotBreaked(
|
||||
iPivot,
|
||||
unAvailableBoxes,
|
||||
barIndex //
|
||||
);
|
||||
if (!has)
|
||||
@@ -3720,6 +3730,7 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
//
|
||||
has = IsPivotBreaked(
|
||||
iPivot,
|
||||
unAvailableBoxes,
|
||||
barIndex //
|
||||
);
|
||||
if (!has)
|
||||
@@ -3757,6 +3768,7 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
//
|
||||
has = IsPivotBreaked(
|
||||
iPivot,
|
||||
unAvailableBoxes,
|
||||
barIndex //
|
||||
);
|
||||
if (!has)
|
||||
@@ -3794,6 +3806,7 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
//
|
||||
has = IsPivotBreaked(
|
||||
iPivot,
|
||||
unAvailableBoxes,
|
||||
barIndex //
|
||||
);
|
||||
if (!has)
|
||||
@@ -3831,6 +3844,7 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
//
|
||||
has = IsPivotBreaked(
|
||||
iPivot,
|
||||
unAvailableBoxes,
|
||||
barIndex //
|
||||
);
|
||||
if (!has)
|
||||
@@ -3868,6 +3882,7 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
//
|
||||
has = IsPivotBreaked(
|
||||
iPivot,
|
||||
unAvailableBoxes,
|
||||
barIndex //
|
||||
);
|
||||
if (!has)
|
||||
@@ -3905,6 +3920,7 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
//
|
||||
has = IsPivotBreaked(
|
||||
iPivot,
|
||||
unAvailableBoxes,
|
||||
barIndex //
|
||||
);
|
||||
if (!has)
|
||||
@@ -3942,6 +3958,7 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
//
|
||||
has = IsPivotBreaked(
|
||||
iPivot,
|
||||
unAvailableBoxes,
|
||||
barIndex //
|
||||
);
|
||||
if (!has)
|
||||
@@ -3979,6 +3996,7 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
//
|
||||
has = IsPivotBreaked(
|
||||
iPivot,
|
||||
unAvailableBoxes,
|
||||
barIndex //
|
||||
);
|
||||
if (!has)
|
||||
@@ -4016,6 +4034,7 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
//
|
||||
has = IsPivotBreaked(
|
||||
iPivot,
|
||||
unAvailableBoxes,
|
||||
barIndex //
|
||||
);
|
||||
if (!has)
|
||||
@@ -4053,6 +4072,7 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
//
|
||||
has = IsPivotBreaked(
|
||||
iPivot,
|
||||
unAvailableBoxes,
|
||||
barIndex //
|
||||
);
|
||||
if (!has)
|
||||
@@ -4090,6 +4110,7 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
//
|
||||
has = IsPivotBreaked(
|
||||
iPivot,
|
||||
unAvailableBoxes,
|
||||
barIndex //
|
||||
);
|
||||
if (!has)
|
||||
@@ -4127,6 +4148,7 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
//
|
||||
has = IsPivotBreaked(
|
||||
iPivot,
|
||||
unAvailableBoxes,
|
||||
barIndex //
|
||||
);
|
||||
if (!has)
|
||||
@@ -4164,6 +4186,7 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
//
|
||||
has = IsPivotBreaked(
|
||||
iPivot,
|
||||
unAvailableBoxes,
|
||||
barIndex //
|
||||
);
|
||||
if (!has)
|
||||
@@ -4201,6 +4224,7 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
//
|
||||
has = IsPivotBreaked(
|
||||
iPivot,
|
||||
unAvailableBoxes,
|
||||
barIndex //
|
||||
);
|
||||
if (!has)
|
||||
@@ -4214,6 +4238,160 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
}
|
||||
Clean(tmp);
|
||||
}
|
||||
|
||||
//
|
||||
has = HasRSICrossedOverOSPivots();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
Copy(
|
||||
rsiCrossedOverOSPivots,
|
||||
tmp //
|
||||
);
|
||||
Clean(rsiCrossedOverOSPivots);
|
||||
while (HasChild(tmp))
|
||||
{
|
||||
//
|
||||
XCAPivot iPivot = tmp[0];
|
||||
ArrayRemove(
|
||||
tmp,
|
||||
0,
|
||||
1 //
|
||||
);
|
||||
|
||||
//
|
||||
has = IsPivotBreaked(
|
||||
iPivot,
|
||||
unAvailableBoxes,
|
||||
barIndex //
|
||||
);
|
||||
if (!has)
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
iPivot,
|
||||
rsiCrossedOverOSPivots //
|
||||
);
|
||||
}
|
||||
}
|
||||
Clean(tmp);
|
||||
}
|
||||
|
||||
//
|
||||
has = HasRSICrossedUnderOBPivots();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
Copy(
|
||||
rsiCrossedUnderOBPivots,
|
||||
tmp //
|
||||
);
|
||||
Clean(rsiCrossedUnderOBPivots);
|
||||
while (HasChild(tmp))
|
||||
{
|
||||
//
|
||||
XCAPivot iPivot = tmp[0];
|
||||
ArrayRemove(
|
||||
tmp,
|
||||
0,
|
||||
1 //
|
||||
);
|
||||
|
||||
//
|
||||
has = IsPivotBreaked(
|
||||
iPivot,
|
||||
unAvailableBoxes,
|
||||
barIndex //
|
||||
);
|
||||
if (!has)
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
iPivot,
|
||||
rsiCrossedUnderOBPivots //
|
||||
);
|
||||
}
|
||||
}
|
||||
Clean(tmp);
|
||||
}
|
||||
|
||||
//
|
||||
has = HasCCICrossedOverOSPivots();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
Copy(
|
||||
cciCrossedOverOSPivots,
|
||||
tmp //
|
||||
);
|
||||
Clean(cciCrossedOverOSPivots);
|
||||
while (HasChild(tmp))
|
||||
{
|
||||
//
|
||||
XCAPivot iPivot = tmp[0];
|
||||
ArrayRemove(
|
||||
tmp,
|
||||
0,
|
||||
1 //
|
||||
);
|
||||
|
||||
//
|
||||
has = IsPivotBreaked(
|
||||
iPivot,
|
||||
unAvailableBoxes,
|
||||
barIndex //
|
||||
);
|
||||
if (!has)
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
iPivot,
|
||||
cciCrossedOverOSPivots //
|
||||
);
|
||||
}
|
||||
}
|
||||
Clean(tmp);
|
||||
}
|
||||
|
||||
//
|
||||
has = HasCCICrossedUnderOBPivots();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
Copy(
|
||||
cciCrossedUnderOBPivots,
|
||||
tmp //
|
||||
);
|
||||
Clean(cciCrossedUnderOBPivots);
|
||||
while (HasChild(tmp))
|
||||
{
|
||||
//
|
||||
XCAPivot iPivot = tmp[0];
|
||||
ArrayRemove(
|
||||
tmp,
|
||||
0,
|
||||
1 //
|
||||
);
|
||||
|
||||
//
|
||||
has = IsPivotBreaked(
|
||||
iPivot,
|
||||
unAvailableBoxes,
|
||||
barIndex //
|
||||
);
|
||||
if (!has)
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
iPivot,
|
||||
cciCrossedUnderOBPivots //
|
||||
);
|
||||
}
|
||||
}
|
||||
Clean(tmp);
|
||||
}
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
@@ -4508,7 +4686,8 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
|
||||
//
|
||||
has = HasRSICrossedOverOSPivots();
|
||||
if (has) {
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
count = CountRSICrossedOverOSPivots();
|
||||
for (int i = 0; i < count; i++)
|
||||
@@ -4532,7 +4711,8 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
|
||||
//
|
||||
has = HasCCICrossedOverOSPivots();
|
||||
if (has) {
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
count = CountCCICrossedOverOSPivots();
|
||||
for (int i = 0; i < count; i++)
|
||||
@@ -4853,7 +5033,8 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
|
||||
//
|
||||
has = HasRSICrossedUnderOBPivots();
|
||||
if (has) {
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
count = CountRSICrossedUnderOBPivots();
|
||||
for (int i = 0; i < count; i++)
|
||||
@@ -4877,7 +5058,8 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
|
||||
//
|
||||
has = HasCCICrossedUnderOBPivots();
|
||||
if (has) {
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
count = CountCCICrossedUnderOBPivots();
|
||||
for (int i = 0; i < count; i++)
|
||||
@@ -5346,6 +5528,7 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
bool CheckPivotCommons(
|
||||
XCAPivot &pivot,
|
||||
XBoxZone &box,
|
||||
XBoxZone &unAvailableBoxes[],
|
||||
int barIndex = 0 //
|
||||
)
|
||||
{
|
||||
@@ -5384,6 +5567,47 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = CheckPivotIsAvailable(
|
||||
box,
|
||||
unAvailableBoxes //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
box.Clean();
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool CheckPivotIsAvailable(
|
||||
XBoxZone &pivotBox,
|
||||
XBoxZone &unAvailableBoxes[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = pivotBox.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int idx = -1;
|
||||
bool isExists = FindBoxIndex(
|
||||
idx,
|
||||
pivotBox,
|
||||
unAvailableBoxes //
|
||||
);
|
||||
result = !isExists;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
@@ -5391,6 +5615,7 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
//
|
||||
bool IsPivotBreaked(
|
||||
XCAPivot &pivot,
|
||||
XBoxZone &unAvailableBoxes[],
|
||||
int barIndex = 0 //
|
||||
)
|
||||
{
|
||||
@@ -5402,6 +5627,7 @@ class XCXCAEAPOIDetector : public XCBase
|
||||
result = CheckPivotCommons(
|
||||
pivot,
|
||||
iBox,
|
||||
unAvailableBoxes,
|
||||
barIndex //
|
||||
);
|
||||
if (!result)
|
||||
|
||||
@@ -422,6 +422,7 @@ int AddGuard(
|
||||
bool DetectXCAEAConditions(
|
||||
XBoxZone &boxes[],
|
||||
XCAEAConditions &conditions,
|
||||
XBoxZone &pivotBox,
|
||||
XBoxZone &box,
|
||||
ENUM_X_DIRECTION &dir,
|
||||
XCXCAEAHelper *helper,
|
||||
@@ -474,6 +475,112 @@ bool DetectXCAEAConditions(
|
||||
int p3IDX = p2IDX + 1;
|
||||
int p4IDX = p3IDX + 1;
|
||||
|
||||
//
|
||||
// Reading Parameters ...
|
||||
|
||||
//
|
||||
// KI ...
|
||||
|
||||
//
|
||||
double cKI = conditions.kiBuffer[cIDX];
|
||||
double pKI = conditions.kiBuffer[pIDX];
|
||||
double p2KI = conditions.kiBuffer[p2IDX];
|
||||
|
||||
//
|
||||
double cKIState = conditions.kiStateBuffer[cIDX];
|
||||
double pKIState = conditions.kiStateBuffer[pIDX];
|
||||
double p2KIState = conditions.kiStateBuffer[p2IDX];
|
||||
|
||||
//
|
||||
// TKI ...
|
||||
|
||||
//
|
||||
double cTKI = conditions.tkiBuffer[cIDX];
|
||||
double pTKI = conditions.tkiBuffer[pIDX];
|
||||
double p2TKI = conditions.tkiBuffer[p2IDX];
|
||||
|
||||
//
|
||||
double cTKIState = conditions.tkiStateBuffer[cIDX];
|
||||
double pTKIState = conditions.tkiStateBuffer[pIDX];
|
||||
double p2TKIState = conditions.tkiStateBuffer[p2IDX];
|
||||
|
||||
//
|
||||
// TREND ...
|
||||
|
||||
//
|
||||
double cTrend = conditions.trendBuffer[cIDX];
|
||||
double pTrend = conditions.trendBuffer[pIDX];
|
||||
double p2Trend = conditions.trendBuffer[p2IDX];
|
||||
|
||||
//
|
||||
double ctrendState = conditions.trendStateBuffer[cIDX];
|
||||
double ptrendState = conditions.trendStateBuffer[pIDX];
|
||||
double p2trendState = conditions.trendStateBuffer[p2IDX];
|
||||
|
||||
//
|
||||
// SWING Low ...
|
||||
double cSWL = conditions.swingLowBuffer[cIDX];
|
||||
double pSWL = conditions.swingLowBuffer[pIDX];
|
||||
double p2SWL = conditions.swingLowBuffer[p2IDX];
|
||||
|
||||
//
|
||||
// SWING High ...
|
||||
double cSWH = conditions.swingHighBuffer[cIDX];
|
||||
double pSWH = conditions.swingHighBuffer[pIDX];
|
||||
double p2SWH = conditions.swingHighBuffer[p2IDX];
|
||||
|
||||
//
|
||||
// PEAK ...
|
||||
double zPeak = conditions.peakBuffer[zIDX];
|
||||
double cPeak = conditions.peakBuffer[cIDX];
|
||||
double pPeak = conditions.peakBuffer[pIDX];
|
||||
double p2Peak = conditions.peakBuffer[p2IDX];
|
||||
double p3Peak = conditions.peakBuffer[p3IDX];
|
||||
|
||||
//
|
||||
// VALE ...
|
||||
double zVale = conditions.valeBuffer[zIDX];
|
||||
double cVale = conditions.valeBuffer[cIDX];
|
||||
double pVale = conditions.valeBuffer[pIDX];
|
||||
double p2Vale = conditions.valeBuffer[p2IDX];
|
||||
double p3Vale = conditions.valeBuffer[p3IDX];
|
||||
|
||||
//
|
||||
// RSI ...
|
||||
double zRSI = conditions.rsiBuffer[zIDX];
|
||||
double cRSI = conditions.rsiBuffer[cIDX];
|
||||
double pRSI = conditions.rsiBuffer[pIDX];
|
||||
double p2RSI = conditions.rsiBuffer[p2IDX];
|
||||
double p3RSI = conditions.rsiBuffer[p3IDX];
|
||||
|
||||
//
|
||||
// CCI ...
|
||||
double zCCI = conditions.cciBuffer[zIDX];
|
||||
double cCCI = conditions.cciBuffer[cIDX];
|
||||
double pCCI = conditions.cciBuffer[pIDX];
|
||||
double p2CCI = conditions.cciBuffer[p2IDX];
|
||||
double p3CCI = conditions.cciBuffer[p3IDX];
|
||||
|
||||
//
|
||||
// RVI ...
|
||||
|
||||
//
|
||||
double zRVI = conditions.rviBuffer[zIDX];
|
||||
double cRVI = conditions.rviBuffer[cIDX];
|
||||
double pRVI = conditions.rviBuffer[pIDX];
|
||||
double p2RVI = conditions.rviBuffer[p2IDX];
|
||||
double p3RVI = conditions.rviBuffer[p3IDX];
|
||||
|
||||
//
|
||||
double zRVISignal = conditions.rviSignalBuffer[zIDX];
|
||||
double cRVISignal = conditions.rviSignalBuffer[cIDX];
|
||||
double pRVISignal = conditions.rviSignalBuffer[pIDX];
|
||||
double p2RVISignal = conditions.rviSignalBuffer[p2IDX];
|
||||
double p3RVISignal = conditions.rviSignalBuffer[p3IDX];
|
||||
|
||||
//
|
||||
// Reading Bars ...
|
||||
|
||||
//
|
||||
XOHCL zBar;
|
||||
XOHCL cBar;
|
||||
@@ -519,146 +626,6 @@ bool DetectXCAEAConditions(
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool isBarBullishVPattern =
|
||||
pBar.IsBullish() &&
|
||||
cBar.low > pBar.low &&
|
||||
p2Bar.low > pBar.low;
|
||||
|
||||
//
|
||||
bool isBarBearishVPattern =
|
||||
pBar.IsBearish() &&
|
||||
cBar.high < pBar.high &&
|
||||
p2Bar.high < pBar.high;
|
||||
|
||||
//
|
||||
// Detect Selected Box ...
|
||||
XBoxZone selectedBox;
|
||||
bool hasBoxes = HasChild(boxes);
|
||||
if (hasBoxes)
|
||||
{
|
||||
//
|
||||
// Detect Selected Boxes ...
|
||||
XBoxZone tmp[];
|
||||
Copy(
|
||||
boxes,
|
||||
tmp //
|
||||
);
|
||||
while (HasChild(tmp))
|
||||
{
|
||||
//
|
||||
idx = GetYoungest(tmp);
|
||||
has = IsValidIndex(idx);
|
||||
if (!has)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
XBoxZone iBox;
|
||||
iBox = tmp[idx];
|
||||
ArrayRemove(
|
||||
tmp,
|
||||
idx,
|
||||
1 //
|
||||
);
|
||||
|
||||
//
|
||||
// Check Selected Box not RSI or CCI ...
|
||||
has = iBox.type == ToString(XCA_PEAKSWHRES) ||
|
||||
iBox.type == ToString(XCA_VALESWLSUP);
|
||||
if (!has)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
bool isBullish = iBox.IsBullish();
|
||||
bool isBearish = iBox.IsBearish();
|
||||
|
||||
//
|
||||
double rejectedCheckPrice =
|
||||
isBullish
|
||||
? iBox.upper
|
||||
: iBox.lower;
|
||||
|
||||
//
|
||||
// Check Box Selecting Senarios ...
|
||||
|
||||
//
|
||||
// Selecting Rejected Boxes ...
|
||||
bool isRejected = cBar.IsRejected(
|
||||
rejectedCheckPrice,
|
||||
iBox.dir,
|
||||
false,
|
||||
false //
|
||||
);
|
||||
|
||||
//
|
||||
// Selecting Activation Boxes ...
|
||||
|
||||
//
|
||||
bool isBullishActivated =
|
||||
isBullish &&
|
||||
isBarBullishVPattern &&
|
||||
cBar.GetUp() > rejectedCheckPrice &&
|
||||
cBar.GetDown() < rejectedCheckPrice;
|
||||
|
||||
//
|
||||
bool isBearishActivated =
|
||||
isBearish &&
|
||||
isBarBearishVPattern &&
|
||||
cBar.GetUp() > rejectedCheckPrice &&
|
||||
cBar.GetDown() < rejectedCheckPrice;
|
||||
|
||||
//
|
||||
bool isActivated = isBullishActivated ||
|
||||
isBearishActivated;
|
||||
|
||||
//
|
||||
has = // isRejected ||
|
||||
isActivated;
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
selectedBox = iBox;
|
||||
|
||||
//
|
||||
iBox.Clean();
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
iBox.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
Clean(tmp);
|
||||
}
|
||||
|
||||
//
|
||||
// Force Conditions to Have Selected Box ...
|
||||
result = hasBoxes &&
|
||||
selectedBox.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
zBar.Clean();
|
||||
cBar.Clean();
|
||||
pBar.Clean();
|
||||
p2Bar.Clean();
|
||||
p3Bar.Clean();
|
||||
p4Bar.Clean();
|
||||
|
||||
//
|
||||
box.Clean();
|
||||
conditions.Clean();
|
||||
selectedBox.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Bars Conditions ...
|
||||
|
||||
@@ -745,6 +712,30 @@ bool DetectXCAEAConditions(
|
||||
isCBarBearishMomentum ||
|
||||
isCBarBearishEngulfed);
|
||||
|
||||
//
|
||||
double pBarLowShadow = pBar.GetLowShadow();
|
||||
double pBarHighShadow = pBar.GetHighShadow();
|
||||
|
||||
//
|
||||
bool isPBarSwingLow =
|
||||
pBarLowShadow > 0 &&
|
||||
pBar.low < p2Bar.low &&
|
||||
pBar.low < cBar.low &&
|
||||
p2Bar.GetUp() >= pBar.low &&
|
||||
p2Bar.GetDown() <= pBar.high &&
|
||||
cBar.GetUp() >= pBar.low &&
|
||||
cBar.GetDown() <= pBar.high;
|
||||
|
||||
//
|
||||
bool isPBarSwingHigh =
|
||||
pBarHighShadow > 0 &&
|
||||
pBar.high > p2Bar.high &&
|
||||
pBar.high > cBar.high &&
|
||||
p2Bar.GetUp() >= pBar.low &&
|
||||
p2Bar.GetDown() <= pBar.high &&
|
||||
cBar.GetUp() >= pBar.low &&
|
||||
cBar.GetDown() <= pBar.high;
|
||||
|
||||
//
|
||||
// Score ...
|
||||
|
||||
@@ -769,174 +760,262 @@ bool DetectXCAEAConditions(
|
||||
conditions
|
||||
.GenerateSummary();
|
||||
|
||||
//
|
||||
// Detect Selected Box ...
|
||||
double providedSL = 0;
|
||||
bool isBoxRejected = false;
|
||||
bool isBoxActivated = false;
|
||||
bool hasBoxes = HasChild(boxes);
|
||||
if (hasBoxes)
|
||||
{
|
||||
//
|
||||
// Detect Selected Boxes ...
|
||||
XBoxZone tmp[];
|
||||
Copy(
|
||||
boxes,
|
||||
tmp //
|
||||
);
|
||||
while (HasChild(tmp))
|
||||
{
|
||||
//
|
||||
idx = GetYoungest(tmp);
|
||||
has = IsValidIndex(idx);
|
||||
if (!has)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
XBoxZone iBox;
|
||||
iBox = tmp[idx];
|
||||
ArrayRemove(
|
||||
tmp,
|
||||
idx,
|
||||
1 //
|
||||
);
|
||||
|
||||
//
|
||||
// Check Selected Box not RSI or CCI ...
|
||||
has = iBox.type == ToString(XCA_PEAKSWHRES) ||
|
||||
iBox.type == ToString(XCA_VALESWLSUP);
|
||||
if (!has)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
bool isBullish = iBox.IsBullish();
|
||||
bool isBearish = iBox.IsBearish();
|
||||
|
||||
//
|
||||
double rejectedCheckPrice =
|
||||
isBullish
|
||||
? iBox.upper
|
||||
: iBox.lower;
|
||||
|
||||
//
|
||||
// Check Box Selecting Senarios ...
|
||||
|
||||
//
|
||||
// Selecting Rejected Boxes ...
|
||||
isBoxRejected = cBar.IsRejected(
|
||||
rejectedCheckPrice,
|
||||
iBox.dir,
|
||||
false,
|
||||
false //
|
||||
);
|
||||
|
||||
//
|
||||
// Selecting Activation Boxes ...
|
||||
|
||||
//
|
||||
bool isBullishActivated =
|
||||
isBullish &&
|
||||
isPBarSwingLow &&
|
||||
cBar.IsBullish() &&
|
||||
cBar.GetUp() > rejectedCheckPrice &&
|
||||
cBar.GetDown() < rejectedCheckPrice;
|
||||
|
||||
//
|
||||
bool isBearishActivated =
|
||||
isBearish &&
|
||||
isPBarSwingHigh &&
|
||||
cBar.IsBearish() &&
|
||||
cBar.GetUp() > rejectedCheckPrice &&
|
||||
cBar.GetDown() < rejectedCheckPrice;
|
||||
|
||||
//
|
||||
isBoxActivated = isBullishActivated ||
|
||||
isBearishActivated;
|
||||
|
||||
//
|
||||
// Detect Box is Selected or not ...
|
||||
has =
|
||||
isBoxRejected ||
|
||||
isBoxActivated;
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
pivotBox = iBox;
|
||||
|
||||
//
|
||||
iBox.Clean();
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
iBox.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
Clean(tmp);
|
||||
}
|
||||
|
||||
//
|
||||
// Force Conditions to Have Selected Box ...
|
||||
result = hasBoxes &&
|
||||
pivotBox.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
zBar.Clean();
|
||||
cBar.Clean();
|
||||
pBar.Clean();
|
||||
p2Bar.Clean();
|
||||
p3Bar.Clean();
|
||||
p4Bar.Clean();
|
||||
|
||||
//
|
||||
box.Clean();
|
||||
pivotBox.Clean();
|
||||
conditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Conditions ...
|
||||
|
||||
//
|
||||
// Reading Values ...
|
||||
bool isRSIBullish =
|
||||
zRSI >= cRSI &&
|
||||
cRSI > pRSI;
|
||||
bool isRSIBearish =
|
||||
zRSI <= cRSI &&
|
||||
cRSI < pRSI;
|
||||
|
||||
//
|
||||
// KI ...
|
||||
bool isCCIBullish =
|
||||
zCCI >= cCCI &&
|
||||
cCCI > pCCI &&
|
||||
(zCCI > conditions.cciOSLevel ||
|
||||
cCCI > conditions.cciOSLevel);
|
||||
bool isCCIBearish =
|
||||
zCCI >= cCCI &&
|
||||
cCCI > pCCI &&
|
||||
(zCCI < conditions.cciOBLevel ||
|
||||
cCCI < conditions.cciOBLevel);
|
||||
|
||||
//
|
||||
double cKI = conditions.kiBuffer[cIDX];
|
||||
double pKI = conditions.kiBuffer[pIDX];
|
||||
double p2KI = conditions.kiBuffer[p2IDX];
|
||||
bool isRVIBullish = false;
|
||||
bool isRVIBearish = false;
|
||||
|
||||
//
|
||||
double cKIState = conditions.kiStateBuffer[cIDX];
|
||||
double pKIState = conditions.kiStateBuffer[pIDX];
|
||||
double p2KIState = conditions.kiStateBuffer[p2IDX];
|
||||
// Signaller Summarization ...
|
||||
|
||||
//
|
||||
// TKI ...
|
||||
|
||||
//
|
||||
double cTKI = conditions.tkiBuffer[cIDX];
|
||||
double pTKI = conditions.tkiBuffer[pIDX];
|
||||
double p2TKI = conditions.tkiBuffer[p2IDX];
|
||||
|
||||
//
|
||||
double cTKIState = conditions.tkiStateBuffer[cIDX];
|
||||
double pTKIState = conditions.tkiStateBuffer[pIDX];
|
||||
double p2TKIState = conditions.tkiStateBuffer[p2IDX];
|
||||
|
||||
//
|
||||
// TREND ...
|
||||
|
||||
//
|
||||
double cTrend = conditions.trendBuffer[cIDX];
|
||||
double pTrend = conditions.trendBuffer[pIDX];
|
||||
double p2Trend = conditions.trendBuffer[p2IDX];
|
||||
|
||||
//
|
||||
double ctrendState = conditions.trendStateBuffer[cIDX];
|
||||
double ptrendState = conditions.trendStateBuffer[pIDX];
|
||||
double p2trendState = conditions.trendStateBuffer[p2IDX];
|
||||
|
||||
//
|
||||
// SWING Low ...
|
||||
|
||||
//
|
||||
double cSWL = conditions.swingLowBuffer[cIDX];
|
||||
double pSWL = conditions.swingLowBuffer[pIDX];
|
||||
double p2SWL = conditions.swingLowBuffer[p2IDX];
|
||||
|
||||
//
|
||||
// SWING High ...
|
||||
|
||||
//
|
||||
double cSWH = conditions.swingHighBuffer[cIDX];
|
||||
double pSWH = conditions.swingHighBuffer[pIDX];
|
||||
double p2SWH = conditions.swingHighBuffer[p2IDX];
|
||||
|
||||
//
|
||||
// PEAK ...
|
||||
|
||||
//
|
||||
double cPeak = conditions.peakBuffer[cIDX];
|
||||
double pPeak = conditions.peakBuffer[pIDX];
|
||||
double p2Peak = conditions.peakBuffer[p2IDX];
|
||||
|
||||
//
|
||||
// VALE ...
|
||||
|
||||
//
|
||||
double cVale = conditions.valeBuffer[cIDX];
|
||||
double pVale = conditions.valeBuffer[pIDX];
|
||||
double p2Vale = conditions.valeBuffer[p2IDX];
|
||||
|
||||
//
|
||||
// COMPLEX ...
|
||||
|
||||
//
|
||||
double iKTIRNDs[] = {
|
||||
cKI,
|
||||
cTKI,
|
||||
cTrend //
|
||||
};
|
||||
|
||||
//
|
||||
double iKTIRNDMax = GetMax(iKTIRNDs);
|
||||
double iKTIRNDMin = GetMin(iKTIRNDs);
|
||||
|
||||
//
|
||||
// Conditions Preparing ...
|
||||
|
||||
//
|
||||
bool isTKITRNDBullish =
|
||||
cKIState > 0 &&
|
||||
cTKIState > 0 &&
|
||||
ctrendState > 0;
|
||||
|
||||
//
|
||||
bool isTKITRNDBullishPrev =
|
||||
pKIState > 0 &&
|
||||
pTKIState > 0 &&
|
||||
ptrendState > 0;
|
||||
|
||||
//
|
||||
bool isTKITRNDBearish =
|
||||
cKIState < 0 &&
|
||||
cTKIState < 0 &&
|
||||
ctrendState < 0;
|
||||
|
||||
//
|
||||
bool isTKITRNDBearishPrev =
|
||||
pKIState < 0 &&
|
||||
pTKIState < 0 &&
|
||||
ptrendState < 0;
|
||||
|
||||
//
|
||||
bool isTKITRNDSwitchedToBullish =
|
||||
isTKITRNDBullish &&
|
||||
!isTKITRNDBullishPrev;
|
||||
|
||||
//
|
||||
bool isTKITRNDSwitchedToBearish =
|
||||
isTKITRNDBearish &&
|
||||
!isTKITRNDBearishPrev;
|
||||
// Cond1 Act Using Box Activation ...
|
||||
|
||||
//
|
||||
bool isCond1Bullish =
|
||||
// conditions.isRSIOS &&
|
||||
// conditions.isValeIsPivot &&
|
||||
// isTKITRNDSwitchedToBullish
|
||||
conditions.isKISwitchedToBullish
|
||||
//
|
||||
false &&
|
||||
isCCIBullish &&
|
||||
isBoxActivated &&
|
||||
pivotBox.IsValid() &&
|
||||
pivotBox.IsBullish()
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool isCond1Bearish =
|
||||
// conditions.isRSIOB &&
|
||||
// conditions.isPeakIsPivot &&
|
||||
// isTKITRNDSwitchedToBearish
|
||||
conditions.isKISwitchedToBearish
|
||||
//
|
||||
false &&
|
||||
isCCIBearish &&
|
||||
isBoxActivated &&
|
||||
pivotBox.IsValid() &&
|
||||
pivotBox.IsBearish()
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
if (isCond1Bullish ||
|
||||
isCond1Bearish)
|
||||
bool isCond1 = isCond1Bullish ||
|
||||
isCond1Bearish;
|
||||
if (isCond1)
|
||||
{
|
||||
//
|
||||
providedSL =
|
||||
isCond1Bullish
|
||||
? MathMin(pBar.low, pivotBox.lower)
|
||||
: MathMax(pBar.high, pivotBox.upper);
|
||||
|
||||
//
|
||||
Print("Cond1");
|
||||
}
|
||||
|
||||
//
|
||||
// Cond2 Act Using Box Rejection ...
|
||||
|
||||
//
|
||||
bool isCond2Bullish =
|
||||
//
|
||||
isBoxRejected &&
|
||||
pivotBox.IsValid() &&
|
||||
pivotBox.IsBullish()
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool isCond2Bearish =
|
||||
//
|
||||
isBoxRejected &&
|
||||
pivotBox.IsValid() &&
|
||||
pivotBox.IsBearish()
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool isCond2 = isCond2Bullish ||
|
||||
isCond2Bearish;
|
||||
if (isCond2)
|
||||
{
|
||||
//
|
||||
providedSL =
|
||||
isCond1Bullish
|
||||
? MathMin(pBar.low, pivotBox.lower)
|
||||
: MathMax(pBar.high, pivotBox.upper);
|
||||
|
||||
//
|
||||
Print("Cond2");
|
||||
}
|
||||
|
||||
//
|
||||
// Summarise Conditions ...
|
||||
|
||||
//
|
||||
bool isBullish =
|
||||
//
|
||||
false
|
||||
//
|
||||
;
|
||||
isCond1Bullish ||
|
||||
isCond2Bullish;
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool isBearish =
|
||||
//
|
||||
false
|
||||
isCond1Bearish ||
|
||||
isCond2Bearish
|
||||
//
|
||||
;
|
||||
|
||||
@@ -956,7 +1035,14 @@ bool DetectXCAEAConditions(
|
||||
conditions.symbol,
|
||||
dir //
|
||||
);
|
||||
double sl = 0; // conditions.kijunSenBuffer[cIDX];
|
||||
|
||||
//
|
||||
double sl =
|
||||
providedSL > 0
|
||||
? providedSL
|
||||
: isBullish
|
||||
? pivotBox.lower
|
||||
: pivotBox.upper;
|
||||
|
||||
//
|
||||
box.dir = dir;
|
||||
@@ -980,7 +1066,7 @@ bool DetectXCAEAConditions(
|
||||
box.from = p4Bar.time;
|
||||
|
||||
//
|
||||
box.type = ToString(dir) + "_Signal_" + conditions.symbol + "_" + ToString(conditions.period);
|
||||
box.type = "XCASignal";
|
||||
}
|
||||
|
||||
//
|
||||
@@ -995,6 +1081,7 @@ bool DetectXCAEAConditions(
|
||||
{
|
||||
//
|
||||
box.Clean();
|
||||
pivotBox.Clean();
|
||||
conditions.Clean();
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ class XCXCAEASignaller : XCBase
|
||||
XCXCAEAHelper *helper;
|
||||
XCXCAEAPOIDrawer *drawer;
|
||||
bool continuesRFTillTarget;
|
||||
XBoxZone unAvailableBoxes[];
|
||||
XCXCAEAPOIDetector *detector;
|
||||
XCAEAStrategyConditions mConditions;
|
||||
XCAEAStrategyConditions mConditionsCollection[];
|
||||
@@ -165,8 +166,13 @@ class XCXCAEASignaller : XCBase
|
||||
|
||||
//
|
||||
// Setup Conditions ...
|
||||
XBoxZone boxes[];
|
||||
XBoxZone pivotBox;
|
||||
XBoxZone signalBox;
|
||||
XBoxZone bullishBoxes[];
|
||||
XBoxZone bearishBoxes[];
|
||||
bool hasSignalBox = false;
|
||||
XCAEAConditions conditions;
|
||||
ENUM_X_DIRECTION signalBoxDir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
@@ -178,6 +184,7 @@ class XCXCAEASignaller : XCBase
|
||||
//
|
||||
// Validate Pivots ...
|
||||
detector.Validate(
|
||||
unAvailableBoxes,
|
||||
zIndex //
|
||||
);
|
||||
|
||||
@@ -190,18 +197,17 @@ class XCXCAEASignaller : XCBase
|
||||
|
||||
//
|
||||
// Bullish ...
|
||||
XBoxZone bullishBoxes[];
|
||||
int bullishBoxesCount = detector
|
||||
.FillBullishBoxes(bullishBoxes);
|
||||
int bullishBoxesCount =
|
||||
detector
|
||||
.FillBullishBoxes(bullishBoxes);
|
||||
|
||||
//
|
||||
// Bearish ...
|
||||
XBoxZone bearishBoxes[];
|
||||
int bearishBoxesCount = detector
|
||||
.FillBearishBoxes(bearishBoxes);
|
||||
int bearishBoxesCount =
|
||||
detector
|
||||
.FillBearishBoxes(bearishBoxes);
|
||||
|
||||
//
|
||||
XBoxZone boxes[];
|
||||
Copy(
|
||||
bullishBoxes,
|
||||
boxes,
|
||||
@@ -215,24 +221,75 @@ class XCXCAEASignaller : XCBase
|
||||
int boxesCount = ArraySize(boxes);
|
||||
bool hasBoxes = IsValidSize(boxesCount);
|
||||
|
||||
//
|
||||
// Filter UnAvailable Boxes ...
|
||||
if (hasBoxes)
|
||||
{
|
||||
//
|
||||
// Remove UnAvailable Boxes ...
|
||||
has = HasChild(unAvailableBoxes);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
count = ArraySize(unAvailableBoxes);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XBoxZone iBox = unAvailableBoxes[i];
|
||||
|
||||
//
|
||||
has = FindBoxIndex(
|
||||
idx,
|
||||
iBox,
|
||||
boxes //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
ArrayRemove(
|
||||
boxes,
|
||||
idx,
|
||||
1 //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
hasBoxes = HasChild(boxes);
|
||||
boxesCount = ArraySize(boxes);
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
//
|
||||
XCAEAConditions conditions;
|
||||
if (hasBoxes)
|
||||
{
|
||||
//
|
||||
// Detect Sinal Box ...
|
||||
hasSignalBox = DetectXCAEAConditions(
|
||||
boxes,
|
||||
conditions,
|
||||
pivotBox,
|
||||
signalBox,
|
||||
signalBoxDir,
|
||||
helper,
|
||||
zIndex,
|
||||
loopback //
|
||||
);
|
||||
|
||||
//
|
||||
// Make Pivot Box UnAvailable ...
|
||||
if (pivotBox.IsValid())
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
pivotBox,
|
||||
unAvailableBoxes //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@@ -360,11 +417,34 @@ class XCXCAEASignaller : XCBase
|
||||
rfReward++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
double rfReward = 2;
|
||||
|
||||
//
|
||||
double rewardRF = risk * rfReward;
|
||||
double rfTP =
|
||||
isBullish
|
||||
? entry + rewardRF
|
||||
: entry - rewardRF;
|
||||
|
||||
//
|
||||
Add(
|
||||
rfTP,
|
||||
mConditions.targets //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup Resource ...
|
||||
|
||||
//
|
||||
Clean(boxes);
|
||||
Clean(bullishBoxes);
|
||||
Clean(bearishBoxes);
|
||||
|
||||
//
|
||||
zBar.Clean();
|
||||
cBar.Clean();
|
||||
@@ -372,6 +452,7 @@ class XCXCAEASignaller : XCBase
|
||||
pPBar.Clean();
|
||||
|
||||
//
|
||||
pivotBox.Clean();
|
||||
signalBox.Clean();
|
||||
conditions.Clean();
|
||||
|
||||
@@ -578,7 +659,7 @@ class XCXCAEASignaller : XCBase
|
||||
{
|
||||
//
|
||||
useGuards = false;
|
||||
continuesRFTillTarget = true;
|
||||
continuesRFTillTarget = false;
|
||||
|
||||
//
|
||||
barTraker.Init(
|
||||
@@ -633,7 +714,7 @@ class XCXCAEASignaller : XCBase
|
||||
|
||||
//
|
||||
// Oscillators Views ...
|
||||
inputs.showCCI = false;
|
||||
inputs.showCCI = true;
|
||||
inputs.showRSI = false;
|
||||
inputs.showMFI = false;
|
||||
inputs.showRVI = false;
|
||||
|
||||
Reference in New Issue
Block a user