以文本方式查看主题 - 金字塔客服中心 - 专业程序化交易软件提供商 (http://weistock.com/bbs/index.asp) -- 公式模型编写问题提交 (http://weistock.com/bbs/list.asp?boardid=4) ---- [求助]求老师指正错误之处,策略区没人回答无人值班吗不?急。。 (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=62666) |
|
-- 作者:利期 -- 发布时间:2014/3/13 15:29:39 -- [求助]求老师指正错误之处,策略区没人回答无人值班吗不?急。。 图表交易 参照论坛示例,写了一套止损、止盈策略, 老师们请批改以下策略语法是否正确。 附合多条件开多,但开仓策略错误,导致止盈后符合多条件又开多仓,再止再开,重复轮回,请求正确写法。 variable:maxprofit=0,qc=0; exittime:=time>=145000; ND:```````````; XD:```````````; 平空开多条件:=ND>XD; 平多开空条件:=ND<XD; 错误策略语句,求助修正。 [ buycond:=count(平空开多条件,0); if holding=0 and buycond then begin buy(1,1,MARKET); maxprofit:=0; end ] //限时清仓 if exittime then begin sell(1,0,MARKET); sellshort(1,0,MARKET); qc:=0; end //多仓止损 if holding>0 and low<enterprice-3 then sell(1,0,market); //预设性条件止盈 win:=0; ht:=0; if holding > 0 and enterbars > 0 then begin win:=(high-enterprice); //记录多仓浮动盈利 if win > maxprofit then maxprofit:=win; //最大获利 ht:=maxprofit-win; //最大盈利后的回调幅度 end if maxprofit<3 and holding>0 then 平多:SELL(平多开空条件,0,market);// 盈利小于3点,采用指标平仓。 if maxprofit>=3 and maxprofit<10 and holding>0 then 止赢1:SELL(ht<1+0.1*(maxprofit-2),0,market); // 3至10点盈利保护1点几利润盈平 if maxprofit>=10 and maxprofit<20 and holding>0 then 止赢2:SELL(ht<0.5*maxprofit,0,market); // 10至20点盈利保50%浮盈利润盈平 if maxprofit>=20 and maxprofit<40 and holding>0 then 止赢3:SELL(ht<maxprofit-10,0,market); // 20点至40点盈利,浮盈回撤10点盈平 if maxprofit>40 and holding>0 then 止赢4:SELL(ht<maxprofit-5 or 平多开空条件,0,market); // 大于40点盈利,浮盈回撤5点或指标平仓,哪个先达到执行哪个 关于SELL()里面的maxprofit,这里三种用法 {1+0.1*(maxprofit-2)} {0.5*maxprofit} {maxprofit-10} 是否正确?为什么要在前面加上“ht<”呢? 另外止盈止损后满足某条件之后重新恢复持仓策略怎么写? 例:即持多仓时,如果止盈(止损)后,趋势没有向空条件发展,在仍然保持多条件情况下,价格重新回调到大于止盈价(止损价)时,重新恢复持多仓。 不可行,即放弃。 请老师帮修改一个上述完整策略。 开平空仓盈损,是否是将上述策略中的low,high和开平空改一下即可?还有什么要改变的吗?
|
|
-- 作者:jinzhe -- 发布时间:2014/3/13 15:35:27 -- 我去看看 |
|
-- 作者:利期 -- 发布时间:2014/3/13 17:10:20 -- jin版,策略版有回复,还是不行。 |
|
-- 作者:利期 -- 发布时间:2014/3/13 17:27:15 --
[此贴子已经被作者于2014/3/13 17:28:57编辑过]
|
|
-- 作者:jinzhe -- 发布时间:2014/3/13 17:29:42 -- 不是你的思路是什么?这个开仓条件为什么要这么写? |
|
-- 作者:利期 -- 发布时间:2014/3/13 17:29:56 -- 是否是在静态盘面中无法正确显示?要在运行中验证? |
|
-- 作者:jinzhe -- 发布时间:2014/3/14 9:07:40 -- 你说的和我问的不是一回事,你写这个buycond:=count(平空开多条件,0);是为了实现什么目的?这样编写是为了什么? |