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


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → 请教老师,这个海龟策略怎么通不过

   

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


  共有2276人关注过本帖树形打印复制链接

主题:请教老师,这个海龟策略怎么通不过

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


加好友 发短信
等级:新手上路 帖子:15 积分:0 威望:0 精华:0 注册:2017/8/19 17:32:20
请教老师,这个海龟策略怎么通不过  发帖心情 Post By:2018/10/22 17:28:08    Post IP:14.204.68.27[只看该作者]

Runmade:0;

Input:riskratio(1,0,2,1)
Input:atrlength(20,5,30,5);
Input:entryperiod(20,5,60,5);
Input:exitperiod(10,5,60,5);

Variable:times=0;

atr:=ref(ma(tr,atrlength),1);
Marginratio:=10/100;

Entryupperband:=ref(hhv(high, entryperiod),1),1+mindff;
Entrylowerband:=ref(llv(low, entryperiod),1)-mindff;

Exitupperband=ref(hhv (high, entryperiod),1)+mindff;
Exitlowerband:=ref(llv(low, entryperiod),1)-mindff;

Entrylongcond:= high>=entryupperband;
Entryshortcond:= low>=entrylowerband;

Exitlongcond:= low<= eixtlowerband;
Exitshortcond:= high<= eixtupperband;

If holding=0 then begin
    Price:=0;
    Lots:=0;

    If entrylongcond then
         Price:=max(open, entryupperband);
         
    If price>0 then begin
         Mycash:=cash(0);

           Lots1:=intpart(mycash/(price*multiplier*marginratio));
           Lots2:=intpart((mycash*riskratio/100)/(atr*multiplier));
           Lots:=max(1,min(Lots1, Lots2));
    end
    
    If lots>=1 then begin
       Buy(1,lots,limitr,price);
       times=1;
    end
end

If holding>0 then begin
    While high>=enterprice+atr/2 and times<4 do begin
       Price:=max(open,enterprice+atr/2);
       Lots:=0;

        If price>0 then begin
           mycash:=cash(0);
           
           Lots1:=intpart(mycash/(price*multiplier*marginratio));
           Lots2:=intpart((mycash*riskratio/100)/(atr*multiplier));
           Lots:=max(1,min(Lots1, Lots2));
         end
        
         if lots>=1 then begin
            buy(1,lots,limitr,price);
            times=times+1;
         end
    end
end
    
If holding=0 then begin
   Price:=0;
   Lots:=0;

   If entrylongcond then
      price:=min(open,entrylowerband);

   If Price>0 then begin
      mycash:=cash(0);
      
      Lots1:=intpart(mycash/(price*multiplier*marginratio));
      Lots2:=intpart((mycash*riskratio/100)/(atr*multiplier));
      Lots:=max(1,min(Lots1, Lots2));
   end

   If lots>=1 then begin
       buyshort(1,lots,limitr,price);
       times:=1;
   end
end

If holding<0 then begin
    While low<=enterprice-atr/2 and times<4 do begin
          price:=min(open,enterprice-atr/2);
          Lots:=0;

          If Price>0 then begin
          Mycash:=cash(0);
          
          Lots1:=intpart(mycash/(price*multiplier*marginratio));
          Lots2:=intpart((mycash*riskratio/100)/(atr*multiplier));
          Lots:=max(1,min(Lots1, Lots2));
      end

      If lots>=1 then begin
         buyshort(1,lots,limitr,price);
          times=times+1;
         end
    end
end
    
    
If holding>0 then begin
     Price: =0

   If entrylongcond then
       Price:=min(open,exitlowerband);

   If low<=enterprice-2*art and enterbars>=1 then 
       Price:=min(open,enterprice-2*atr);

   If price>0 then 
       Sell(1,holding,limitr,price);
end

If holding<0 then begin
   Price: =0

   If exitshortcond then
       Price:=max(open,exitupperband);

   If high>= enterprice+2*art and enterbars>=1 then 
       Price:=max(open,enterprice+2*atr);

   If Price>0 then
       Sellshort(1,holdine,limitr,price);
end

盈亏:Asset-500000,noaxis,colorred,linethick2;



 回到顶部
帅哥哟,离线,有人找我吗?
wenarm
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:管理员 帖子:26632 积分:0 威望:0 精华:7 注册:2015/4/9 14:59:07
  发帖心情 Post By:2018/10/22 20:13:48    Post IP:180.158.226.127[只看该作者]

这段代码是你自己写的?错误百出。很多地方缺少分号,,并且很多变量未定义以及语句部分语句不知何意等。建议你根据报错提示,逐步修改自己的策略。
Input:riskratio(1,0,2,1);//少分号
Input:atrlength(20,5,30,5);


Entryupperband:=ref(hhv(high, entryperiod),1),1+mindff;//????????




编程无捷径,技巧靠积累。
 回到顶部