有您的持续关注
我们会做得更好

注释交易时间段的指标3FoldTradingHours



3FoldTradingHours指标可以根据设定时间段(分三段)来注释自己需要交易的时间。

比如参数设置如下:
extern int       FromHourTrade1=06;
extern int       ToHourTrade1=08;
extern int       FromHourTrade2=11;
extern int       ToHourTrade2=12;
extern int       FromHourTrade3=13;
extern int       ToHourTrade3=18;

那么做时间段内图表注释为 * TRADING HOURS * 否则为 * NON-TRADING HOURS * 当然如果有时间需要你可以根据程序扩展为报警或者手机短信提醒模式。

3FoldTradingHours指标图表效果如下:

3FoldTradingHours指标

3FoldTradingHours指标MQL4源码如下:

//+------------------------------------------------------------------+
//|                                            3FoldTradingHours.mq4 |
//|                                                        cubesteak |
//|                                         http://www.cubesteak.net |
//+------------------------------------------------------------------+
#property copyright "cubesteak"
#property link      "http://www.cubesteak.net"

#property indicator_chart_window     

//---- input parameters
extern int       FromHourTrade1=-1;
extern int       ToHourTrade1=-1;
extern int       FromHourTrade2=-1;
extern int       ToHourTrade2=-1;
extern int       FromHourTrade3=-1;
extern int       ToHourTrade3=-1;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   
//----
   
int a,b,c;
bool UseHourTrade = true;

if (UseHourTrade)
{

   if (
         FromHourTrade1==-1 &&
         ToHourTrade1==-1 &&
         FromHourTrade2==-1 &&
         ToHourTrade2==-1 &&
         FromHourTrade3==-1 &&
         ToHourTrade3==-1 
      ) Comment("Trading Hours Not Set");
      else
      {

      int now = Hour();
      if (

            ( (now>=FromHourTrade1) ) &&
            ( (now<=ToHourTrade1) )
         
         ) a=1;

   
      if (

            ( (now>=FromHourTrade2) ) &&
            ( (now<=ToHourTrade2) )
         
         ) b=1;


      if (

            ( (now>=FromHourTrade3) ) &&
            ( (now<=ToHourTrade3) )
         
         ) c=1;

      if (
            (a!=1) &&
            (b!=1) &&
            (c!=1)
         )
      {
      Comment(
      "\n"," ^^^^^^^^^^^^^^^^^^^^",
      "\n","   * NON-TRADING HOURS * ",
      "\n"," ^^^^^^^^^^^^^^^^^^^^");
      }
      else    Comment(
      "\n"," ^^^^^^^^^^^^^^^^",
      "\n","   * TRADING HOURS * ",
      "\n"," ^^^^^^^^^^^^^^^^");
      }
}

   
//----
   return(0);
  }
//+------------------------------------------------------------------+

如您喜欢此文章请点下面分享按钮↴峰汇在线 » 注释交易时间段的指标3FoldTradingHours
上一篇:
下一篇:
分享到:更多 ()