HLine wont' draw..help

 
Just want to draw a line....one horizontal line (will add more after this one works). I drag the indicator (*.mq4) on top of my chart and nothing happens. Why isn't it drawing a horizontal line? What it should be doing is taking the price level "1.68744" and adding variable "hirange" and drawing the line at that price level. When I compile, No errors, no warnings.
#property indicator_chart_window

extern double closeprice    =    1.68744; 
extern int    lowrange      =     25;
extern int    hirange       =     40;
extern color  LineColor     =   Gray;


int start()
  {
      
string   top40;

   

   ObjectCreate(top40, OBJ_HLINE, 0, 0, closeprice+hirange);
   ObjectSet(top40, OBJPROP_STYLE, STYLE_SOLID);
   ObjectSet(top40, OBJPROP_WIDTH, 2);
   ObjectSet(top40, OBJPROP_COLOR, LineColor);

   return(0);
 }
 

it's very easy to spot what the problem is by using GetLastError

   if(!ObjectCreate(top40, OBJ_HLINE, 0, 0, closeprice+hirange))
      Alert(GetLastError());

the error you get (4204) means

 

4204

ERR_NO_OBJECT_NAME

No object name

 

one more thing

i believe you don't want the HLine to be drawn at 41.68744 (closeprice+hirange) am i right ?

 
extern double closeprice    =    1.68744; 
extern double    lowrange   =    0.00025;
extern double    hirange    =    0.00040;
extern color  LineColor     =   Gray;


No, I don't want it to increment to that number. I updated to the intended result.

My line of code is not within an "if" statement, like you have it. Do I need to do it that way?


I'm playing with the code more and no improvement. I established the name of the object by creating a string "top40" (w/o quotations). ObjectCreate takes the first parameter for the name of the object, which I stated as "top40", so why would I get an error 'no object name'?


Thx for your help :-)

 
int start()
  {
      
string   a="top40";

   

   ObjectCreate(a, OBJ_HLINE, 0, 0, closeprice+hirange);
   ObjectSet(a, OBJPROP_STYLE, STYLE_SOLID);
   ObjectSet(a, OBJPROP_WIDTH, 2);
   ObjectSet(a, OBJPROP_COLOR, LineColor);
   Alert(GetLastError());
}
I think I was declaring the string variable incorrectly. I had "string top40;" and now I have "string a=top40;" ...I now get an error 4200?
 
int start()
  {
      
string   a="top40";

   
   ObjectDelete(a); // <--new line added to compensate for 4200 error "object already exists"
   ObjectCreate(a, OBJ_HLINE, 0, 0, closeprice+hirange);
   ObjectSet(a, OBJPROP_STYLE, STYLE_SOLID);
   ObjectSet(a, OBJPROP_WIDTH, 2);
   ObjectSet(a, OBJPROP_COLOR, LineColor);
   Alert(GetLastError());
}


The new line "Object Delete" should delete any previous instances of this. But now after compiling I get error "0", which is not in the documentation https://docs.mql4.com/constants/errorswarnings/errorcodes
 

wait--wait---wait!!!  I think I figured it out...I'll post the working code next...WOO-HOO!!!

Reason: