以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  [求助]回撤加仓写法  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=50060)

--  作者:akasha3322
--  发布时间:2013/3/21 23:33:24
--  [求助]回撤加仓写法
if holding=0  then begin
   if enterlongcond  then begin
      buy(1,1,market);
      HL:=high;
      cc:=1;
    end
   if entershortcond  then begin
      buyshort(1,1,market);
      HL:=low;
      cc:=-1; 
    end  
    
end  

//中间变量
if cc=-1 and low<HL then begin
   HL:=low;
end

if cc=1 and high>HL then begin
   HL:=high;
end
//加仓
if cc=1 and HL-close>=dayopen*0.01 then begin
   buy(1,1,market);
   cc:=2;
 end
   
if cc=-1 and close-HL>=dayopen*0.01 then begin
   buyshort(1,1,market);
   cc:=-2;
 end   

原意是最高回撤开盘价1%加仓1手,但是结果出来后只有多头会加仓,空头不会加仓,请高手看看到底哪里写错了。
[此贴子已经被作者于2013-3-21 23:33:45编辑过]

--  作者:jinzhe
--  发布时间:2013/3/22 9:28:13
--  
平仓语句是没有贴出来还是没写?
--  作者:akasha3322
--  发布时间:2013/3/22 9:51:58
--  
if holding<0 and enterlongcond then begin
    sellshort(1,0,thisclose); 
end 
    
if holding>0 and entershortcond then begin
    sell(1,0,thisclose);
end
平仓有写的,很简单应该没问题就没贴上,主条件就是一根均线突破