这样编写程序顺序合理,正确? pdd:=aq1>=1 and l>fl;
pkk:=aq1>=1 and h<fh;
VARIABLE: ll=0, hh=0, astop=0, bstop=0, temp_ll[]=0, temp_hh[]=0;
//交易系统
if enterbars>1 and l<astop -2*MINDIFF and holding>0 then sell(1,0,marketr);//止损止盈,实时出场
if h>valuewhen(TYPE(2),hhv(fh,10)) and holding=0 and 仓差>0 then buy(1,ss,marketr);//止损后,再次入场
if enterbars>1 and h>bstop +2*MINDIFF and holding<0 then sellshort(1,0,marketr);//止损止盈,实时出场
if l<valuewhen(TYPE(4),llv(fl,10)) and holding=0 and 仓差<0 then buyshort(1,ss,marketr);//止损后,再次入场
//开多
temp_ll:=llv(l,2);
if pdd then
begin
sellshort(1,0,marketr);
buy(holding=0 and 仓差>0,ss,marketr);
ll:=temp_ll;
end
astop:=ll;
//开空
temp_hh:=hhv(h,2);
if pkk then
begin
sell(1,0,marketr);
buyshort(holding=0 and 仓差<0,ss,marketr);
hh:=temp_hh;
end
bstop:=hh;
另外这样编写法:pdd:=aq1>=1 and l>fl;
pkk:=aq1>=1 and h<fh;
//交易系统
temp_ll:=llv(l,2);
if pdd then
begin
sellshort(1,0,marketr);
buy(holding=0 and 仓差>0,ss,marketr);
ll:=temp_ll;
end
if enterbars>1 and l<ll-2*MINDIFF and holding>0 then sell(1,0,marketr);//止损止盈,实时出场
if h>valuewhen(TYPE(2),hhv(fh,10)) and holding=0 and 仓差>0 then buy(1,ss,marketr);
temp_hh:=hhv(h,2);
if pkk then
begin
sell(1,0,marketr);
buyshort(holding=0 and 仓差<0,ss,marketr);
hh:=temp_hh;
end
if enterbars>1 and h>hh+2*MINDIFF and holding<0 then sellshort(1,0,marketr);
if l<valuewhen(TYPE(4),llv(fl,10)) and holding=0 and 仓差<0 then buyshort(1,ss,marketr);
在线等。VIP

此主题相关图片如下:qq图片20170520151708.png

客户
若不正确帮忙修改,请帮忙改为后台模式。
[此贴子已经被作者于2017/5/20 15:23:21编辑过]
在实盘跑的时候,出现单独的开多或者开空,平多或者平空都正确,
1)一遇到双向的开仓(平空开多,平多开空)就出现问题,出现不能平空就出现开多,或者干脆出现信号就不下单。
2)问题出现在这里反手,
if pdd then
begin
sellshort(1,0,marketr);
buy(holding=0 and 仓差>0,ss,marketr);
ll:=temp_ll;
end
估计是不是函数holding实盘问题,实盘取不到持仓。若出现这样的图表交易该如何处理?
[此贴子已经被作者于2017/5/21 14:44:16编辑过]
VARIABLE: ll=0, hh=0, astop=0, bstop=0, temp_ll[]=0, temp_hh[]=0;
//交易系统
if enterbars>1 and l<astop -2*MINDIFF and holding>0 then sell(1,0,marketr);//止损止盈,实时出场
if enterbars>1 and h>bstop +2*MINDIFF and holding<0 then sellshort(1,0,marketr);//止损止盈,实时出场
//开多
temp_ll:=llv(l,2);
if pdd then
begin
sellshort(1,0,marketr);
buy(holding=0 and 仓差>0,ss,marketr);
ll:=temp_ll;
end
astop:=ll;
//开空
temp_hh:=hhv(h,2);
if pkk then
begin
sell(1,0,marketr);
buyshort(holding=0 and 仓差<0,ss,marketr);
hh:=temp_hh;
end
bstop:=hh;
if h>valuewhen(TYPE(2),hhv(fh,10)) and holding=0 and 仓差>0 then buy(1,ss,marketr);//止损后,再次入场
if l<valuewhen(TYPE(4),llv(fl,10)) and holding=0 and 仓差<0 then buyshort(1,ss,marketr);//止损后,再次入场
这样顺序?
具体思路
1)条件pdd:=aq1>=1 and l>fl;开多
pkk:=aq1>=1 and h<fh;开空
2)平仓就反手
3)若开仓后,开多的跌破开仓对应的2日最低点-2滑点止损;若开空的升破开仓对应的2日高点+2滑点止损;动态实盘止损。
4)若开多止损后,很快价格又再次上涨突破上次开多的10日内高点位置,开多单;
开空止损相反; 平仓条件执行1)