以文本方式查看主题 - 金字塔客服中心 - 专业程序化交易软件提供商 (http://weistock.com/bbs/index.asp) -- 公式模型编写问题提交 (http://weistock.com/bbs/list.asp?boardid=4) ---- 帮忙看看这个怎么写 (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=144171) |
-- 作者:yuanhang -- 发布时间:2016/12/6 14:00:16 -- 帮忙看看这个怎么写 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,发现不行. 帮忙看看怎么写谢谢
|
-- 作者:jinzhe -- 发布时间:2016/12/6 14:02:08 -- 用texitbars 平仓后最高价 hhv(h,texitbars+1) |
-- 作者:yuanhang -- 发布时间:2016/12/6 14:12:43 -- 老师我之前用Texitbar,出现一个问题。就是当我第一次定义平仓后,再第二轮,会在我定义的bar 的高值平仓,系统 就把这个bar定义为 新的Extbar,后面的就乱了, 就一直按照 定义的bar高值平仓。不是按照我之前的平仓条件平仓。 这个问题怎么解决呢
|
-- 作者:jinzhe -- 发布时间:2016/12/6 14:35:43 -- 那么上面的两个平仓里面,哪个定义为“初始平仓的” |
-- 作者:yuanhang -- 发布时间:2016/12/6 14:38:43 -- 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。这两个平仓 地位一样。
|
-- 作者:jinzhe -- 发布时间:2016/12/6 15:07:41 -- 任何开仓之后的第一根平仓都是要重新计算这个高点的吗?
|
-- 作者:yuanhang -- 发布时间:2016/12/6 15:10:15 -- 我的模式 基本上会出现开平情况有:1;开2手,平1手,平1手; 2、开2手,平2手。 我是想定义这两种情况的最后平仓的BAR的最高值。每一轮都要重新计算,前一个最后平仓值。
|
-- 作者:jinzhe -- 发布时间:2016/12/6 15:13:18 -- 以下是引用yuanhang在2016-12-6 15:10:15的发言:
我的模式 基本上会出现开平情况有:1;开2手,平1手,平1手; 2、开2手,平2手。
我是想定义这两种情况的最后平仓的BAR的最高值。每一轮都要重新计算,前一个最后平仓值。 “最后平仓的BAR的最高值”这个指的是情况1里面,第二个平1手吗? |
-- 作者:yuanhang -- 发布时间:2016/12/6 15:18:33 -- 最后平仓的BAR最高值,包括情况1中的 第二次平仓,也包括情况2中的2手平仓。 |
-- 作者:jinzhe -- 发布时间:2016/12/6 15:38:30 -- 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); |