老师,帮帮忙编写一下股指模型
加载到5分钟K线图上
当时间小于101500,当天无交易时,K线上穿20均线,做多。止损5个点,第二根5分钟K线结束时亏损则止损出场,若为盈利则止损任为5个点,走出7个点后保本止损,止盈点设在最近两根连续阳线中的最低点。
当时间小于101500,当天无交易时,K线下穿20均线,做空。止损5个点,第二根5分钟K线结束时亏损则止损出场,若为盈利则止损设为5个点,走出7个点后保本止损,止盈点设在最近两根连续阴线中的最高点。
当时间大于101500,模型今天无交易时,当天放弃交易。
当时间小于144500,模型入场做多一次出场后,破当天最高点继续做多一次,止损5个点,第二根5分钟K线结束时亏损则出场,若为盈利则止损任为5个点,走出7个点保本止损,否则拿到当天收盘。
当时间小于144500,模型入场做空一次出场后,破当天最低点继续做空一次,止损5个点,第二根5分钟K线结束时亏损则出场,若为盈利则止损任为5个点,走出7个点保本止损,否则拿到当天收盘。
具体限制,每天最多交易两次,若1小时内无交易则当天不做,止损最多5个点,第2跟K线结束时若亏损则止损,若2跟K线内最大盈利为7点,则保本止损,两根K线后最大盈利为7点,也是保本位止损。最后5分钟平仓。
首先先谢谢金字塔的各位老师了。万分感谢
VARIABLE:n=0,a=0;
VARIABLE:m=0,b=0;
l2:=valuewhen(c>o and ref(c>o,1),llv(l,2));
h2:=valuewhen(c<o and ref(c<o,1),hhv(h,2));
buycond:= time <101500 and n=0 and cross(c,ma(c,20));
sellcond:=time <101500 and m=0 and cross(ma(c,20),c);
if buycond then BEGIN
buy(holding=0,1,market);
n:=1;
a:=h;
end
if ref(buycond,1) and holding>0 and c-enterprice<0 then sell(holding>0,0,market);
if enterbars>1 and enterprice-c>5*mindiff then sell(holding>0,0,market);
if h>a then a:=h;
if a-c>7*mindiff then sell(holding>0,0,limitr,l2);
if sellcond then BEGIN
buyshort(holding=0,1,market);
m:=1;
b:=l;
end
if ref(sellcond,1) and holding<0 and enterprice-c<0 then sellshort(holding<0,0,market);
if enterbars>1 and c-enterprice>5*mindiff then sellshort(holding<0,0,market);
if l<b then b:=l;
if close-b>7*mindiff then sellshort(holding>0,0,limitr,h2);
先写了前面的10点15的条件,14点45的条件和上面的类似,都是全局变量记录次数和记录最高最低价,楼主试着自己写一下