诚信为本
量力而为
当前位置:峰汇在线 > MetaTrader 4 > MT4指标 > 正文

主要外汇市场开市时间指标 H_aligator_Clock.mq4

H_aligator_Clock指标创建文字对象显示设定的外汇市场开盘时间。

图表:H_aligator_Clock指标

源码:

//+------------------------------------------------------------------+
//|                                             H_aligator_Clock.mq4 |
//|                                                           Jerome |
//+------------------------------------------------------------------+
#property copyright "Jerome"
#property link      "http://www.125808047.com/"

//------------------------------------------------------------------
// Instructions
//    BrokerTZ  - Timezone of your Broker (in hours from GMT)
//    LocalTz   - Your timezone in hours from GMT
//    DST       - Is it daylight savings time?
//    ShowLocal - 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 clock
//
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Red

extern double       BrokerTZ=-7;
extern double       LocalTz=+1;
extern bool         DST=true;
extern bool         ShowLocal=true;
extern int          corner=0;
extern int          topOff=100;
extern color        labelColor=Yellow;
extern color        clockColor=White;

double ExtMapBuffer1[];
int LondonTZ = 1;
int TokyoTZ = 9;
int NewYorkTZ = -4;

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate (const int rates_total,
                 const int prev_calculated,
                 const datetime& time[],
                 const double& open[],
                 const double& high[],
                 const double& low[],
                 const double& close[],
                 const long& tick_volume[],
                 const long& volume[],
                 const int& spread[])
  {
   int    counted_bars=IndicatorCounted();
   int dstDelta=-1;
   if ( DST )
      dstDelta = 0;
   
   datetime brokerTime = CurTime();
   datetime GMT = brokerTime - (BrokerTZ+dstDelta)*3600;
   datetime local = GMT + (LocalTz + dstDelta) * 3600;
   datetime london = GMT + (LondonTZ + dstDelta) * 3600;
   datetime tokyo = GMT + (TokyoTZ + dstDelta) * 3600;
   datetime newyork = GMT + (NewYorkTZ + dstDelta) * 3600;
   
   string GMTs = TimeToStr( GMT, TIME_MINUTES );
   string locals = TimeToStr( local, TIME_MINUTES  );
   string londons = TimeToStr( london, TIME_MINUTES  );
   string tokyos = TimeToStr( tokyo, TIME_MINUTES  );
   string newyorks = TimeToStr( newyork, TIME_MINUTES  );
   string brokers = TimeToStr( CurTime(), TIME_MINUTES );
   
   if ( ShowLocal ) {
      ObjectSetText( "locl", "Local:", 10, "Arial", labelColor );
      ObjectSetText( "loct", locals, 10, "Arial", clockColor );
   }
   ObjectSetText( "gmtl", "GMT", 10, "Arial", labelColor );
   ObjectSetText( "gmtt", GMTs, 10, "Arial", clockColor );
   ObjectSetText( "nyl", "New York:", 10, "Arial", labelColor );
   ObjectSetText( "nyt", newyorks, 10, "Arial", clockColor );
   ObjectSetText( "lonl", "London:", 10, "Arial", labelColor );
   ObjectSetText( "lont", londons, 10, "Arial", clockColor );
   ObjectSetText( "tokl", "Tokyo:", 10, "Arial", labelColor );
   ObjectSetText( "tokt", tokyos, 10, "Arial", clockColor );
   ObjectSetText( "brol", "Broker:", 10, "Arial", labelColor );
   ObjectSetText( "brot", brokers, 10, "Arial", clockColor );
      return(rates_total);
  }
//+------------------------------------------------------------------+
//| 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 );
return(0);
}

void OnInit(void)
  {
   Comment("www.125808047.com");
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   
   int top=topOff;
   if ( ShowLocal ) {
      ObjectMakeLabel( "locl", 90, top );
      ObjectMakeLabel( "loct", 45, top );
   }
   ObjectMakeLabel( "gmtl", 90, top-15 );
   ObjectMakeLabel( "gmtt", 45, top-15 );
   ObjectMakeLabel( "nyl", 90, top-30 );
   ObjectMakeLabel( "nyt", 45, top-30 );
   ObjectMakeLabel( "lonl", 90, top-45 );
   ObjectMakeLabel( "lont", 45, top-45 );
   ObjectMakeLabel( "tokl", 90, top-60 );
   ObjectMakeLabel( "tokt", 45, top-60 );
   ObjectMakeLabel( "brol", 90, top-75 );
   ObjectMakeLabel( "brot", 45, top-75 );
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
   void OnDeinit(const int reason)
    {
   ObjectDelete( "locl" );
   ObjectDelete( "loct" );
   ObjectDelete( "nyl" );
   ObjectDelete( "nyt" );
   ObjectDelete( "gmtl" );
   ObjectDelete( "gmtt" );
   ObjectDelete( "lonl" );
   ObjectDelete( "lont" );
   ObjectDelete( "tokl" );
   ObjectDelete( "tokt" );
   ObjectDelete( "brol" );
   ObjectDelete( "brot" );
   }
打赏
版权所有转载请注明标题及链接:峰汇在线 » 主要外汇市场开市时间指标 H_aligator_Clock.mq4
上一篇:
下一篇:
分享到: 更多 (0)

如您觉得此文不错请扫码打赏!

支付宝扫一扫打赏

微信扫一扫打赏