This commit is contained in:
2025-04-25 02:04:21 +03:30
parent aa648284cf
commit e1bcf58bc8
4 changed files with 384 additions and 13 deletions
@@ -617,6 +617,12 @@ class XCXCAEAPOIDetector : public XCBase
double ticksDividerInPoints; // Ticks and Volume Detection Divider in Point ...
ENUM_TIMEFRAMES ticksDetectionPerid; // Ticks and Volume Detection Loopback ...
//
// TREND ...
XBoxZone trendPivotP; // Prev Pivot of Market Trend ...
XBoxZone trendPivotC; // Current Pivot of Market Trend ...
ENUM_X_DIRECTION trendDir; // Trend Direction ...
//
// TICK Pivots ...
@@ -744,6 +750,11 @@ class XCXCAEAPOIDetector : public XCBase
valeSupSWLPivot.Clean();
peakResSWHPivot.Clean();
//
trendPivotP.Clean();
trendPivotC.Clean();
trendDir = X_DIRECTION_NONE;
//
CleanPivots();
@@ -784,6 +795,7 @@ class XCXCAEAPOIDetector : public XCBase
detectPVFVGBearishPivots = true;
//
trendDir = X_DIRECTION_NONE;
}
//
@@ -1900,6 +1912,8 @@ class XCXCAEAPOIDetector : public XCBase
}
//
// Detect Market Trend ...
DetectMarketTrend();
}
//
@@ -2517,6 +2531,8 @@ class XCXCAEAPOIDetector : public XCBase
ReversePivots();
//
// Detect Market Trend ...
DetectMarketTrend();
}
//
@@ -2674,6 +2690,24 @@ class XCXCAEAPOIDetector : public XCBase
return result;
}
//
bool MarketTrend(ENUM_X_DIRECTION &trend)
{
//
bool result = false;
//
// Update Market Trend ...
DetectMarketTrend();
//
trend = trendDir;
result = HasDirection(trend);
//
return result;
}
//
// Counters ...
@@ -3318,6 +3352,141 @@ class XCXCAEAPOIDetector : public XCBase
return result;
}
//
void DetectMarketTrend()
{
//
int idx = -1;
int count = 0;
bool has = false;
//
XBoxZone tmp[];
count = FillPivots(tmp);
has = HasChild(tmp);
if (!has)
{
return;
}
//
XBoxZone cPivot;
XBoxZone pPivot;
ENUM_X_DIRECTION dir = X_DIRECTION_NONE;
while (HasChild(tmp))
{
//
XBoxZone iPivot;
idx = GetYoungest(tmp);
has = IsValidIndex(idx);
if (!has)
{
//
iPivot.Clean();
break;
}
//
ArrayRemove(
tmp,
idx,
1 //
);
//
// Check Pivot Type is Peak or Vale ...
has =
Contains(
"XCA_PEAKSWHRES",
iPivot.type //
) ||
Contains(
"XCA_VALESWLSUP",
iPivot.type //
);
if (!has)
{
//
iPivot.Clean();
break;
}
//
// Check Can Set CPivot ...
bool canSetCPivot =
!cPivot.IsValid()
? true
: cPivot.from < iPivot.from;
if (canSetCPivot)
{
//
if (cPivot.IsValid())
{
pPivot = cPivot;
}
//
cPivot = iPivot;
}
//
// Check Can Set PPivot ...
bool canSetPPivot =
!cPivot.IsValid()
? false
: iPivot.from < cPivot.from
? !pPivot.IsValid()
? true
: cPivot.from < iPivot.from
: false;
if (canSetPPivot)
{
pPivot = iPivot;
}
//
has = cPivot.IsValid() &&
pPivot.IsValid();
if (has)
{
//
iPivot.Clean();
break;
}
//
iPivot.Clean();
}
//
// Check Resources for Detecting Conditions ...
bool hasTrend =
//
cPivot.IsValid() &&
pPivot.IsValid() &&
cPivot.dir == pPivot.dir &&
cPivot.from > pPivot.from &&
(IsBullish(cPivot.dir)
? cPivot.lower > pPivot.lower
: cPivot.upper < pPivot.upper);
//
;
if (hasTrend)
{
//
trendPivotC = cPivot;
trendPivotP = pPivot;
trendDir = cPivot.dir;
}
//
Clean(tmp);
cPivot.Clean();
pPivot.Clean();
//
}
//
};
+120 -6
View File
@@ -43,6 +43,7 @@ class XCXCAEAPOIDrawer : public XCBase
//
// Drawers ...
bool drawTrendLine;
bool drawTickPivots;
bool drawVolumePivots;
bool drawRSIPeakPivots;
@@ -74,6 +75,8 @@ class XCXCAEAPOIDrawer : public XCBase
color fvgBearishPivotsColor;
color valeSupSWLPivotsColor;
color peakResSWHPivotsColor;
color trendLineBullishColor;
color trendLineBearishColor;
color pvFVGBullishPivotsColor;
color pvFVGBearishPivotsColor;
@@ -95,6 +98,8 @@ class XCXCAEAPOIDrawer : public XCBase
int fvgBearishPivotsWidth;
int valeSupSWLPivotsWidth;
int peakResSWHPivotsWidth;
int trendLineBullishWidth;
int trendLineBearishWidth;
int pvFVGBullishPivotsWidth;
int pvFVGBearishPivotsWidth;
@@ -116,6 +121,8 @@ class XCXCAEAPOIDrawer : public XCBase
ENUM_LINE_STYLE fvgBearishPivotsStyle;
ENUM_LINE_STYLE valeSupSWLPivotsStyle;
ENUM_LINE_STYLE peakResSWHPivotsStyle;
ENUM_LINE_STYLE trendLineBullishStyle;
ENUM_LINE_STYLE trendLineBearishStyle;
ENUM_LINE_STYLE pvFVGBullishPivotsStyle;
ENUM_LINE_STYLE pvFVGBearishPivotsStyle;
@@ -167,6 +174,7 @@ class XCXCAEAPOIDrawer : public XCBase
ignoreUpdateOSCTos = true;
//
drawTrendLine = false;
drawTickPivots = false;
drawVolumePivots = false;
drawRSIPeakPivots = false;
@@ -193,6 +201,7 @@ class XCXCAEAPOIDrawer : public XCBase
cciValePivotsColor = defaultBullishColor;
fvgBullishPivotsColor = defaultBullishColor;
valeSupSWLPivotsColor = defaultBullishColor;
trendLineBullishColor = defaultBullishColor;
pvFVGBullishPivotsColor = defaultBullishColor;
//
@@ -200,6 +209,7 @@ class XCXCAEAPOIDrawer : public XCBase
cciPeakPivotsColor = defaultBearishColor;
fvgBearishPivotsColor = defaultBearishColor;
peakResSWHPivotsColor = defaultBearishColor;
trendLineBearishColor = defaultBearishColor;
pvFVGBearishPivotsColor = defaultBearishColor;
//
@@ -215,6 +225,7 @@ class XCXCAEAPOIDrawer : public XCBase
cciValePivotsWidth = defaultBullishWidth;
fvgBullishPivotsWidth = defaultBullishWidth;
valeSupSWLPivotsWidth = defaultBullishWidth;
trendLineBullishWidth = defaultBullishWidth;
pvFVGBullishPivotsWidth = defaultBullishWidth;
//
@@ -222,6 +233,7 @@ class XCXCAEAPOIDrawer : public XCBase
cciPeakPivotsWidth = defaultBearishWidth;
fvgBearishPivotsWidth = defaultBearishWidth;
peakResSWHPivotsWidth = defaultBearishWidth;
trendLineBearishWidth = defaultBearishWidth;
pvFVGBearishPivotsWidth = defaultBearishWidth;
//
@@ -237,6 +249,7 @@ class XCXCAEAPOIDrawer : public XCBase
cciValePivotsStyle = defaultBullishStyle;
fvgBullishPivotsStyle = defaultBullishStyle;
valeSupSWLPivotsStyle = defaultBullishStyle;
trendLineBullishStyle = defaultBullishStyle;
pvFVGBullishPivotsStyle = defaultBullishStyle;
//
@@ -244,6 +257,7 @@ class XCXCAEAPOIDrawer : public XCBase
cciPeakPivotsStyle = defaultBearishStyle;
fvgBearishPivotsStyle = defaultBearishStyle;
peakResSWHPivotsStyle = defaultBearishStyle;
trendLineBearishStyle = defaultBearishStyle;
pvFVGBearishPivotsStyle = defaultBearishStyle;
}
@@ -251,6 +265,7 @@ class XCXCAEAPOIDrawer : public XCBase
void Draw(datetime to = NULL)
{
//
DrawTrendLine();
DrawTickPivots(to);
DrawVolumePivots(to);
DrawRSIPeakPivots(to);
@@ -269,6 +284,7 @@ class XCXCAEAPOIDrawer : public XCBase
void Clear()
{
//
mTrendLineObjects.Clear();
mTickPivotObjects.Clear();
mVolumePivotObjects.Clear();
mRSIPeakPivotObjects.Clear();
@@ -287,6 +303,97 @@ class XCXCAEAPOIDrawer : public XCBase
//
//
//
void DrawTrendLine()
{
//
if (!drawTrendLine)
{
return;
}
//
ENUM_X_DIRECTION trend = X_DIRECTION_NONE;
bool has = detector.MarketTrend(trend);
if (!has)
{
return;
}
//
long chartID = drawer.ChartIdentification();
int subWindow = drawer.SubWindowIdentification();
//
bool hasBullishTrend = IsBullish(trend);
//
double pPrice = hasBullishTrend
? detector.trendPivotP.lower
: detector.trendPivotP.upper;
//
datetime pTime = detector.trendPivotC.from;
//
double cPrice = hasBullishTrend
? detector.trendPivotC.lower
: detector.trendPivotC.upper;
//
datetime cTime = detector.trendPivotC.from;
//
string tlName = ToString(trend) +
"_TL_" +
ToString(pPrice) +
"_" +
ToString(cPrice);
//
int tlWidth = hasBullishTrend
? trendLineBullishWidth
: trendLineBearishWidth;
//
color tlColor = hasBullishTrend
? trendLineBullishColor
: trendLineBearishColor;
//
ENUM_LINE_STYLE tlStyle = hasBullishTrend
? trendLineBullishStyle
: trendLineBearishStyle;
//
CChartObjectTrend *iObj;
iObj = new CChartObjectTrend();
has = iObj.Create(
chartID,
tlName,
subWindow,
pTime,
pPrice,
cTime,
cPrice //
);
if (has)
{
//
// Style Object ...
iObj.Color(tlColor);
iObj.Width(tlWidth);
iObj.Style(tlStyle);
//
// Store Object ...
mTrendLineObjects.Add(iObj);
}
//
ZeroMemory(iObj);
}
//
void DrawTickPivots(datetime to = NULL)
{
@@ -309,12 +416,14 @@ class XCXCAEAPOIDrawer : public XCBase
//
int count = detector.CountTickPivots();
for (int i = 0; i < count; i++) {
for (int i = 0; i < count; i++)
{
//
XBoxZone iBox = detector.tickPivots[i];
//
if (canUpdateTo) {
if (canUpdateTo)
{
iBox.to = to;
}
@@ -324,7 +433,8 @@ class XCXCAEAPOIDrawer : public XCBase
iBox,
iObj //
);
if (has) {
if (has)
{
//
// Style Pivot ...
iObj.BoxColor(tickPivotsColor);
@@ -364,12 +474,14 @@ class XCXCAEAPOIDrawer : public XCBase
//
int count = detector.CountVolumePivots();
for (int i = 0; i < count; i++) {
for (int i = 0; i < count; i++)
{
//
XBoxZone iBox = detector.volumePivots[i];
//
if (canUpdateTo) {
if (canUpdateTo)
{
iBox.to = to;
}
@@ -379,7 +491,8 @@ class XCXCAEAPOIDrawer : public XCBase
iBox,
iObj //
);
if (has) {
if (has)
{
//
// Style Pivot ...
iObj.BoxColor(volumePivotsColor);
@@ -1029,6 +1142,7 @@ class XCXCAEAPOIDrawer : public XCBase
//
CArrayObj mTickPivotObjects;
CArrayObj mTrendLineObjects;
CArrayObj mVolumePivotObjects;
CArrayObj mRSIPeakPivotObjects;
CArrayObj mRSIValePivotObjects;
+79 -5
View File
@@ -421,6 +421,7 @@ int AddGuard(
//
bool DetectXCAEAConditions(
ENUM_X_DIRECTION trend,
XBoxZone &pivots[],
XCAEAConditions &conditions,
XBoxZone &pivotBox,
@@ -454,11 +455,21 @@ bool DetectXCAEAConditions(
loopback = NormalizeInt(loopback, 5);
//
// Retrieve Some Requirements ...
string symbol = helper.GetSymbol();
ENUM_TIMEFRAMES period = helper.GetPeriod();
double points = GetPoints(symbol);
//
// Trend Parsing ...
bool hasTrend = HasDirection(trend);
bool hasBullishTrend = hasTrend &&
IsBullish(trend);
bool hasBearishTrend = hasTrend &&
IsBearish(trend);
//
// Retrieve Previous and Current Bar Conditions ...
XCAEAConditions pConditions;
result = helper.GetConditions(
conditions,
@@ -482,6 +493,7 @@ bool DetectXCAEAConditions(
}
//
// Define IDXses ...
int zIDX = barIndex;
int cIDX = zIDX + 1;
int pIDX = cIDX + 1;
@@ -489,9 +501,6 @@ bool DetectXCAEAConditions(
int p3IDX = p2IDX + 1;
int p4IDX = p3IDX + 1;
//
// Reading Parameters ...
//
// Reading Bars ...
@@ -545,6 +554,7 @@ bool DetectXCAEAConditions(
// Bars Conditions ...
//
// Temparory Bar Direction ...
ENUM_X_DIRECTION cBarDir;
//
@@ -647,6 +657,7 @@ bool DetectXCAEAConditions(
bearishScore > bullishScore;
//
// Generating Conditions Summary ...
string summary =
conditions
.GenerateSummary();
@@ -654,16 +665,76 @@ bool DetectXCAEAConditions(
//
// Conditions ...
//
// Parsing Pivots ...
//
// Detect Selected Pivot ...
XBoxZone oscPivots[];
XBoxZone lastOSCPivot;
double providedSL = 0;
bool hasPivots = HasChild(pivots);
if (hasPivots)
{
//
// Detect Selected Boxes ...
// Detect Selected Pivots ...
count = ArraySize(pivots);
for (int i = 0; i < count; i++)
{
//
XBoxZone iPivot = pivots[i];
//
// Detect Selected Last OSC Pivots ...
bool isOSC =
Contains(
"XCA_RSI",
iPivot.type //
) ||
Contains(
"XCA_CCI",
iPivot.type //
);
bool canSetOSC =
!isOSC
? false
: !lastOSCPivot.IsValid()
? true
: lastOSCPivot.from < iPivot.from;
if (canSetOSC)
{
lastOSCPivot = iPivot;
}
//
iPivot.Clean();
//
}
}
//
// Detect New OSC Pivot Happens ...
bool hasNewOSC = lastOSCPivot.IsValid() &&
cBar.time == lastOSCPivot.to;
if (hasNewOSC)
{
//
XCBoxObject *iObj;
has = helper.poiDrawer.DrawBox(
lastOSCPivot,
iObj //
);
if (has)
{
//
iObj.BoxWidth(2);
//
Print("OSC Box Detected ...");
}
//
ZeroMemory(iObj);
}
//
@@ -855,6 +926,9 @@ bool DetectXCAEAConditions(
conditions.Clean();
}
//
lastOSCPivot.Clean();
//
zBar.Clean();
cBar.Clean();
+16 -2
View File
@@ -171,10 +171,12 @@ class XCXCAEASignaller : XCBase
XBoxZone pivotBox;
XBoxZone signalBox;
int pivotsCount = 0;
bool hasTrend = false;
bool hasPivots = false;
double additionalSL = 0;
bool hasSignalBox = false;
XCAEAConditions conditions;
ENUM_X_DIRECTION trend = X_DIRECTION_NONE;
ENUM_X_DIRECTION signalBoxDir = X_DIRECTION_NONE;
//
@@ -190,12 +192,16 @@ class XCXCAEASignaller : XCBase
zIndex //
);
//
// Check Market Trend ...
hasTrend = detector.MarketTrend(trend);
//
// Draw Founded Pivots ...
drawer.Draw(cTime);
//
// Retrieve Valid Boxes ...
// Retrieve Valid Pviots ...
pivotsCount = detector.FillPivots(pivots);
hasPivots = IsValidSize(pivotsCount);
@@ -245,6 +251,7 @@ class XCXCAEASignaller : XCBase
//
// Detect Sinal Box ...
hasSignalBox = DetectXCAEAConditions(
trend,
pivots,
conditions,
pivotBox,
@@ -758,7 +765,8 @@ class XCXCAEASignaller : XCBase
//
// Configure Drawer ...
drawer.drawTickPivots = true;
drawer.drawTrendLine = true;
drawer.drawTickPivots = false;
drawer.drawVolumePivots = false;
drawer.drawRSIPeakPivots = true;
drawer.drawRSIValePivots = true;
@@ -783,6 +791,8 @@ class XCXCAEASignaller : XCBase
drawer.fvgBearishPivotsWidth = 2;
drawer.valeSupSWLPivotsWidth = 1;
drawer.peakResSWHPivotsWidth = 1;
drawer.trendLineBullishWidth = 4;
drawer.trendLineBullishWidth = 4;
drawer.pvFVGBullishPivotsWidth = 1;
drawer.pvFVGBearishPivotsWidth = 1;
@@ -798,6 +808,8 @@ class XCXCAEASignaller : XCBase
drawer.fvgBearishPivotsColor = clrRed;
drawer.valeSupSWLPivotsColor = clrAqua;
drawer.peakResSWHPivotsColor = clrMagenta;
drawer.trendLineBullishColor = clrAqua;
drawer.trendLineBullishColor = clrMagenta;
drawer.pvFVGBullishPivotsColor = clrLime;
drawer.pvFVGBearishPivotsColor = clrRed;
@@ -813,6 +825,8 @@ class XCXCAEASignaller : XCBase
drawer.fvgBearishPivotsStyle = STYLE_DASHDOTDOT;
drawer.valeSupSWLPivotsStyle = STYLE_SOLID;
drawer.peakResSWHPivotsStyle = STYLE_SOLID;
drawer.trendLineBullishWidth = STYLE_SOLID;
drawer.trendLineBullishWidth = STYLE_SOLID;
drawer.pvFVGBullishPivotsStyle = STYLE_DASHDOTDOT;
drawer.pvFVGBearishPivotsStyle = STYLE_DASHDOTDOT;