input:k(0.7,0.1,1,0.1);
dist1:=barslast(day>ref(day,1))+1;
dist2:=ref(dist1,dist1);
predayhigh:=ref(hhv(high,dist2),dist1);
predaylow:=ref(llv(low,dist2),dist1);
predayclose:=ref(close,dist1);
predayrange:=max(predayhigh-predayclose,predayclose-predaylow);
dayopen:=ref(open,dist1-1);
upperband:=dayopen+k*predayrange;
lowerband:=dayopen-k*predayrange;
if holding=0 then begin
if high>=upperband then
buy(1,volunit,limitr,max(open,upperband));
end
if holding=0 then begin
if low<=lowerband then
buyshort(1,volunit,limitr,min(open,lowerband));
end
if holding>0 then begin
if low<=lowerband then begin
sell(1,holding,limitr,min(open,lowerband));
buyshort(1,volunit,limitr,min(open,lowerband));
end
if time>=closetime(0) then
sell(1,holding,limitr,close);
end
if holding<0 then begin
if high>=upperband then begin
sellshort(1,holding,limitr,max(open,upperband));
buy(1,volunit,limitr,max(open,upperband));
end
if time>=closetime(0) then
sellshort(1,holding,limitr,close);
end
资产:asset,noaxis,colorred,linethick2;
不错 可程序编得有误
if high>=upperband then
buy(1,volunit,limitr,max(open,upperband));
if time>=closetime(0) then
sellshort(1,holding,limitr,close);
都有问题
看了几个你编得几个程序 都有一样的问题。
连续数据测试时,每个月末和月初时的最高最低价一样,应该是软件系统问题
请问老师我把它导入新建交易系统,怎么一个信号都没有啊?图表交易可以用吗?
//等价改写,1分钟周期
input:k(0.7,0.1,1,0.1);
N:=barslast(date<>ref(date,1))+1;
predayhigh:=ref(hhv(h,N),N); //昨日最高价
predaylow:=ref(LLv(L,N),N); //昨日最低价
predayclose:=VALUEWHEN(DATE<>REF(DATE,1),REF(CLOSE,1)); //昨收
predayrange:=max(predayhigh-predayclose,predayclose-predaylow);
dayopen:=valuewhen(date<>ref(date,1),o); //当日开盘价
upperband:=dayopen+k*predayrange;
lowerband:=dayopen-k*predayrange;
if low<=lowerband then
begin
sell(holding>0,holding,limitr,min(open,lowerband));
buyshort(holding=0,volunit,limitr,min(open,lowerband));
end
if high>=upperband then
begin
sellshort(holding<0,holding,limitr,max(open,upperband));
buy(holding=0,volunit,limitr,max(open,upperband));
end
if time>=closetime(0)-300 then
begin
sell(holding>0,holding,limitr,close);
sellshort(holding<0,holding,limitr,close);
end
资产:asset,noaxis,colorred,linethick2;
input:k(0.7,0.1,1,0.1);
dist1:=barslast(day>ref(day,1))+1;
dist2:=ref(dist1,dist1);
predayhigh:=ref(hhv(high,dist2),dist1);
predaylow:=ref(llv(low,dist2),dist1);
predayclose:=ref(close,dist1);
predayrange:=max(predayhigh-predayclose,predayclose-predaylow);
dayopen:=ref(open,dist1-1);
upperband:=dayopen+k*predayrange;
lowerband:=dayopen-k*predayrange;
if holding=0 then begin
if high>=upperband then
buy(1,volunit,limitr,max(open,upperband));
end
if holding=0 then begin
if low<=lowerband then
buyshort(1,volunit,limitr,min(open,lowerband));
end
if holding>0 then begin
if low<=lowerband then begin
sell(1,holding,limitr,min(open,lowerband));
buyshort(1,volunit,limitr,min(open,lowerband));
end
if time>=closetime(0) then
sell(1,holding,limitr,close);
end
if holding<0 then begin
if high>=upperband then begin
sellshort(1,holding,limitr,max(open,upperband));
buy(1,volunit,limitr,max(open,upperband));
end
if time>=closetime(0) then
sellshort(1,holding,limitr,close);
end
资产:asset,noaxis,colorred,linethick2;
感谢大师们