Last Works ...
This commit is contained in:
@@ -41,6 +41,7 @@ enum ENUM_XCHARTOBJECTS
|
||||
X_BAR_ARROW_OBJ = 7862,
|
||||
//
|
||||
X_SIGNAL_OBJ = 8860,
|
||||
X_TREND_OBJ = 8861,
|
||||
//
|
||||
// Structured ...
|
||||
X_TRADE_DAY_OBJ = 9860,
|
||||
@@ -1941,3 +1942,214 @@ class XCBearishFVGObject : public XCZoneObject
|
||||
};
|
||||
|
||||
//
|
||||
|
||||
//
|
||||
// XTrend ...
|
||||
class XCTrendObject : public XCBaseObject
|
||||
{
|
||||
//
|
||||
public:
|
||||
//
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
void XCTrendObject()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
void ~XCTrendObject()
|
||||
{
|
||||
//
|
||||
Clean(mSwingLows);
|
||||
Clean(mSwingHighs);
|
||||
|
||||
//
|
||||
mTrend.Delete();
|
||||
}
|
||||
|
||||
bool CreateByTrend(
|
||||
long chart_id,
|
||||
const int window,
|
||||
XTrend &trend //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = trend.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
string name = trend.GetTag();
|
||||
string nameHash = ToMD5(name);
|
||||
|
||||
//
|
||||
int swingLowsCount = ArraySize(trend.swingLows);
|
||||
int swingHighsCount = ArraySize(trend.swingHighs);
|
||||
|
||||
//
|
||||
double price1 = 0;
|
||||
double price2 = 0;
|
||||
datetime from = NULL;
|
||||
if (trend.isBullish)
|
||||
{
|
||||
//
|
||||
from = trend.swingLows[0].time;
|
||||
price1 = trend.swingLows[0].GetDown();
|
||||
price2 = trend.swingLows[swingLowsCount - 1].GetDown();
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
from = trend.swingHighs[0].time;
|
||||
price1 = trend.swingHighs[0].GetUp();
|
||||
price2 = trend.swingHighs[swingHighsCount - 1].GetUp();
|
||||
}
|
||||
|
||||
//
|
||||
string trendName = name;
|
||||
result = mTrend.Create(
|
||||
chart_id,
|
||||
trendName,
|
||||
window,
|
||||
from,
|
||||
price1,
|
||||
trend.at,
|
||||
price2 //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
mTrend.Width(1);
|
||||
color clrTrend = trend.isBullish
|
||||
? clrAqua
|
||||
: trend.isBearish
|
||||
? clrMagenta
|
||||
: clrGray;
|
||||
mTrend.Color(clrTrend);
|
||||
mTrend.Style(STYLE_SOLID);
|
||||
|
||||
//
|
||||
int arrowCode = 108;
|
||||
if (trend.isBullish)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < swingLowsCount; i++)
|
||||
{
|
||||
//
|
||||
XOHCL iBar = trend.swingLows[i];
|
||||
|
||||
//
|
||||
string iName = "XSPL_" + nameHash;
|
||||
|
||||
//
|
||||
XCSwingLowObject iObj;
|
||||
result = iObj.CreateBySwing(
|
||||
chart_id,
|
||||
iName,
|
||||
window,
|
||||
iBar,
|
||||
arrowCode //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
iObj.ArrowWidth(5);
|
||||
iObj.ArrowColor(clrAqua);
|
||||
iObj.ArrowAnchor(ANCHOR_TOP);
|
||||
|
||||
//
|
||||
AddRef(
|
||||
iObj,
|
||||
mSwingLows //
|
||||
);
|
||||
}
|
||||
}
|
||||
else if (trend.isBearish)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < swingHighsCount; i++)
|
||||
{
|
||||
//
|
||||
XOHCL iBar = trend.swingHighs[i];
|
||||
|
||||
//
|
||||
string iName = "XSPH_" + nameHash;
|
||||
|
||||
//
|
||||
XCSwingHighObject iObj;
|
||||
result = iObj.CreateBySwing(
|
||||
chart_id,
|
||||
iName,
|
||||
window,
|
||||
iBar,
|
||||
arrowCode //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
iObj.ArrowWidth(5);
|
||||
iObj.ArrowColor(clrMagenta);
|
||||
iObj.ArrowAnchor(ANCHOR_BOTTOM);
|
||||
|
||||
//
|
||||
AddRef(
|
||||
iObj,
|
||||
mSwingHighs //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
if (result)
|
||||
{
|
||||
ObjName(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
mTrend.Delete();
|
||||
Clean(mSwingLows);
|
||||
Clean(mSwingHighs);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve Object Type ...
|
||||
*
|
||||
* @return ( ENUM_XCHARTOBJECTS )
|
||||
*/
|
||||
virtual ENUM_XCHARTOBJECTS Type()
|
||||
{
|
||||
return X_TREND_OBJ;
|
||||
}
|
||||
|
||||
//
|
||||
private:
|
||||
//
|
||||
CChartObjectTrend mTrend;
|
||||
XCSwingLowObject mSwingLows[];
|
||||
XCSwingHighObject mSwingHighs[];
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
//
|
||||
|
||||
@@ -731,6 +731,25 @@ class XCBaseExpert : public XSCBaseAlert
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Time Handlers ...
|
||||
|
||||
virtual void HandleOnNewMonth()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void HandleOnNewWeek()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void HandleOnNewDay()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void HandleOnNewHour()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate Identifier Tag ...
|
||||
*
|
||||
@@ -798,50 +817,74 @@ class XCBaseExpert : public XSCBaseAlert
|
||||
{
|
||||
//
|
||||
// Monthly Report ....
|
||||
if (mReportNewMonths &&
|
||||
mTimeTracker.IsNewMonth())
|
||||
if (mTimeTracker.IsNewMonth())
|
||||
{
|
||||
//
|
||||
string msg = "New Month ...";
|
||||
HandleOnNewMonth();
|
||||
|
||||
//
|
||||
Alert(msg);
|
||||
if (mReportNewMonths)
|
||||
{
|
||||
//
|
||||
string msg = "New Month ...";
|
||||
|
||||
//
|
||||
Alert(msg);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Weekly Report ....
|
||||
if (mReportNewWeeks &&
|
||||
mTimeTracker.IsNewWeek())
|
||||
if (mTimeTracker.IsNewWeek())
|
||||
{
|
||||
//
|
||||
string msg = "New Week ...";
|
||||
HandleOnNewWeek();
|
||||
|
||||
//
|
||||
Alert(msg);
|
||||
if (mReportNewWeeks)
|
||||
{
|
||||
//
|
||||
string msg = "New Week ...";
|
||||
|
||||
//
|
||||
Alert(msg);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Daily Report ....
|
||||
if (mReportNewDays &&
|
||||
mTimeTracker.IsNewDay())
|
||||
if (mTimeTracker.IsNewDay())
|
||||
{
|
||||
//
|
||||
string msg = "New Day ...";
|
||||
HandleOnNewDay();
|
||||
|
||||
//
|
||||
Alert(msg);
|
||||
if (mReportNewDays)
|
||||
{
|
||||
//
|
||||
string msg = "New Day ...";
|
||||
|
||||
//
|
||||
Alert(msg);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Hourly Report ....
|
||||
if (mReportNewHours &&
|
||||
mTimeTracker.IsNewHour())
|
||||
if (mTimeTracker.IsNewHour())
|
||||
{
|
||||
//
|
||||
string msg = "New Hour ...";
|
||||
HandleOnNewHour();
|
||||
|
||||
//
|
||||
Alert(msg);
|
||||
if (mReportNewHours)
|
||||
{
|
||||
//
|
||||
string msg = "New Hour ...";
|
||||
|
||||
//
|
||||
Alert(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user