帮忙看下这个问题在哪里 ,越改问题越多,图上好多小白开仓信号,
1:希望再帮忙修改每天正反只能个开一次
2:我写的止损条件好像图中显示的并不正确,本来是当开仓价格回碰当天开盘价止损。
万分感谢
runmode:0;
dayopen:=valuewhen(date<>ref(date,1),o);
enterlongcond:=high>=dayopen;
entershortcond:=low<=dayopen;
exittime:=time>=1458;
if holding=0 and time>1015 then begin
if enterlongcond then
buy(1,1,limitr,close+mindiff);
if entershortcond then
buyshort(1,1,limitr,close-mindiff);
end
if holding>0 and time>1015 then begin
exitlongcond:=enterprice<=dayopen;
if exitlongcond then
sell(1,holding,limitr,dayopen);
if enterlongcond and enterbars>=1 then
sell(1,holding,limitr,close-mindiff);
buyshort(1,1,limitr,close-mindiff);
if exittime then
sell(1,holding,limitr,o);
end
if holding<0 and time>1015 then begin
exitshortcond:=enterprice>=dayopen;
if exitshortcond then
sellshort(1,holding,limitr,dayopen);
if entershortcond and enterbars>=1 then
sellshort(1,holding,limitr,closse+mindiff);
buy(1,1,limitr,close+mindiff);
if exittime then
sellshort(1,holding,limitr,o);
end
/
资产:asset-500000,noaxis,coloryellow,linethick2;
盈亏:(asset-500000)/500000,linethick0;
胜率:PERCENTWIN,linethick0;
设计思路:
开仓条件:开盘至10点15之前的高低点作为上下轨, 10点15后如高价突破上轨做多,低价突破下轨做空。 (每天多空开仓只限一次)
止损:开仓价高于当天开盘价,空头止损, 开仓价低于当天开仓价,多头止损。
退出: 每天收盘前1分钟平仓。
谢谢
写完了。
variable :aa=0,bb=0;
nn:=barslast(date<>ref(date,1));
sg:valuewhen(time<=101500,hhv(h,nn+1));//上轨
xg:valuewhen(time<=101500,llv(l,nn+1));//下轨
jk:ref(o,nn);//今日开盘
aa1:aa,linethick0;
bb1:bb,linethick0;
//10点15后如高价突破上轨做多,低价突破下轨做空(每天多空开仓只限一次)
if time >101500 and h>sg and aa=0 then begin
sellshort(holding<0,0,thisclose);
buy(holding=0,1,thisclose);
aa:=1;
end
if time >101500 and l<xg and bb=0 then begin
sell(holding>0,0,thisclose);
buyshort(holding=0,1,thisclose);
bb:=1;
end
//止损:开仓价高于当天开盘价,空头止损, 开仓价低于当天开仓价,多头止损。
if enterprice>jk then sellshort(holding<0,0,thisclose);
if enterprice<jk then sell(holding>0,0,thisclose);
//退出: 每天收盘前1分钟平仓。
if time>=145900 and time<=150000 then begin
sellshort(holding<0,0,thisclose);
sell(holding>0,0,thisclose);
end
if time>=150000 then begin
aa:=0;
bb:=0;
end
哈哈 万分感谢啊 ,不请客都不好意思了
为啥啊最后 还要写这个?有啥意义?
if time>=150000 then begin
aa:=0;
bb:=0;
end
还有平仓手数 为啥不填写?
sellshort(holding<0,0,thisclose);
sell(holding>0,0,thisclose);
1.您是每天做交易的,收盘前把全局变量赋值为0.才不会影响第2天的开仓.
2.sell(holding>0,0,thisclose);//这里的第2个参数可以写成具体手数1,也可写成0,表示全局平仓.
如果还是不懂,去仔细看看函数说明.