Scripts: popup tip: any bar's local time

 

popup tip: any bar's local time:

popup tip: any bar's local time, with help of a verticle line.

Author: joshatt

 

try this one..

auto create the line.

if vline deleted.. script removed

#property show_inputs
extern int INTERVAL_MILLIS = 100;
extern int serverzone = 0;
extern int localzone = 8;
 
 
int deinit()
   {
   ObjectDelete("test09msg");  
   WindowRedraw();
   return(0);
   }
   
 
int start()
   {
 
   int Diff = localzone - serverzone;
   
   string VlineName="time_line",var1;
   datetime VlineTime, VlineTimePrevious, tlocal;
   double drawpos;
   
   ObjectCreate(VlineName,OBJ_VLINE,0,WindowTimeOnDropped(),0);  // add this to create line
   ObjectSet(VlineName,OBJPROP_COLOR,Yellow);                    // set color
 
   while( !(IsTesting() || IsStopped()) ) 
      {
      
      drawpos = 0.1*WindowPriceMax() + 0.9*WindowPriceMin();  // <----- 0.1+0.9=1,(0.2+0.8,0.3+0.7....) just adjust this to change Text object hight position.
         VlineTime = ObjectGet(VlineName,OBJPROP_TIME1);
         if(ObjectFind(VlineName) == -1 ) break;  //  if vline deleted.. script removed
      if(VlineTime != VlineTimePrevious  ) 
         {
         if(ObjectFind("test09msg") == -1 )          
            ObjectCreate("test09msg", OBJ_TEXT, 0, VlineTime, drawpos);
         
         tlocal = VlineTime + (Diff * PERIOD_H1 * 60);
         
        
         
         ObjectSetText("test09msg", "                              "+ TimeToStr(tlocal,TIME_DATE )+"_"+ TimeToStr(tlocal,TIME_MINUTES), 10, "Times New Roman", Gray);
         ObjectSet("test09msg",OBJPROP_TIME1,VlineTime);
         //Print(WindowPriceMin()*1.1);
         ObjectSet("test09msg",OBJPROP_PRICE1,drawpos);
         WindowRedraw();
                  
         VlineTimePrevious = VlineTime;
         
         }
         
      Sleep(INTERVAL_MILLIS);
     
      }
   return(0);
}
 

try this one..

auto create the line.

if vline deleted.. script removed

#property show_inputs
extern int INTERVAL_MILLIS = 100;
extern int serverzone = 0;
extern int localzone = 8;
 
 
int deinit()
   {
   ObjectDelete("test09msg");  
   WindowRedraw();
   return(0);
   }
   
 
int start()
   {
 
   int Diff = localzone - serverzone;
   
   string VlineName="time_line",var1;
   datetime VlineTime, VlineTimePrevious, tlocal;
   double drawpos;
   
   ObjectCreate(VlineName,OBJ_VLINE,0,WindowTimeOnDropped(),0);  // add this to create line
   ObjectSet(VlineName,OBJPROP_COLOR,Yellow);                    // set color
 
   while( !(IsTesting() || IsStopped()) ) 
      {
      
      drawpos = 0.1*WindowPriceMax() + 0.9*WindowPriceMin();  // <----- 0.1+0.9=1,(0.2+0.8,0.3+0.7....) just adjust this to change Text object hight position.
         VlineTime = ObjectGet(VlineName,OBJPROP_TIME1);
         if(ObjectFind(VlineName) == -1 ) break;  //  if vline deleted.. script removed
      if(VlineTime != VlineTimePrevious  ) 
         {
         if(ObjectFind("test09msg") == -1 )          
            ObjectCreate("test09msg", OBJ_TEXT, 0, VlineTime, drawpos);
         
         tlocal = VlineTime + (Diff * PERIOD_H1 * 60);
         
        
         
         ObjectSetText("test09msg", "                              "+ TimeToStr(tlocal,TIME_DATE )+"_"+ TimeToStr(tlocal,TIME_MINUTES), 10, "Times New Roman", Gray);
         ObjectSet("test09msg",OBJPROP_TIME1,VlineTime);
         //Print(WindowPriceMin()*1.1);
         ObjectSet("test09msg",OBJPROP_PRICE1,drawpos);
         WindowRedraw();
                  
         VlineTimePrevious = VlineTime;
         
         }
         
      Sleep(INTERVAL_MILLIS);
     
      }
   return(0);
}
 

That's cool. I can learn from this.

So sorry I did not check this thread for such a long time, thought nobody likes this code.......

 

Hi...

This script seems to be not working properly on my PC.

I guess these lines never been executed

      if(VlineTime != VlineTimePrevious  ) 
         {
         if(ObjectFind("test09msg") == -1 )          
            ObjectCreate("test09msg", OBJ_TEXT, 0, VlineTime, drawpos);
         
         tlocal = VlineTime + (Diff * PERIOD_H1 * 60);
         
        
         
         ObjectSetText("test09msg", "                              "+ TimeToStr(tlocal,TIME_DATE )+"_"+ TimeToStr(tlocal,TIME_MINUTES), 10, "Times New Roman", Gray);
         ObjectSet("test09msg",OBJPROP_TIME1,VlineTime);
         //Print(WindowPriceMin()*1.1);
         ObjectSet("test09msg",OBJPROP_PRICE1,drawpos);
         WindowRedraw();
                  
         VlineTimePrevious = VlineTime;
         
         }
still shows server time
Reason: