The question is about MQL4 language for MetaTraders 4 platform.
I want to draw a horizontal line. I found the below mentioned snippet somewhere online and am trying to use it inside OnCaculate() function to draw a horizontal line on, let's say the maximum value in last 5 minutes.
int i; //let's assume it has a valid value for the highest value index
if (!ObjectCreate(0, "HLine", OBJ_HLINE, 0, 0, High[i]))
{
Print(__FUNCTION__, ": Failed to create a horizontal line! Error code =", GetLastError());
return (false);
}
I see this error in the log window:
OnCalculate: Failed to create a horizontal line! Error code = 4200
What is wrong in this snippet? If it is incorrect, please guide me with a correct way.
Error 4200meansObject already exists: see error codesSo you'll need to
ObjectDelete(0, "HLine")first.