mt4 - Period - Issue - page 2

 
Max Enrik:
On my broker - EURUSD starts from 00:00 and FB 17:30,

so I try just for counts from First Bar of Currently Day and to future Period H1 (with below code)

int _mmin = ( ( Time[0] - iTime( Symbol(), PERIOD_D1, 0 ) ) / 60 ) / _Period;
int _cnt  = MathMin( Bars, _mmin );
for ( int i = 0; i < _cnt; i++ ) {}

Example: 

EURUSD have 23 Hours in a day. (Which one above code works for EURUSD)

FB have 06 Hours in a day. (Above code does not work for FB)

So, I try to get '23 for EURUSD' and '6 for FB' I hope you understand me.

And I really need good advice and comment.

All the best.

If you want to start from the first bar of the current day, use this

      for (int i=iBarShift(NULL,0,iTime(NULL,PERIOD_D1,0)); i>=0; i--)
      {
         // the rest of the processing
      }
 
Marco vd Heijden:
I am sorry but i do not understand what you are trying to do.

(English is not my native language.)

Above code works perfect for EURUSD - #1 / screenshot

Above code does not work correctly for FB - #2 / screenshot

I would like to 'OBJ_VLINE' will be stop at the first hour (first hour can be - 00:00 - 01:00 - 02:00 - 03:00 - and so on)  of the Day.

I hope this comment will help.

 
Mladen Rakic:

If you want to start from the first bar of the current day, use this

      for (int i=iBarShift(NULL,0,iTime(NULL,PERIOD_D1,0)); i>=0; i--)
      {
         // the rest of the processing
      }

You much clearly understand me.

You made my day. Thank you so much more.