Try this:
fxnew5: "function must have a body" appears
bool ObjectCreate( long chart_id, string name, ENUM_OBJECT type, int sub_window, datetime time1 ); |
|

- docs.mql4.com
Try this:
thanks Janusz & WH, but this looks like the MT4 code?
in MT4 I just tried it, works fine and pratical (nothing to declare first) to use as usual.... but in my MT5 code this command doesn't work.
"Time[0] undeclared identifier"
the MT5 description in the manual looks similar to MT4, but it seems that one has to declare such a function("ObjectCreate") first or not?
but what's the final step to get a vertical line placed (MT5) on Bar 0 ??
test code is empty apart from
int OnCalculate(const int rates_total,
const int prev_calculated,
const int begin,
const double &price[])
{ObjectCreate(ChartID(), "N", OBJ_VLINE, 0, Time[0],0); return(0);}
Yes, you are right. In MQL5 Time[0] doesn't exist, so you must obtain last candle time by CopyRates function:
CopyRates(_Symbol, _Period, 0, 1, rates);
ObjectCreate(ChartID(), "N", OBJ_VLINE, 0, rates[0].time,0);

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
hello,
https://www.mql5.com/en/docs/objects/objectcreate
a vertical line doesn't appear in my chart window (Bar 0 is needed) of a custom indicator
when this function is defined (definition part)
bool ObjectCreate(
long chart_id,
string name,
ENUM_OBJECT type,
int sub_window,
datetime time1
);
and in the OnCalculate part ObjectCreate(0,"N",OBJ_VLINE,0,0,0) is used ?
----
when trying ObjectCreate(0,"N",OBJ_VLINE,0,0); (subwindow and time) > the message "function must have a body" appears
For helpful hints thanks in advance