Open date for bars on weekly timeframe in MT4

 

Hello,

I use NY+7 brokers on multiple MT4 platforms, there are no Sunday daily bars on the charts.

But why when I switch to weelky timeframe, the open date for bars becomes Sunday? E.g. currently the most recent weekly bar opens on 2021.10.10, which is Sunday. Is it fixable?

 
  1. Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
              General rules and best pratices of the Forum. - General - MQL5 programming forum?
    Next time, post in the correct place. The moderators will likely move this thread there soon.

  2. Not fixable because it's not broken.
  3. Why do you care?
  4. To get the first bar of the week, use:
    int iBOW(ENUM_TIMEFRAMES tf=PERIOD_CURRENT){
       datetime week = iTime(_Symbol, PERIOD_W1, 0);
       int iTF = iBarShift(_Symbol, tf, week, true); if(iTF >= 0) return iTF;
       return iBarShift(_Symbol, tf, week) + 1;
    }

    On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
              Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26.4 (2019)

 

1. My bad, somehow I didn't see it.

2. So it's normal. Why is it Sunday though?

3. I care because I save screenshots of charts and I mark open date for candles with vertical lines, and that lines show wrong open date.

4. Thanks for the solution, I think I'll find an indicator, which plots plain vertical lines and will make it work with this code.

 

2. Some brokers have Sunday bars; one terminal to rule them all.

3. Period separators aren't enough?

 

2. And this simple thing doesn't function properly after more than 1,5 decades of development. Amazing.

3. Period separators don't suit me at all:

a) they are not customizable,

b) on daily tf they mark start of the months, on weekly tf they mark start of the years, while I put vertical lines on specific weekly candles in order to see candle open dates on the screenshots.

 

I modified this indicator https://www.mql5.com/en/code/15515 and now tooltip shows correct(actual) time for weekly candles.

iCrosshair
iCrosshair
  • www.mql5.com
Handy crosshair for MetaTrader 4.
Files:
iCrosshair.mq4  10 kb