Indicator Miscellaneous Questions - page 7

 

Yes, but you have to code it.

Example:

Local TimeBroker ABroker B
00:00
(GMT)
01:00
(GMT+1)
02:00
(GMT+2)

You can't use PERIOD_D1 because

  • The D1 bar of Broker A starts at 23:00 local (1 hour early)
  • The D1 bar of Broker B starts at 22:00 local (2 hours early)

So you must use the H1 bars with iBarShift and iHighest / iLowest (or CopyHigh/CopyLow) to manually create your "day" as you want it.

----

Here is a quick script that might illustrate the point.

Drop it onto a chart and you'll see it draws a rectangle around a 'day' starting at 23:00 server time.

#define strict
#property show_inputs

#define DAY 86400
#define HOUR 3600

extern int time_shift = -1; // Hours to shift server time by

void OnStart()
  {
   time_shift*=HOUR;

   datetime oldest_bar = Time[Bars-1],
            midnight   = oldest_bar-(oldest_bar%DAY);

   while(midnight<=TimeCurrent())
     {
      datetime day_begin = midnight + time_shift,
               day_end   = day_begin + DAY - 1;
      double high[],
             low[];
      int high_cnt = CopyHigh(_Symbol, PERIOD_H1, day_begin, day_end, high),
          low_cnt  = CopyLow (_Symbol, PERIOD_H1, day_begin, day_end, low);
      if(high_cnt>0 && low_cnt>0)
        {
         double day_high = high[ArrayMaximum(high)],
                day_low  = low [ArrayMinimum(low)];
         string obj_name = TimeToString(day_begin,TIME_DATE);
         ObjectCreate(0, obj_name, OBJ_RECTANGLE, 0, day_begin, day_high, day_end, day_low);
        }
      midnight+=DAY;
     }
  }  


 

 
honest_knave:

Yes, but you have to code it.

I should study this example.

Thanks a lot. 

 

Once again thanks a lot for your great example.
After your comment I easily solved my issue.

---

I tried something for time offset automatically set for different brokers, unfortunately that did not work.

Q:  Can I write some code for automatically time offset sets for different brokers, is it possible?
     ( I still try something for it )

Thanks a lot. 

 

I try below code, but it does not give me correct value.

Q:  What is wrong in below code? ( I did not figure out )

datetime start=(datetime)SymbolInfoInteger(Symbol(),SYMBOL_START_TIME);

Thanks a lot.

 
Max Enrik:

I try below code, but it does not give me correct value.

Q:  What is wrong in below code? ( I did not figure out )

datetime start=(datetime)SymbolInfoInteger(Symbol(),SYMBOL_START_TIME);

Thanks a lot.

It seems not all brokers set this up correctly. Please see here 
 
honest_knave:
It seems not all brokers set this up correctly. Please see here 

There is no chance!
I am just thinking professional programmers and codes gave up?! Of course not. : / ( but I am )

Thanks a lot.

( I have idea I will try it at least - later )
 
Max Enrik:

There is no chance!
I am just thinking professional programmers and codes gave up?! Of course not. : / ( but I am )

Thanks a lot.

( I have idea I will try it at least - later )

There are always workarounds.

For example, you can go back through the H1 or M30 bars looking for a time gap bigger than 1 bar's time span (i.e. the market was shut during this gap).

But you need to be careful of weekends and public holidays, and incomplete history.

 
honest_knave:

There are always workarounds.
For example, you can go back through the H1 or M30 bars looking for a time gap bigger than 1 bar's time span (i.e. the market was shut during this gap).
But you need to be careful of weekends and public holidays, and incomplete history.

Thanks a lot for your useful comment.
 

I just need learn about date time, because so far when I try to write code related date time I always spent a lot of time that part of codes. ( even I successfully finished my scripts but I never understand more clearly )
So now I try to get data 1st bar ( Current day first bar 1m, 5m, 15m, 30m, 1h and so on ) of the day, but I can't.

( I have many and many tabs in google chrome browser relates about this - just nonsense )

So can someone help me how to write code for first bar of the day ( M1, 5M and so on ) with example and explain, please.

Of course tomorrow I will continue to research about this concern.

Thanks a lot in advance. 

 

First bar of the day should be the first bar after TimeHour() started over with counting.

That will be of course the first bar of anything M1 , M5 , M15 etc they all start new bars.

Reason: