当价格下穿上轨时开多单,止损条件是当价格低于开仓这根K线最低点时止损平仓,止盈条件是当价格上穿上轨时止盈平仓。
当价格上穿上轨时开空仓,止损条件是当价格超过开仓这根K线最高点时止损平仓,止盈条件是当价格上穿下轨时止盈平仓。
帮忙这个公式怎样编写?这个开仓条件改了,和上午发的帖不一样了。费心了!拜托!
楼主发的多个策略贴,内容大致都是差不多的,你可以根据之前我们为你改写的自行尝试修改,如果你什么事情都伸手让别人为你做,那么你自己什么时候才能成长起来
variable:hh=0,ll=0;
MID : MA(CLOSE,26);
UPPER:MID + 2*STD(CLOSE,26);
LOWER:MID - 2*STD(CLOSE,26);
//平空开多--价格下穿上轨
if cross(UPPER,c) then
begin
sellshort(holding<0,1,market);
if holding=0 then
begin
buy(1,1,market);
ll:=low;
end
end
//价格超过开多这根K线的最低点时止损平多
if holding>0 and enterbars>1 then sell(c<ll,1,market);
//止盈条件是当价格上穿上轨时止盈平仓
scs:=cross(c,upper);
if holding>0 and enterbars>1 then sell(scs,1,market);
//平多开空--价格上穿上轨时
if cross(c,UPPER) then
begin
sell(holding>0,1,market);
if holding=0 then
begin
buyshort(1,1,market);
hh:=high;
end
end
//价格超过开空这根K线的最高点时止损平空
if holding<0 and enterbars>1 then sellshort(c>hh,1,market);
//止盈条件是当价格上穿下轨时止盈平仓。
scx:=cross(c,lower);
if holding<0 and enterbars>1 then sellshort(scx,1,market);
如果楼主仔细看看,您所说的更换了条件后的策略
在之前发的帖子里,已经完全实现了.
推荐您,看看论坛置顶的视频教程和文档教程,这样有助于您看懂编写的代码,同时也有利于您的进一步学习.