请教:iMAOnArray()函数的使用

 

double iMAOnArray( double array[], int total, int period, int ma_shift, int ma_method, int shift)

Calculation of the Moving Average on data stored in a numeric array. Unlike iMA(...), the iMAOnArray function does not take data by symbol name, timeframe, the applied price. The price data must be previously prepared. The indicator is calculated from left to right. To access to the array elements as to a series array (i.e., from right to left), one has to use the ArraySetAsSeries function.

array[] - Array with data.
total - The number of items to be counted. 0 means whole array.
period - Averaging period for calculation.
ma_shift - MA shift
ma_method - MA method. It can be any of the Moving Average method enumeration value.
shift - Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago).

翻译大意:

对存储在数组中的数进行移动平均计算。 与iMA()函数不同的是,iMAOnArray 不是按照货币名称,K线周期,应用的价格来 获取数据。 参与计算的价格数据必须事先准备好。

这个指标是按照从左到右计算。为了像序列数组那样(如从右到左)获取数组元素,你必须使用ArraySetAsSeries函数

1)要使用iMAOnArray 函数,参加计算的数组必须是 序列数组(Series Array:其索引是与时间有对应关系的),是这样的必须是序列数组吗?

用于用户自定义数组如MyMacd[200],其元素与时间没有对应关系,所以必须使用ArraySetAsSeries(MyMacd,true) 来使之与时间对应。

所有参与iXXXXOnArray计算的数组都必须是序列数组,对吗?

2) The indicator is calculated from left to right,这里说是从左到右计算,即从过去到现在。 可是见过很多语句, 在使用iMA 或者iMAOnArray 函数 的for 语句时候是这样的:

for(i=0;i<=limit;i++){...}

这显然是从现在计算到过去,矛盾?

 

建议先分清什么是 排列方向(顺序), 什么是计算方向. 什么时候计算方向是无关因素

实际上没限制强迫什么, 关键是准备如何准备和使用....数组

ArraySetAsSeries(MyMacd,true) 是设置排列方向的.

这也怪MT, 不该为了定义时间习惯,又要迁就C习惯,弄出两个排列方向, 如果默认只有一个排列方向就没问题了.

 

谢谢DxdCn先生的解答!

如果跟时间扯上关系,就得用ArraySetAsSeries(MyMacd,true) 设置排列方向的来计算

如果跟时间没有关系,也就是排列方向没有关系的话,喜欢用什么方向计算都是可以的。

原因: