This commit is contained in:
2025-04-22 13:07:47 +03:30
parent a3a02973ef
commit 168f2c58d1
7 changed files with 437 additions and 55 deletions
-12
View File
@@ -2792,12 +2792,6 @@ class XCX121Helper : public XCBase
conditions.strBuffer // conditions.strBuffer //
); );
//
Copy(
xstrConditions.strMidBuffer,
conditions.strMidBuffer //
);
// //
Copy( Copy(
xstrConditions.strUpBuffer, xstrConditions.strUpBuffer,
@@ -2834,12 +2828,6 @@ class XCX121Helper : public XCBase
conditions.strSMHighBuffer // conditions.strSMHighBuffer //
); );
//
Copy(
xstrConditions.strMidStateBuffer,
conditions.strMidStateBuffer //
);
// //
// Conditions ... // Conditions ...
+1 -1
View File
@@ -1077,7 +1077,7 @@ class XCX121XVOLUMEHelper : public XCBaseHelper
{ {
// //
// Buffers ... // Buffers ...
if (barInex < 0) { if (barIndex < 0) {
barIndex = 0; barIndex = 0;
} }
+5 -5
View File
@@ -4657,8 +4657,8 @@ class XCTicksZone : public XCTwoBarZone
// Calculate Start and End Time ... // Calculate Start and End Time ...
datetime from = startBar.time; datetime from = startBar.time;
datetime to = endBar.time; datetime to = endBar.time;
ulong fromM = ((ulong)startBar.time * 1000); ulong fromM = ((ulong)to * 1000);
ulong toM = ((ulong)endBar.time * 1000); ulong toM = ((ulong)from * 1000);
// //
// Symbol and Period ... // Symbol and Period ...
@@ -4672,7 +4672,7 @@ class XCTicksZone : public XCTwoBarZone
// //
// Retrieve Ticks between Times ... // Retrieve Ticks between Times ...
SpecificClean(mTicks); SpecificClean(mTicks);
CopyTicksRange( int res = CopyTicksRange(
symbol, symbol,
mTicks, mTicks,
COPY_TICKS_ALL, COPY_TICKS_ALL,
@@ -4826,8 +4826,8 @@ class XCTicksZone : public XCTwoBarZone
mType = X_POI_TICKS_ZONES; mType = X_POI_TICKS_ZONES;
mEndBar = endBar; mEndBar = endBar;
mStartBar = startBar; mStartBar = startBar;
From(startBar.time); From(endBar.time);
To(endBar.time); To(startBar.time);
// //
result = IsValid(); result = IsValid();
+366 -33
View File
@@ -13,6 +13,7 @@
////////////////////////////////////////////////////// //////////////////////////////////////////////////////
// //
// Global Properties ... // Global Properties ...
#property library
#property copyright "Copyright 2023, SaherElm IT Center" #property copyright "Copyright 2023, SaherElm IT Center"
#property link "https://saherelm.ir" #property link "https://saherelm.ir"
#property version "1.00" #property version "1.00"
@@ -469,17 +470,17 @@ struct XCAPivot
}; };
// //
struct XCAPVFVG struct XCAPVPivot
{ {
// //
// Props ... // Props ...
double value; double value;
XCAPivot fvgs[]; XCAPivot pivots[];
ENUM_X_DIRECTION dir; ENUM_X_DIRECTION dir;
// //
// Constructor ... // Constructor ...
XCAPVFVG() XCAPVPivot()
{ {
Clean(); Clean();
} }
@@ -492,7 +493,7 @@ struct XCAPVFVG
{ {
// //
value = 0; value = 0;
Clean(fvgs); Clean(pivots);
dir = X_DIRECTION_NONE; dir = X_DIRECTION_NONE;
// //
@@ -514,7 +515,7 @@ struct XCAPVFVG
} }
// //
void AddFVG(XCAPivot &pivot) void AddPivot(XCAPivot &pivot)
{ {
// //
if (!IsValid() || if (!IsValid() ||
@@ -528,7 +529,7 @@ struct XCAPVFVG
bool has = FindPivotIndex( bool has = FindPivotIndex(
idx, idx,
pivot, pivot,
fvgs // pivots //
); );
if (has) if (has)
{ {
@@ -538,43 +539,43 @@ struct XCAPVFVG
// //
AddRef( AddRef(
pivot, pivot,
fvgs // pivots //
); );
} }
// //
int GetFVGs(XBoxZone &fvgBoxes[]) int GetPivots(XBoxZone &pivotBoxes[])
{ {
// //
int result = 0; int result = 0;
// //
Clean(fvgBoxes); Clean(pivotBoxes);
// //
bool has = false; bool has = false;
// //
has = IsValid() && has = IsValid() &&
HasChild(fvgs); HasChild(pivots);
if (!has) if (!has)
{ {
return result; return result;
} }
// //
int count = ArraySize(fvgs); int count = ArraySize(pivots);
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
// //
XBoxZone iBox; XBoxZone iBox;
has = fvgs[i].AsBox(iBox); has = pivots[i].AsBox(iBox);
if (has) if (has)
{ {
// //
AddRef( AddRef(
iBox, iBox,
fvgBoxes // pivotBoxes //
); );
} }
@@ -583,13 +584,159 @@ struct XCAPVFVG
} }
// //
result = ArraySize(fvgBoxes); result = ArraySize(pivotBoxes);
// //
return result; return result;
} }
}; };
//
struct XCAPVTick
{
//
XCAPivot pivot;
XCTicksZone *zone;
//
XCAPVTick()
{
Clean();
}
//
// Tools ...
//
void Clean()
{
//
pivot.Clean();
//
ZeroMemory(zone);
ZeroMemory(this);
}
//
bool IsValid()
{
//
bool result = false;
//
result = pivot.IsValid() &&
zone != NULL;
//
return result;
}
//
bool Init(XCAPivot &_pivot)
{
//
bool result = false;
//
result = _pivot.IsValid();
if (!result)
{
return result;
}
//
int toIDX = _pivot.ToIndex();
int fromIDX = _pivot.FromIndex();
int rangeLength = fromIDX - toIDX;
result = IsValidIndex(fromIDX) &&
IsValidIndex(toIDX);
if (!result)
{
//
Clean();
return result;
}
//
XOHCL toBar;
XOHCL fromBar;
result = toBar.Init(
_pivot.symbol,
_pivot.period,
toIDX //
);
result = result &&
fromBar.Init(
_pivot.symbol,
_pivot.period,
fromIDX //
);
if (!result)
{
//
toBar.Clean();
fromBar.Clean();
//
Clean();
//
return result;
}
//
double rangeDivider = 10 * GetPoints(_pivot.symbol);
double rangeL = toBar.FindLowest(rangeLength, MODE_LOW);
double rangeH = toBar.FindHighest(rangeLength, MODE_HIGH);
double rangeDiff = (rangeH - rangeL);
int zoneLevels = (int)(rangeDiff / rangeDivider);
//
XCTicksZone *_zone;
_zone = new XCTicksZone();
_zone.Levels(zoneLevels);
result = _zone.Init(
fromBar,
toBar //
);
if (!result)
{
//
toBar.Clean();
fromBar.Clean();
ZeroMemory(_zone);
//
Clean();
//
return result;
}
//
pivot = _pivot;
zone = _zone;
//
result = IsValid();
if (!result)
{
Clean();
}
//
toBar.Clean();
fromBar.Clean();
ZeroMemory(_zone);
//
return result;
}
//
};
/** /**
* Find Specified Pivot Index inside a Collection of Pivots ... * Find Specified Pivot Index inside a Collection of Pivots ...
* *
@@ -725,12 +872,12 @@ void AddPivot(
* *
* @param value: double, Peak or Vale Value ... * @param value: double, Peak or Vale Value ...
* @param fvg: XCAPivot instance reference, Specified Pivot ... * @param fvg: XCAPivot instance reference, Specified Pivot ...
* @param collection: XCAPVFVG instance Collection ... * @param collection: XCAPVPivot instance Collection ...
*/ */
void AddOrUpdatePVFVG( void AddOrUpdatePVFVG(
double value, double value,
XCAPivot &fvg, XCAPivot &fvg,
XCAPVFVG &collection[] // XCAPVPivot &collection[] //
) )
{ {
// //
@@ -761,7 +908,7 @@ void AddOrUpdatePVFVG(
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
// //
XCAPVFVG iTem = collection[i]; XCAPVPivot iTem = collection[i];
// //
bool isSameValue = iTem.value == value; bool isSameValue = iTem.value == value;
@@ -789,7 +936,7 @@ void AddOrUpdatePVFVG(
{ {
// //
// New Item ... // New Item ...
XCAPVFVG iPVFVG; XCAPVPivot iPVFVG;
// //
iPVFVG.dir = dir; iPVFVG.dir = dir;
@@ -798,7 +945,7 @@ void AddOrUpdatePVFVG(
// //
AddRef( AddRef(
fvg, fvg,
iPVFVG.fvgs // iPVFVG.pivots //
); );
// //
@@ -811,12 +958,56 @@ void AddOrUpdatePVFVG(
{ {
// //
// Add Pivot to Existing Item ... // Add Pivot to Existing Item ...
collection[idx].AddFVG(fvg); collection[idx].AddPivot(fvg);
} }
// //
} }
/**
* Add Specified PVTick to Collection ...
*
* @param pvTick: XCAPVTick instance Reference ...
* @param pvTicks: XCAPVTickinstance Reference Collection ...
*/
void AddPVTick(
XCAPVTick &pvTick,
XCAPVTick &pvTicks[] //
)
{
//
bool has = pvTick.IsValid();
if (!has)
{
return;
}
//
has = false;
int count = ArraySize(pvTicks);
for (int i = 0; i < count; i++)
{
//
has = pvTicks[i].pivot.IsSameAs(pvTick.pivot);
if (has)
{
break;
}
}
//
if (has)
{
return;
}
//
AddRef(
pvTick,
pvTicks //
);
}
// //
// Implementations ... // Implementations ...
class XCXCAEAPOIDetector : public XCBase class XCXCAEAPOIDetector : public XCBase
@@ -958,8 +1149,12 @@ class XCXCAEAPOIDetector : public XCBase
XCAPivot cciCrossedUnderOBPivots[]; XCAPivot cciCrossedUnderOBPivots[];
// //
XCAPVFVG pvFVGBullishPivots[]; XCAPVTick peakTicks[];
XCAPVFVG pvFVGBearishPivots[]; XCAPVTick valeTicks[];
//
XCAPVPivot pvFVGBullishPivots[];
XCAPVPivot pvFVGBearishPivots[];
// //
// Constructors ... // Constructors ...
@@ -2120,6 +2315,21 @@ class XCXCAEAPOIDetector : public XCBase
peakSWHResPivots, peakSWHResPivots,
maxAllowedPivots // maxAllowedPivots //
); );
//
XCAPVTick peakTick;
has = peakTick.Init(peakSWHResPivot);
if (has)
{
//
AddPVTick(
peakTick,
peakTicks //
);
}
//
peakTick.Clean();
} }
// //
@@ -2185,6 +2395,21 @@ class XCXCAEAPOIDetector : public XCBase
valeSWLSupPivots, valeSWLSupPivots,
maxAllowedPivots // maxAllowedPivots //
); );
//
XCAPVTick valeTick;
has = valeTick.Init(valeSWLSupPivot);
if (has)
{
//
AddPVTick(
valeTick,
valeTicks //
);
}
//
valeTick.Clean();
} }
// //
@@ -4664,7 +4889,7 @@ class XCXCAEAPOIDetector : public XCBase
// //
// PVFVG ... // PVFVG ...
XCAPVFVG tmpPVFVG[]; XCAPVPivot tmpPVFVG[];
// //
has = HasPVFVGBullishPivots(); has = HasPVFVGBullishPivots();
@@ -4679,7 +4904,7 @@ class XCXCAEAPOIDetector : public XCBase
while (HasChild(tmpPVFVG)) while (HasChild(tmpPVFVG))
{ {
// //
XCAPVFVG iPVFVG = tmpPVFVG[0]; XCAPVPivot iPVFVG = tmpPVFVG[0];
ArrayRemove( ArrayRemove(
tmpPVFVG, tmpPVFVG,
0, 0,
@@ -4689,10 +4914,10 @@ class XCXCAEAPOIDetector : public XCBase
// //
XCAPivot tmpFVGs[]; XCAPivot tmpFVGs[];
Copy( Copy(
iPVFVG.fvgs, iPVFVG.pivots,
tmpFVGs // tmpFVGs //
); );
Clean(iPVFVG.fvgs); Clean(iPVFVG.pivots);
while (HasChild(tmpFVGs)) while (HasChild(tmpFVGs))
{ {
// //
@@ -4714,14 +4939,14 @@ class XCXCAEAPOIDetector : public XCBase
// //
AddRef( AddRef(
iPivot, iPivot,
iPVFVG.fvgs // iPVFVG.pivots //
); );
} }
} }
Clean(tmpFVGs); Clean(tmpFVGs);
// //
if (HasChild(iPVFVG.fvgs)) if (HasChild(iPVFVG.pivots))
{ {
// //
AddRef( AddRef(
@@ -4747,7 +4972,7 @@ class XCXCAEAPOIDetector : public XCBase
while (HasChild(tmpPVFVG)) while (HasChild(tmpPVFVG))
{ {
// //
XCAPVFVG iPVFVG = tmpPVFVG[0]; XCAPVPivot iPVFVG = tmpPVFVG[0];
ArrayRemove( ArrayRemove(
tmpPVFVG, tmpPVFVG,
0, 0,
@@ -4757,10 +4982,10 @@ class XCXCAEAPOIDetector : public XCBase
// //
XCAPivot tmpFVGs[]; XCAPivot tmpFVGs[];
Copy( Copy(
iPVFVG.fvgs, iPVFVG.pivots,
tmpFVGs // tmpFVGs //
); );
Clean(iPVFVG.fvgs); Clean(iPVFVG.pivots);
while (HasChild(tmpFVGs)) while (HasChild(tmpFVGs))
{ {
// //
@@ -4782,14 +5007,14 @@ class XCXCAEAPOIDetector : public XCBase
// //
AddRef( AddRef(
iPivot, iPivot,
iPVFVG.fvgs // iPVFVG.pivots //
); );
} }
} }
Clean(tmpFVGs); Clean(tmpFVGs);
// //
if (HasChild(iPVFVG.fvgs)) if (HasChild(iPVFVG.pivots))
{ {
// //
AddRef( AddRef(
@@ -5580,9 +5805,90 @@ class XCXCAEAPOIDetector : public XCBase
Clean(tmp); Clean(tmp);
} }
//
// PVTICKS ...
//
XCAPVTick tmpTicks[];
//
has = HasPeakTicks();
if (has)
{
//
Copy(
peakTicks,
tmpTicks //
);
Clean(peakTicks);
while (HasChild(tmpTicks))
{
//
XCAPVTick iPVTick = tmpTicks[0];
ArrayRemove(
tmpTicks,
0,
1);
//
has = IsPivotBreaked(
iPVTick.pivot,
unAvailableBoxes,
barIndex //
);
if (!has)
{
//
AddRef(
iPVTick,
peakTicks //
);
}
}
Clean(tmpTicks);
}
//
has = HasValeTicks();
if (has)
{
//
Copy(
valeTicks,
tmpTicks //
);
Clean(valeTicks);
while (HasChild(tmpTicks))
{
//
XCAPVTick iPVTick = tmpTicks[0];
ArrayRemove(
tmpTicks,
0,
1);
//
has = IsPivotBreaked(
iPVTick.pivot,
unAvailableBoxes,
barIndex //
);
if (!has)
{
//
AddRef(
iPVTick,
valeTicks //
);
}
}
Clean(tmpTicks);
}
// //
Clean(tmp); Clean(tmp);
Clean(tmpPVFVG); Clean(tmpPVFVG);
Clean(tmpTicks);
} }
// //
@@ -6888,6 +7194,33 @@ class XCXCAEAPOIDetector : public XCBase
return ArraySize(cciCrossedUnderOBPivots); return ArraySize(cciCrossedUnderOBPivots);
} }
//
// PVTICKS ...
//
bool HasPeakTicks()
{
return HasChild(peakTicks);
}
//
int CountPeakTicks()
{
return ArraySize(peakTicks);
}
//
bool HasValeTicks()
{
return HasChild(valeTicks);
}
//
int CountValeTicks()
{
return ArraySize(valeTicks);
}
// //
// Protected ... // Protected ...
protected: protected:
+60 -4
View File
@@ -13,6 +13,7 @@
////////////////////////////////////////////////////// //////////////////////////////////////////////////////
// //
// Global Properties ... // Global Properties ...
#property library
#property copyright "Copyright 2023, SaherElm IT Center" #property copyright "Copyright 2023, SaherElm IT Center"
#property link "https://saherelm.ir" #property link "https://saherelm.ir"
#property version "1.00" #property version "1.00"
@@ -65,6 +66,9 @@ class XCXCAEAPOIDrawer : public XCBase
bool drawCCICrossedOverOSPivots; bool drawCCICrossedOverOSPivots;
bool drawCCICrossedUnderOBPivots; bool drawCCICrossedUnderOBPivots;
//
bool drawTicks;
// //
// Colorize Props ... // Colorize Props ...
@@ -212,6 +216,9 @@ class XCXCAEAPOIDrawer : public XCBase
drawCCICrossedOverOSPivots = false; drawCCICrossedOverOSPivots = false;
drawCCICrossedUnderOBPivots = false; drawCCICrossedUnderOBPivots = false;
//
drawTicks = false;
// //
// Color ... // Color ...
defBullishPivotColor = clrLime; defBullishPivotColor = clrLime;
@@ -274,6 +281,7 @@ class XCXCAEAPOIDrawer : public XCBase
void Draw(datetime to = NULL) void Draw(datetime to = NULL)
{ {
// //
DrawTicks();
DrawSWHPivots(to); DrawSWHPivots(to);
DrawSWLPivots(to); DrawSWLPivots(to);
DrawPeakPivots(to); DrawPeakPivots(to);
@@ -306,6 +314,54 @@ class XCXCAEAPOIDrawer : public XCBase
// //
// //
//
void DrawTicks()
{
//
if (!drawTicks)
{
return;
}
//
// PEAK TICKS ...
bool has = detector.HasPeakTicks();
if (has) {
//
int count = detector.CountPeakTicks();
for (int i = 0; i < count; i++) {
//
XCTicksZoneObject *iObj;
has = drawer.CreateTicksZone(
detector.peakTicks[i].zone,
iObj //
);
if (has) {
mPeakPivotObjects.Add(iObj);
}
}
}
//
// VALE TICKS ...
has = detector.HasValeTicks();
if (has) {
//
int count = detector.CountValeTicks();
for (int i = 0; i < count; i++) {
//
XCTicksZoneObject *iObj;
has = drawer.CreateTicksZone(
detector.valeTicks[i].zone,
iObj //
);
if (has) {
mPeakPivotObjects.Add(iObj);
}
}
}
}
// //
void DrawSWHPivots(datetime to = NULL) void DrawSWHPivots(datetime to = NULL)
{ {
@@ -725,11 +781,11 @@ class XCXCAEAPOIDrawer : public XCBase
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
// //
XCAPVFVG iPVFVG = detector.pvFVGBullishPivots[i]; XCAPVPivot iPVFVG = detector.pvFVGBullishPivots[i];
// //
XBoxZone fvgBoxes[]; XBoxZone fvgBoxes[];
int fvgBoxesCount = iPVFVG.GetFVGs(fvgBoxes); int fvgBoxesCount = iPVFVG.GetPivots(fvgBoxes);
has = IsValidSize(fvgBoxesCount); has = IsValidSize(fvgBoxesCount);
if (has) if (has)
{ {
@@ -840,11 +896,11 @@ class XCXCAEAPOIDrawer : public XCBase
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
// //
XCAPVFVG iPVFVG = detector.pvFVGBearishPivots[i]; XCAPVPivot iPVFVG = detector.pvFVGBearishPivots[i];
// //
XBoxZone fvgBoxes[]; XBoxZone fvgBoxes[];
int fvgBoxesCount = iPVFVG.GetFVGs(fvgBoxes); int fvgBoxesCount = iPVFVG.GetPivots(fvgBoxes);
has = IsValidSize(fvgBoxesCount); has = IsValidSize(fvgBoxesCount);
if (has) if (has)
{ {
+1
View File
@@ -13,6 +13,7 @@
////////////////////////////////////////////////////// //////////////////////////////////////////////////////
// //
// Global Properties ... // Global Properties ...
#property library
#property copyright "Copyright 2023, SaherElm IT Center" #property copyright "Copyright 2023, SaherElm IT Center"
#property link "https://saherelm.ir" #property link "https://saherelm.ir"
#property version "1.00" #property version "1.00"
+4
View File
@@ -13,6 +13,7 @@
////////////////////////////////////////////////////// //////////////////////////////////////////////////////
// //
// Global Properties ... // Global Properties ...
#property library
#property copyright "Copyright 2023, SaherElm IT Center" #property copyright "Copyright 2023, SaherElm IT Center"
#property link "https://saherelm.ir" #property link "https://saherelm.ir"
#property version "1.00" #property version "1.00"
@@ -796,6 +797,9 @@ class XCXCAEASignaller : XCBase
drawer.drawCCICrossedOverOSPivots = false; drawer.drawCCICrossedOverOSPivots = false;
drawer.drawCCICrossedUnderOBPivots = false; drawer.drawCCICrossedUnderOBPivots = false;
//
drawer.drawTicks = true;
// //
// Configure Width ... // Configure Width ...
drawer.peakPivotWidth = 1; drawer.peakPivotWidth = 1;