Vertical line is not working

 

I have a few functions inside void OnTick()  {} that run on every tick and draw/update data on the chart. All of them work except this one:


void drawVLine()  {

   string name = "VLine";
   if (ObjectFind(name) != -1) {ObjectDelete(name);}
   ObjectCreate(name, OBJ_VLINE, 0, 5, 0);
   ObjectSet(name, OBJPROP_COLOR, DodgerBlue);
   ObjectSet(name, OBJPROP_WIDTH, 1);
   ObjectSet(name, OBJPROP_STYLE, STYLE_SOLID);
}


What is wrong with it?

TIA

 
   ObjectCreate(name, OBJ_VLINE, 0, 5, 0);

What time do you want the line drawn at?

 
Keith Watford:

What time do you want the line drawn at?

Five bars behind.
 
In future please post in the correct section
I will move this topic to the MQL4 and Metatrader 4 section.
 
whoowl:
Five bars behind.

You need to enter a time not the number of bars.

 
Keith Watford:
In future please post in the correct section
I will move this topic to the MQL4 and Metatrader 4 section.
Sorry, I don't understand that criterion. My question is not about any Metatrader 4 feature, it's about an indicator I am writing myself.
 
whoowl:
Sorry, I don't understand that criterion. My question is not about any Metatrader 4 feature, it's about an indicator I am writing myself.

You are writing an indicator for MT4 using MQL4, so it belongs in the MQL4 and Metatrader 4 section.

Reason: