last works on XOBS ...

This commit is contained in:
2025-02-07 02:22:19 +03:30
parent 114f327efe
commit 58c59f5514
11 changed files with 6802 additions and 1396 deletions
+546
View File
@@ -28,6 +28,7 @@
#include <ChartObjects/ChartObjectsArrows.mqh>
#include <ChartObjects/ChartObjectsLines.mqh>
#include <ChartObjects/ChartObjectsShapes.mqh>
#include <ChartObjects\ChartObjectsFibo.mqh>
#include <ChartObjects\ChartObjectsTxtControls.mqh>
//
@@ -45,6 +46,7 @@ enum ENUM_XCHARTOBJECTS
X_TREND_OBJ = 8861,
X_XPVPIVOT_OBJ = 8862,
X_OHCL_OBJ = 8863,
X_RR_OBJ = 8864,
//
// Structured ...
X_TRADE_DAY_OBJ = 9860,
@@ -2511,6 +2513,550 @@ class XCBoxObject : public XCBaseObject
CChartObjectRectangle mRect;
};
class XCRRObject : public XCBaseObject
{
//
public:
//
/**
* Creator ...
*
* @param chart_id: Long, Specified Chart ID ...
* @param window: Integer, Specified Chart Window ID ...
* @param rr: XRR instance Reference ...
* @param prefix: String ...
*
* @return ( bool )
*/
bool Create(
long chart_id,
int window,
XRR &rr,
string prefix = NULL //
)
{
//
bool result = false;
//
result = rr.IsValid();
if (!result)
{
return result;
}
//
string name = rr.GetTag();
if (IsValid(prefix))
{
name = prefix + "_" + name;
}
string nameMD5 = ToMD5(name);
//
bool isLong = IsLong(rr.type);
//
double price1 = rr.entry;
double price2 = rr.sl;
//
datetime time1 = rr.time;
datetime time2 = (datetime)((int)rr.time + 2 * PeriodSeconds(rr.period));
//
result = mFibo.Create(
chart_id,
name,
window,
time1,
price1,
time2,
price2 //
);
if (!result)
{
return result;
}
//
mRR = rr;
ObjName(name);
//
int tpsCount = ArraySize(rr.tps);
int levels = tpsCount + 2;
result = mFibo.LevelsCount(levels);
if (!result)
{
return result;
}
//
// Set Fibo Levels ...
//
result = mFibo.LevelValue(0, 0);
if (!result)
{
return result;
}
result = mFibo.LevelDescription(0, "SL");
if (!result)
{
return result;
}
//
result = mFibo.LevelValue(1, 1.0);
if (!result)
{
return result;
}
result = mFibo.LevelDescription(1, "Entry");
if (!result)
{
return result;
}
//
for (int i = 0; i < tpsCount; i++)
{
//
int idx = i + 2;
double level = 1.0 + rr.tps[i];
string description = "TP " + ToString(rr.tps[i]);
//
result = mFibo.LevelValue(
idx,
level //
);
if (!result)
{
break;
}
//
result = mFibo.LevelDescription(
idx,
description //
);
if (!result)
{
break;
}
}
if (!result)
{
return result;
}
//
return result;
}
//
// Getter(s) / Setter(s) ...
//
// Virtual ...
/**
* Retrieve Object Type ...
*
* @return ( ENUM_XCHARTOBJECTS )
*/
virtual ENUM_XCHARTOBJECTS Type()
{
return X_RR_OBJ;
}
//
private:
//
//
// Props ...
XRR mRR;
CChartObjectFibo mFibo;
//
bool SetSLProps(
int width = 1,
color clr = clrRed,
ENUM_LINE_STYLE style = STYLE_SOLID,
string description = "" //
)
{
//
bool result = false;
//
result = SetLevelProps(
0,
width,
clr,
style,
description //
);
//
return result;
}
//
bool SetEntryProps(
int width = 1,
color clr = clrOrange,
ENUM_LINE_STYLE style = STYLE_SOLID,
string description = "" //
)
{
//
bool result = false;
//
result = SetLevelProps(
0,
width,
clr,
style,
description //
);
//
return result;
}
//
bool SetTPProps(
double tpValue,
int width = 1,
color clr = clrLime,
ENUM_LINE_STYLE style = STYLE_SOLID,
string description = "" //
)
{
//
bool result = false;
//
int tpIDX = FindIndex(
tpValue,
mRR.tps //
);
result = IsValidIndex(tpIDX);
if (!result)
{
return result;
}
//
tpIDX += 2;
//
result = SetLevelProps(
tpIDX,
width,
clr,
style,
description //
);
//
return result;
}
//
bool SetLevelProps(
int id,
int width = 1,
color clr = clrYellow,
ENUM_LINE_STYLE style = STYLE_SOLID,
string description = "" //
)
{
//
bool result = false;
//
// Color ...
result = mFibo.LevelColor(
id,
clr //
);
if (!result)
{
return result;
}
//
// Style ...
result = mFibo.LevelStyle(
id,
style //
);
if (!result)
{
return result;
}
//
// Width ...
if (width > 0)
{
//
result = mFibo.LevelWidth(
id,
width //
);
if (!result)
{
return result;
}
}
//
// Description ...
if (IsValid(description))
{
//
result = mFibo.LevelDescription(
id,
description //
);
if (!result)
{
return result;
}
}
//
return result;
}
};
class XCTrendObject : public XCBaseObject
{
//
public:
//
/**
* Creator ...
*
* @param chart_id: Long, Specified Chart ID ...
* @param window: Integer, Specified Chart Window ID ...
* @param rr: XRR instance Reference ...
* @param prefix: String ...
*
* @return ( bool )
*/
bool Create(
long chart_id,
int window,
XSwingPoint &swings[],
string prefix = NULL //
)
{
//
bool result = false;
//
int count = ArraySize(swings);
result =
count >= 2 &&
IsValidSize(count);
if (!result)
{
return result;
}
//
ENUM_X_SWING_TYPE type = swings[0].type;
bool isSwingLows = type == X_SWING_LOW;
//
double values[];
int valuesCount = ExtractSwings(
swings,
values //
);
result = valuesCount == count;
if (!result)
{
return result;
}
//
int firstIDX = -1;
double first = 0;
datetime firstTime = NULL;
//
int secondIDX = -1;
double second = 0;
datetime secondTime = NULL;
//
if (isSwingLows)
{
//
first = GetMin(
values,
firstIDX,
0,
0 //
);
if (IsValidIndex(firstIDX))
{
//
firstTime = swings[firstIDX].time;
//
second = FindBiggerThan(
first,
values,
true //
);
secondIDX = FindIndex(
second,
values //
);
if (IsValidIndex(secondIDX))
{
secondTime = swings[secondIDX].time;
}
}
}
else
{
//
first = GetMax(
values,
firstIDX,
0,
0 //
);
if (IsValidIndex(firstIDX))
{
//
firstTime = swings[firstIDX].time;
//
second = FindLesserThan(
first,
values,
true //
);
secondIDX = FindIndex(
second,
values //
);
if (IsValidIndex(secondIDX))
{
secondTime = swings[secondIDX].time;
}
}
}
//
// Validate Points ...
result =
//
IsValidIndex(firstIDX) &&
IsValidIndex(secondIDX) &&
//
IsSpecifiedValid(firstTime) &&
IsSpecifiedValid(secondTime) &&
//
(isSwingLows
? first < second
: first > second)
//
;
if (!result)
{
return result;
}
//
string name = ToString(type) + "_" + ToString(first) + "_" + ToString(second);
if (IsValid(prefix))
{
name = prefix + "_" + name;
}
string nameMD5 = ToMD5(name);
//
result = mTrend.Create(
chart_id,
name,
window,
firstTime,
first,
secondTime,
second //
);
if (!result)
{
return result;
}
//
ObjName(name);
//
return result;
}
//
// Getter(s) / Setter(s) ...
/**
* Set Trend Color ...
*
* @param value: Color ...
*/
void TrendColor(color value)
{
mTrend.Color(value);
}
void TrendRayLeft(bool value)
{
mTrend.RayLeft(value);
}
void TrendRayRight(bool value)
{
mTrend.RayRight(value);
}
//
// Virtual ...
/**
* Retrieve Object Type ...
*
* @return ( ENUM_XCHARTOBJECTS )
*/
virtual ENUM_XCHARTOBJECTS Type()
{
return X_TREND_OBJ;
}
//
private:
//
//
// Props ...
CChartObjectTrend mTrend;
};
//
// Zone Ticks ...
+107
View File
@@ -2780,6 +2780,9 @@ class XCPOIDrawer : public XCBase
//
bool result = false;
//
object = NULL;
//
result = zone.IsValid();
if (!result)
@@ -2812,6 +2815,63 @@ class XCPOIDrawer : public XCBase
return result;
}
/**
* Create Trend Line Object ...
*
* @param swings: XSwingPoint instance Collection ...
*
* @return ( bool )
*/
bool CreateTrend(
XSwingPoint &swings[],
XCTrendObject *&object //
)
{
//
bool result = false;
//
object = NULL;
//
result = ArraySize(swings) >= 2 &&
IsValidSize(ArraySize(swings));
if (!result)
{
return result;
}
//
string prefix = Prefix();
long chartID = ChartIdentification();
int window = SubWindowIdentification();
//
object = new XCTrendObject();
result = object.Create(
chartID,
window,
swings,
prefix //
);
//
if (!result)
{
return result;
}
//
color clrTrend = swings[0].type == X_SWING_LOW
? SwingLowColor()
: SwingHighColor();
object.TrendColor(clrTrend);
object.TrendRayRight(true);
//
return result;
}
/**
* Create Consolidation Zone Object ...
*
@@ -3100,6 +3160,53 @@ class XCPOIDrawer : public XCBase
return result;
}
/**
* Create Specific Risk Reward (RR) on Chart ...
*
* @param rr: XRR instance Reference ...
*
* @return ( bool )
*/
bool CreateRR(
XRR &rr,
XCRRObject *&object //
)
{
//
bool result = false;
//
object = NULL;
//
result = rr.IsValid();
if (!result)
{
return result;
}
//
string prefix = Prefix();
long chartID = ChartIdentification();
int window = SubWindowIdentification();
//
object = new XCRRObject();
result = object.Create(
chartID,
window,
rr,
prefix //
);
if (!result)
{
return result;
}
//
return result;
}
/**
* Draw Specified Signal ...
*