以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  如何在K线上画出移动止损线  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=75043)

--  作者:zsg465341578
--  发布时间:2015/1/27 15:16:39
--  如何在K线上画出移动止损线

老师好,下面是期指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


--  作者:jinzhe
--  发布时间:2015/1/27 15:23:39
--  
drawsl(islastbar,enterprice-10,0,0,2)
--  作者:zsg465341578
--  发布时间:2015/1/27 16:12:41
--  
老师,我只想在有持仓的时候显示止损线!另外一条移动止损线怎么画?
--  作者:jinzhe
--  发布时间:2015/1/27 16:21:33
--  
有何需求请全部写出来
--  作者:zsg465341578
--  发布时间:2015/1/27 16:26:07
--  
老师,在上述代码中,我想在有持仓的时候分别显示固定止损和移动止损线和相应的点位,谢谢!
--  作者:pyd
--  发布时间:2015/1/27 16:43:15
--  

 

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) ;//移动

[此贴子已经被作者于2015/1/27 17:09:10编辑过]

--  作者:zsg465341578
--  发布时间:2015/1/27 16:57:33
--  
图上没有任何显示
--  作者:pyd
--  发布时间:2015/1/27 17:05:35
--  

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) ;//移动

[此贴子已经被作者于2015/1/27 17:08:50编辑过]

--  作者:zsg465341578
--  发布时间:2015/1/27 17:10:42
--  

是不是这样的?-------仍然没有显示内容呀:

 

//中间变量
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


--  作者:jinzhe
--  发布时间:2015/1/27 17:14:53
--  
3个画图语句写最后不要加在任何的IF BEGIN END里面