--
Input:
Money(10,1,100,1),//参与资金,以万为单位。
N1(5,1,20,1),
N2(20,5,60,1),
N3(60,20,100,1); //缺省值,最小值,最大值,步长
VARIABLE:lots=0;
half:(high+low+close)/3,ColorYellow;//中值。
//ma1:ma(c,n2);
ma2:ema(c,n2),ColorMagenta;
ma3:ema(c,n3),ColorGreen;
//基础策略
//ma2趋势向上。优先做这种
b1:ma2>ref(ma2,1),NoDraw;
//low靠近ma2,但收在ma2的0.98上。
b2:llv(l,3)<ma2*1.03 and llv(c,2)>ma2*0.98,NoDraw;
//昨日收阳,今日的中值位置买入。
b3:ref(c,1)>ref(c,2),Nodraw;
buyt:b1 and b2 and b3,NoDraw;
s1:c<ma2,NODRAW;
buyprice:=ref(half,1);
lots:=intpart(money*100/buyprice);
if holding=0 and buyt then BUY(1 ,lots,limitr ,buyprice);
if holding>0 and s1 then sell(1,0,THISCLOSE);