以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  测评有结果但是k线图上没信号  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=142693)

--  作者:tanyongde
--  发布时间:2016/11/14 15:43:25
--  测评有结果但是k线图上没信号
如下开平仓指令,模拟交易时开仓没问题,平仓有问题,是那里写错?

//建立多头的进场条件
long:=h>a and ref(c,1)>line ;
if long then
begin
//tsellshort(holding<0,0,mkt);
sellshort(holding<0,0,marketr);
//tbuy(holding=0,p,mkt)
buy(holding=0,p, limitr ,a);
end
//建立空头的进场条件
short:=l<b and ref(c,1)<line ;
if short then
begin
//tsell(holding>0,0,mkt);
sell(holding>0,0,marketr);
//tbuyshort(holding=0,p,mkt);
buyshort(holding=0,p,limitr,b);
end
//盈亏计算 
     if enterbars>0 then begin 
         win1:=(c-enterprice)/enterprice*10000; 
         if win1>maxprofit then 
             maxprofit:=win1; 
         win2:=(maxprofit-win1)/maxprofit*10000; 
     end 
 
     //多头初始浮亏 p1% 止损 
     if win1<-p1 then 
     begin
          //tsell(1,holding,mkt); 
         sell(1,holding,marketr); 
      end
 
     //多头利润大于 p2% 止盈 
     if win1>p2 then 
     begin
         //tsell(1,holding,mkt); 
         sell(1,holding,marketr); 
     end

     //多头获利后回撤 p3%止盈 
     if win2>p3 and openprofit>0 then 
    begin
         //tsell(1,holding,mkt); 
         sell(1,holding,marketr); 
    end

     
     //盈亏计算 
     if enterbars>0 then begin 
         win1:=(enterprice-c)/enterprice*100; 
         if win1>maxprofit then 
             maxprofit:=win1; 
         win2:=(maxprofit-win1)/maxprofit*10000; 
     end 
 
     //空头初始浮亏超过 p1% 止损 
     if win1<-p1 then 
     begin
         //tsellshort(1,holding,mkt); 
         sellshort(1,holding,marketr); 
     end
 
     //空头利润大于 p2%止盈 
     if win1>p2 then 
     begin
         //tsellshort(1,holding,mkt); 
         sellshort(1,holding,marketr); 
     end
      
     //空头回撤 p3% 止盈 
     if win2>p3 and openprofit>0 then 
     begin
         //tsellshort(1,holding,mkt); 
         sellshort(1,holding,marketr);
     end

持仓:holding,linethick0;
资产:asset,noaxis;
可用现金:cash(0),linethick0;

      

--  作者:jinzhe
--  发布时间:2016/11/14 15:51:35
--  

平仓有信号出现吗

[此贴子已经被作者于2016-11-14 15:51:40编辑过]

--  作者:tanyongde
--  发布时间:2016/11/14 16:26:42
--  
回测有平仓信号,模拟有问题?
--  作者:jinzhe
--  发布时间:2016/11/14 16:29:37
--  
不是回测,你当前k线图上,有平仓信号没?
--  作者:tanyongde
--  发布时间:2016/11/14 16:44:56
--  
  没有平仓信号,接浮利回撤应有信号
--  作者:jinzhe
--  发布时间:2016/11/14 17:05:11
--  
没信号说明当前的行情下是不满足平仓条件的。而回测有信号,说明回测和当前k线图所使用的k线数据,是不一致的,用户把当前k线图显示的数据和回测使用数据,调成一样的
--  作者:tanyongde
--  发布时间:2016/11/14 17:08:09
--  
编写有错吗?
--  作者:jinzhe
--  发布时间:2016/11/14 17:15:26
--  
回测有信号,就说明编写没错