请问mt5中如何获取倒数第10根K线均线的值?

 

问个问题mt5中如何获取倒数第10根K线均线的值
mt4中 iMa = iMA(symbol, period, Ma, 0, MODE_SMA, PRICE_CLOSE, i);
mt5 怎么办,这个i没了,怎么获取i的值

请提供一下脚本代码,谢谢!

 

先定义Ma()函数:

//Ma()

double Ma(string Symbol,ENUM_TIMEFRAMES period,int n,int index)
  {
   double buf[];
   ArraySetAsSeries(buf,true);
   int a=iMA(Symbol,period,n,0,MODE_SMA,PRICE_CLOSE);
   int copied=CopyBuffer(a,0,0,index+1,buf);
   return(buf[index]);

  }


然后调用:

最后一根K线的均线值:

ma =Ma(symbol, period,ma,0);


倒数第10根K线均线的值 :

ref10_ma =Ma(symbol, period,ma,10);

 
非常感谢!我擅长MQL4方面的问题,或者与MQL5通用的部分,有问题可以问我