close

 

MA1[i] = iMA(NULL, 0, 5, 0, 1, PRICE_CLOSE, i);
MA2[i] = iMA(NULL, 0, 10, 0, 1, PRICE_CLOSE, i);
MA3[i] = (MA1[i]+MA2[i])/2;

如果這樣寫, MA3裡包含了MA1[]&MA2[]兩個Array
編程不會顯示錯誤, 但是MA3會跑不出來;
改成下面的寫法就可以了

double mm =iMA(NULL, 0, 5, 0, 1, PRICE_CLOSE, i);
double kk =iMA(NULL, 0, 10, 0, 1, PRICE_CLOSE, i);
MA1[i] = mm;
MA2[i] = kk;
MA3[i] = (mm + kk)/2;

或是

MA1[i] = iMA(NULL, 0, 5, 0, 1, PRICE_CLOSE, i);
MA2[i] = iMA(NULL, 0, 10, 0, 1, PRICE_CLOSE, i);
MA3[i] = (iMA(NULL, 0, 5, 0, 1, PRICE_CLOSE, i)+ iMA(NULL, 0, 10, 0, 1, PRICE_CLOSE, i))/2;


arrow
arrow
    全站熱搜
    創作者介紹
    創作者 Robin0320 的頭像
    Robin0320

    縫隙中求生存 Life in GAP

    Robin0320 發表在 痞客邦 留言(0) 人氣()