以文本方式查看主题 - 金字塔客服中心 - 专业程序化交易软件提供商 (http://weistock.com/bbs/index.asp) -- 金字塔软件问题提交 (http://weistock.com/bbs/list.asp?boardid=2) ---- 如何在测试的时候让开平仓信号都反着来? (http://weistock.com/bbs/dispbbs.asp?boardid=2&id=137876) |
-- 作者:chenshall -- 发布时间:2016/8/11 15:24:09 -- 如何在测试的时候让开平仓信号都反着来? 如何在测试的时候让开平仓信号都反着来? 譬如说信号开空,测试的时候开多,平空变成平多
|
-- 作者:wenarm -- 发布时间:2016/8/11 15:38:40 -- 直接修改你开平仓的条件就可以了 |
-- 作者:chenshall -- 发布时间:2016/8/11 15:51:45 -- 条件比较复杂,里面还有止盈止损,反着开之后做不到跟原来开平仓一致,现在只需要测试的时候反着就可以,发现使用价格反转以后信号是反的了,但是价格不对 |
-- 作者:wenarm -- 发布时间:2016/8/11 16:03:38 -- 1.首先你要理解你的代码的逻辑。 2.回测其实是在图表的基础上做的统计。像你说的这个需求,除了修改你的策略没有别的方式。 你使用价格翻转,k线发生变化的同时价格也会发生变化。 另外你这样做有什么意义吗?
[此贴子已经被作者于2016-8-11 16:05:34编辑过]
|
-- 作者:chenshall -- 发布时间:2016/8/11 16:15:08 -- 反着做对冲啊 |
-- 作者:qwer123 -- 发布时间:2016/8/11 16:42:22 -- 用stkindiex读取程序的holding,乘-1. rr1:=stkindiex(\'if00\',\'qq25.持仓\',0,21,10,0); r12:=-1*rr1; //***************************** if holding=0 and r12>0 then buy(1,r12,limitr,c); if holding=0 and r12<0 then buyshort(1,abs(r12),limitr,c); if holding>0 and r12>0 and holding>r12 then sell(1,holding-r12,limitr,c); if holding>0 and r12>0 and holding<r12 then buy(1,r12-holding,limitr,c); if holding>0 and r12<0 then begin sell(1,holding,limitr,c); buyshort(1,abs(r12),limitr,c); end if holding<0 and r12<0 and holding>r12 then buyshort(1,holding-r12,limitr,c); if holding<0 and r12<0 and holding<r12 then sellshort(1,r12-holding,limitr,c); if holding<0 and r12>0 then begin sellshort(1,holding,limitr,c); buy(1,r12,limitr,c); end if r12=0 and holding>0 then sell(holding>0,holding,limitr,c); if r12=0 and holding<0 then sellshort(holding<0,abs(holding),limitr,c); //******************************** 盈亏:asset-1000000,colorred,linethick1,noaxis; 日盈亏:asset-ref(asset,todaybar),noaxis,colorred,linethick0; 持仓:holding,linethick0; |