Add Support to Draw Rect on XZoneChart Object ...

This commit is contained in:
2024-10-22 15:44:45 +03:30
parent a6e4d625e4
commit eab3888c88
3 changed files with 313 additions and 50 deletions
+153 -47
View File
@@ -25,6 +25,7 @@
//
#include <ChartObjects/ChartObject.mqh>
#include <ChartObjects/ChartObjectsLines.mqh>
#include <ChartObjects/ChartObjectsShapes.mqh>
//
// Definitions ...
@@ -272,6 +273,8 @@ class XCZoneObject : public CChartObject
* @param lowerPrice1: Double ...
* @param lowerPrice2: Double ...
* @param objprefix: String ...
* @param forceRect: Boolean ...
*
* @return ( bool )
*/
bool Create(
@@ -284,7 +287,8 @@ class XCZoneObject : public CChartObject
const double upperPrice2,
const double lowerPrice1,
const double lowerPrice2,
const string objprefix = NULL //
const string objprefix = NULL,
const bool forceRect = false //
)
{
//
@@ -315,49 +319,137 @@ class XCZoneObject : public CChartObject
: objprefix + "_";
//
// Upper Bound ...
// Check Params For Rectangle ...
bool canDrawRect =
forceRect &&
upperPrice1 == upperPrice2 &&
lowerPrice1 == lowerPrice1;
//
string upperName = prefix + ToString(X_UPPER) + "_" + name;
//
result = mUpperTrend.Create(
chart_id,
upperName,
window,
time1,
upperPrice1,
time2,
upperPrice2 //
);
if (!result)
{
return result;
}
//
// Lower Bound ...
//
string lowerName = prefix + ToString(X_LOWER) + "_" + name;
//
result = mLowerTrend.Create(
chart_id,
lowerName,
window,
time1,
lowerPrice1,
time2,
lowerPrice2 //
);
if (!result)
// Draw Rectangle ...
if (canDrawRect)
{
//
mUpperTrend.Delete();
result = mRect.Create(
chart_id,
name,
window,
time1,
upperPrice1,
time2,
lowerPrice1 //
);
}
//
// Draw as Trend Line ...
else
{
//
// Upper Bound ...
//
string upperName = prefix + ToString(X_UPPER) + "_" + name;
//
result = mUpperTrend.Create(
chart_id,
upperName,
window,
time1,
upperPrice1,
time2,
upperPrice2 //
);
if (!result)
{
return result;
}
//
// Lower Bound ...
//
string lowerName = prefix + ToString(X_LOWER) + "_" + name;
//
result = mLowerTrend.Create(
chart_id,
lowerName,
window,
time1,
lowerPrice1,
time2,
lowerPrice2 //
);
if (!result)
{
//
mUpperTrend.Delete();
return result;
}
}
//
return result;
}
/**
* Create XCZoneObject by Providing a XZone ...
*
* @param chart_id: Long ...
* @param name: String ...
* @param window: Integer ...
* @param time1: DateTime ...
* @param time2: DateTime ...
* @param zone: XZone instance ...
* @param objprefix: String ...
* @param forceRect: Boolean ...
*
* @return ( bool )
*/
bool CreateByZone(
long chart_id,
const string name,
const int window,
const datetime time1,
const datetime time2,
const XZone &zone,
const string objprefix = NULL,
const bool forceRect = false //
)
{
//
bool result = false;
//
NormalizeTime(time2);
//
XZone tmpZone = zone;
result =
time1 < time2 &&
IsValid(time1) &&
IsValid(name) &&
tmpZone.IsValid();
if (!result)
{
return result;
}
//
result = Create(
chart_id,
name,
window,
time1,
time2,
zone.upper,
zone.upper,
zone.lower,
zone.lower,
objprefix //
);
//
return result;
}
@@ -386,6 +478,7 @@ class XCZoneObject : public CChartObject
}
//
mRect.Width(value);
mUpperTrend.Width(value);
mLowerTrend.Width(value);
}
@@ -398,6 +491,7 @@ class XCZoneObject : public CChartObject
void ZoneColor(color value)
{
//
mRect.Color(value);
mUpperTrend.Color(value);
mLowerTrend.Color(value);
}
@@ -410,6 +504,7 @@ class XCZoneObject : public CChartObject
void ZoneStyle(ENUM_LINE_STYLE value)
{
//
mRect.Style(value);
mUpperTrend.Style(value);
mLowerTrend.Style(value);
}
@@ -423,6 +518,7 @@ class XCZoneObject : public CChartObject
//
CChartObjectTrend mUpperTrend;
CChartObjectTrend mLowerTrend;
CChartObjectRectangle mRect;
//
};
@@ -607,6 +703,7 @@ class XCSupportZoneObject : public XCZoneObject
* @param window: Integer ...
* @param support: XOHCL instance ...
* @param time2: DateTime ...
* @param forceRect: Boolean ...
*
* @return ( bool )
*/
@@ -614,22 +711,24 @@ class XCSupportZoneObject : public XCZoneObject
long chart_id,
const string name,
const int window,
XOHCL &support,
datetime time2 //
const XOHCL &support,
const datetime time2,
const bool forceRect = false //
)
{
//
bool result = false;
//
result = support.IsValid();
XOHCL tmpSupport = support;
result = tmpSupport.IsValid();
if (!result)
{
return result;
}
//
double bottom = support.GetDown();
double bottom = tmpSupport.GetDown();
//
result = Create(
@@ -641,7 +740,9 @@ class XCSupportZoneObject : public XCZoneObject
bottom,
bottom,
support.low,
support.low //
support.low,
NULL,
forceRect //
);
//
@@ -689,6 +790,7 @@ class XCResistanceZoneObject : public XCZoneObject
* @param window: Integer ...
* @param resistance: XOHCL instance ...
* @param time2: DateTime ...
* @param forceRect: Boolean ...
*
* @return ( bool )
*/
@@ -696,22 +798,24 @@ class XCResistanceZoneObject : public XCZoneObject
long chart_id,
const string name,
const int window,
XOHCL &resistance,
datetime time2 //
const XOHCL &resistance,
const datetime time2,
const bool forceRect = false //
)
{
//
bool result = false;
//
result = resistance.IsValid();
XOHCL tmpResistance = resistance;
result = tmpResistance.IsValid();
if (!result)
{
return result;
}
//
double up = resistance.GetUp();
double up = tmpResistance.GetUp();
//
result = Create(
@@ -723,7 +827,9 @@ class XCResistanceZoneObject : public XCZoneObject
resistance.high,
resistance.high,
up,
up //
up,
NULL,
forceRect //
);
//
+4 -2
View File
@@ -4383,7 +4383,8 @@ class XCPOI : public XSCBaseAlert
name,
Window(),
bar,
cBarTime //
cBarTime,
true // Force Draw Rect ...
);
if (!isCreated)
{
@@ -4450,7 +4451,8 @@ class XCPOI : public XSCBaseAlert
name,
Window(),
bar,
cBarTime //
cBarTime,
true // Force Draw Rect ...
);
if (!isCreated)
{