以文本方式查看主题

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

--  作者:pretty12315
--  发布时间:2016/8/9 9:13:08
--  [求助]MT4转化为金字塔
老师 您好。请帮我把MT4的模型转化成 金字塔的。谢谢

//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
#property copyright "DX_多空x"
#property link      ""

#property indicator_chart_window
#property indicator_buffers 6

#property indicator_color1 Magenta
#property indicator_color2 Aqua       //最大  
#property indicator_color3 Yellow
#property indicator_color4 White    
#property indicator_color5 Magenta  
#property indicator_color6 Aqua
//---- input parameters


input int ma01   =2;
input int StepSizeMin=23; //=30-100
//input int HL波幅=120;
      int PeriodWATR=2;
      int AdvanceMin=0;
      int HighLow=1;

//---- indicator buffers
double ManyLine[];
double EmptyLine[];
double LineMinBuffer[];
double MaBuffer[];
double HighLine[];
double LowLine[];
//double biaojiLine[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
  int init()
  {
   string short_name;
//---- indicator line
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,3);   
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,3);   
   SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,3); 
   SetIndexStyle(3,DRAW_LINE,0);
   SetIndexStyle(4,DRAW_LINE,2); 
   SetIndexStyle(5,DRAW_LINE,2);   
    
   SetIndexShift(0,AdvanceMin);
   SetIndexShift(1,AdvanceMin);
   SetIndexShift(2,AdvanceMin);
   SetIndexShift(3,AdvanceMin);
   SetIndexShift(4,AdvanceMin);
   SetIndexShift(5,AdvanceMin);   
   
   SetIndexBuffer(0,ManyLine);
   SetIndexBuffer(1,EmptyLine);
   SetIndexBuffer(2,LineMinBuffer); 
   SetIndexBuffer(3,MaBuffer);
   //SetIndexBuffer(3,biaojiLine);
   SetIndexBuffer(4,HighLine); 
   SetIndexBuffer(5,LowLine);

   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
//---- name for DataWindow and indicator subwindow label
   short_name="DX_多空x";
   
   IndicatorShortName(short_name);
   
//----
   SetIndexDrawBegin(0,PeriodWATR);
   SetIndexDrawBegin(1,PeriodWATR);
   SetIndexDrawBegin(2,PeriodWATR);
   SetIndexDrawBegin(3,PeriodWATR);
//----
   return(0);
  }

//+------------------------------------------------------------------+
//| StepMA_3D_v1                                                         |
//+------------------------------------------------------------------+
int start()
  {
   int      shift,TrendMin;
   double   SminMin0,SmaxMin0,SminMin1,SmaxMin1;
   
   for(shift=Bars-1;shift>=0;shift--)
   {
 if (HighLow ==1)
 {
     MaBuffer[shift]= iMA(NULL,0,ma01,NULL,MODE_LWMA,PRICE_WEIGHTED,shift);  
 SmaxMin0= MaBuffer[shift]+2*StepSizeMin*Point;
 SminMin0= MaBuffer[shift]-2*StepSizeMin*Point;
 
 if( MaBuffer[shift]<SmaxMin3) TrendMin=1; 
 if( MaBuffer[shift]>SminMin3) TrendMin=-1;  
 }

 if(TrendMin>0 && SminMin0<SminMin1) SminMin0=SminMin1;
 if(TrendMin<0 && SmaxMin0>SmaxMin1) SmaxMin0=SmaxMin1; 
 
 if (TrendMin>0) LineMinBuffer[shift]=SminMin0+StepSizeMin*Point;
 if (TrendMin<0) LineMinBuffer[shift]=SmaxMin0-StepSizeMin*Point;  
 
 SminMin1=SminMin0;
 SmaxMin1=SmaxMin0;
 
 if(LineMinBuffer[shift]>LineMinBuffer[shift+1])
 {
    //黄线上升
    if(LineMinBuffer[shift+1]>LineMinBuffer[shift+2])
    {
       //一直上升中
       ManyLine[shift]=ManyLine[shift+1];
       //biaojiLine[shift]=LineMinBuffer[shift];
    }
    else
    {
       if(LineMinBuffer[shift+1]==LineMinBuffer[shift+2])
       {
          if(ManyLine[shift+1]==LineMinBuffer[shift+1])
          {
             //刚开始上升
             ManyLine[shift]=LineMinBuffer[shift+1];
             //biaojiLine[shift]=LineMinBuffer[shift]+1;
          }
          else
          {
             //一直上升中
             ManyLine[shift]=ManyLine[shift+1];
             //biaojiLine[shift]=LineMinBuffer[shift];
          }
       }
    }
    EmptyLine[shift]=LineMinBuffer[shift];
 }
 else
 {
    if(LineMinBuffer[shift]<LineMinBuffer[shift+1])
    {
       //黄线下降
       if(LineMinBuffer[shift+1]<LineMinBuffer[shift+2])
       {
          //一直下降中
          EmptyLine[shift]=EmptyLine[shift+1];
          //biaojiLine[shift]=LineMinBuffer[shift];
       }
       else
       {
          if(LineMinBuffer[shift+1]==LineMinBuffer[shift+2])
          {
             
             if(EmptyLine[shift+1]==LineMinBuffer[shift+1])
             {
                //刚开始下降
                EmptyLine[shift]=LineMinBuffer[shift+1];
                //biaojiLine[shift]=LineMinBuffer[shift]-1;
             }
             else
             {
                //一直下降中
                EmptyLine[shift]=EmptyLine[shift+1];
                //biaojiLine[shift]=LineMinBuffer[shift];
             }
          }
       }
       ManyLine[shift]=LineMinBuffer[shift];
    }
    else
    {
       //黄线保持水平
       if(ManyLine[shift+1]==LineMinBuffer[shift+1])
       {
          //最小值与黄线重合,继续保持最小值与黄线重合,最大值不变
          ManyLine[shift]=LineMinBuffer[shift];
          EmptyLine[shift]=EmptyLine[shift+1];
          //biaojiLine[shift]=LineMinBuffer[shift];
       }
       else
       {
          if(EmptyLine[shift+1]==LineMinBuffer[shift+1])
          {
             //最大值与黄线重合,继续保持最大值与黄线重合,最小值不变
             EmptyLine[shift]=LineMinBuffer[shift];
             ManyLine[shift]=ManyLine[shift+1];
             //biaojiLine[shift]=LineMinBuffer[shift];
          }
       }
    }
 }
             HighLine[shift]=ManyLine[shift]+StepSizeMin*Point;
             LowLine[shift] =EmptyLine[shift]-StepSizeMin*Point;
 
}
return(0);
 }


--  作者:jinzhe
--  发布时间:2016/8/9 9:22:34
--  

能否逐一注释一下,

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


--  作者:pretty12315
--  发布时间:2016/8/9 10:07:32
--  
现在用在外汇上。准备把它用于 国内期货交易。先根据图形颜色,做手动交易。条件合适,就做成全自动程序化。
--  作者:jinzhe
--  发布时间:2016/8/9 10:18:54
--  
以下是引用jinzhe在2016-8-9 9:22:34的发言:

能否逐一注释一下,

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

需要代码的注释,谢谢


--  作者:syb319
--  发布时间:2016/8/28 10:47:23
--  
看看是什么