17评论

1收藏

时间指标

avatar 谢少 | 5622 人阅读 | 17 人评论 | 2011-12-29

我这里有个时间指标跟大家共享一下,本人觉得蛮不错的,同时显示好几个地区的时间。
  还有个问题向大家请教:移动十字线窗口下边所显示的时间为什么与电脑系统上的时间总相差5个小时,怎样改会显示北京时间为准?(bull 大师研制的那个试了也是一样的)  
  
  //北京时间 //
  
  #property  copyright \"None\"
  #property  link      \"None\"
  
  //------------------------------------------------------------------
  // Instructions
  //    BrokerTZ  - Timezone of your Broker (in hours from GMT)
  //    ChinaTz   - Your timezone in hours from GMTwww
  //    DST       - Is it daylight savings time?FxPro,外汇,
  //    ShowChina - Set to tru to show your local time zone
  //    corner    - 0 = top left, 1 = top right, 2 = bottom left, 3 = bottom right
  //    topOff    - pixels from top to show the clock
  //    labelColor- Color of label
  //    clockColor- Color of clockw
  #property indicator_chart_window
  #property indicator_buffers 1
  #property indicator_color1 Lime
  
  //---- input parameters
  extern double       BrokerTZ= 0;
  extern bool         DST=true;
  extern bool         ShowChina=true;
  extern int          corner=3;
  extern int          topOff=70;
  extern color        labelColorTM=Lime;
  extern color        clockColorTM=Lime;
  extern color        labelColorChina=DeepSkyBlue;
  extern color        clockColorChina=DeepSkyBlue;
  extern color        labelColorNewYork=DeepSkyBlue;
  extern color        clockColorNewYork=DeepSkyBlue;
  extern color        labelColorLondon=DeepSkyBlue;
  extern color        clockColorLondon=DeepSkyBlue;
  extern color        labelColorTokyo=DeepSkyBlue;
  extern color        clockColorTokyo=DeepSkyBlue;
  extern color        labelColorGMT=DeepSkyBlue;
  extern color        clockColorGMT=DeepSkyBlue;
  
  //---- buffers
  double ExtMapBuffer1[];
  int TMTZ = -3;  // Daylight saving time is -3 and Winter time is -4
  int ChinaTZ = 8;
  int TokyoTZ = 9;
  int LondonTZ = 1;
  int NewYorkTZ = -3; // Daylight saving time is -3 and Winter time is -4
  //+------------------------------------------------------------------+
  //| Custom indicator iteration function
  //+------------------------------------------------------------------+
  int start()
   {
   int    counted_bars=IndicatorCounted();
  //----
    int dstDelta=-1;
    if ( DST )
       dstDelta = 0;
  
    datetime brokerTime = CurTime();
    datetime GMT = brokerTime - (BrokerTZ+dstDelta)*3600;
    datetime tm = GMT + (NewYorkTZ - 1) * 3600;  // Regular time
  //   datetime tm = GMT + (NewYorkTZ + dstDelta) * 3600; // Sunlight saving time
  
   datetime china = GMT + (ChinaTZ + dstDelta) * 3600;
   datetime tokyo = GMT + (TokyoTZ + dstDelta) * 3600;
   datetime london = GMT + (LondonTZ + dstDelta) * 3600;
   datetime newyork = GMT + (NewYorkTZ - 1) * 3600;   // Regular time
   
   //   datetime newyork = GMT + (NewYorkTZ + dstDelta) * 3600;     // Sunlight saving time
   //Print( brokerTime, \" \", GMT, \" \", london, \" \", tokyo, \" \", china, \" \", newyork  );
   
   string GMTs = TimeToStr( GMT, TIME_MINUTES );
   string tms = TimeToStr( tm, TIME_SECONDS  );
   string chinas = TimeToStr( china, TIME_MINUTES  );
   string tokyos = TimeToStr( tokyo, TIME_MINUTES  );
   string londons = TimeToStr( london, TIME_MINUTES  );
   string newyorks = TimeToStr( newyork, TIME_MINUTES  );
   
   //ObjectSetText( \"times\", timeText, 10, \"Arial\", clockColor );
   if ( ShowChina ) {
   ObjectSetText( \"chil\", \"China:\", 10, \"Arial\", labelColorChina );
   ObjectSetText( \"chit\", chinas, 10, \"Arial\", clockColorChina );
   }
   ObjectSetText( \"tml\", 10, \"Arial\", labelColorTM );
   ObjectSetText( \"tmt\", tms, 16, \"Arial\", clockColorTM );
   ObjectSetText( \"tokl\", \"Tokyo:\", 10, \"Arial\", labelColorTokyo );
   ObjectSetText( \"tokt\", tokyos, 10, \"Arial\", clockColorTokyo );
   ObjectSetText( \"nyl\", \"New York:\", 10, \"Arial\", labelColorNewYork );
   ObjectSetText( \"nyt\", newyorks, 10, \"Arial\", clockColorNewYork );
   ObjectSetText( \"lonl\", \"London:\", 10, \"Arial\", labelColorLondon );
   ObjectSetText( \"lont\", londons, 10, \"Arial\", clockColorLondon );
   ObjectSetText( \"gmtl\", \"GMT:\", 10, \"Arial\", labelColorGMT );
   ObjectSetText( \"gmtt\", GMTs, 10, \"Arial\", clockColorGMT );
   
  //----
   return(0);
   }
  //+------------------------------------------------------------------+
  //+------------------------------------------------------------------+
  //| Custom indicator initialization function                        
  //+------------------------------------------------------------------+
  int ObjectMakeLabel( string n, int xoff, int yoff ) {
   ObjectCreate( n, OBJ_LABEL, 0, 0, 0 );
   ObjectSet( n, OBJPROP_CORNER, corner );
   ObjectSet( n, OBJPROP_XDISTANCE, xoff );
   ObjectSet( n, OBJPROP_YDISTANCE, yoff );
   ObjectSet( n, OBJPROP_BACK, true );
  }
  int init()
   {
  //---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   
   int top=topOff;
   if ( ShowChina )
      ObjectMakeLabel( \"tml\", 50, top+10 );
      ObjectMakeLabel( \"tmt\", 10, top+10 );
  //      ObjectMakeLabel( \"chil\", 50, top+10 );
  //      ObjectMakeLabel( \"chit\", 10, top+10 );
      ObjectMakeLabel( \"nyl\", 50, top-8 );
      ObjectMakeLabel( \"nyt\", 10, top-8 );      
      ObjectMakeLabel( \"lonl\", 50, top-26 );
      ObjectMakeLabel( \"lont\", 10, top-26 );      
      ObjectMakeLabel( \"tokl\", 50, top-44 );
      ObjectMakeLabel( \"tokt\", 10, top-44 );
      ObjectMakeLabel( \"gmtl\", 50, top-62 );
      ObjectMakeLabel( \"gmtt\", 10, top-62 );
  
  //----
     return(0);
     }
  //+------------------------------------------------------------------+
  //| Custom indicator deinitialization function  
  //+------------------------------------------------------------------+
  int deinit()
    {
  //----\"
    ObjectDelete( \"tml\" );
    ObjectDelete( \"tmt\" );
    ObjectDelete( \"chil\" );
    ObjectDelete( \"chit\" );
    ObjectDelete( \"tokl\" );
    ObjectDelete( \"tokt\" );
    ObjectDelete( \"gmtl\" );
    ObjectDelete( \"gmtt\" );
    ObjectDelete( \"nyl\" );
    ObjectDelete( \"nyt\" );
    ObjectDelete( \"lonl\" );
    ObjectDelete( \"lont\" );
   
  //----
    return(0);
    }  
  
  以后再发现有什么好东西再跟大家分享。。。。。。
""
还没有人打赏,支持一下

评论|共 17 个

win8

发表于 2012-11-22 00:28:10 | 显示全部楼层

谢谢分享  

越野车

发表于 2012-11-22 00:28:10 | 显示全部楼层

顶你一下.  

门神

发表于 2012-11-22 00:28:10 | 显示全部楼层

不错!  

怨女

发表于 2012-11-22 00:28:10 | 显示全部楼层

支持你就顶你  

情人日记

发表于 2012-11-22 00:28:10 | 显示全部楼层

这贴子你会收藏吗  

qq12615987

发表于 2012-11-22 00:28:10 | 显示全部楼层

…没我说话的余地…飘走  

vivi

发表于 2012-11-22 00:28:10 | 显示全部楼层

资金量设置的是10000美元啊,  

UKBNCKPv

发表于 2012-11-22 00:28:10 | 显示全部楼层

我也想学习学习~~  

fvepkuonb

发表于 2020-6-5 17:07:15 | 显示全部楼层

不错不错,楼主您辛苦了。。。

12下一页
您需要登录后才可以回帖 登录 | 注册 微信登录

EA之家评论守则