请问你的第二个价格-3%如何理解?
variable:aa=0;
cc:c;
中轨:stkindi('','boll.mid',0,2);
下轨:stkindi('','boll.LOWER',0,2);
上轨:stkindi('','boll.UPPER',0,2);
开多:=c>o and h>ref(h,1) and l<ref(l,1);
开空:=c<o and h>ref(h,1) and l<ref(l,1);
if 开多 and cross(c,下轨) then
begin
buy(1,1,market);
aa:=0;
end
//多头止损
if aa=0 and ((c-enterprice)/enterprice)<-0.03 then 止损: sell(1,0,market);
if aa=0 and cross(c,中轨) and holding>0 and enterbars>0 then aa:=1;
if aa=1 and cross(中轨,c) and holding>0 and enterbars>0 then aa:=2;
//多头止盈
if aa=2 then 止盈: sell(1,0,market);
if 开空 and cross(c,上轨) then
begin
buyshort(1,1,market);
aa:=0;
end
//空头止损
if aa=0 and (c-enterprice)/enterprice>0.03 then sellshort(1,0,market);
if aa=0 and cross(中轨,c) and holding<0 and enterbars>0 then aa:=1;
if aa=1 and cross(c,中轨) and holding<0 and enterbars>0 then aa:=2;
//空头止盈
if aa=2 then sellshort(1,0,market);