以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  有关回测的问题  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=155546)

--  作者:sidadeapu
--  发布时间:2017/6/29 13:35:09
--  有关回测的问题


此主题相关图片如下:无标题222.png
按此在新窗口浏览图片

此主题相关图片如下:无标题111.png
按此在新窗口浏览图片

 

写了一个简单的公式,回测时为什么前两笔成交数量那么大?

附:

上轨:ref(hhv(high,20),1);
下轨:ref(llv(low,20),1);

atr:ma(tr,20),NOAXIS;

IF atr>=50 THEN
   SS:=1;
IF atr<50 THEN
   SS:=2;

if holding>0  then begin
   price:=0;
if l<=下轨 then
   price:=min(open,下轨);
if price>0 then  
   sell(1,holding,limitr,price);
end

if holding<0  then begin
   price:=0;
if h>=上轨 then
   price:=max(open,上轨);
if price>0 then
   sellshort(1,holding,limitr,price);
end


if holding=0  then begin
   price:=0;
if h>=上轨 then
   price:=max(open,上轨);
if price>0  then
   buy(1,SS,limitr,price);
end 

if holding=0  then begin
   price:=0;
if l<=下轨 then
   price:=min(open,下轨);
if price>0  then
   buyshort(1,SS,limitr,price);
end


 


--  作者:pyd
--  发布时间:2017/6/29 14:14:17
--  

atr需要有20根以上才有值,最初的20根k线atr没有值导致ss没法取值,

可以用variable给ss一个初始值