If h>ref(h,1) then begin
tbuy(tholding=0,2,mkt);
end
if tholding>0 and l<tenterprice-20*mindiff then tsell(1,0,mkt);//止损
if tholding>0 and L<ref(l,1) then tsell(1,1,mkt);//平仓
老师 我想定义一下初始平仓之后的bar的最高价,想下次开仓时,价格回到上次平仓bar的最高值时,主动平掉1手,另一手再止损或者平仓。
是不是要用VALUEWHEN函数呢,之前用exitbar,发现不行. 帮忙看看怎么写谢谢
用texitbars
平仓后最高价 hhv(h,texitbars+1)
老师我之前用Texitbar,出现一个问题。就是当我第一次定义平仓后,再第二轮,会在我定义的bar 的高值平仓,系统 就把这个bar定义为
新的Extbar,后面的就乱了, 就一直按照 定义的bar高值平仓。不是按照我之前的平仓条件平仓。
这个问题怎么解决呢
if tholding>0 and l<tenterprice-20*mindiff then tsell(1,0,mkt);//止损
if tholding>0 and L<ref(l,1) then tsell(1,1,mkt);//平仓
这两个出那个信号 ,我就定义此bar。这两个平仓 地位一样。
任何开仓之后的第一根平仓都是要重新计算这个高点的吗?
我的模式 基本上会出现开平情况有:1;开2手,平1手,平1手;
2、开2手,平2手。
我是想定义这两种情况的最后平仓的BAR的最高值。每一轮都要重新计算,前一个最后平仓值。
以下是引用yuanhang在2016-12-6 15:10:15的发言:我的模式 基本上会出现开平情况有:1;开2手,平1手,平1手;
2、开2手,平2手。
我是想定义这两种情况的最后平仓的BAR的最高值。每一轮都要重新计算,前一个最后平仓值。
“最后平仓的BAR的最高值”这个指的是情况1里面,第二个平1手吗?
最后平仓的BAR最高值,包括情况1中的 第二次平仓,也包括情况2中的2手平仓。
globalvariable:hh=0;
If h>ref(h,1) and tholding=0 then begin
tbuy(tholding=0,2,mkt);
hh:=0;
end
if tholding>0 and l<tenterprice-20*mindiff then begin
hh:=h;
tsell(1,0,mkt);//止损
end
if tholding=2 and L<ref(l,1) then tsell(1,1,mkt);//平仓
if tholding=1 and L<ref(l,1) then begin
tsell(1,1,mkt);//平仓
hh:=h;
end
if tholding=0 and h>=hh then hh:=h;
if tholding=2 and h>=hh then tsell(1,1,mkt);