add Resistance POI Mechanism ...

This commit is contained in:
2024-10-22 14:19:36 +03:30
parent ec87a19198
commit 64cfece3eb
3 changed files with 1335 additions and 10 deletions
+380 -3
View File
@@ -31,15 +31,24 @@
enum ENUM_XCHARTOBJECTS
{
//
// Global ...
X_ZONE,
X_FROM_TO,
//
// Structured ...
X_TRADE_DAY,
X_MARKET_SESSION,
X_SUPPORT_ZONE,
X_RESISTANCE_ZONE,
};
enum ENUM_X_CHART_IDS
{
X_TO,
X_FROM,
X_TO
X_UPPER,
X_LOWER,
};
//
@@ -60,14 +69,24 @@ string ToString(ENUM_X_CHART_IDS value)
//
switch (value)
{
//
case X_TO:
result = "XTO";
break;
//
case X_FROM:
result = "XFROM";
break;
//
case X_TO:
result = "XTO";
case X_UPPER:
result = "XUPPER";
break;
//
case X_LOWER:
result = "XLOWER";
break;
}
@@ -78,6 +97,9 @@ string ToString(ENUM_X_CHART_IDS value)
//
// Implementation ...
//
// Global Chart Objects ...
//
// From To Chart Object ...
class XCFromToObject : public CChartObject
@@ -217,6 +239,197 @@ class XCFromToObject : public CChartObject
//
};
//
// Zone Chart Object ...
class XCZoneObject : public CChartObject
{
//
public:
//
//
// Constructors ...
void XCZoneObject()
{
}
//
// Deconstructors ...
void ~XCZoneObject()
{
}
/**
* Create XCZoneObject ...
*
* @param chart_id: Long ...
* @param name: String ...
* @param window: Integer ...
* @param time1: DateTime ...
* @param time2: DateTime ...
* @param upperPrice1: Double ...
* @param upperPrice2: Double ...
* @param lowerPrice1: Double ...
* @param lowerPrice2: Double ...
* @param objprefix: String ...
* @return ( bool )
*/
bool Create(
long chart_id,
const string name,
const int window,
const datetime time1,
const datetime time2,
const double upperPrice1,
const double upperPrice2,
const double lowerPrice1,
const double lowerPrice2,
const string objprefix = NULL //
)
{
//
bool result = false;
//
// Validate Args ...
result = IsValid(name) && IsValid(time1);
if (!result)
{
return result;
}
//
NormalizeTime(time2);
//
result = time1 < time2;
if (!result)
{
return result;
}
//
string prefix =
!IsValid(objprefix)
? ""
: objprefix + "_";
//
// 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;
}
/**
* Retrieve Object Type ...
*
* @return ( ENUM_XCHARTOBJECTS )
*/
virtual ENUM_XCHARTOBJECTS Type()
{
return X_ZONE;
}
/**
* Set Zone Line Width ...
*
* @param value: Integer ...
*/
void ZoneWidth(int value)
{
//
if (value < 1)
{
value = 1;
}
//
mUpperTrend.Width(value);
mLowerTrend.Width(value);
}
/**
* Set Zone Color ...
*
* @param value: Color ...
*/
void ZoneColor(color value)
{
//
mUpperTrend.Color(value);
mLowerTrend.Color(value);
}
/**
* Set Zone Line Style ...
*
* @param value: ENUM_LINE_STYLE member ...
*/
void ZoneStyle(ENUM_LINE_STYLE value)
{
//
mUpperTrend.Style(value);
mLowerTrend.Style(value);
}
//
protected:
//
//
private:
//
CChartObjectTrend mUpperTrend;
CChartObjectTrend mLowerTrend;
//
};
//
// Structured Chart Object ...
//
// XTradeDay Object ...
class XCTardeDayObject : public XCFromToObject
@@ -367,3 +580,167 @@ class XCMarketSessionObject : public XCFromToObject
};
//
// Support Zone ...
class XCSupportZoneObject : public XCZoneObject
{
//
public:
//
//
// Constructors ...
void XCSupportZoneObject()
{
}
//
// Deconstructors ...
void ~XCSupportZoneObject()
{
}
/**
* Draw Support Zone Object by Providing Support Zone ...
*
* @param chart_id: Long ...
* @param name: String ...
* @param window: Integer ...
* @param support: XOHCL instance ...
* @param time2: DateTime ...
*
* @return ( bool )
*/
bool CreateBySupport(
long chart_id,
const string name,
const int window,
XOHCL &support,
datetime time2 //
)
{
//
bool result = false;
//
result = support.IsValid();
if (!result)
{
return result;
}
//
double bottom = support.GetDown();
//
result = Create(
chart_id,
name,
window,
support.time,
time2,
bottom,
bottom,
support.low,
support.low //
);
//
return result;
}
/**
* Retrieve Object Type ...
*
* @return ( ENUM_XCHARTOBJECTS )
*/
virtual ENUM_XCHARTOBJECTS Type()
{
return X_SUPPORT_ZONE;
}
//
};
//
// Resistance Zone ...
class XCResistanceZoneObject : public XCZoneObject
{
//
public:
//
//
// Constructors ...
void XCResistanceZoneObject()
{
}
//
// Deconstructors ...
void ~XCResistanceZoneObject()
{
}
/**
* Draw Resistance Zone Object by Providing Resistance Zone ...
*
* @param chart_id: Long ...
* @param name: String ...
* @param window: Integer ...
* @param resistance: XOHCL instance ...
* @param time2: DateTime ...
*
* @return ( bool )
*/
bool CreateByResistance(
long chart_id,
const string name,
const int window,
XOHCL &resistance,
datetime time2 //
)
{
//
bool result = false;
//
result = resistance.IsValid();
if (!result)
{
return result;
}
//
double up = resistance.GetUp();
//
result = Create(
chart_id,
name,
window,
resistance.time,
time2,
resistance.high,
resistance.high,
up,
up //
);
//
return result;
}
/**
* Retrieve Object Type ...
*
* @return ( ENUM_XCHARTOBJECTS )
*/
virtual ENUM_XCHARTOBJECTS Type()
{
return X_RESISTANCE_ZONE;
}
//
};
//