以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://222.73.7.161/bbs/index.asp)
--  公式模型编写问题提交  (http://222.73.7.161/bbs/list.asp?boardid=4)
----  请教平台突破下单交易系统问题  (http://222.73.7.161/bbs/dispbbs.asp?boardid=4&id=7062)

--  作者:brighyel
--  发布时间:2011/7/1 14:32:48
--  请教平台突破下单交易系统问题

编了一个平台突破下单的简单交易系统

 

1、设置一个区间,ceilprice为上轨,floorprice为下轨,突破上轨买入2手,突破下轨卖出2手

2、设置止损为loss,如果浮赢达到一定数额(loss+fee)平掉1手,剩下1手追踪止赢,梯度为dispoint

 

好像无法实现下单功能,不知道是啥原因,代码如下

 

 input:ceilprice(6788,3000,9000),floorprice(6781,3000,9000),loss(12,0,100),num(2,2,100),dispoint(12,2,600),fee(20,0,60);

       variable:longfuying=0,shortfuying=0,longyk=0,shortyk=0;

      //第一步,设置上下价,num=2
      IF holding=0 then
      begin
      longfuying:= 0;
      shortfuying:=0;
      longchase:=0;
      shortchase:=0;
      longyk:=0;
      shortyk:=0;
      BUY(holding=0,num,STOP,ceilprice);//市价超过上限时买入
      BUYSHORT(holding=0,num,STOP,floorprice);//市价低于下限时沽出
      end     
     
      //第二步,设止损,设初步止盈
      IF ABS(holding)=num then
      begin        
      SELL(holding>0,holding,STOPR,ENTERPRICE-loss);
      SELLSHORT(holding<0,holding,STOPR,ENTERPRICE+loss);
      SELL(holding > 0,num*0.5,LIMITR,ENTERPRICE+loss+fee);
      SELLSHORT(holding < 0,num*0.5,LIMITR,ENTERPRICE-loss-fee);                  
      end
     
       //第三步,跟踪止损 
     longyk:=HHV(H,ENTERBARS)-enterprice-fee;
     shortyk:=enterprice-LLV(L,ENTERBARS)-fee;
       if holding>0 then //持仓为多单时
        if longyk>0 then
           begin
                longfuying:=longyk;
                longchase:=longfuying-mod(longfuying,dispoint)+enterprice-loss;
           end
        else
           begin
           longfuying:=0;
           longchase:=enterprice-loss;
           end
          
       if holding <0  then//持仓为空单时
         if shortyk>0 then
           begin
               
                shortfuying:=shortyk;
                shortchase:=enterprice+loss-(shortfuying-mod(longfuying,dispoint));
           end
         else
           begin
           shortfuying:=0;
           shortchase:=enterprice+loss;
           end
          
      
      IF ABS(holding)=num*0.5 then
      begin
      SELL(holding>0,holding,STOPR,longchase);
      SELLSHORT(holding<0,holding,STOPR,shortchase);
      end
  


--  作者:fly
--  发布时间:2011/7/1 15:04:40
--  

BUY(holding=0,num,STOP,ceilprice);//市价超过上限时买入
BUYSHORT(holding=0,num,STOP,floorprice);//市价低于下限时沽出
类似的语句,不妨改成,

BUY(c>ceilprice and holding=0,num,thisclose);//市价超过上限时买入
BUYSHORT(c<floorprice and holding=0,num,thisclose);//市价低于下限时沽出

 

推荐您,先把1手的固定止损和固定止盈先写好.下单什么的都通过了

然后再转成1手固定止损和1手移动止盈.

[此贴子已经被作者于2011-7-1 15:11:10编辑过]

--  作者:wzywzy292
--  发布时间:2011/7/6 21:11:21
--  
 学习