老师好,下面是期指1分钟交易代码范本,我想在1分钟K线图上分别画出固定止损线和移动止损线,请问代码怎么实现,谢谢:
//中间变量
variable:highprice=0;
win1:=0;
win2:=0;
//交易条件
kd:=kd1 and kd2;
pd:=pd1 and pd2 ;
//交易系统
if kd then begin
sellshort(1,0,limitr,c);
buy(holding=0,1,limitr,c);
highprice:=enterprice;
zs:=enterprice-10;//10点固定止损
end
if enterprice-c>=10 then 多损:sell(holding>0,0,limitr,zs);
if holding>0 then begin
if c>highprice then highprice:=c;
win1:=(c-enterprice)/enterprice*100;
win2:=(highprice-c)/(highprice-enterprice)*100;
if win1>0 and win1<=0.88 and win2>40 then begin
多回:sell(1,0,limitr,highprice-(highprice-enterprice)*0.4);
end
if win1>0.88 and win2>20 then begin
多赢:sell(1,0,limitr,highprice-(highprice-enterprice)*0.2);
end
end
drawsl(islastbar,enterprice-10,0,0,2) ;//固定
drawsl(win1>0 and win1<=0.88 and win2>40 and islastbar ,c,0,0,2) ;//移动
drawsl(win1>0.88 and win2>20 and islastbar ,c,0,0,2) ;//移动
drawsl(islastbar and holding>0,enterprice-10,0,0,2) ;//固定
drawsl(islastbar and holding>0,highprice-(highprice-enterprice)*0.4,0,0,2) ;//移动
drawsl(islastbar and holding>0 ,highprice-(highprice-enterprice)*0.2,0,0,2) ;//移动
是不是这样的?-------仍然没有显示内容呀:
//中间变量
variable:highprice=0;
win1:=0;
win2:=0;
//交易条件
ma5:=ma(c,5);
ma30:=ma(c,30);
kd:=cross(ma5,ma30);
pd:=cross(ma30,ma5);
//交易系统
if kd then begin
sellshort(1,0,limitr,c);
buy(holding=0,1,limitr,c);
highprice:=enterprice;
zs:=enterprice-10;//10点固定止损
drawsl(islastbar and holding>0,c,0,0,2) ;//固定
end
if enterprice-c>=10 then 多损:sell(holding>0,0,limitr,zs);
if holding>0 then begin
if c>highprice then highprice:=c;
win1:=(c-enterprice)/enterprice*100;
win2:=(highprice-c)/(highprice-enterprice)*100;
if win1>0 and win1<=0.88 and win2>40 then begin
drawsl(islastbar and holding>0,highprice-(highprice-enterprice)*0.4,0,0,2) ;//移动
多回:sell(1,0,limitr,highprice-(highprice-enterprice)*0.4);
end
if win1>0.88 and win2>20 then begin
drawsl(islastbar and holding>0 ,highprice-(highprice-enterprice)*0.2,0,0,2) ;//移动
多赢:sell(1,0,limitr,highprice-(highprice-enterprice)*0.2);
end
end