This commit is contained in:
2024-11-19 22:03:44 +03:30
parent ee9ea11b6a
commit a345aa52c1
7 changed files with 1003 additions and 43 deletions
+245 -2
View File
@@ -1801,6 +1801,168 @@ class XCSignalObject : public XCBaseObject
//
// Zone Ticks ...
//
// Specify How to Draws Specified Levels ...
struct XTickZoneLevelSpecs
{
//
double percent; // Max Allowed Percent of Tick Zone ...
//
// Label Info ...
color labelColor;
string labelFont;
int labelFontSize;
double labelAngel;
//
// Zone Info ...
bool zoneFill;
int zoneWidth;
color zoneColor;
ENUM_LINE_STYLE zoneStyle;
//
// Constructor ...
XTickZoneLevelSpecs()
{
Default();
}
//
// Tools ...
/**
* Initialize Drawing Specs ...
*
* @param _percent: Double, Max Allowed Percent ...
* @param _labelColor: Color, Specified Label Color ...
* @param _zoneColoe: Color, Specified Zone Color ...
* @param _zoneFill: Boolean, Specified Fill Zone or not ...
* @param _zoneStyle: ENUM_LINE_STYLE member, Specified Zone Style ...
* @param _labelFontSize: Integer, Specified Label Font Size ...
* @param _labelFont: String, Specified Label Font Name ...
* @param _labelAngel: Double, Specified Label Angel ...
*
* @return ( bool )
*/
bool Init(
double _percent,
color _labelColor = clrWhite,
color _zoneColor = clrWhite,
bool _zoneFill = false,
ENUM_LINE_STYLE _zoneStyle = STYLE_DOT,
int _zoneWidth = 1,
int _labelFontSize = 12,
string _labelFont = "Arial",
double _labelAngel = 0 //
)
{
//
bool result = false;
//
Default();
//
result = _percent > 0;
if (!result)
{
return result;
}
//
percent = _percent;
labelColor = _labelColor;
zoneColor = _zoneColor;
zoneFill = _zoneFill;
zoneStyle = _zoneStyle;
//
if (_zoneWidth > 0)
{
zoneWidth = _zoneWidth;
}
//
if (_labelFontSize > 0)
{
labelFontSize = _labelFontSize;
}
//
if (IsSpecifiedValid(_labelFont))
{
labelFont = _labelFont;
}
//
if (_labelAngel >= 0)
{
labelAngel = _labelAngel;
}
//
result = IsValid();
//
return result;
}
/**
* Set Default Properties ...
*/
void Default()
{
//
percent = 0;
//
// Label ...
labelAngel = 0;
labelFontSize = 13;
labelFont = "Arial";
labelColor = clrWhite;
//
// Zone ...
zoneWidth = 1;
zoneFill = false;
zoneColor = clrWhite;
zoneStyle = STYLE_DOT;
}
/**
* Validate ...
*
* @return ( bool )
*/
bool IsValid()
{
//
bool result = false;
//
result =
//
percent > 0 &&
//
// Zone ...
zoneWidth > 0 &&
//
// Label ...
labelFontSize > 0 &&
IsSpecifiedValid(labelFont)
//
;
//
return result;
}
//
};
class XCTickZoneObject : public XCBaseObject
{
//
@@ -2028,6 +2190,7 @@ class XCTicksZoneObject : public XCBaseObject
long chart_id,
int window,
XCTicksZone &zone,
XTickZoneLevelSpecs &specs[],
string prefix = NULL //
)
{
@@ -2057,7 +2220,7 @@ class XCTicksZoneObject : public XCBaseObject
XCTickZone *iZone = zone.GetZone(i);
XCTickZoneObject *iObj;
iObj = new XCTickZoneObject();
result = iObj.Create(
bool isCreated = iObj.Create(
chart_id,
window,
ToString(i) + "_" + name,
@@ -2066,11 +2229,35 @@ class XCTicksZoneObject : public XCBaseObject
iZone,
prefix //
);
if (!result)
if (!isCreated)
{
break;
}
//
XTickZoneLevelSpecs iSpec;
bool hasSpecs = FindSpecs(
iZone,
iSpec,
specs //
);
if (hasSpecs)
{
//
// Label ...
iObj.LabelFont(iSpec.labelFont);
iObj.LabelAngle(iSpec.labelAngel);
iObj.LabelColor(iSpec.labelColor);
iObj.LabelSize(iSpec.labelFontSize);
//
// Zone ...
iObj.ZoneFill(iSpec.zoneFill);
iObj.ZoneColor(iSpec.zoneColor);
iObj.ZoneWidth(iSpec.zoneWidth);
iObj.ZoneStyle(iSpec.zoneStyle);
}
//
mZones.Add(iObj);
}
@@ -2108,11 +2295,67 @@ class XCTicksZoneObject : public XCBaseObject
//
// Actions ...
/**
* Destroy Object ...
*/
void Destroy()
{
mZones.Clear();
}
/**
* Find Specified TickZone Drawing Specs ...
*
* @param zone: XCTickZone instance, reference to Search For it ...
* @param spec: XTickZoneLevelSpecs instance, reference to Result ...
* @param specs: XTickZoneLevelSpecs instance Collection for Search ...
*
* @return ( bool )
*/
bool FindSpecs(
XCTickZone *zone,
XTickZoneLevelSpecs &spec,
XTickZoneLevelSpecs &specs[] //
)
{
//
bool result = false;
//
int count = ArraySize(specs);
result =
zone.IsValid() &&
IsValidSize(count);
if (!result)
{
return result;
}
//
for (int i = 0; i < count; i++)
{
//
XTickZoneLevelSpecs iSpecs = specs[i];
//
bool isSpecValidForZone =
!spec.IsValid()
? zone.percent <= iSpecs.percent
: zone.percent <= iSpecs.percent &&
spec.percent > iSpecs.percent;
if (isSpecValidForZone)
{
spec = iSpecs;
}
}
//
result = spec.IsValid();
//
return result;
}
//
private:
//
+1
View File
@@ -1156,6 +1156,7 @@ class XCPOIDetector : public XCBaseAlert
//
state.ticksZone = mTicksZone;
//
}
+194 -7
View File
@@ -1372,6 +1372,139 @@ class XCPOIDrawer : public XCBase
BearishFVGStyle(STYLE_DOT);
BearishFVGColor(clrRed);
//
// Add Default TickZone Specs ...
bool isSpecsInited = false;
bool fillTickZone = false;
XTickZoneLevelSpecs specs10;
isSpecsInited = specs10.Init(
10,
clrWhite,
clrWhite,
fillTickZone //
);
if (isSpecsInited)
{
AddTickZoneLevelSpecs(specs10);
}
//
XTickZoneLevelSpecs specs20;
isSpecsInited = specs20.Init(
20,
clrOrange,
clrOrange,
fillTickZone //
);
if (isSpecsInited)
{
AddTickZoneLevelSpecs(specs20);
}
//
XTickZoneLevelSpecs specs30;
isSpecsInited = specs30.Init(
30,
clrOrange,
clrOrange,
fillTickZone //
);
if (isSpecsInited)
{
AddTickZoneLevelSpecs(specs30);
}
//
XTickZoneLevelSpecs specs40;
isSpecsInited = specs40.Init(
40,
clrOrange,
clrOrange,
fillTickZone //
);
if (isSpecsInited)
{
AddTickZoneLevelSpecs(specs40);
}
//
XTickZoneLevelSpecs specs50;
isSpecsInited = specs50.Init(
50,
clrYellow,
clrYellow,
fillTickZone //
);
if (isSpecsInited)
{
AddTickZoneLevelSpecs(specs50);
}
//
XTickZoneLevelSpecs specs60;
isSpecsInited = specs60.Init(
60,
clrYellow,
clrYellow,
fillTickZone //
);
if (isSpecsInited)
{
AddTickZoneLevelSpecs(specs60);
}
//
XTickZoneLevelSpecs specs70;
isSpecsInited = specs70.Init(
70,
clrYellow,
clrYellow,
fillTickZone //
);
if (isSpecsInited)
{
AddTickZoneLevelSpecs(specs70);
}
//
XTickZoneLevelSpecs specs80;
isSpecsInited = specs80.Init(
80,
clrRed,
clrRed,
fillTickZone //
);
if (isSpecsInited)
{
AddTickZoneLevelSpecs(specs80);
}
//
XTickZoneLevelSpecs specs90;
isSpecsInited = specs90.Init(
90,
clrRed,
clrRed,
fillTickZone //
);
if (isSpecsInited)
{
AddTickZoneLevelSpecs(specs90);
}
//
XTickZoneLevelSpecs specs100;
isSpecsInited = specs100.Init(
100,
clrRed,
clrRed,
fillTickZone //
);
if (isSpecsInited)
{
AddTickZoneLevelSpecs(specs100);
}
//
}
@@ -2280,9 +2413,64 @@ class XCPOIDrawer : public XCBase
//
// Ticks Zone ...
/**
* Add Tick Zone Draw Specifications ...
*
* @param specs: XTickZoneLevelSpecs instance ...
*/
void AddTickZoneLevelSpecs(
XTickZoneLevelSpecs &specs //
)
{
//
if (!specs.IsValid())
{
return;
}
//
bool isExists = false;
int count = ArraySize(mTicksZoneSpecs);
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XTickZoneLevelSpecs iSpec = mTicksZoneSpecs[i];
//
isExists = specs.percent == iSpec.percent;
if (isExists)
{
break;
}
}
}
if (isExists)
{
return;
}
//
AddRef(
specs,
mTicksZoneSpecs //
);
}
/**
* Draw Specified Ticker Zone ...
*
* @param zone: XCTicksZone instance Specified Ticker Zone ...
* @param object: XCTicksZoneObject pointer ...
*
* @return ( bool )
*/
bool CreateTicksZone(
XCTicksZone &zone,
XCTicksZoneObject *&object)
XCTicksZoneObject *&object //
)
{
//
bool result = false;
@@ -2311,6 +2499,7 @@ class XCPOIDrawer : public XCBase
chartID,
window,
zone,
mTicksZoneSpecs,
prefix //
);
@@ -2320,12 +2509,6 @@ class XCPOIDrawer : public XCBase
return result;
}
//
// object.ZoneFill(fill);
// object.ZoneColor(crl);
// object.ZoneWidth(width);
// object.ZoneStyle(style);
//
return result;
}
@@ -2438,5 +2621,9 @@ class XCPOIDrawer : public XCBase
color mBearishFVGColor; // Bearish FVG Color ...
ENUM_LINE_STYLE mBearishFVGStyle; // Bearish FVG Style ...
//
// Ticks Zone ...
XTickZoneLevelSpecs mTicksZoneSpecs[]; // Zone Draw Specifications ...
//
};