以文本方式查看主题 - 金字塔客服中心 - 专业程序化交易软件提供商 (http://weistock.com/bbs/index.asp) -- 公式模型编写问题提交 (http://weistock.com/bbs/list.asp?boardid=4) ---- 请教平仓代码的问题 (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=59599) |
-- 作者:punkcat401 -- 发布时间:2013/12/6 9:18:44 -- 请教平仓代码的问题 variable:maxprofit=0;
IF holding>0 and enterbars>0 THEN BEGIN
盈利大于50,小于100,这个条件描述是用 maxprofit>50 and maxprofit<100,还是 win>50 AND win<100 呢?
我之前用的maxprofit,但空头(enterprice-L)止盈结果不对,用win反而对了,但是多头止盈又不正常了。 |
-- 作者:jinzhe -- 发布时间:2013/12/6 9:41:27 -- maxprofit_duo:=hhv(h-enterprice,enterbars+1); maxprofit_kong:=llv(enterprice-l,enterbars+1);
if maxprofit_duo>100 and maxprofit_duo<50 and holding>0 and c-enterpcie<=0.3*maxprofit_duo then sell; if maxprofit_kong>100 and maxprofit_kong<50 and holding<0 and enterpcie-c<=0.3*maxprofit_kong then sell; |
-- 作者:punkcat401 -- 发布时间:2013/12/6 11:32:00 -- 以下是引用jinzhe在2013/12/6 9:41:27的发言:
maxprofit_duo:=hhv(h-enterprice,enterbars+1); maxprofit_kong:=llv(enterprice-l,enterbars+1);
if maxprofit_duo>100 and maxprofit_duo<50 and holding>0 and c-enterpcie<=0.3*maxprofit_duo then sell; if maxprofit_kong>100 and maxprofit_kong<50 and holding<0 and enterpcie-c<=0.3*maxprofit_kong then sell; c-enterpcie<=0.3*maxprofit_duo then sell 回撤超过30%,应该是 c-enterpcie <= (1-0.3)*maxprofit_duo 吧? |
-- 作者:jinzhe -- 发布时间:2013/12/6 13:05:32 -- 这个数学上的定义,用户自己斟酌吧,我主要给出思路 |
-- 作者:punkcat401 -- 发布时间:2013/12/6 14:50:09 -- 以下是引用jinzhe在2013/12/6 13:05:32的发言:
if maxprofit_kong>100 and maxprofit_kong<50 and holding<0 and enterpcie-c<=0.3*maxprofit_kong then sell;
多头没问题,空头仍然不对,不出信号,空头如果去掉“maxprofit_kong>100 and maxprofit_kong<50” 这个条件就正常了
这也太怪了吧,为啥呢 |
-- 作者:jinzhe -- 发布时间:2013/12/6 15:00:00 -- maxprofit_duo:=hhv(h-enterprice,enterbars+1); maxprofit_kong:=llv(enterprice-l,enterbars+1);
这个要改一改
maxprofit_duo:=hhv(henterbars+1)-enterprice,; maxprofit_kong:=enterprice-llv(l,enterbars+1); |
-- 作者:punkcat401 -- 发布时间:2013/12/6 15:10:30 -- 以下是引用jinzhe在2013/12/6 15:00:00的发言:
maxprofit_duo:=hhv(h-enterprice,enterbars+1); maxprofit_kong:=llv(enterprice-l,enterbars+1);
这个要改一改
maxprofit_duo:=hhv(henterbars+1)-enterprice,; maxprofit_kong:=enterprice-llv(l,enterbars+1); 信号是有了,但是后面“enterpcie-c<=0.3*maxprofit_kong ” 不对,用>=或<=都不对 |
-- 作者:jinzhe -- 发布时间:2013/12/6 15:17:58 -- 有什么不对的地方? |
-- 作者:punkcat401 -- 发布时间:2013/12/6 15:31:40 -- 以下是引用jinzhe在2013/12/6 15:17:58的发言:
有什么不对的地方? maxprofit_kong:=llv(enterprice-l,enterbars+1); if maxprofit_kong>100 and holding<0 and enterprice-c<=0.3*maxprofit_kong then sell;
这两行平空的代码,有的地方是回撤参数不管填多少都不变,有的是回撤比例完全和参数不对,有的是开仓后第二根就平掉但没有回撤
之前的代码只是空头有问题,多头没问题,这是什么原因呢,和我最开始的写法一样,都是空头没信号 [此贴子已经被作者于2013/12/6 15:32:41编辑过]
|
-- 作者:jinzhe -- 发布时间:2013/12/6 15:42:43 -- 100是具体的资金还是点数? |