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


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → 先止损后开仓,一一对应

   

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


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

主题:先止损后开仓,一一对应

帅哥哟,离线,有人找我吗?
系统使用者
  11楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:黑侠 帖子:808 积分:667 威望:0 精华:0 注册:2011/4/9 16:17:57
  发帖心情 Post By:2017/5/21 18:09:25    Post IP:110.184.39.21[只看该作者]

//交易系统
temp_ll:=llv(l,2);
if pdd then
begin
   sellshort(1,0,marketr);
   buy(holding=0 and 仓差>0,ss,marketr);
   ll:=temp_ll;
end
 if enterbars>1 and l<ll-2*MINDIFF and holding>0 then sell(1,0,marketr);//止损止盈,实时出场
 if h>valuewhen(TYPE(2),hhv(fh,10)) and holding=0 and 仓差>0 then buy(1,ss,marketr);
 if pkk and holding>0 then sell(1,0,marketr);

temp_hh:=hhv(h,2);
if pkk then
begin
   sell(1,0,marketr);
   buyshort(holding=0 and 仓差<0,ss,marketr);
   hh:=temp_hh;
end
 if enterbars>1 and h>hh+2*MINDIFF and holding<0 then sellshort(1,0,marketr);
 if l<valuewhen(TYPE(4),llv(fl,10)) and holding=0 and 仓差<0 then buyshort(1,ss,marketr);
 if pdd and holding<0 then sellshort(1,0,marketr);

这样?

 回到顶部
帅哥哟,离线,有人找我吗?
系统使用者
  12楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:黑侠 帖子:808 积分:667 威望:0 精华:0 注册:2011/4/9 16:17:57
  发帖心情 Post By:2017/5/21 18:10:28    Post IP:110.184.39.21[只看该作者]

在实盘跑的时候,出现单独的开多或者开空,平多或者平空都正确,(这是止损后的)
1)一遇到双向的开仓(平空开多,平多开空)就出现问题,出现不能平空就出现开多,或者干脆出现信号就不下单。
2)问题出现在这里反手,
if pdd then
begin
   sellshort(1,0,marketr);
   buy(holding=0 and 仓差>0,ss,marketr);
   ll:=temp_ll;
end
估计是不是函数holding实盘问题,实盘取不到持仓。若出现这样的图表交易该如何处理?

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


加好友 发短信
等级:管理员 帖子:26632 积分:0 威望:0 精华:7 注册:2015/4/9 14:59:07
  发帖心情 Post By:2017/5/22 9:14:28    Post IP:180.169.30.6[只看该作者]

一楼:策略运行一班都是先开仓后止损。不太理解这个需求的作用。

另外你的一楼和二楼中的代码,请表述下具体需求,才能判断。

 

问题2:7楼中的内容是你用的是固定时间间隔方式还是走完k模式?

 

holding是账户的虚拟持仓,如果你使用的信号会发生变化,那么holding也会随之变化,(它反馈的不是实际账户的持仓)



编程无捷径,技巧靠积累。
 回到顶部
帅哥哟,离线,有人找我吗?
系统使用者
  14楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:黑侠 帖子:808 积分:667 威望:0 精华:0 注册:2011/4/9 16:17:57
  发帖心情 Post By:2017/5/22 11:33:21    Post IP:222.211.183.68[只看该作者]

都是固定时间间隔

holding是账户的虚拟持仓,如果你使用的信号会发生变化,那么holding也会随之变化,(它反馈的不是实际账户的持仓)
图表实际账户的持仓,使用那个函数?

 回到顶部
帅哥哟,离线,有人找我吗?
系统使用者
  15楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:黑侠 帖子:808 积分:667 威望:0 精华:0 注册:2011/4/9 16:17:57
  发帖心情 Post By:2017/5/22 11:34:34    Post IP:222.211.183.68[只看该作者]

具体思路
1)条件pdd:=aq1>=1 and l>fl;开多
            pkk:=aq1>=1 and h<fh;开空
2)平仓就反手
3)若开仓后,开多的跌破开仓对应的2日最低点-2滑点止损;若开空的升破开仓对应的2日高点+2滑点止损;动态实盘止损。
4)若开多止损后,很快价格又再次上涨突破上次开多的10日内高点位置,开多单;
    开空止损相反;   平仓条件执行1)

//交易系统
temp_ll:=llv(l,2);
if pdd then
begin
   sellshort(1,0,marketr);
   buy(holding=0 and 仓差>0,ss,marketr);
   ll:=temp_ll;
end
 if enterbars>1 and l<ll-2*MINDIFF and holding>0 then sell(1,0,marketr);//止损止盈,实时出场
 if h>valuewhen(TYPE(2),hhv(fh,10)) and holding=0 and 仓差>0 then buy(1,ss,marketr);
 if pkk and holding>0 then sell(1,0,marketr);

temp_hh:=hhv(h,2);
if pkk then
begin
   sell(1,0,marketr);
   buyshort(holding=0 and 仓差<0,ss,marketr);
   hh:=temp_hh;
end
 if enterbars>1 and h>hh+2*MINDIFF and holding<0 then sellshort(1,0,marketr);
 if l<valuewhen(TYPE(4),llv(fl,10)) and holding=0 and 仓差<0 then buyshort(1,ss,marketr);
 if pdd and holding<0 then sellshort(1,0,marketr);

这样?

 回到顶部
帅哥哟,离线,有人找我吗?
系统使用者
  16楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:黑侠 帖子:808 积分:667 威望:0 精华:0 注册:2011/4/9 16:17:57
  发帖心情 Post By:2017/5/22 11:36:09    Post IP:222.211.183.68[只看该作者]

上面代码编写正确的话,请帮忙改为后台模式

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


加好友 发短信
等级:管理员 帖子:26632 积分:0 威望:0 精华:7 注册:2015/4/9 14:59:07
  发帖心情 Post By:2017/5/22 12:51:44    Post IP:180.169.30.6[只看该作者]

图表无法直接操作实际账户持仓。需要用后台才行。图表中使用后台函数会造成信号闪烁。

 

 

temp_ll:=llv(l,2);
if pdd then
begin
   tsellshort(1,0,MKT),ORDERQUEUE;
   tbuy(holding=0 and 仓差>0,ss,MKT),ORDERQUEUE;
   ll:=temp_ll;
end
 if tenterbars>1 and l<ll-2*MINDIFF and tholding>0 then tsell(1,0,MKT);//止损止盈,实时出场
 if h>valuewhen(tTYPE(2),hhv(fh,10)) and tholding=0 and 仓差>0 then tbuy(1,ss,MKT);
 if pkk and tholding>0 then tsell(1,0,MKT);


temp_hh:=hhv(h,2);
if pkk then
begin
   tsell(1,0,MKT),ORDERQUEUE;
   tbuyshort(tholding=0 and 仓差<0,ss,MKT),ORDERQUEUE;
   hh:=temp_hh;
end
 if tenterbars>1 and h>hh+2*MINDIFF and tholding<0 then tsellshort(1,0,MKT);
 if l<valuewhen(tTYPE(4),llv(fl,10)) and tholding=0 and 仓差<0 then tbuyshort(1,ss,MKT);
 if pdd and tholding<0 then tsellshort(1,0,MKT);

[此贴子已经被作者于2017/5/22 15:27:31编辑过]


编程无捷径,技巧靠积累。
 回到顶部
总数 17 上一页 1 2