105评论

0收藏

修改为固定60分钟周期 其他周期不显示

avatar tang5202008 | 8469 人阅读 | 105 人评论 | 2021-08-31

100金币
//+------------------------------------------------------------------+
//|                                               VIP_HeikenAshi.mq4 |
//|                                       Copyright © 2010, KingLion |
//|                                     http://www.metastock.org.ua/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, KingLion"
#property link      "http://www.metastock.org.ua/"

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1  Red
#property indicator_color2  DodgerBlue
#property indicator_width1  2
#property indicator_width2  2
#property indicator_minimum 0
#property indicator_maximum 1


//--- input parameters
extern ENUM_TIMEFRAMES TimeFrame = PERIOD_CURRENT;   // Time frame
extern string Custom_Indicator = "VIP Heiken Ashi";
extern string Copyright = "Copyright © 2010, KingLion";
extern string Web_Address = "www.metastock.org.ua";
//--- buffers
double HA_0[];
double HA_1[];
double HA_Open[];
double HA_Close[],count[];
string indicatorFileName;
#define _mtfCall(_buff,_ind) iCustom(NULL,TimeFrame,indicatorFileName,PERIOD_CURRENT,"","","",_buff,_ind)


int init()
  {
      IndicatorBuffers(5);
      SetIndexStyle(0, DRAW_HISTOGRAM);
      SetIndexBuffer(0, HA_0);
      SetIndexLabel(0, "HA_0");
      SetIndexStyle(1, DRAW_HISTOGRAM);
      SetIndexBuffer(1, HA_1);
      SetIndexLabel(1, "HA_1");
      SetIndexBuffer(2, HA_Open);
      SetIndexLabel(2, "HA_Open");
      SetIndexBuffer(3, HA_Close);
      SetIndexLabel(3, "HA_Close");
      SetIndexBuffer(4,count);
      SetIndexDrawBegin(0, 10);
      SetIndexDrawBegin(1, 10);


   indicatorFileName = WindowExpertName();
   TimeFrame         = fmax(TimeFrame,_Period);
   IndicatorShortName(timeFrameToString(TimeFrame)+" vip heiken ashi");
   return(0);
  }
int deinit()
  {
   return(0);
  }
int start()
{
   int i,counted_bars=IndicatorCounted();
      if(counted_bars<0) return(-1);
      if(counted_bars>0) counted_bars--;
            int limit = fmin(Bars-counted_bars,Bars-1); count[0] = limit;
            if (TimeFrame != _Period)
            {
               limit = (int)MathMax(limit,fmin(Bars-1,_mtfCall(4,0)*TimeFrame/Period()));
               for (i=limit; i>=0; i--)
               {
                  int y = iBarShift(NULL,TimeFrame,Time);
                     HA_0  = _mtfCall(0,y);
                     HA_1  = _mtfCall(1,y);
               }
   return(0);
   }

   for(i=limit;i>=0;i--)
    {
      double OHLC4 = NormalizeDouble((Open + High + Low + Close) / 4.0, Digits);
             OHLC4 = (OHLC4 + Close) / 2.0;
      double OHLC8 = NormalizeDouble((HA_Open[i + 1] + (HA_Close[i + 1])) / 2.0, Digits);
      double MaxHigh = MathMax(High, MathMax(OHLC8, OHLC4));
      double MinLow = MathMin(Low, MathMin(OHLC8, OHLC4));
      if (OHLC8 < OHLC4) {
         HA_0 = EMPTY_VALUE;
         HA_1 = 1;
      } else {
         HA_0 = 1;
         HA_1 = EMPTY_VALUE;
      }
      HA_Open = OHLC8;
      HA_Close = OHLC4;
   }
   return(0);
  }

  //+-------------------------------------------------------------------
//|                                                                  
//+-------------------------------------------------------------------
//
//
//
//
//

string sTfTable[] = {"M1","M5","M15","M30","H1","H4","D1","W1","MN"};
int    iTfTable[] = {1,5,15,30,60,240,1440,10080,43200};

string timeFrameToString(int tf)
{
   for (int i=ArraySize(iTfTable)-1; i>=0; i--)
         if (tf==iTfTable) return(sTfTable);
                              return("");

}
QQ图片20210831125103.png

""
还没有人打赏,支持一下

评论|共 105 个

迷藏

发表于 2021-8-31 13:10:57 来自手机 | 显示全部楼层

string sTfTable[] = {"H4"}; int    iTfTable[] = {60};

迷藏

发表于 2021-8-31 13:12:11 来自手机 | 显示全部楼层

string sTfTable[] = {"H1"}; int    iTfTable[] = {60};试试看

tang5202008

发表于 2021-8-31 13:35:07 来自手机 | 显示全部楼层

不行 没有通过测试

tang5202008

发表于 2021-8-31 13:36:46 | 显示全部楼层

去掉多周期选着 最后一段代码

抖机灵pk装弱智

发表于 2021-8-31 20:37:25 来自手机 | 显示全部楼层

保留  “H1”和(60,)就行了

小心脏

发表于 2021-8-31 22:28:45 | 显示全部楼层

顶下

tang5202008

发表于 2021-9-1 00:08:28 来自手机 | 显示全部楼层

保留以后  指标废了调不出来

编程逆袭仔

发表于 2021-9-2 21:36:37 | 显示全部楼层

紫晶灵儿

发表于 2021-9-4 15:38:20 | 显示全部楼层

谢谢

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

EA之家评论守则