以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  [求助]请帮忙完善一个漏洞,谢谢  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=61215)

--  作者:fang2627
--  发布时间:2014/1/23 9:33:22
--  [求助]请帮忙完善一个漏洞,谢谢
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);


这个程序存在一个问题就是当平仓和开仓同时出现时,只执行平仓命令而忽略开仓命令。比如说当前是开空仓中,同时出现平空仓和开多仓信号,系统只执行平空仓,却没执行开多仓。请问应该如何修正这个问题?

此主题相关图片如下:qq截图20140122212405.jpg
按此在新窗口浏览图片


另外,如果下单价格需要是当前价格的一系列价格,比如当前价是2200点,需要买入2200、2200.2、2200.4、这三个的全部当前卖单,应该如何修改程序?


--  作者:jinzhe
--  发布时间:2014/1/23 9:41:29
--  
if 多 then begin
 sellshort(holding<0, 0, thisclose);
 buy(holding=0 {AND TIME<144000}, 100%, LIMIT);
 end

 

 

limit后面没有定义价位

改成thisclose就行

if 多 then begin
 sellshort(holding<0, 0, thisclose);
 buy(holding=0 {AND TIME<144000}, 100%, thisclose);
 end
 
后面的做不到

--  作者:fang2627
--  发布时间:2014/1/23 9:59:13
--  
非常感谢"jinzhe"的帮助,谢谢!
--  作者:fang2627
--  发布时间:2014/1/23 15:14:45
--  
if 多 then begin
 sellshort(holding<0, 0, thisclose);
 buy(holding=0 {AND TIME<144000}, 100%, LIMIT);
 end


若是修改为:

if 多 then begin
 sellshort(holding<0, 0, limit,close);
 buy(holding=0 {AND TIME<144000}, 100%, limit,close);
 end

这样是否可行呢?

--  作者:jinzhe
--  发布时间:2014/1/23 15:16:50
--  
limit是次周期限价交易,容易因行情波动而变成不成交的价格,所以推荐用limitr,本周期限价交易
 
if 多 then begin
 sellshort(holding<0, 0, limitr,close);
 buy(holding=0 {AND TIME<144000}, 100%, limitr,close);
 end