加入止盈止损后 出现问题
runmode:0;
dayopen:=valuewhen(date>ref(date,1),o);
upperband:dayopen+dayopen*0.005;
dnband:dayopen-dayopen*0.005;
centre:(upperband+dnband)/2;
enterlongcond:=high>=upperband;
entershortcond:=low<=dnband;
atr:=ref(ma(tr,10),1);
exittime:=time>1458;
if enterlongcond and time<=145800 then begin
sellshort(holding<0 and enterbars>=1,1,limitr,upperband);
buy(holding=0,1,limitr,upperband);
end
if entershortcond and time<=145800 then begin
sell(holding>0 and enterbars>=1,1,limitr,dnband);
buyshort(holding=0,1,limitr,dnband);
end
//止损
if ref(c,1)>centre then sellshort(holding<0,holding,limitr,centre+mindiff);
if ref(c,1)<centre then sell(holding>0,holding,limitr,centre-mindiff);
//止盈
if ref(c,1)>enterprice+atr then sell(holding>0,holding,limitr,thisclose);
if ref(c,1)<enterprice-atr then sellshort(holding<0,holding,limitr,thisclose);
if exittime then begin
sell(holding>0,1,thisclose);
sellshort(holding<0,1,thisclose);
end
1.金字塔的时间,都是6位数
2.直接用centre+mindiff去发委托单,centre是最小变动价位的整数倍吗?
顶一下 请高手们回复
1.金字塔的时间,都是6位数
2.直接去发委托单的价格,一定要是最小变动价位的整数倍.
你可以用小数位为奇数的去手工下个个IF的单子,看看效果如果
3.注意看BUY等下单函数及其各个参数.
runmode:0;
dayopen:=valuewhen(date>ref(date,1),o);
upperband:dayopen+dayopen*0.005;
dnband:dayopen-dayopen*0.005;
centre:(upperband+dnband)/2;
enterlongcond:=high>=upperband;
entershortcond:=low<=dnband;
atr:=ref(ma(tr,10),1);
if enterlongcond and time<=145800 then begin
sellshort(holding<0 and enterbars>=1,1,limitr,c+2*mindiff);
buy(holding=0,1,limitr,c+2*mindiff);
end
if entershortcond and time<=145800 then begin
sell(holding>0 and enterbars>=1,1,limitr,c-2*mindiff);
buyshort(holding=0,1,limitr,c-2*mindiff);
end
//止损
if ref(c,1)>centre then sellshort(holding<0,holding,limitr,c+2*mindiff);
if ref(c,1)<centre then sell(holding>0,holding,limitr,c-2*mindiff);
//止盈
if ref(c,1)>enterprice+atr then sell(holding>0,holding,market);
if ref(c,1)<enterprice-atr then sellshort(holding<0,holding,market);
if time>=145800 then begin
sell(holding>0,1,thisclose);
sellshort(holding<0,1,thisclose);
end
模型逻辑是没问题的.
是否止盈止损指令可以加入到正反手的指令里?
加入进去干什么,难道你的止盈止损指令也要满足你正反手指令的条件.