ObjectCreate not drawing
That's because you didn't give it a name
const string h4ShortE = ?
SDC:
That's because you didn't give it a name
Wow, thanks! I wouldn't have guessed that one.
alyehoud:
Wow, thanks! I wouldn't have guessed that one.
Wow, thanks! I wouldn't have guessed that one.
why not ?
if (!ObjectCreate(ChartID(),h4ShortE,OBJ_HLINE,0,0, h4Short)) Alert(GetLastError());
the last error is 4204 =
| 4204 |
ERR_NO_OBJECT_NAME |
No object name |
Also be aware, if you create more than one object each one requires a unique name.
alyehoud: Wow, thanks! I wouldn't have guessed that one.
| You would have, had you bothered to check. What are Function return values ? How do I use them ? - MQL4 forum |
Learning MQL4 and trying to make a simple EMA calculator that will place a line on the chart (using OBJ_HLINE since I don't know how to do a continuous line like in the default indicator). Everything seems fine, but I can't get the line to draw. I've been through so many sets of code, trying to see what I'm doing wrong, and know it's something small, but I'm at a loss. Here's what I have:
[code]
void movingAvg()
{
const string h4ShortE;
//H4 EMAS CALCULATIONS
double h4Short = iMA(NULL,0,150,0,MODE_EMA,PRICE_CLOSE,0);
double h4Long = iMA(NULL,0,365,0,MODE_EMA,PRICE_CLOSE,0);
//D1 EMAS CALCULATIONS
double d1Short = iMA(NULL,0,150,0,MODE_EMA,PRICE_CLOSE,0);
double d1Long = iMA(NULL,0,365,0,MODE_EMA,PRICE_CLOSE,0);
ObjectCreate(ChartID(),h4ShortE,OBJ_HLINE,0,0, h4Short);
ObjectSetInteger(ChartID(),h4ShortE,OBJPROP_COLOR,clrRed);
ObjectSetInteger(ChartID(),h4ShortE,OBJPROP_STYLE,STYLE_SOLID);
ObjectSetInteger(ChartID(),h4ShortE,OBJPROP_WIDTH,1);
}
[/code]