发表于:2005-06-02 01:24只看该作者
2楼
UserFunction(name,param1,param2,...)
name: user function name
param1: fisrt numeric parameter (if needed)
...: other numeric parameters (if needed)
如:
UserFunction("SampleFunc", High, Low);
3楼
谢谢,这我知道,
但samplefunc的编写格式,你有吗?
4楼
顶一下,
5楼
顶二下
发表于:2005-06-02 02:23只看该作者
6楼
写了一个判断两条均线是否下穿的例子,调用时应该是
UserFunction("isDownCross",shortSupportPeriod,midSupportPeriod,1,1);
或者
UserFunction("isDownCross");
/*[[
Name := isDownCross
Author := Copyright ?2005, MetaQuotes Software Corp.
Link := http://www.metaquotes.net/
]]*/
/**************
maPeriod1下穿maPeriod2
needSameTrend:是否需要maPeriod2也向下
***************/
Input: maPeriod1(15),maPeriod2(45),shiftBars(1),needSameTrend(0);
Arrays:maValues1[3](0),maValues2[3](0);
Var:maxBars(5);
Var:MAType(0); //均线类型:简单
If(Bars<(maPeriod2+shiftBars+3)) Then Return(False);
maValues1[1] = iMA(maPeriod1,MAType,shiftBars);
maValues1[2] = iMA(maPeriod1,MAType,shiftBars+1);
maValues2[1] = iMA(maPeriod2,MAType,shiftBars);
maValues2[2] = iMA(maPeriod2,MAType,shiftBars+1);
if(maValues1[1]>=maValues1[2]) then return(false);
If(needSameTrend==1 & maValues2[1]>maValues2[2]) Then Return(False);
If(maValues1[1]=maValues2[2]) Then Return (True);
Return (False);