欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → 加入交易次数限制后结果异常

   

欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。    


  共有2029人关注过本帖树形打印复制链接

主题:加入交易次数限制后结果异常

美女呀,离线,留言给我吧!
cssfortune
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:83 积分:0 威望:0 精华:0 注册:2014/7/2 11:35:22
加入交易次数限制后结果异常  发帖心情 Post By:2014/7/28 12:22:59    Post IP:14.153.23.238[只看该作者]

早盘突破系统,1分钟上测试2年,

刚开始写完交易次数是1700多;后来添加了一个每天只能交易一手的条件,结果交易次数只有3次了!

添加了交易次数限制的代码如下,是我写的逻辑出错了吗?

 

input:T(30,5,60,5),
SS(1,1,10,1),
U(1,1,10,1),
D(1,1,10,1),
CS(1,1,5,1);//交易次数限制
VARIABLE:NUM=0;//统计开仓动作

 

n:=barslast(date<>ref(date,1))+1;//开盘以来的K线数量
hh:=hhv(high,n);//开盘以来的高价
H30:=valuewhen(time>=opentime(1) and time<=opentime(1)+T*100,hh);//30分钟内的高价
ll:=llv(low,n);//开盘以来的低价
L30:=valuewhen(time>=opentime(1) and time<=opentime(1)+T*100,ll);//30分钟内的低价
上轨:H30+U*MINDIFF,linethick2;
下轨:L30-D*MINDIFF,linethick2;
buycond:=cross(high,上轨);//做多条件
buyshortcond:=cross(下轨,low);//做空条件
buyprice:=max(open,上轨)+1*mindiff;//开多价格
buyshortprice:=min(open,下轨)-1*mindiff;//开空价格

 

stopbuy:max(valuewhen(n=1,open),ref(high,1)*(1-0.5/100)),linedot;//多头止损价位

stopshort:min(valuewhen(n=1,open),ref(low,1)*(1-0.5/100)),linedot;//空头止损价位
sellcond:=cross(stopbuy,low);//平多条件
sellshortcond:=cross(high,stopshort);//平空条件
sellprice:=min(open,stopbuy)-1*mindiff;//平多价格
sellshortprice:=max(open,stopshort)+1*mindiff;//平空价格


entertime:=time>opentime(1)+T*100 and time<closetime(0)-10*100;//入场交易时间
exittime:=time>=closetime(0)-10*100;//平仓离场时间

 

if entertime and holding=0 and num<CS then  {开仓入场}
begin 
 if buycond then
    BEGIN
    buy(1,ss,limitr,buyprice);
    NUM:=NUM+1;
    END
 else if buyshortcond then
    BEGIN
    buyshort(1,ss,limitr,buyshortprice);
    NUM:=NUM+1;
    END
end

 

if enterbars>1 and holding<>0 then {止损离场}
begin
 if holding>0 and sellcond then
    sell(1,ss,limitr,sellprice);
 else if holding<0 and sellshortcond then
    sellshort(1,ss,limitr,sellshortprice);
end

 

if exittime and holding<>0 then  {收盘平仓}
begin
  sell(holding>0,ss,limitr,open-1*mindiff);
  sellshort(holding<0,ss,limitr,open+1*mindiff);
  NUM:=0;
end

 

持仓:holding,linethick0;
净利润:netprofit,linethick0;
资产:asset,linethick0;
资金:cash(0),linethick0;


 
 

 

 

 

 

 

 

 

 


 回到顶部
美女呀,离线,留言给我吧!
cssfortune
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:83 积分:0 威望:0 精华:0 注册:2014/7/2 11:35:22
  发帖心情 Post By:2014/7/28 12:24:43    Post IP:14.153.23.238[只看该作者]

并且检查了一下图表,本来当天是数据是满足交易条件的,却没有显示也没有执行交易信号。

 回到顶部
帅哥哟,离线,有人找我吗?
jinzhe
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:罗宾汉 帖子:46311 积分:50819 威望:0 精华:2 注册:2011/3/23 8:50:25
  发帖心情 Post By:2014/7/28 13:22:14    Post IP:58.246.57.26[只看该作者]

if exittime and holding<>0 then  {收盘平仓}
begin
  sell(holding>0,ss,limitr,open-1*mindiff);
  sellshort(holding<0,ss,limitr,open+1*mindiff);
  NUM:=0;
end

 

改成

 

if exittime and holding<>0 then  {收盘平仓}
begin
  sell(holding>0,ss,limitr,open-1*mindiff);
  sellshort(holding<0,ss,limitr,open+1*mindiff);
end

if exittime then   NUM:=0;



金字塔—专业程序化交易量化投资平台

客户服务部

----------------------------------------------------------- 欢迎您参加我公司的技术培训,具体培训需求请发邮件到service@weistock.com

您的宝贵建议或者投诉,请发往邮箱:weiwei@weistock.com

 回到顶部
美女呀,离线,留言给我吧!
cssfortune
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:83 积分:0 威望:0 精华:0 注册:2014/7/2 11:35:22
  发帖心情 Post By:2014/7/28 13:35:51    Post IP:14.153.23.238[只看该作者]

试了一下,的确纠正过来了图片点击可在新窗口打开查看谢谢、、


 回到顶部