Strategy Test versus Real Time behavior

 
I am new to this system but not to programming. I am somewhat mystified by the behavior of the strategy tester with regard to the simple code snippet – which is simply trying to test for a new day beginning. The code is: datetime Yesterday; int LastDay = 0; bool started = false; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- Yesterday = 0; Alert("Init!"); //---- return(0); } int deinit() { //---- //---- return(0); } int start() { //---- datetime Today; Today = 0; Today = TimeCurrent(); Alert( TimeToStr(Today),":",TimeSeconds(Today), " ",TimeToStr(Yesterday),":",TimeSeconds(Yesterday)); Alert (TimeDay(Today)," ",LastDay); if (TimeDay(Today) != LastDay) { Alert("New Day"); } Yesterday = Today; LastDay = TimeDay(Today); //---- return(0); } //+------------------------------------------------------------------+ When I run this attached to a chart the code recognizes a new day when it occurs and prints it out as an alert. However, when I run in the strategy tester LastDay is never zero and the "New Day" alert never occurs. Am I missing something really obvious here? I have attached the file
Files:
dayturner.mq4  2 kb
 

Where's an air-rifle when you need one?


CB

Reason: