Drawing Line every 15 minutes

To add comments, please log in or register
therustytrader
455
therustytrader  

I am trying to make an indicator that just draws a line every quarter hour to help me be able to keep track of time better.

Right now it only draws one line at the nearest hour.  I am new to mql so any help would be greatly appreciated.


int init()
  {
      if(Minute()== 00 || Minute()== 15 || Minute()== 30 || Minute()== 45)
      {
          ObjectCreate("Quarter Hours",OBJ_VLINE,0,Time[0],0);
      }
      WindowRedraw();         
   return(0);
  }
Files:
line.png 26 kb
Vladimir Karputov
Moderator
121277
Vladimir Karputov  
therustytrader:

I am trying to make an indicator that just draws a line every quarter hour to help me be able to keep track of time better.

Right now it only draws one line at the nearest hour.  I am new to mql so any help would be greatly appreciated.


Try the following code:

   MqlDateTime str1;
   TimeToStruct(TimeLocal(),str1);
   if(str1.min%15==0)
      ObjectCreate("Quarter Hours",OBJ_VLINE,0,Time[0],0);
therustytrader
455
therustytrader  
Thanks but this is just drawing a line on the candle where the indicator is added to the chart at.
Vladimir Karputov
Moderator
121277
Vladimir Karputov  
therustytrader:
Thanks but this is just drawing a line on the candle where the indicator is added to the chart at.
Place this code in OnCalculate () function and the line will be drawn every 15 minutes.
therustytrader
455
therustytrader  
Ok thanks for your help,  one last question on this.  How do I get it to draw the line on previous candles?
therustytrader
455
therustytrader  

I want to thank you so much for your help.  I learned a lot today about MQL programming and how to set buffers and how the time functions work.

All and all after much searching I found an indicator doing what I wanted.

Thank you again for helping me understand MQL more.

To add comments, please log in or register