以文本方式查看主题 - 金字塔客服中心 - 专业程序化交易软件提供商 (http://weistock.com/bbs/index.asp) -- 公式模型编写问题提交 (http://weistock.com/bbs/list.asp?boardid=4) ---- [讨论]谁能解释下这开平仓带止损的模型 (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=73887) |
|
-- 作者:hksl1023 -- 发布时间:2015/1/4 11:34:02 -- [讨论]谁能解释下这开平仓带止损的模型 谁能解释下这开平仓带止损的模型 看不懂怎么开仓的 想套用他的移动止损 我现在的模型有 kd kk pd pk 怎么套用移动止损呢 runmode:0; variable:zs=0,cc=0,hl=0; ma5:=ma(c,5); ma20:=ma(c,20); entertime:=time>100000 and time<144500; if holding>0 and cc<=0 then sell(1,1,limitr,o); if holding<0 and cc>=0 then sellshort(1,1,limitr,o); if holding=0 and cc>0 then buy(1,1,limitr,o); if holding=0 and cc<0 then buyshort(1,1,limitr,o); if cc>0 and l<zs then begin sell(1,1,limitr,min(o,zs-0.6)); cc:=0; end if cc<0 and h>zs then begin sellshort(1,1,limitr,max(o,zs+0.6)); cc:=0; end if cc>0 and ma5<ma20 then cc:=0; if cc<0 and ma5>ma20 then cc:=0; if cc=0 and ma5>ma20 and entertime then begin cc:=1; zs:=c-10; hl:=h; end if cc=0 and ma5<ma20 and entertime then begin cc:=-1; zs:=c+10; hl:=l; end if cc>0 and h>hl then begin//创新高后,上移hl hl:=h; zs:=hl-10; end if cc<0 and l<hl then begin//创新低后,下移hl hl:=l; zs:=hl+10; end if time>=150000 then begin cc:=0; end |
|
-- 作者:netfox -- 发布时间:2015/1/4 11:50:12 -- HL=High 就是这个意思
止损就是 high-10 low+10
空头与多头用了同一个变量HL ,所以开头才定义变量 HL=0
移动止损就是平仓条件, 新写一个平仓条件即可。 |
|
-- 作者:hksl1023 -- 发布时间:2015/1/4 13:53:31 -- 如果用上面的移动止损套用我的模型该如何编写,请帮我改写,在此谢过 |
|
-- 作者:jinzhe -- 发布时间:2015/1/4 14:01:32 -- if holding>0 and cc<=0 then sell(1,1,limitr,o); if holding<0 and cc>=0 then sellshort(1,1,limitr,o); if holding=0 and cc>0 then buy(1,1,limitr,o); if holding=0 and cc<0 then buyshort(1,1,limitr,o);
把你的条件替代进上面的4句话 |
|
-- 作者:hksl1023 -- 发布时间:2015/1/4 14:39:49 -- if cc>0 and ma5<ma20 then cc:=0; if cc<0 and ma5>ma20 then cc:=0; if cc=0 and ma5>ma20 and entertime then begin cc:=1; zs:=c-10; hl:=h; end if cc=0 and ma5<ma20 and entertime then begin cc:=-1; zs:=c+10; hl:=l; end 这部分该如何理解呢 |
|
-- 作者:jinzhe -- 发布时间:2015/1/4 14:47:16 -- 开仓后给变量赋初值 |
|
-- 作者:hksl1023 -- 发布时间:2015/1/4 15:16:50 -- 搞晕了 不如你直接给我套下这个止损 我的开平仓条件 kd kk pd pk |
|
-- 作者:hksl1023 -- 发布时间:2015/1/4 15:22:49 -- 顺便帮帮我把这个移动止损的条件加入到启动条件里 if(holding>0 AND REF(C,1)<ENTERPRICE,开多移动止损,不启动); IF(HOLDING<0 AND REF(C,1)>ENTERPRICE,开空移动止损,不启动);
|
|
-- 作者:jinzhe -- 发布时间:2015/1/4 15:29:32 -- 1.如何把你的开平条件加进去,前面已经说过了, if holding>0 and pd then sell(1,1,limitr,o); if holding<0 and pk then sellshort(1,1,limitr,o); if holding=0 and kd then buy(1,1,limitr,o); if holding=0 and kk then buyshort(1,1,limitr,o); 2.你的移动止损嵌套不进去,要么用自己的,要么用上面的 |
|
-- 作者:hksl1023 -- 发布时间:2015/1/4 16:01:00 -- 现在的问题是这里 怎么修改
|