ObjectCreate() and Time[]

 

I am trying to create a vertical line at any specified time. For example the 6am candle.


I have scoured the net for a solution but I can only find people mentioning using 0 fof teh last created candle or time[1] for the candle before the last, time[2] for the secodn from last etc etc.



Is it possible to specify a specific time? And if so, how?


Thanks a lot to anyone that help.


Olly

 

Hi Olly

The paramenters for ObjectCreate() include time, so you can (and must) specify the time with a datetime variable or constant.

https://docs.mql4.com/objects/ObjectCreate

The series time[] has type datetime so that's OK, but you can use any datetime variable you want.

datetime When = D'2009.12.10 12:30';
ObjectCreate("Vertical Line", OBJ_VLINE, 0, When, 0 );

Cheers

Jellybean

 
Thank you very much for this answer