以文本方式查看主题 - 金字塔客服中心 - 专业程序化交易软件提供商 (http://weistock.com/bbs/index.asp) -- 公式模型编写问题提交 (http://weistock.com/bbs/list.asp?boardid=4) ---- 为什么会开平同时下单,老师看下 (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=100655) |
-- 作者:splisun -- 发布时间:2016/7/11 9:28:14 -- 为什么会开平同时下单,老师看下 多头止盈:=h>ref(close,enterbars)*1.005 and enterbars>1; 多头止损:=l<ref(close,enterbars)*0.995 and enterbars>1; 空头止盈:=l<ref(close,enterbars)*0.995 and enterbars>1; 空头止损:=h>ref(close,enterbars)*1.005 and enterbars>1; //********************交易系统*****提前n秒下单******************************* input:tq(5,3,60,1);//定义变量 abb:=(time0-timetot0(dynainfo(207))<=tq) or not(islastbar); if abb then begin if holding=0 and 开多 then buy(1,1,thisclose),ignorecheckprice,orderqueue; if holding=0 and 开空 then buyshort(1,1,thisclose),ignorecheckprice,orderqueue; if holding>0 and 多头止损 then sell(1,1,thisclose),ignorecheckprice,orderqueue; if holding<0 and 空头止损 then sellshort(1,1,thisclose),ignorecheckprice,orderqueue; end //***************************提前n秒下单********************************** if abb then begin if holding>0 and 多头止盈 then sell(1,1,thisclose),ignorecheckprice,orderqueue;//多头平仓 if holding<0 and 空头止盈 then sellshort(1,1,thisclose),ignorecheckprice,orderqueue;//空头平仓 end |
-- 作者:jinzhe -- 发布时间:2016/7/11 9:35:39 -- 因为k线图上同时出了开和平的信号,说明此时开平条件是同时满足的 |
-- 作者:splisun -- 发布时间:2016/7/11 9:44:39 -- 止损、止盈要开仓后波动0.5%并且要走一根K线以后,怎么可能同时开平呢 |
-- 作者:jinzhe -- 发布时间:2016/7/11 9:47:30 -- 因为代码里面的enterbars判断是写在开仓之前的,所以止损判断里面就变成了判断上一次开仓的周期而不是现在开仓的周期
直接把开仓周期判断,写在平仓语句里面,不要提前写 |
-- 作者:splisun -- 发布时间:2016/7/11 9:55:50 -- 在改成这样才行吗? 多头止盈:=h>ref(close,enterbars)*1.005; 多头止损:=l<ref(close,enterbars)*0.995; 空头止盈:=l<ref(close,enterbars)*0.995; 空头止损:=h>ref(close,enterbars)*1.005;
|
-- 作者:jinzhe -- 发布时间:2016/7/11 10:03:24 -- 多头止盈:=h>ref(close,enterbars)*1.005 and enterbars>1;
多头止损:=l<ref(close,enterbars)*0.995 and enterbars>1;
空头止盈:=l<ref(close,enterbars)*0.995 and enterbars>1;
空头止损:=h>ref(close,enterbars)*1.005 and enterbars>1;
//********************交易系统*****提前n秒下单*******************************
input:tq(5,3,60,1);//定义变量
abb:=(time0-timetot0(dynainfo(207))<=tq) or not(islastbar);
if abb then begin
if holding=0 and 开多 then buy(1,1,thisclose),ignorecheckprice,orderqueue;
if holding=0 and 开空 then buyshort(1,1,thisclose),ignorecheckprice,orderqueue;
if holding>0 and 多头止损 and enterbars>1 then sell(1,1,thisclose),ignorecheckprice,orderqueue;
if holding<0 and 空头止损 and enterbars>1 then sellshort(1,1,thisclose),ignorecheckprice,orderqueue;
end
//***************************提前n秒下单**********************************
if abb then begin
if holding>0 and 多头止盈 and enterbars>1 then sell(1,1,thisclose),ignorecheckprice,orderqueue;//多头平仓
if holding<0 and 空头止盈 and enterbars>1 then sellshort(1,1,thisclose),ignorecheckprice,orderqueue;//空头平仓
end
|
-- 作者:splisun -- 发布时间:2016/7/11 10:06:35 -- 多谢,测试 |