last works on Detecting Pivots ...

- Pivots Detection works Fine;
- Analyse Pivots Has some issues and i have to Fix them ...
This commit is contained in:
2025-09-23 16:36:53 +03:30
parent 1a948307f2
commit 3812246e5c
9 changed files with 1934 additions and 143 deletions
+245 -1
View File
@@ -1458,13 +1458,21 @@ class XCPivotAnalysisObject : public XCBaseObject
* @param chart_id: Long, Specified Chart ID ...
* @param window: Integer, Specified Chart Window ID ...
* @param model: XPivotAnalysis, reference model ...
* @param drawPivots: Specified to Draw Pivots or not ...
* @param peakArrow: int, Specified Arrow Code for Peak Pivots ...
* @param valeArrow: int, Specified Arrow Code for Vale Pivots ...
* @param threshold: int, distance between price and arrow in Point ...
*
* @return ( bool )
*/
bool Create(
long chart_id,
int window,
XPivotAnalysis &model //
XPivotAnalysis &model,
bool drawPivots = true,
int peakArrow = 159,
int valeArrow = 159,
int threshold = 5 //
)
{
//
@@ -1562,6 +1570,70 @@ class XCPivotAnalysisObject : public XCBaseObject
);
}
//
// Draw Pivots ...
if (drawPivots &&
model.HasPivots())
{
//
XOHCL iBar;
int arrow = 0;
bool has = false;
string name = NULL;
XCBarArrowObject *iObj;
ENUM_X_PRICE type = X_PRICE_NONE;
int pivotsCount = ArraySize(model.pivots);
for (int i = 0; i < pivotsCount; i++)
{
//
has = model.pivots[i].GetBar(iBar);
if (!has)
{
continue;
}
//
arrow = model.pivots[i].IsPeak()
? peakArrow
: valeArrow;
name = model.pivots[i].GetObjectID();
type = model.pivots[i].IsPeak()
? X_PRICE_HIGH
: X_PRICE_LOW;
iObj = new XCBarArrowObject();
has = iObj.CreateByBar(
chart_id,
name,
window,
arrow,
iBar,
type,
threshold //
);
if (has)
{
//
if (model.pivots[i].IsPeak())
{
mPeaks.Add(iObj);
}
else
{
mVales.Add(iObj);
}
}
//
iBar.Clean();
ZeroMemory(iObj);
}
//
// Cleanup Resources ...
iBar.Clean();
ZeroMemory(iObj);
}
//
// Setting Object Name ...
if (result)
@@ -1821,9 +1893,181 @@ class XCPivotAnalysisObject : public XCBaseObject
mResistanceBox.Style(value);
}
/**
* Set Width ...
*
* @param value: Integer ...
*/
void PeaksWidth(int value)
{
//
// Normalize ...
value = NormalizeInt(value, 1);
//
// Validate ...
int count = mPeaks.Total();
bool has = IsValidSize(count);
if (!has)
{
return;
}
//
XCBarArrowObject *iPeak;
for (int i = 0; i < count; i++)
{
//
iPeak = (XCBarArrowObject *)mPeaks.At(i);
iPeak.ArrowWidth(value);
ZeroMemory(iPeak);
}
}
/**
* Set Color ...
*
* @param value: Color ...
*/
void PeaksColor(color value)
{
//
// Validate ...
int count = mPeaks.Total();
bool has = IsValidSize(count);
if (!has)
{
return;
}
//
XCBarArrowObject *iPeak;
for (int i = 0; i < count; i++)
{
//
iPeak = (XCBarArrowObject *)mPeaks.At(i);
iPeak.ArrowColor(value);
ZeroMemory(iPeak);
}
}
/**
* Set Arrow Anchor ...
*
* @param value: ENUM_ARROW_ANCHOR member ...
*/
void PeaksAnchor(ENUM_ARROW_ANCHOR value)
{
//
// Validate ...
int count = mPeaks.Total();
bool has = IsValidSize(count);
if (!has)
{
return;
}
//
XCBarArrowObject *iPeak;
for (int i = 0; i < count; i++)
{
//
iPeak = (XCBarArrowObject *)mPeaks.At(i);
iPeak.ArrowAnchor(value);
ZeroMemory(iPeak);
}
}
/**
* Set Width ...
*
* @param value: Integer ...
*/
void ValesWidth(int value)
{
//
// Normalize ...
value = NormalizeInt(value, 1);
//
// Validate ...
int count = mVales.Total();
bool has = IsValidSize(count);
if (!has)
{
return;
}
//
XCBarArrowObject *iVale;
for (int i = 0; i < count; i++)
{
//
iVale = (XCBarArrowObject *)mVales.At(i);
iVale.ArrowWidth(value);
ZeroMemory(iVale);
}
}
/**
* Set Color ...
*
* @param value: Color ...
*/
void ValesColor(color value)
{
//
// Validate ...
int count = mVales.Total();
bool has = IsValidSize(count);
if (!has)
{
return;
}
//
XCBarArrowObject *iVale;
for (int i = 0; i < count; i++)
{
//
iVale = (XCBarArrowObject *)mVales.At(i);
iVale.ArrowColor(value);
ZeroMemory(iVale);
}
}
/**
* Set Arrow Anchor ...
*
* @param value: ENUM_ARROW_ANCHOR member ...
*/
void ValesAnchor(ENUM_ARROW_ANCHOR value)
{
//
// Validate ...
int count = mVales.Total();
bool has = IsValidSize(count);
if (!has)
{
return;
}
//
XCBarArrowObject *iVale;
for (int i = 0; i < count; i++)
{
//
iVale = (XCBarArrowObject *)mVales.At(i);
iVale.ArrowAnchor(value);
ZeroMemory(iVale);
}
}
//
private:
//
CArrayObj mPeaks;
CArrayObj mVales;
CChartObjectTrend mUpper;
CChartObjectTrend mLower;
XCBoxObject *mSupportBox;
+99 -6
View File
@@ -262,7 +262,7 @@ class XCPOIDrawer : public XCBase
//
return result;
}
/**
* Draw Bar Arrow Object ...
*
@@ -397,8 +397,8 @@ class XCPOIDrawer : public XCBase
? X_PRICE_HIGH
: X_PRICE_LOW;
XPOIStyle style = pivot.IsPeak()
? defaultBullishStyle
: defaultBearishStyle;
? defaultBearishStyle
: defaultBullishStyle;
ENUM_ARROW_ANCHOR anchor = pivot.IsPeak()
? ANCHOR_BOTTOM
: ANCHOR_TOP;
@@ -431,6 +431,72 @@ class XCPOIDrawer : public XCBase
return result;
}
/**
* Draw Specified Pivot Collection ...
*
* @param pivots: XPivot, reference Collection to Draw ...
* @param draws: CArrayObj, pointer reference to Hold Drawn Objects ...
* @param peakArrow: int, Specified Arrow Code for Peak Pivots ...
* @param valeArrow: int, Specified Arrow Code for Vale Pivots ...
* @param threshold: int, distance between price and arrow in Point ...
*
* @return ( int )
*/
int DrawPivots(
XPivot &pivots[],
CArrayObj *&draws,
int peakArrow = 159,
int valeArrow = 159,
int threshold = 5 //
)
{
//
int result = 0;
//
// Prepare ...
draws.Clear();
//
// Validate ...
if (!HasChild(pivots))
{
return result;
}
//
bool has = false;
XCBarArrowObject *iObj;
int count = ArraySize(pivots);
for (int i = 0; i < count; i++)
{
//
// Draw Indexed Pivot ...
has = DrawPivot(
pivots[i],
iObj,
peakArrow,
valeArrow,
threshold //
);
//
if (has)
{
draws.Add(iObj);
}
//
ZeroMemory(iObj);
}
//
result = draws.Total();
//
return result;
}
/**
* Draw Specified Box ...
*
@@ -811,12 +877,21 @@ class XCPOIDrawer : public XCBase
* Draw Pivot Analysis ...
*
* @param analysis: XPivotAnalysis, referece Specified Pivot Analysis ...
* @param object: XCPivotAnalysisObject, pointer reference for Drawn Object ...
* @param drawPivots: Specified to Draw Pivots or not ...
* @param peakArrow: int, Specified Arrow Code for Peak Pivots ...
* @param valeArrow: int, Specified Arrow Code for Vale Pivots ...
* @param threshold: int, distance between price and arrow in Point ...
*
* @return ( bool )
*/
bool DrawXPivotAnalysis(
bool DrawPivotAnalysis(
XPivotAnalysis &analysis,
XCPivotAnalysisObject *&object //
XCPivotAnalysisObject *&object,
bool drawPivots = true,
int peakArrow = 159,
int valeArrow = 159,
int threshold = 5 //
)
{
//
@@ -843,7 +918,11 @@ class XCPOIDrawer : public XCBase
result = object.Create(
ChartIdentification(),
SubWindowIdentification(),
analysis //
analysis,
drawPivots,
peakArrow,
valeArrow,
threshold //
);
if (result)
{
@@ -1263,6 +1342,20 @@ class XCPOIDrawer : public XCBase
object.LowerRayRight(true);
}
//
// Peak Pivots ...
style = defaultBearishStyle;
object.PeaksColor(style.clr);
object.PeaksWidth(style.width);
object.PeaksAnchor(ANCHOR_BOTTOM);
//
// Vale Pivots ...
style = defaultBullishStyle;
object.ValesColor(style.clr);
object.ValesWidth(style.width);
object.ValesAnchor(ANCHOR_TOP);
//
style.Clean();
}