以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  [求助]请老师帮忙把这个MT4模型转换成金字塔  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=137726)

--  作者:pretty12315
--  发布时间:2016/8/9 9:18:55
--  [求助]请老师帮忙把这个MT4模型转换成金字塔
请老师帮忙把这个MT4模型转换成金字塔。非常感谢图片点击可在新窗口打开查看


//+------------------------------------------------------------------+
//|                                                FJ_3.0(波幅x).mq4 |
//|                                                                  |
//|                                               
//+------------------------------------------------------------------+


#property copyright "FJ_3.0(波幅x)"
#property link      ""

#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 DarkGray
#property indicator_color2 Red
#property indicator_color3 Lime
#property indicator_color4 Yellow
#property indicator_color5 Magenta
#property indicator_color6 Blue
#property indicator_color7 Aqua
#property indicator_color8 Blue

input int   ma11    =3;
input int   IPeriod =20;
input int   HighLow =40;
input bool  timeWeek=true;
input bool  timeDay =false;
input int       星期=01;
input int       小时=01;
input int       分钟=00;
input int     HLopen=0;
input string  hlopen= "开盘=0,收盘=1,最高=2,最低=3";
      
//---- buffers
double AxBuffer[];
double HiBuffer[];
double LoBuffer[];
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double EmaBuffer[];
double OpenBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   IndicatorShortName("");
   
//---- indicators
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID, 2);
   SetIndexBuffer(0,AxBuffer);
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID, 5);
   SetIndexBuffer(1,HiBuffer);
   SetIndexStyle(2,DRAW_LINE,STYLE_SOLID, 5);
   SetIndexBuffer(2,LoBuffer);
   SetIndexStyle(3,DRAW_LINE, STYLE_SOLID, 2);
   SetIndexBuffer(3,ExtMapBuffer1);
   SetIndexStyle(4,DRAW_LINE, STYLE_SOLID, 2);
   SetIndexBuffer(4,ExtMapBuffer2);
   SetIndexStyle(5,DRAW_LINE, STYLE_SOLID, 2);
   SetIndexBuffer(5,ExtMapBuffer3);
   SetIndexStyle(6,DRAW_LINE, STYLE_SOLID, 1);
   SetIndexBuffer(6,EmaBuffer);
   SetIndexStyle(7,DRAW_LINE, STYLE_SOLID, 2);
   SetIndexBuffer(7,OpenBuffer);

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| DynamicRS                                                        |
//+------------------------------------------------------------------+
int start()
  {
   int i,counted_bars=IndicatorCounted();

//----
   i=Bars-counted_bars-1;
   while(i>=0)
     {
      if(High[i]<High[i+1] && (Open[i]+High[i])/2+IPeriod*Point<ExtMapBuffer1[i+1])   
         {
          ExtMapBuffer1[i]=(Open[i]+High[i])/2+IPeriod*Point;
          ExtMapBuffer3[i]=(Open[i]+High[i])/2+IPeriod*Point; 
         }          
      else if(Low[i]>Low[i+1] && (Open[i]+Low[i])/2-IPeriod*Point>ExtMapBuffer1[i+1])
         {
          ExtMapBuffer1[i]=(Open[i]+Low[i])/2-IPeriod*Point;
          ExtMapBuffer2[i]=(Open[i]+Low[i])/2-IPeriod*Point;
         }
      else
         {
          ExtMapBuffer1[i]=ExtMapBuffer1[i+1];
          if(ExtMapBuffer1[i+1]==ExtMapBuffer2[i+1]) 
             ExtMapBuffer2[i]=ExtMapBuffer1[i+1];
          else if(ExtMapBuffer1[i+1]==ExtMapBuffer3[i+1]) 
             ExtMapBuffer3[i]=ExtMapBuffer1[i+1];
         } 
         
         
         
     if(High[i]<High[i+1] && High[i]+HighLow*Point<AxBuffer[i+1])   
         {
          AxBuffer[i]=High[i]+HighLow*Point;
          LoBuffer[i]=High[i]+HighLow*Point;          
         }          
      else if(Low[i]>Low[i+1] && Low[i]-HighLow*Point>AxBuffer[i+1])
         {
          AxBuffer[i]=Low[i]-HighLow*Point;
          HiBuffer[i]=Low[i]-HighLow*Point;

         }
      else
         {
          AxBuffer[i]=AxBuffer[i+1];
          if(AxBuffer[i+1]==HiBuffer[i+1]) 
             HiBuffer[i]=AxBuffer[i+1];
          else if(AxBuffer[i+1]==LoBuffer[i+1]) 
             LoBuffer[i]=AxBuffer[i+1];
         } 
         
         EmaBuffer[i]= iMA(NULL,0,ma11,NULL,MODE_LWMA,PRICE_WEIGHTED,i);       
      i--;
     }
     
//+------------------------------------------------------------------+
double openline=0;

int ww=0;

for (i=(Bars-1);i>0;i--)
    {
      if (((TimeHour(Time[i])== 23) && (TimeMinute(Time[i]) <= 59))
         || ((TimeDayOfWeek(Time[i])== 5) && (TimeHour(Time[i])== 22) && (TimeMinute(Time[i]) < 59)))
        ww=0;
        
        
   if (timeWeek==true)
     {
  if (TimeDayOfWeek(Time[i])==星期 && TimeHour(Time[i])==小时 && TimeMinute(Time[i]) == 分钟  && ww == 0) 
    {
     if (HLopen==0)openline=Open[i];
else if (HLopen==1)openline=Close[i];
else if (HLopen==2)openline=High[i];
else if (HLopen==3)openline=Low[i];    

    ww=1;
    }
     OpenBuffer[i]=openline;
  } 

  else  if (timeDay==true)
     {
  if (TimeHour(Time[i])== 小时 && TimeMinute(Time[i]) == 分钟 && ww == 0)
    {
     
     if (HLopen==0)openline=Open[i];
else if (HLopen==1)openline=Close[i];
else if (HLopen==2)openline=High[i];
else if (HLopen==3)openline=Low[i]; 
    ww=1;
    }
     OpenBuffer[i]=openline;
     }

   }

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

--  作者:jinzhe
--  发布时间:2016/8/9 9:33:50
--  

能否逐一注释一下,

能否解释一下这代码是用来做什么的?