Detect a daychange

 

Hey guys,

my next step to do is to detect a day change.

I think it's very simple to do but i really don't know how to code it.

Can you give me some hints?

Thanks

 
Can you specify what exactly you mean by a "day change" ?
 
day change = change of day from i.e. tuesday to wednesday
 
int dow = TimeDayOfWeek(Time[0]);
static int day; bool newDay = dow != day; dow = day;
if (newDay) ...
 

ok thanks for the code above.

i tried to realize it by coding it like that...

thus it`s weekend i can`t check if it`s working or not (no ticks):

can you pleace check it if it would work?

thanks

int start()
  {
   bool isNewDay = false;
   int dow = TimeDayOfWeek(Time[0]);
   int day;
 
   if (dow != day)
   {
      isNewDay = true;
      Alert("NEW DAY"+dow);
   }
   else 
   {
      dow = day;
   }
  return(0);
}
 

someone?

 
FlashX:

someone?

Well, you can check it yourself using the back-tester. People around here generally don't spent their time testing for other people.
 
i tryed it over backtester but at ger30 it says that the new day comes at 21:42 till 21:59 when the markt closes but there is no day change...daychange would be at night?!
 
The time functions you're using refers to Days_Change based on Broker's Time/Trading Days. This is why RaptorUK asked you to define day change. If you want day change based on your Local Time, then you'll have to use TimeLocal(). The market is currently closed for everyone. So I for one wouldn't be able to test any functions with TimeLocal (except for maybe within the init() ). My New_Day is more than likely not the same New_Day for you because we might have different time zones. Lastly, any new day function you create will only Alert once after the first tick after your Local-Time goes from Mid-Night.
 

how can i find out what the hour of previous bar was?

i can`t find out.

 
Use iTime and TimeHour
Reason: