Help with lines

 

Hi all I am very new to MQL4 and hoping someone will feel sorry for me and tell me where I'm going wrong please...

To start with I'm trying to draw two vertical solid red lines on a chart one at midnight and the other at seven in the morning.

 When I run what I have written I get one at midnight and nothing at seven and the midnight one is dotted not solid. 

 

extern string FirstVLineName="MyLine1";
extern color FirstVLineColor=Red; 
extern int FirstVLineStyle=STYLE_SOLID;
extern string SecondVLineName1="MyLine2";
extern color SecondVLineColor1=Red;
extern int SecondVLineStyle1=STYLE_SOLID;


int start()
  {
  //int counted_bars=IndicatorCounted();
  //int bars_count=BarsPerWindow(),h,m;
  int HH=TimeHour(Time[0]);
  int Unused = 0;
  int HH1=TimeHour(Time[7]);
  int Unused1 = 0;
  
     ObjectCreate(FirstVLineName, OBJ_VLINE, 0, HH, Unused);
     ObjectSet(FirstVLineName, OBJPROP_STYLE, FirstVLineStyle);
     ObjectSet(FirstVLineName, OBJPROP_COLOR, FirstVLineColor); 
     
     ObjectCreate(SecondVLineName1, OBJ_VLINE, 0, HH1, Unused1);
     ObjectSet(SecondVLineName1, OBJPROP_STYLE, SecondVLineStyle1);
     ObjectSet(SecondVLineName1, OBJPROP_COLOR, SecondVLineColor1);
     
  
   return(0);        
 
LTR:

tell me where I'm going wrong please...

vertical lines one at midnight and the other at seven in the morning.


  1. For large amounts of code, attach it
  2.   int HH=TimeHour(Time[0]);
      int HH1=TimeHour(Time[7]);
    
    Start by telling me what Time[0] and Time[7] return? What HH and HH1 are? And what time you are passing to ObjectCreate()?
 

[0] I am hoping is midnight and

[7] is 7am 

 HH & HH1 I understood I had to assign something to TimeHour  which would then tell the program where to draw the lines

have i completly mis-understood what I read 

 
LTR: [0] I am hoping is midnight and
Now stop hoping and RTFM. Answer the question: what does Time[0] and Time[7] return?
 
LTR:

[0] I am hoping is midnight and

[7] is 7am 

 HH & HH1 I understood I had to assign something to TimeHour  which would then tell the program where to draw the lines

have i completly mis-understood what I read 

Use the Forum search to search for midnight and you would have found this:  https://www.mql5.com/en/forum/135849
 

I took WHRoeder advice to Read The Fucking Manual I also looked at the link you advised RaptorUK can you tell where in the manual under TimeCurrent its says (PERIOD_D1 * 60) under Date & Time Functions.

 

In 

int Hour()

Returns the hour (0,1,2,..23) so i assumed 0 was midnight and 7 would be 7am obviously I was wrong  I guess for someone like WHRoeder who knows how this all works giving a little help to someone is just too much to ask 

 
LTR:

I took WHRoeder advice to Read The XXXX Manual I also looked at the link you advised RaptorUK can you tell where in the manual under TimeCurrent its says (PERIOD_D1 * 60) under Date & Time Functions.

 

In 

int Hour()

Returns the hour (0,1,2,..23) so i assumed 0 was midnight and 7 would be 7am obviously I was wrong  I guess for someone like WHRoeder who knows how this all works giving a little help to someone is just too much to ask 

You might want to edit your post to remove you inappropriate language,  it serves no purpose other than harming any point you may want to make.


Why are you quoting the function Hour()  ?  you don't use this function in your code,  you do use  Time[],  did you read the Documentation on that Predefined variable ? it says "Series array that contains open time of each bar of the current chart."  so Time[0]  is the open time for bar 0,  bar 0 is the currently forming bar.

 

If you want to use my code to determine the datetime of Midnight feel free,  if you don't then by all means work out when Midnight was for yourself. 

 

Thank you for your help RaptorUk I will go back to the documentation as I still don't get it hopefully one day I will, as reading something from the documentation is all good until you get stuck and thought this was the place to ask just like my code wrong again and as for upsetting WHRoeder with what I put I'm sure he's thicker skinned than that.

 

I asked you some questions, so you would learn. But you refuse to answer. Twice.

Apparently you don't want to learn, you just want a snippet to drop into your code.

Therefor you get my standard line: Since there are no slaves here, you have only three choices: Search for it, learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt and the nature of your problem.

 
I thought i did i thought the 0 was midnight and the 7 was 7am and i had to assign something to the time i do want to learn how to code but i cant seem to get it and it very frustrating so if ive offended anyone im sorry and will go back to the book and documentation as its not just the two verical lines i want achieve i just thought doing one bit at a time would be easier than trying to do everything i want at once walk before i can run. I also dont think i mentioned slavery i admire what you lot can do as i dont seem to be able to grasp it yet
 
Show me where in the documentation it says Time[0] is midnight? THREE times I have asked: what does Time[0] and Time[7] return?
Reason: