以文本方式查看主题 - 金字塔客服中心 - 专业程序化交易软件提供商 (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=166014) |
-- 作者:FEITAO8848 -- 发布时间:2018/10/22 17:28:08 -- 请教老师,这个海龟策略怎么通不过 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 -- 发布时间:2018/10/22 20:13:48 -- 这段代码是你自己写的?错误百出。很多地方缺少分号,,并且很多变量未定义以及语句部分语句不知何意等。建议你根据报错提示,逐步修改自己的策略。 Input:riskratio(1,0,2,1);//少分号 Input:atrlength(20,5,30,5); Entryupperband:=ref(hhv(high, entryperiod),1),1+mindff;//???????? |