递归函数问题
正在学习用户函数的编写,想写一个指数平滑移动平均线,需要用到递归函数,我写得程序如下,保存为EMA,但编译没有通过,提示“被调用函数的序列参数不能使用默认值”。但我不知错在哪儿,该怎么改,请老师指教://------------------------------------------------------------------------
// 简称: EMA
// 名称: 指数平滑移动平均线
// 类别: 用户函数
// 类型: 用户函数
// 输出: 数值型
//------------------------------------------------------------------------
Params
NumericSeries Length(1);
Vars
Numeric CurrentValue;
Begin
If (CurrentBar == 0) {
CurrentValue = Close;
} Else {
CurrentValue = (Close*2 + EMA*(Length-1))/(Length+1);
}
Return CurrentValue;
End
找到问题所在了,对于参数Length的声明要用Numeric而不可以是NumericSeries。
页:
[1]