last works ...

This commit is contained in:
2025-09-26 19:48:34 +03:30
parent 353a204162
commit 21ce1ebf4f
12 changed files with 3029 additions and 544 deletions
+283 -83
View File
@@ -1468,6 +1468,8 @@ class XCPivotAnalysisObject : public XCBaseObject
* @param chart_id: Long, Specified Chart ID ...
* @param window: Integer, Specified Chart Window ID ...
* @param model: XPivotAnalysis, reference model ...
* @param drawTrends: Specified to Draw Trends or not ...
* @param drawZones: Specified to Draw Support and Resistance Zones or not ...
* @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 ...
@@ -1479,6 +1481,8 @@ class XCPivotAnalysisObject : public XCBaseObject
long chart_id,
int window,
XPivotAnalysis &model,
bool drawTrends = true,
bool drawZones = true,
bool drawPivots = true,
int peakArrow = 159,
int valeArrow = 159,
@@ -1502,91 +1506,138 @@ class XCPivotAnalysisObject : public XCBaseObject
//
// Generate Object ID ...
string objID = model.GetObjectID();
string upperName = model.GetUpperObjectID();
string lowerName = model.GetLowerObjectID();
//
// Extract Recent Pivots ...
//
// Creating Upper ...
result = mUpper.Create(
chart_id,
upperName,
window,
model.fromTime,
model.peakFrom,
model.toTime,
model.peakTo //
);
if (!result)
// Draw Trend Lines ...
mUpper = NULL;
mLower = NULL;
if (drawTrends)
{
return result;
//
string upperName = model.GetUpperObjectID();
string lowerName = model.GetLowerObjectID();
//
RemoveObjects(upperName, chart_id, window);
RemoveObjects(lowerName, chart_id, window);
//
// Creating Upper ...
mUpper = new CChartObjectTrend();
result = mUpper.Create(
chart_id,
upperName,
window,
model.fromTime,
model.peakFrom,
model.toTime,
model.peakTo //
);
if (!result)
{
//
// Destroy Trending Objects ...
DestroyObject(mUpper);
DestroyObject(mLower);
//
return result;
}
//
// Create Lower ...
mLower = new CChartObjectTrend();
result = mLower.Create(
chart_id,
lowerName,
window,
model.fromTime,
model.valeFrom,
model.toTime,
model.valeTo //
);
if (!result)
{
//
// Destroy Trending Objects ...
DestroyObject(mUpper);
DestroyObject(mLower);
//
return result;
}
}
//
// Create Lower ...
result = mLower.Create(
chart_id,
lowerName,
window,
model.fromTime,
model.valeFrom,
model.toTime,
model.valeTo //
);
if (!result)
{
//
mUpper.Detach();
mUpper.Delete();
//
return result;
}
//
// Support ...
XBoxZone tmpBox;
// Draw Zones ...
mSupportBox = NULL;
has = model.HasSupportBox(tmpBox);
if (has)
{
//
datetime to = TimeCurrent();
string name = model.GetSupportBoxObjectID();
mSupportBox = new XCBoxObject();
has = mSupportBox.Create(
chart_id,
window,
name,
tmpBox.upper,
tmpBox.lower,
tmpBox.from,
to //
);
}
//
// Resistance ...
tmpBox.Clean();
mResistanceBox = NULL;
has = model.HasResistanceBox(tmpBox);
if (has)
if (drawZones)
{
//
datetime to = TimeCurrent();
string name = model.GetResistanceBoxObjectID();
mResistanceBox = new XCBoxObject();
has = mResistanceBox.Create(
chart_id,
window,
name,
tmpBox.upper,
tmpBox.lower,
tmpBox.from,
to //
);
// Support ...
XBoxZone tmpBox;
has = model.HasSupportBox(tmpBox);
if (has)
{
//
datetime to = TimeCurrent();
string name = model.GetSupportBoxObjectID();
RemoveObjects(name, chart_id, window);
mSupportBox = new XCBoxObject();
result = mSupportBox.Create(
chart_id,
window,
name,
tmpBox.upper,
tmpBox.lower,
tmpBox.from,
to //
);
if (!result)
{
//
DestroyObject(mUpper);
DestroyObject(mLower);
DestroyObject(mSupportBox);
//
return result;
}
}
//
// Resistance ...
tmpBox.Clean();
has = model.HasResistanceBox(tmpBox);
if (has)
{
//
datetime to = TimeCurrent();
string name = model.GetResistanceBoxObjectID();
RemoveObjects(name, chart_id, window);
mResistanceBox = new XCBoxObject();
result = mResistanceBox.Create(
chart_id,
window,
name,
tmpBox.upper,
tmpBox.lower,
tmpBox.from,
to //
);
if (!result)
{
//
DestroyObject(mUpper);
DestroyObject(mLower);
DestroyObject(mSupportBox);
DestroyObject(mResistanceBox);
//
return result;
}
}
}
//
@@ -1615,6 +1666,7 @@ class XCPivotAnalysisObject : public XCBaseObject
? peakArrow
: valeArrow;
name = model.pivots[i].GetObjectID();
RemoveObjects(name, chart_id, window);
type = model.pivots[i].IsPeak()
? X_PRICE_HIGH
: X_PRICE_LOW;
@@ -1686,6 +1738,8 @@ class XCPivotAnalysisObject : public XCBaseObject
Delete();
//
DestroyObject(mUpper);
DestroyObject(mLower);
DestroyObject(mSupportBox);
DestroyObject(mResistanceBox);
}
@@ -1706,6 +1760,12 @@ class XCPivotAnalysisObject : public XCBaseObject
value = 1;
}
//
if (mUpper == NULL)
{
return;
}
//
mUpper.Width(value);
}
@@ -1717,6 +1777,12 @@ class XCPivotAnalysisObject : public XCBaseObject
*/
void UpperColor(color value)
{
//
if (mUpper == NULL)
{
return;
}
//
mUpper.Color(value);
}
@@ -1728,6 +1794,12 @@ class XCPivotAnalysisObject : public XCBaseObject
*/
void UpperStyle(ENUM_LINE_STYLE value)
{
//
if (mUpper == NULL)
{
return;
}
//
mUpper.Style(value);
}
@@ -1739,6 +1811,13 @@ class XCPivotAnalysisObject : public XCBaseObject
*/
void UpperRayLeft(bool value)
{
//
if (mUpper == NULL)
{
return;
}
//
mUpper.RayLeft(value);
}
@@ -1749,6 +1828,13 @@ class XCPivotAnalysisObject : public XCBaseObject
*/
void UpperRayRight(bool value)
{
//
if (mUpper == NULL)
{
return;
}
//
mUpper.RayRight(value);
}
@@ -1765,6 +1851,12 @@ class XCPivotAnalysisObject : public XCBaseObject
value = 1;
}
//
if (mLower == NULL)
{
return;
}
//
mLower.Width(value);
}
@@ -1776,6 +1868,12 @@ class XCPivotAnalysisObject : public XCBaseObject
*/
void LowerColor(color value)
{
//
if (mLower == NULL)
{
return;
}
//
mLower.Color(value);
}
@@ -1787,6 +1885,12 @@ class XCPivotAnalysisObject : public XCBaseObject
*/
void LowerStyle(ENUM_LINE_STYLE value)
{
//
if (mLower == NULL)
{
return;
}
//
mLower.Style(value);
}
@@ -1798,6 +1902,13 @@ class XCPivotAnalysisObject : public XCBaseObject
*/
void LowerRayLeft(bool value)
{
//
if (mLower == NULL)
{
return;
}
//
mLower.RayLeft(value);
}
@@ -1808,6 +1919,13 @@ class XCPivotAnalysisObject : public XCBaseObject
*/
void LowerRayRight(bool value)
{
//
if (mLower == NULL)
{
return;
}
//
mLower.RayRight(value);
}
@@ -2100,8 +2218,8 @@ class XCPivotAnalysisObject : public XCBaseObject
//
CArrayObj mPeaks;
CArrayObj mVales;
CChartObjectTrend mUpper;
CChartObjectTrend mLower;
CChartObjectTrend *mUpper;
CChartObjectTrend *mLower;
XCBoxObject *mSupportBox;
XCBoxObject *mResistanceBox;
};
@@ -2137,14 +2255,16 @@ void AddObjects(
/**
* Destroy Object if Exists ...
*
*
* @param object: pointer refrence to Destroy ...
*/
void DestroyObject(XCBoxObject *&object) {
void DestroyObject(XCBoxObject *&object)
{
//
// Validate ...
bool has = object != NULL;
if (!has) {
if (!has)
{
return;
}
@@ -2162,14 +2282,16 @@ void DestroyObject(XCBoxObject *&object) {
/**
* Destroy Object if Exists ...
*
*
* @param object: pointer refrence to Destroy ...
*/
void DestroyObject(XCPivotAnalysisObject *&object) {
void DestroyObject(XCPivotAnalysisObject *&object)
{
//
// Validate ...
bool has = object != NULL;
if (!has) {
if (!has)
{
return;
}
@@ -2185,4 +2307,82 @@ void DestroyObject(XCPivotAnalysisObject *&object) {
ZeroMemory(object);
}
/**
* Destroy Object if Exists ...
*
* @param object: pointer refrence to Destroy ...
*/
void DestroyObject(CChartObjectTrend *&object)
{
//
// Validate ...
bool has = object != NULL;
if (!has)
{
return;
}
//
object.Detach();
object.Delete();
//
delete object;
ZeroMemory(object);
}
/**
* Remove Drawn Objects from Chart ...
*
* @param tag: Specified Object Name, if NULL remove all Objects ...
* @param chartId: long, Specified Chart ...
* @param subWindow: int Specified Sub Window ...
*/
void RemoveObjects(
string tag = NULL,
long chartId = -1,
int subWindow = -1 //
)
{
//
// Normalize Args ...
//
if (chartId == -1)
{
chartId = 0;
}
//
if (subWindow == -1)
{
subWindow = 0;
}
//
bool has = false;
string iName = NULL;
for (int iObj = ObjectsTotal(chartId, subWindow) - 1; iObj >= 0; iObj--)
{
//
// Retrieve Object Name ...
iName = ObjectName(chartId, iObj, subWindow);
//
// Check Can Delete Object or not ...
has =
!IsSpecifiedValid(tag)
? true
: StringFind(iName, tag) >= 0;
if (has)
{
ObjectDelete(chartId, iName);
}
}
//
// Redraw Chart ...
ChartRedraw();
}
//
@@ -835,6 +835,7 @@ class XCPOIDrawer : public XCBase
ulong chartId = ChartIdentification();
int subWindow = SubWindowIdentification();
string name = ToXString(dir) + "_Trend_" + ToXString(price1) + "_" + ToXString(price2);
RemoveObjects("_Trend_", chartId, subWindow);
//
object = new CChartObjectTrend();
@@ -872,6 +873,8 @@ class XCPOIDrawer : public XCBase
*
* @param analysis: XPivotAnalysis, referece Specified Pivot Analysis ...
* @param object: XCPivotAnalysisObject, pointer reference for Drawn Object ...
* @param drawTrends: Specified to Draw Trends or not ...
* @param drawZones: Specified to Draw Support and Resistance Zones or not ...
* @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 ...
@@ -882,6 +885,8 @@ class XCPOIDrawer : public XCBase
bool DrawPivotAnalysis(
XPivotAnalysis &analysis,
XCPivotAnalysisObject *&object,
bool drawTrends = true,
bool drawZones = true,
bool drawPivots = true,
int peakArrow = 159,
int valeArrow = 159,
@@ -913,6 +918,8 @@ class XCPOIDrawer : public XCBase
ChartIdentification(),
SubWindowIdentification(),
analysis,
drawTrends,
drawZones,
drawPivots,
peakArrow,
valeArrow,