此主题相关图片如下:无标题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
atr需要有20根以上才有值,最初的20根k线atr没有值导致ss没法取值,
可以用variable给ss一个初始值