t2 in ObjectCreate (OBJ_TREND,) dont cover holidays

 
hi

am using a code to draw a horizontal trend line from t1, p1  to t2,p1 (which will draw it horizontally and to the right) . 

some time i tried to draw the trend line for example  : over  90 bars but because of the holidays the trend line will not cover  90 bars.. 

how to solve this?



 

You may try this solution:

datetime CorrectTime(datetime time, int bars_forward)
{
   int counted=0;
   while(counted<bars_forward)
   {
      if(iBarShift(_Symbol, PERIOD_CURRENT, time, true)!=-1 || time>Time[0])
         counted++;
      time+=PeriodSeconds();
   }      
   return time;   
}
 
Yashar Seyyedin......thanks for your help, i will tray this..... and sorry for my late replay 
Yashar Seyyedin
Yashar Seyyedin
  • 2024.05.11
  • www.mql5.com
Trader's profile
 
abd-: i tried to draw the trend line for example  : over  90 bars but because of the holidays the trend line will not cover  90 bars.. 

A Tline is from time one to time two. It is not over bars.

You assume that every bar every exists — they don't. What if there are no ticks during a specific candle period? There can be minutes between ticks during the Asian session, think M1 chart. Larger charts, think weekend, market holiday (country and broker specific), requires knowledge of when your broker stops and starts (not necessary the same as the market.)
          "Free-of-Holes" Charts - MQL4 Articles (2006)
          No candle if open = close ? - MQL4 programming forum (2010)

 
William Roeder #:


You assume that every bar every exists
         

i didnt take this in to considerations , my assumption and thinking is about holidays only..lets solve the problem of Sundays and Saturdays ..first

 

Hi

I don’t think that there is a better solution that going in a loop through history and count those 90 bars and find the times of the starting and ending point of the loop.

There is no universal way to work on times using bars only – just make your code base on available data from chart.

Best Regards

 

Marzena Maria Szmit #:
just make your code base on available data from chart.


that is the solution

regard

Reason: