以文本方式查看主题 - 金字塔客服中心 - 专业程序化交易软件提供商 (http://weistock.com/bbs/index.asp) -- 策略编写求助区 (http://weistock.com/bbs/list.asp?boardid=11) ---- 请教一下如何编写资金管理的程序 (http://weistock.com/bbs/dispbbs.asp?boardid=11&id=53368) |
-- 作者:fang2627 -- 发布时间:2013/6/26 8:17:55 -- 请教一下如何编写资金管理的程序 在原来程序基础上,想按照倒金字塔的方式逐渐加仓。恳请指教! 分三次建仓,比例为(4:4:2),当第一次出现买入信号后,买入资金总量的4成,倘若买入价不触发止损条件,且K线站上买入价的102%时买入资金总量的4成, 当两次买入均价触发止损条件则平仓,倘若两次均价不触发止损条件,且K线站上第二次买入价的102%时买入资金总量的2成.当三次买入均价触发止损信号后一次性平仓。 INPUT:M(26,5,500,30); INPUT:N(2,0.1,10,1); INPUT:X(0.2,0.2,10,0.2); MID : MA(CLOSE,M); UPPER: MID + N*STD(CLOSE,M); LOWER: MID - N*STD(CLOSE,M); 多:=ALL(C>O+15*X,2) AND ALL(O>MID,2); 空:=ALL(C<O-15*X,2) AND ALL(O<MID,2); if 多 then begin sellshort(holding<0, 0, thisclose); buy(holding=0 {AND TIME<144000}, 100%, LIMIT); end HH:=HHV(H,BARSLAST(HOLDING<=0)); 多止损1:HH<Enterprice+60*X AND C<=HH-60*X ,LINETHICK0; 多止损2:Enterprice*1.02>=HH AND HH>=Enterprice+60*X AND C<Enterprice+2*X ,LINETHICK0; 多止损3:HH>Enterprice*1.02 AND C<HH*0.98 ,LINETHICK0; 多止损4:TIME>144000 AND C<Enterprice*1.02 ,LINETHICK0; if 多止损1 OR 多止损2 OR 多止损3 OR 多止损4 then sell(holding>0, 0, thisclose); if 空 then begin sell(holding>0, 0, thisclose); buyshort(holding=0 {AND TIME<144000}, 100%, thisclose); end LL:=LLV(L,BARSLAST(HOLDING>=0)); 空止损1:LL>Enterprice-60*X AND C>=LL+60*X ,LINETHICK0; 空止损2:Enterprice<=LL*1.02 AND LL<=Enterprice-60*X AND C>Enterprice-2*X ,LINETHICK0; 空止损3:LL*1.02<Enterprice AND C*0.98>LL ,LINETHICK0; 空止损4:TIME>144000 AND C*1.02>Enterprice ,LINETHICK0; if 空止损1 OR 空止损2 OR 空止损3 OR 空止损4 then sellshort(holding<0, 0, thisclose); [此贴子已经被作者于2013/6/26 8:18:55编辑过]
|
-- 作者:fly -- 发布时间:2013/6/27 9:35:57 -- 图表程序化的资金不是真实的资金,是虚拟的 |