Add Support to Draw Rect on XZoneChart Object ...
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
//
|
//
|
||||||
#include <ChartObjects/ChartObject.mqh>
|
#include <ChartObjects/ChartObject.mqh>
|
||||||
#include <ChartObjects/ChartObjectsLines.mqh>
|
#include <ChartObjects/ChartObjectsLines.mqh>
|
||||||
|
#include <ChartObjects/ChartObjectsShapes.mqh>
|
||||||
|
|
||||||
//
|
//
|
||||||
// Definitions ...
|
// Definitions ...
|
||||||
@@ -272,6 +273,8 @@ class XCZoneObject : public CChartObject
|
|||||||
* @param lowerPrice1: Double ...
|
* @param lowerPrice1: Double ...
|
||||||
* @param lowerPrice2: Double ...
|
* @param lowerPrice2: Double ...
|
||||||
* @param objprefix: String ...
|
* @param objprefix: String ...
|
||||||
|
* @param forceRect: Boolean ...
|
||||||
|
*
|
||||||
* @return ( bool )
|
* @return ( bool )
|
||||||
*/
|
*/
|
||||||
bool Create(
|
bool Create(
|
||||||
@@ -284,7 +287,8 @@ class XCZoneObject : public CChartObject
|
|||||||
const double upperPrice2,
|
const double upperPrice2,
|
||||||
const double lowerPrice1,
|
const double lowerPrice1,
|
||||||
const double lowerPrice2,
|
const double lowerPrice2,
|
||||||
const string objprefix = NULL //
|
const string objprefix = NULL,
|
||||||
|
const bool forceRect = false //
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -315,49 +319,137 @@ class XCZoneObject : public CChartObject
|
|||||||
: objprefix + "_";
|
: objprefix + "_";
|
||||||
|
|
||||||
//
|
//
|
||||||
// Upper Bound ...
|
// Check Params For Rectangle ...
|
||||||
|
bool canDrawRect =
|
||||||
|
forceRect &&
|
||||||
|
upperPrice1 == upperPrice2 &&
|
||||||
|
lowerPrice1 == lowerPrice1;
|
||||||
|
|
||||||
//
|
//
|
||||||
string upperName = prefix + ToString(X_UPPER) + "_" + name;
|
// Draw Rectangle ...
|
||||||
|
if (canDrawRect)
|
||||||
//
|
|
||||||
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();
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = Create(
|
||||||
|
chart_id,
|
||||||
|
name,
|
||||||
|
window,
|
||||||
|
time1,
|
||||||
|
time2,
|
||||||
|
zone.upper,
|
||||||
|
zone.upper,
|
||||||
|
zone.lower,
|
||||||
|
zone.lower,
|
||||||
|
objprefix //
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -386,6 +478,7 @@ class XCZoneObject : public CChartObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
mRect.Width(value);
|
||||||
mUpperTrend.Width(value);
|
mUpperTrend.Width(value);
|
||||||
mLowerTrend.Width(value);
|
mLowerTrend.Width(value);
|
||||||
}
|
}
|
||||||
@@ -398,6 +491,7 @@ class XCZoneObject : public CChartObject
|
|||||||
void ZoneColor(color value)
|
void ZoneColor(color value)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
mRect.Color(value);
|
||||||
mUpperTrend.Color(value);
|
mUpperTrend.Color(value);
|
||||||
mLowerTrend.Color(value);
|
mLowerTrend.Color(value);
|
||||||
}
|
}
|
||||||
@@ -410,6 +504,7 @@ class XCZoneObject : public CChartObject
|
|||||||
void ZoneStyle(ENUM_LINE_STYLE value)
|
void ZoneStyle(ENUM_LINE_STYLE value)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
mRect.Style(value);
|
||||||
mUpperTrend.Style(value);
|
mUpperTrend.Style(value);
|
||||||
mLowerTrend.Style(value);
|
mLowerTrend.Style(value);
|
||||||
}
|
}
|
||||||
@@ -423,6 +518,7 @@ class XCZoneObject : public CChartObject
|
|||||||
//
|
//
|
||||||
CChartObjectTrend mUpperTrend;
|
CChartObjectTrend mUpperTrend;
|
||||||
CChartObjectTrend mLowerTrend;
|
CChartObjectTrend mLowerTrend;
|
||||||
|
CChartObjectRectangle mRect;
|
||||||
|
|
||||||
//
|
//
|
||||||
};
|
};
|
||||||
@@ -607,6 +703,7 @@ class XCSupportZoneObject : public XCZoneObject
|
|||||||
* @param window: Integer ...
|
* @param window: Integer ...
|
||||||
* @param support: XOHCL instance ...
|
* @param support: XOHCL instance ...
|
||||||
* @param time2: DateTime ...
|
* @param time2: DateTime ...
|
||||||
|
* @param forceRect: Boolean ...
|
||||||
*
|
*
|
||||||
* @return ( bool )
|
* @return ( bool )
|
||||||
*/
|
*/
|
||||||
@@ -614,22 +711,24 @@ class XCSupportZoneObject : public XCZoneObject
|
|||||||
long chart_id,
|
long chart_id,
|
||||||
const string name,
|
const string name,
|
||||||
const int window,
|
const int window,
|
||||||
XOHCL &support,
|
const XOHCL &support,
|
||||||
datetime time2 //
|
const datetime time2,
|
||||||
|
const bool forceRect = false //
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
//
|
//
|
||||||
result = support.IsValid();
|
XOHCL tmpSupport = support;
|
||||||
|
result = tmpSupport.IsValid();
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
double bottom = support.GetDown();
|
double bottom = tmpSupport.GetDown();
|
||||||
|
|
||||||
//
|
//
|
||||||
result = Create(
|
result = Create(
|
||||||
@@ -641,7 +740,9 @@ class XCSupportZoneObject : public XCZoneObject
|
|||||||
bottom,
|
bottom,
|
||||||
bottom,
|
bottom,
|
||||||
support.low,
|
support.low,
|
||||||
support.low //
|
support.low,
|
||||||
|
NULL,
|
||||||
|
forceRect //
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -689,6 +790,7 @@ class XCResistanceZoneObject : public XCZoneObject
|
|||||||
* @param window: Integer ...
|
* @param window: Integer ...
|
||||||
* @param resistance: XOHCL instance ...
|
* @param resistance: XOHCL instance ...
|
||||||
* @param time2: DateTime ...
|
* @param time2: DateTime ...
|
||||||
|
* @param forceRect: Boolean ...
|
||||||
*
|
*
|
||||||
* @return ( bool )
|
* @return ( bool )
|
||||||
*/
|
*/
|
||||||
@@ -696,22 +798,24 @@ class XCResistanceZoneObject : public XCZoneObject
|
|||||||
long chart_id,
|
long chart_id,
|
||||||
const string name,
|
const string name,
|
||||||
const int window,
|
const int window,
|
||||||
XOHCL &resistance,
|
const XOHCL &resistance,
|
||||||
datetime time2 //
|
const datetime time2,
|
||||||
|
const bool forceRect = false //
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
//
|
//
|
||||||
result = resistance.IsValid();
|
XOHCL tmpResistance = resistance;
|
||||||
|
result = tmpResistance.IsValid();
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
double up = resistance.GetUp();
|
double up = tmpResistance.GetUp();
|
||||||
|
|
||||||
//
|
//
|
||||||
result = Create(
|
result = Create(
|
||||||
@@ -723,7 +827,9 @@ class XCResistanceZoneObject : public XCZoneObject
|
|||||||
resistance.high,
|
resistance.high,
|
||||||
resistance.high,
|
resistance.high,
|
||||||
up,
|
up,
|
||||||
up //
|
up,
|
||||||
|
NULL,
|
||||||
|
forceRect //
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -4383,7 +4383,8 @@ class XCPOI : public XSCBaseAlert
|
|||||||
name,
|
name,
|
||||||
Window(),
|
Window(),
|
||||||
bar,
|
bar,
|
||||||
cBarTime //
|
cBarTime,
|
||||||
|
true // Force Draw Rect ...
|
||||||
);
|
);
|
||||||
if (!isCreated)
|
if (!isCreated)
|
||||||
{
|
{
|
||||||
@@ -4450,7 +4451,8 @@ class XCPOI : public XSCBaseAlert
|
|||||||
name,
|
name,
|
||||||
Window(),
|
Window(),
|
||||||
bar,
|
bar,
|
||||||
cBarTime //
|
cBarTime,
|
||||||
|
true // Force Draw Rect ...
|
||||||
);
|
);
|
||||||
if (!isCreated)
|
if (!isCreated)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -47,6 +47,18 @@ enum ENUM_XPOIS
|
|||||||
// Support nad Resistance ...
|
// Support nad Resistance ...
|
||||||
X_POI_SUPPORT, // Support Zone ...
|
X_POI_SUPPORT, // Support Zone ...
|
||||||
X_POI_RESISTANCE, // Resistance Zone ...
|
X_POI_RESISTANCE, // Resistance Zone ...
|
||||||
|
//
|
||||||
|
// Supply and Demand Zones ...
|
||||||
|
X_POI_SUPPLY_ZONE, // Supply Zone ...
|
||||||
|
X_POI_DEMAND_ZONE, // Demand Zone ...
|
||||||
|
//
|
||||||
|
// Order Blocks ...
|
||||||
|
X_POI_BULLISH_ORDERBLOCK, // Bullish Order Block ...
|
||||||
|
X_POI_BEARISH_ORDERBLOCK, // Bearish Order Block ...
|
||||||
|
//
|
||||||
|
// Fair Value Gaps ...
|
||||||
|
X_POI_BULLISH_FVG, // Bullish Order Block ...
|
||||||
|
X_POI_BEARISH_FVG, // Bearish Order Block ...
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -75,6 +87,18 @@ enum ENUM_XPOI_EVENTS
|
|||||||
// Support nad Resistance ...
|
// Support nad Resistance ...
|
||||||
X_SUPPORT_ZONE_DETECTED, // Support Zone ...
|
X_SUPPORT_ZONE_DETECTED, // Support Zone ...
|
||||||
X_RESISTANCE_ZONE_DETECTED, // Resistance Zone ...
|
X_RESISTANCE_ZONE_DETECTED, // Resistance Zone ...
|
||||||
|
//
|
||||||
|
// Supply nad Demand ...
|
||||||
|
X_SUPPLY_ZONE_DETECTED, // Supply Zone ...
|
||||||
|
X_DEMAND_ZONE_DETECTED, // Demand Zone ...
|
||||||
|
//
|
||||||
|
// Order Blocks ...
|
||||||
|
X_BULLISH_ORDERBLOCK_DETECTED, // Bullish Order Block ...
|
||||||
|
X_BEARISH_ORDERBLOCK_DETECTED, // Bearish Order Block ...
|
||||||
|
//
|
||||||
|
// Fair Value Gaps ...
|
||||||
|
X_BULLISH_FVG_DETECTED, // Bullish Fair Value Gapّ ...
|
||||||
|
X_BEARISH_FVG_DETECTED, // Bearish Fair Value Gapّ ...
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -84,7 +108,8 @@ enum ENUM_XSESSION
|
|||||||
X_TOKYO,
|
X_TOKYO,
|
||||||
X_SYDNEY,
|
X_SYDNEY,
|
||||||
X_LONDON,
|
X_LONDON,
|
||||||
X_NEW_YORK
|
X_NEW_YORK,
|
||||||
|
X_FRANKFORT,
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -303,6 +328,100 @@ struct XMarketSession
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// Zone Struct ...
|
||||||
|
struct XZone
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Props ...
|
||||||
|
double upper;
|
||||||
|
double lower;
|
||||||
|
string prefix;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Constructor ...
|
||||||
|
void XZone()
|
||||||
|
{
|
||||||
|
Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool Init(
|
||||||
|
double _upper,
|
||||||
|
double _lower,
|
||||||
|
string _prefix //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
_upper > 0 &&
|
||||||
|
_lower > 0 &&
|
||||||
|
_upper > _lower &&
|
||||||
|
IsValid(_prefix);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
upper = _upper;
|
||||||
|
lower = _lower;
|
||||||
|
prefix = _prefix;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = IsValid();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
void Clean()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
upper = 0;
|
||||||
|
lower = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
prefix = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool IsValid()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = upper > 0 &&
|
||||||
|
lower > 0 &&
|
||||||
|
upper > lower &&
|
||||||
|
IsValid(prefix);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
string GetTag()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
string result = NULL;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = prefix +
|
||||||
|
"_XZone_" +
|
||||||
|
ToString(upper) + "_" +
|
||||||
|
ToString(lower);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
// XOHCL Event Handler ...
|
// XOHCL Event Handler ...
|
||||||
typedef void (*TXOHCLEventHandler)(
|
typedef void (*TXOHCLEventHandler)(
|
||||||
@@ -322,6 +441,12 @@ typedef void (*TXSessionEventHandler)(
|
|||||||
ENUM_XPOI_EVENTS event //
|
ENUM_XPOI_EVENTS event //
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Zone Handler ...
|
||||||
|
typedef void (*TXZoneEventHandler)(
|
||||||
|
ENUM_XPOI_EVENTS event //
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Extensions ...
|
// Extensions ...
|
||||||
|
|
||||||
@@ -369,6 +494,36 @@ string ToString(ENUM_XPOIS value)
|
|||||||
case X_POI_RESISTANCE:
|
case X_POI_RESISTANCE:
|
||||||
result = "XRES";
|
result = "XRES";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
case X_POI_SUPPLY_ZONE:
|
||||||
|
result = "XSUPPLY";
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
case X_POI_DEMAND_ZONE:
|
||||||
|
result = "XDEMAND";
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
case X_POI_BULLISH_ORDERBLOCK:
|
||||||
|
result = "XBULLOB";
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
case X_POI_BEARISH_ORDERBLOCK:
|
||||||
|
result = "XBEAROB";
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
case X_POI_BULLISH_FVG:
|
||||||
|
result = "XBULLFVG";
|
||||||
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
case X_POI_BEARISH_FVG:
|
||||||
|
result = "XBEARFVG";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user