以文本方式查看主题 - 金字塔客服中心 - 专业程序化交易软件提供商 (http://weistock.com/bbs/index.asp) -- 公式模型编写问题提交 (http://weistock.com/bbs/list.asp?boardid=4) ---- 请教如下程序如何做到连亏两次则开反手仓 (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=80000) |
-- 作者:panjia1000 -- 发布时间:2015/6/20 16:11:01 -- 请教如下程序如何做到连亏两次则开反手仓 variable:HigherAfterEntry=0,LowerAfterEntry=999999; input:n1(1,1,3,1); input:n2(14,5,40,1); input:n3(95,50,100,1); MA5: MA(CLOSE,5); MA10:MA(CLOSE,10); MA20:MA(CLOSE,20); avvol:ma(ref(vol,2),5),noaxis,linethick0; dayopen:=valuewhen(date<>ref(date,1),open); if date<>ref(date,1) then begin loss:=0; count1:=1; end 计数一:=count1,noaxis,linethick0; 计数二:=loss,noaxis,linethick0; h_1:=ref(h,1); l_1:=ref(l,1); lots:=1; If enterbars=0 then
begin
HigherAfterEntry:=enterprice;
LowerAfterEntry:=enterprice;
end; else If enterbars>=1 then
begin
HigherAfterEntry:=max(HigherAfterEntry,h_1);
LowerAfterEntry:=min(LowerAfterEntry,l_1);
end; hh:HigherAfterEntry,noaxis,linethick0; ll:LowerAfterEntry,noaxis,linethick0; if holding>0 and l<=ENTERPRICE-n2 then begin sell(1,holding,limitr,enterprice-n2),IGNORECHECKPRICE; end if holding<0 and h>=ENTERPRICE+n2 then begin sellshort(1,holding,limitr,enterprice+n2),IGNORECHECKPRICE; end if holding=0 and count1=1 then begin if MA5>=MA10+2 then begin buy(1,lots,limitr,open),IGNORECHECKPRICE;
HigherAfterEntry:=enterprice;
LowerAfterEntry:=enterprice; end end if holding=0 and count1=1 then begin if MA5<=MA10-2 then begin buySHORT(1,lots,limitr,open),IGNORECHECKPRICE;
HigherAfterEntry:=enterprice;
LowerAfterEntry:=enterprice; end end if holding>0 and enterbars>0 then begin if enterbars>=1 and HigherAfterEntry>=enterprice*(1+N1/100) then begin price:=EnterPrice+(HigherAfterEntry-EnterPrice)*n3/100; if low<=price then begin sell(1,holding,limitr,min(open,price)) ,IGNORECHECKPRICE; count1:=1; end end; end; if holding<0 and enterbars>0 then begin if enterbars>=1 and lowerAfterEntry<=enterprice*(1-N1/100) then begin price:=EnterPrice - (EnterPrice-LowerAfterEntry)*n3/100; if high>=price then begin sellshort(1,holding,limitr,max(open,price)),IGNORECHECKPRICE; count1:=1; end; end end; |
-- 作者:panjia1000 -- 发布时间:2015/6/20 16:16:07 -- 即多仓连亏两次就反手开空仓,或空仓连亏两次就开多仓 即多仓连亏两次就反手开空仓,或空仓连亏两次就开多仓 |
-- 作者:jinzhe -- 发布时间:2015/6/23 8:55:08 -- count1是自己的计数变量吗? |
-- 作者:panjia1000 -- 发布时间:2015/6/23 22:20:40 -- count1是自己的计数变量 count1是自己的计数变量 |
-- 作者:jinzhe -- 发布时间:2015/6/24 9:31:04 -- variable:HigherAfterEntry=0,LowerAfterEntry=999999; h_1:=ref(h,1);
hh:HigherAfterEntry,noaxis,linethick0;
if holding=0 and MA5<=MA10-2 then if cs_duo=2 then begin If enterbars=0 then if holding>0 then price:=EnterPrice+(HigherAfterEntry-EnterPrice)*n3/100; if holding<0 then price:=EnterPrice - (EnterPrice-LowerAfterEntry)*n3/100; if holding>0 and enterbars>0 and HigherAfterEntry>=enterprice*(1+N1/100) and low<=price and bj=1 then sell(1,holding,limitr,min(open,price)) ,IGNORECHECKPRICE; end; if holding>0 and l<=ENTERPRICE-n2 and bj=1 then if holding<0 and h>=ENTERPRICE+n2 and bj=0 then |