萌新求助,最简单的5日移动均线如何编写?mql4

 
如题。
 
Wqthex:
如题。

iMA(NULL,0,5,0,MODE_SMA,PRICE_MEDIAN,i);

 
Lin Luo:

iMA(NULL,0,5,0,MODE_SMA,PRICE_MEDIAN,i);

新建了个指标后自带了这么多东西,完全不知道应该写在哪里,一脸懵,请大佬赐教



input int      均线周期=5;

//--- indicator buffers
double         MABuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,MABuffer);
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---

//--- return value of prev_calculated for next call
   return(rates_total);
  }