????? 交易條件以多頭為例:
??????a) 價(jià)格創(chuàng)20期新高
??????b)??a條件滿足后的3個(gè)周期內(nèi)創(chuàng)2期新低,記錄下這個(gè)新低值
????? c) ?b條件滿足后的3個(gè)周期內(nèi)再次出現(xiàn)20期新高,此時(shí)開倉(cāng)買入
????? d)??止損條件:以b條件中的新低作為止損價(jià)格
????? e)? 止盈條件:當(dāng)價(jià)格達(dá)到2倍風(fēng)險(xiǎn)數(shù)額即2*(開倉(cāng)價(jià)-止損價(jià))止盈???????????????????
?
?
//nlow記錄創(chuàng)20新高后3期內(nèi)創(chuàng)2期新低時(shí)k線的最低值
//mhigh記錄創(chuàng)20期新低后3期內(nèi)創(chuàng)2期新高時(shí)k線的最高值
VARIABLE:nlow=0,mhigh=0;
//定義手?jǐn)?shù)量
Input:snum(1,1,100,1);
//中間變量
h20:ref(hhv(h,20),1);//20周期最高價(jià)
l20:ref(llv(l,20),1);//20周期最低價(jià)
h2:=ref(hhv(h,2),1);//2周期最高價(jià)
l2:=ref(llv(l,2),1);//2周期最低價(jià)
//創(chuàng)20新高后3期內(nèi)創(chuàng)2期新低,記錄最低價(jià)
con1:=BARSLAST(h>h20)<=3 and BARSLAST(h>h20)>0 and low<l2;
if con1 then nlow:=low;
//創(chuàng)20期新低后3期內(nèi)創(chuàng)2期新高,記錄最高價(jià)
con2:=barslast(low<l20)<=3 and BARSLAST(l<l20)>0 and high>h2;
if con2 then mhigh:=high;
?
//開多平多條件,創(chuàng)新低3周期內(nèi)再次創(chuàng)20期新高。平多條件分為止損止盈
BuyCond:=barslast(con1)<=3 and BARSLAST(con1)>0 and high>h20;
SellCond1:=low<=nlow;
SellCond2:=high-enterprice>2*abs(enterprice-nlow);
//開空平空條件
BuyshortCond:=barslast(con2)<=3 and BARSLAST(con2)>0? and l<l20;
SellshortCond1:=high>=mhigh;
SellshortCond2:=enterprice-low>=2*abs(mhigh-enterprice);
?
//交易策略
if SellCond1 then 多損:Sell(holding>0,snum,market);
if SellCond2 then 多盈:Sell(holding>0,snum,market);
if BuyshortCond then buyshort(holding=0,snum,market);
if SellshortCond1? then 空損:sellshort(holding<0,snum,market);
if SellshortCond2? then 空盈:sellshort(holding<0,snum,market);
if BuyCond then Buy(holding=0,snum,market);
?
?
?
{別忘了將本網(wǎng)告訴您身邊的朋友,向朋友傳達(dá)有用資料,也是一種人情,你朋友會(huì)感謝你的。}
?