以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  金字塔软件问题提交  (http://weistock.com/bbs/list.asp?boardid=2)
----  在进行回测的时候,如何才能知道当前K线是否是最后一根K线  (http://weistock.com/bbs/dispbbs.asp?boardid=2&id=140817)

--  作者:microsoft
--  发布时间:2016/10/12 18:01:43
--  在进行回测的时候,如何才能知道当前K线是否是最后一根K线

RT,逐K线模式


--  作者:microsoft
--  发布时间:2016/10/12 18:42:25
--  

是回测的最后一根K线


--  作者:王锋
--  发布时间:2016/10/12 19:08:38
--  
barpos 就是回测时你的K线序列
--  作者:microsoft
--  发布时间:2016/10/12 19:11:07
--  

我是想在回测的最后一根K线输出一些数据,但是回测结束的时间不是当前日期


--  作者:王锋
--  发布时间:2016/10/12 19:12:14
--  
ISLASTBAR函数
--  作者:microsoft
--  发布时间:2016/10/13 17:40:23
--  

在回测的时候不起作用呢,例如测试的结束日期是20160331

是不是测试的时候最后一根K线和设置的结束日期无关,固定为当前的最新的K线?


--  作者:wenarm
--  发布时间:2016/10/14 9:49:08
--  

对弈回测,计算到当时的k线,这个k在当时就是最后一根,

至于你想在回测中确定是否是自己回测最后的一个。只能通过代码比较日期进行处理。

但是这就本末倒置的,策略编写调试的整个过程是回测----模拟---实盘。

回测主要是针对策略对历史上数据进行一个系统的分析统计。

 


--  作者:microsoft
--  发布时间:2016/10/14 10:58:37
--  

在回测的时候,ISLASTBAR并不起作用,至回测结束也没有为1,不能调用outputCw和msgout(1,\'finish\')

我的版本是3.92 x64

 

pel代码

逐K模式

 

if ISLASTBAR then
//if pbdate = date and time >= CCLOSETIME then
begin
  tmp4:=outputCw(-1,year,month,year,month,asset,maxAsset,minAsset,huiche,huicheBl,maxHuiChe,maxHuicheBl);

  msgout(1,\'finish\');
end

 

vba代码

\'历史回测时,输出具体每个月的数据
function outputCw(Formula,initial,yearP1,monthP1,yearP2,monthP2,asset,maxAsset,minAsset,huiche,huicheBl,maxHuiChe,maxHuicheBl)
    if initial =1 then
       pbCwArray.RemoveAll()
    end if
   
    if initial =0 then
       pbCwArray.AddBack(asset)
    end if
   
    dim outputStr
    outputStr = ""
    if initial < 0 then
       \'if abs(initial) = Formula.DataSize then\'最后一根K线
       pbCwArray.AddBack(asset)
       application.MsgOut("enter")
       outputStr = formulaParam
       arrLen = pbCwArray.Count
       yyl = 0
       for n = 1 to arrLen -1 step 1
          yyl = pbCwArray.GetAt(n) - pbCwArray.GetAt(n-1)
          outputStr = outputStr & "," & cstr(yyl)
       next
      
       document.DebugFile "C:\\\\" & formula.name  &  ".Txt",outputStr,0
       \'outputStr = formulaParam & "," &
       \'end if
    end if
   
end function