runmode:0;
input:ceilingamt(60),flooramt(20),bolbandtrig(2);
variable:lookbackdays=20;
todayvolatility:=std(close,30);
yesterdayvolatility:=std(ref(close,1),30);
deltavolatility:=(todayvolatility-yesterdayvolatility)/todayvolatility;
lookbackdays:=lookbackdays*(1+deltavolatility);
lookbackdays:=round(lookbackdays);
lookbackdays:=min(lookbackdays,ceilingamt);
lookbackdays:=max(lookbackdays,flooramt);
mid:=ma(close,lookbackdays);
upband:=mid+bolbandtrig*std(close,lookbackdays);
dnband:=mid-bolbandtrig*std(close,lookbackdays);
buypoint:=ref(hhv(high,lookbackdays),1);
sellpoint:=ref(llv(low,lookbackdays),1);
longliqpoint:=ma(close,lookbackdays);
shortliqpoint:=ma(close,lookbackdays);
if holding=0 then begin
if close>upband then
buy(1,1,limitr,max(open,buypoint));
end
if holding=0 then begin
if close<dnband then
buyshort(1,1,limitr,min(open,sellpoint));
end
if holding>0 then begin
if close<dnband then begin
sell(1,holding,limitr,min(open,sellpoint));
buyshort(1,1,limitr,min(open,sellpoint));
end
if low<=longliqpoint then
sell(1,holding,limitr,min(open,longliqpoint));
end
if holding<0 then begin
if close>upband then begin
sellshort(1,holding,limitr,max(open,buypoint));
buy(1,1,limitr,max(open,buypoint));
end
if high>=shortliqpoint then
sellshort(1,holding,limitr,max(open,shortliqpoint));
end
盈亏:asset-50000,noaxis,colorred,linethick2;
if close>upband then
buy(1,1,limitr,max(open,buypoint));
end
使用了未来数据,按收盘价判断条件,却以开盘价来确定开仓价。
有哪个好心人请帮忙添加注释!
input:ceilingamt(60,15,80,5){????},flooramt(20,5,40,5){???},bolbandtrig(2,1,5,0.5){???};
variable:lookbackdays=20; //突破周期
todayvolatility:=std(close,30); //30周标准差
yesterdayvolatility:=std(ref(close,1),30); //前周标准差
deltavolatility:=(todayvolatility-yesterdayvolatility)/todayvolatility; //估算差波动率
lookbackdays:=lookbackdays*(1+deltavolatility); //突破周期*波动率
lookbackdays:=round(lookbackdays);
lookbackdays:=min(lookbackdays,ceilingamt); // 跟下一句可能有冲突????
lookbackdays:=max(lookbackdays,flooramt); // ???????
mid:=ma(close,lookbackdays);
upband:=mid+bolbandtrig*std(close,lookbackdays);
dnband:=mid-bolbandtrig*std(close,lookbackdays);
buypoint:=ref(hhv(high,lookbackdays),1);
sellpoint:=ref(llv(low,lookbackdays),1);
longliqpoint:=ma(close,lookbackdays);
shortliqpoint:=ma(close,lookbackdays);