last ...
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -2570,706 +2570,6 @@ 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 + 5 * 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,
|
||||
XPoint &swings[],
|
||||
bool useMinAsStart = true,
|
||||
string prefix = NULL //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
int count = ArraySize(swings);
|
||||
result =
|
||||
count >= 2 &&
|
||||
IsValidSize(count);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
double min = 0;
|
||||
datetime minAt = NULL;
|
||||
|
||||
//
|
||||
double max = 0;
|
||||
datetime maxAt = NULL;
|
||||
|
||||
//
|
||||
// Etract Min/Max ...
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XPoint iPoint = swings[i];
|
||||
|
||||
//
|
||||
if (!iPoint.IsValid())
|
||||
{
|
||||
//
|
||||
iPoint.Clean();
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
bool canSetMin =
|
||||
min == 0
|
||||
? true
|
||||
: min > iPoint.value;
|
||||
if (canSetMin)
|
||||
{
|
||||
//
|
||||
minAt = iPoint.at;
|
||||
min = iPoint.value;
|
||||
}
|
||||
|
||||
//
|
||||
bool canSetMax =
|
||||
max == 0
|
||||
? true
|
||||
: max < iPoint.value;
|
||||
if (canSetMax)
|
||||
{
|
||||
//
|
||||
maxAt = iPoint.at;
|
||||
max = iPoint.value;
|
||||
}
|
||||
|
||||
//
|
||||
iPoint.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
double first =
|
||||
useMinAsStart
|
||||
? min
|
||||
: max;
|
||||
datetime firstTime =
|
||||
useMinAsStart
|
||||
? minAt
|
||||
: maxAt;
|
||||
|
||||
//
|
||||
double second =
|
||||
useMinAsStart
|
||||
? max
|
||||
: min;
|
||||
datetime secondTime =
|
||||
useMinAsStart
|
||||
? maxAt
|
||||
: minAt;
|
||||
|
||||
//
|
||||
// Validate Points ...
|
||||
result =
|
||||
//
|
||||
first > 0 &&
|
||||
second > 0 &&
|
||||
(useMinAsStart
|
||||
? first <= second
|
||||
: first >= second) &&
|
||||
IsSpecifiedValid(firstTime) &&
|
||||
IsSpecifiedValid(secondTime)
|
||||
//
|
||||
;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
ENUM_X_DIRECTION dir =
|
||||
useMinAsStart
|
||||
? X_DIRECTION_BULLISH
|
||||
: X_DIRECTION_BEARISH;
|
||||
|
||||
//
|
||||
string name = "XTRND" + ToString(dir) + "_" + 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 ...
|
||||
|
||||
|
||||
@@ -2816,123 +2816,6 @@ 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 Trend Line Object ...
|
||||
*
|
||||
* @param swings: XSwingPoint instance Collection ...
|
||||
* @param useMinAsStart: Specified Min Value as Start ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool CreateTrend(
|
||||
XPoint &swings[],
|
||||
XCTrendObject *&object,
|
||||
bool useMinAsStart = true //
|
||||
)
|
||||
{
|
||||
//
|
||||
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,
|
||||
useMinAsStart,
|
||||
prefix //
|
||||
);
|
||||
|
||||
//
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
color clrTrend = useMinAsStart
|
||||
? SwingLowColor()
|
||||
: SwingHighColor();
|
||||
object.TrendColor(clrTrend);
|
||||
object.TrendRayRight(true);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Consolidation Zone Object ...
|
||||
*
|
||||
@@ -3376,53 +3259,6 @@ 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 ...
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user