以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  [求助]mt4指标,公式里的x值怎么改,谢谢  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=62835)

--  作者:banker2882
--  发布时间:2014/3/19 9:08:20
--  [求助]mt4指标,公式里的x值怎么改,谢谢
//+------------------------------------------------------------------+
//|                                                         1111.mq4 |
//|                       Copyright ?2011, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2011, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_separate_window

#property indicator_buffers 1
#property indicator_color1 Red

extern int MaxPer = 500;     //Maximal period analysed
extern int MinPer = 1;        //Minimal period analysed
extern int bar2update = 1;    //Nombre de barres entre chaque update

double FlatBuf[];  //Flattened close price buffer

int LastUpdate=0;
string ShName="";

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,FlatBuf);
   //Correct if needed MinPer and MaxPer
  if(MinPer<2) MinPer=2;
  if(MaxPer<MinPer) MaxPer=MinPer;
  //Correct if needed Bar2Update
  if(bar2update<0) bar2update=1;



//---- name for DataWindow and indicator subwindow label
   ShName=" 1111("+MinPer+" to "+MaxPer+" Periods)";
   IndicatorShortName(ShName);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
    
   //Check Enough Bars
   if(Bars<3*MaxPer)
   {
      Print(" Not Enough bars! - you need 3*MaxPer -> " + DoubleToStr(3*MaxPer,0));
      return(0);
   }
   else
      IndicatorShortName(ShName);
   
   //Check bar2update
   if(bar2update<1) bar2update=1;
   //Check Update needed
   if(Time[0]-LastUpdate>=bar2update*Period()*60)
   {
      LastUpdate=Time[0];
      
      //--- Call main function
      ComputeIt(1);
   }   
      
      
//----
   return(0);
  }
//+------------------------------------------------------------------+
int ComputeIt(int x)
{
   int i;
   int k;
   double a;
   double b;
   //---- Set flatBuf to 0
   for(i=0;i<=3*MaxPer+2;i++)
   {
      FlatBuf=0;
   }
   
   //Calculate flattened price
   a=Close[x+3*MaxPer-1];
   b=(Close[x]-a)/(x+3*MaxPer-2);      
   for(i=3*MaxPer;i>=1;i--)
      FlatBuf=Close[x+i-1]-(a+b*(3*MaxPer-i));
   return(0);
}

公式里的x值是什么  红色部分

--  作者:jinzhe
--  发布时间:2014/3/19 9:27:56
--  

你这个怎么着也得发到MT4论坛吧?


--  作者:banker2882
--  发布时间:2014/3/19 11:29:57
--  [求助]mt4指标,公式里的x值怎么改,谢谢
主要是我想改成金字塔指标,x那不知道如何改
--  作者:jinzhe
--  发布时间:2014/3/19 13:10:10
--  
所以说你发到MT4论坛让人给你解释一下。。。你只发代码不发解释我们也看不懂。。。