欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件策略编写求助区 → 求助

   

欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。    


  共有17849人关注过本帖平板打印复制链接

主题:求助

帅哥哟,离线,有人找我吗?
guotx2010
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:蜘蛛侠 帖子:1366 积分:5210 威望:0 精华:7 注册:2010/12/11 18:00:33
  发帖心情 Post By:2011/4/13 9:44:45 [只看该作者]

首先在公式系统建立一个多空趋势的公式:

 

J:MA(C,5)>LLV(L,5),linethick0;     //J>0为多头
D:MA(C,5)<HHV(H,5),linethick0;   //D>0为空头

 

然后建立策略:

DuoTou:=Stkindi(stklabel(),'MA5DuoKong.J',0,6,0);    //日线多头趋势
KongTou:=Stkindi(stklabel(),'MA5DuoKong.D',0,6,0);   //日线空头趋势
Buy1:=MA(C,5)>LLV(L,5) And DuoTou>0;
BuyP:=MA(C,5)<HHV(H,5);
Sell1:=MA(C,5)<HHV(H,5) And KongTou>0;
SellP:=MA(C,5)>LLV(L,5);

//使用系列模式时
//{平多}EXITLONG:BuyP,TFILTER;
//{开空}ENTERSHORT:Sell1,TFILTER;
//
//{平空}EXITSHORT:SellP ,TFILTER;
//{开多} ENTERLONG:Buy1,TFILTER;

//使用逐K线模式时
variable:DuoKong=1;
OrdVol:=1;     {开仓手数}
ZsDs:=10;     {止损点数}
//以下变量用于移动止盈,,移动止盈只能保证你尽可能稳健盈利,却不能保证盈利最大化,如果不想使用,可是将总开关设置为0
YdZy:=0,linethick0;   {移动止盈总开关,1为开,0为关}
variable:HighPrice=0,LowPrice=0; {保存开仓后的最高价、最低价}
variable:DHcDs=3,KHcDs=3;   {多、空单回撤点数}
variable:DYlDs=7,KYlDs=7;   {多、空单盈利点数,当盈利点数达到这个标准后,如果回撤达到上面的参数值就平仓}
variable:Z3B1=0;     {赚3保1开关}
variable:MaxProfit=0,CurrentProfit=0; {最大盈利、当前盈利}


//持有空单
If Holding<0 then Begin
 If SellP And Enterbars>=2 then begin   //平空单
  空平:SellShort(1,0,mkt),orderqueue;
 End
 
 //止损
 If C-Enterprice>=ZsDs then begin
  空损:SellShort(1,0,mkt),orderqueue;
 End
 
 //移动止盈
 If YdZy=1 then begin
  //每周期判断是否创新低
  If L<LowPrice then begin
   LowPrice:=L;
  End
  //如果盈利超过10点之后回撤达到3点,就平仓,保住盈利
  If Enterprice-LowPrice>=KYlDs then begin
   If L-LowPrice>=KHcDs Then Begin  //回撤超过3点
    空赢:SellShort(1,0,market);
   End
  End
 End
 
 //赚3保1
 If Z3B1=1 then begin
  If Enterprice-LowPrice>=3 then begin
   If Enterprice-L<=1.2 then begin
    空保:SellShort(1,0,market);
   End
  End
 End
End

//开多单
If holding=0 then begin
 If DuoKong=1 Or DuoKong=2 then begin
  If Buy1 then begin
   多开:Buy(1,ordVol,mkt);
   HighPrice:=Enterprice;  //将开仓价保存到最高价
  End
 End
end

//持有多单
If Holding>0 then Begin
 If BuyP And Enterbars>=2 then begin  {平多单}
  多平:Sell(1,0,mkt),orderqueue;
 End
 
 //多单管理
 //止损
 If Enterprice-C>=ZsDs then begin
  多损:Sell(1,0,mkt),orderqueue;
 End

 //移动止盈
 If YdZy=1 then begin
  //每周期判断是否创新高
  If H>HighPrice then begin
   HighPrice:=H;
  End
 
//如果盈利超过10点之后回撤达到3点,就平仓,保住盈利
  If HighPrice-Enterprice>=DYlDs then begin
   If HighPrice-H>=DHcDs Then Begin  //回撤超过3点
    多赢:Sell(1,0,market);
   End
  End
 End

 //赚3保1
 If Z3B1=1 then begin
  If HighPrice-Enterprice>=3 then begin
   If H-Enterprice<=1.2 then begin
    多保:Sell(1,0,market);
   End
  End
 End
End

//开空单
If holding=0 then begin
 If DuoKong=1 Or DuoKong=3 then begin
  If Sell1 then begin
   空开:BuyShort(1,ordVol,mkt);
   LowPrice:=enterprice;
  End
 End
end

最低价:LowPrice,linethick0;
最高价:HighPrice,linethick0;
开仓价:Enterprice,noaxis,linethick0;
持仓:Holding,linethick0;

//收益:asset,noaxis,colorred;
//次数:totaltrade,linethick0;
//胜率:percentwin,linethick0;
//连亏:maxseqloss,linethick0;
//连赢:maxseqwin,linethick0;

 

 

 

 


 回到顶部
总数 45 1 2 3 4 5 下一页