以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  请问这段代码为何在图表上没有收盘平仓的信号?  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=31224)

--  作者:mao100003801
--  发布时间:2012/12/6 13:04:12
--  请问这段代码为何在图表上没有收盘平仓的信号?

//买开执行
if cond1  and time <151200  then
 begin
 if holding<0 then bp0:SELLSHORT(1,0,THISCLOSE);//平空 
 if holding=0 then bk1:buy(1,1,THISCLOSE);//开多
 exit;
 end
//平多:
if (cond3 or cond31) and holding>0 then
 begin
 sp1:SELL(1,0,THISCLOSE);//平多
 end

//卖开执行
if cond2  and time <151200 then
 begin
 if holding>0 then  sp0:SELL(1,0,THISCLOSE);//平多
 if holding=0 then  sk1:buySHORT(1,1,THISCLOSE);//开空
 exit;
 end


//多单止损
cond32:=close<Ma(close,5);
if holding>0 then
begin
bkpp:=AVGENTERPRICE;
if close<bkpp-losspoint and cond32 then 多单止损:SELL(1,0,THISCLOSE);//平多
exit;
end

//空单止损
cond41:=close>MA(close,5);
if holding<0 then
begin
skpp:=AVGENTERPRICE;
if close>skpp+losspoint and cond41 then 空单止损:SELLSHORT(1,0,THISCLOSE);//平空
exit;
end

//收盘平仓
if time >151200 and holding<>0 then
begin
 if holding<0 then 收盘平空:SELLSHORT(1,0,THISCLOSE);//平空
 if holding>0 then 收盘平多:SELL(1,0,THISCLOSE);//平多
 end

 

 


--  作者:jinzhe
--  发布时间:2012/12/6 13:13:32
--  
exit是何用意?
--  作者:mao100003801
--  发布时间:2012/12/6 22:44:08
--  
exit用来防止在同一根K线上开平仓。这个会影响最后一段的执行么?
--  作者:RogarZ
--  发布时间:2012/12/6 23:34:08
--  

不明白你exit的意思 同一根开平用enterbar去控制就行了。

 

没有完整的代码,不清楚你这个为什么没有在收盘前平仓。

你试着自己用金字塔的调试功能 单步跟踪下看看。若不会用的话,参考金字塔高级教程