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


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → 加入止损公式一直未能成功,郁闷

   

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


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

主题:加入止损公式一直未能成功,郁闷

帅哥哟,离线,有人找我吗?
lty9055
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:18 积分:0 威望:0 精华:0 注册:2014/12/18 21:14:50
加入止损公式一直未能成功,郁闷  发帖心情 Post By:2015/1/14 12:59:05    Post IP:116.252.64.168[只看该作者]

buycond:=count(c>o,2)=2;
sellcond:=count(c<o,2)=2;
if holding>0 and sellcond then sell(1,1,thisclose);
if holding<0 and buycond then sellshort(1,1,thisclose);
if holding=0 and buycond then buy(1,1,thisclose);
if holding=0 and sellcond then buyshort(1,1,thisclose);

 

老师,想在该策略上加入止损,一直弄不成,非常郁闷!

我的想法:入场后在次周期内如亏损5个点即时止损;在第二个周期内如亏损2个点即时止损;在第三个周期内如平本即时止损;在第四个周期内如盈利返回10%即时止盈。用于股指使用。


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


加好友 发短信
等级:超级版主 帖子:8439 积分:0 威望:0 精华:0 注册:2014/7/14 13:43:36
  发帖心情 Post By:2015/1/14 13:09:15    Post IP:58.246.57.26[只看该作者]


if enterbars=1 and enterprice-l>=5 then sell(holding>0,holding,market);
if enterbars=1 and h-enterprice>=5 then sellshort(holding<0,holding,market);
if enterbars=2 and enterprice-l>=2 then sell(holding>0,holding,market);
if enterbars=2 and h-enterprice>=2 then sellshort(holding<0,holding,market);
if enterbars=3 and enterprice-l>=0 then sell(holding>0,holding,market);
if enterbars=3 and h-enterprice>=0 then sellshort(holding<0,holding,market);

if enterbars=4 and h-enterprice>=0.1*enterprice then sell(holding>0,holding,market);
if enterbars=4 and enterprice-l>=0.1*enterprice then sellshort(holding<0,holding,market);

[此贴子已经被作者于2015/1/14 13:09:27编辑过]

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


加好友 发短信
等级:新手上路 帖子:18 积分:0 威望:0 精华:0 注册:2014/12/18 21:14:50
  发帖心情 Post By:2015/1/14 15:12:09    Post IP:116.252.64.168[只看该作者]

if enterbars=1 and enterprice-l>=5 then sell(holding>0,holding,market);
if enterbars=1 and h-enterprice>=5 then sellshort(holding<0,holding,market);
if enterbars=2 and enterprice-l>=2 then sell(holding>0,holding,market);
if enterbars=2 and h-enterprice>=2 then sellshort(holding<0,holding,market);
if enterbars=3 and enterprice-l>=0 then sell(holding>0,holding,market);
if enterbars=3 and h-enterprice>=0 then sellshort(holding<0,holding,market);

if enterbars=4 and h-enterprice>=0.1*enterprice then sell(holding>0,holding,market);
if enterbars=4 and enterprice-l>=0.1*enterprice then sellshort(holding<0,holding,market);

感谢老师!

有个地方改动一下,我不想在次周期开盘价执行止损,我想一当碰到了马上发出指令执行止损。这应该改为哪个?谢谢


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


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

在图表交易里面设置为 固定时间间隔模式


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

客户服务部

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

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

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


加好友 发短信
等级:新手上路 帖子:18 积分:0 威望:0 精华:0 注册:2014/12/18 21:14:50
  发帖心情 Post By:2015/1/14 16:14:52    Post IP:116.252.64.168[只看该作者]

我的想法:入场后在次周期内如亏损5个点即时止损;在第二个周期内如亏损2个点即时止损;在第三个周期内如平本即时止损;在第四个周期内如盈利返回10%即时止盈。用于股指使用。

 

老师,可能我写的不够明白,应该是次周期内如亏损5个点即时止损;在第二个周期内如比较上周期收盘价低2个点即时止损;在第三个周期内如比较上周期收盘价平本即时止损;在第四个周期内如盈利返回10%即时止盈。

 

已经止损了,就不能再开仓,这个公式放在系统内,经常出现平仓后又马上开仓的情况。

能不能用“止损”“止盈”符号在k线图中标识,如果是平空平多,很混乱。感谢老师!


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


加好友 发短信
等级:超级版主 帖子:8439 积分:0 威望:0 精华:0 注册:2014/7/14 13:43:36
  发帖心情 Post By:2015/1/14 16:29:13    Post IP:58.246.57.26[只看该作者]

意思和上周期收盘价先比而不是和开仓价相比止损?

盈利返回10%是指盈利开仓价的10%?


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


加好友 发短信
等级:新手上路 帖子:18 积分:0 威望:0 精华:0 注册:2014/12/18 21:14:50
  发帖心情 Post By:2015/1/14 17:31:26    Post IP:116.252.64.168[只看该作者]

是的,感谢老师

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


加好友 发短信
等级:超级版主 帖子:8439 积分:0 威望:0 精华:0 注册:2014/7/14 13:43:36
  发帖心情 Post By:2015/1/15 9:29:55    Post IP:58.246.57.26[只看该作者]

VARIABLE:n=0,m=0;
buycond:=count(c>o,2)=2;
sellcond:=count(c<o,2)=2;
c1:VALUEWHEN(enterbars=1,c);//开仓后下根k的收盘价
c2:VALUEWHEN(enterbars=2,c);//开仓后第二根k的收盘价

if holding>0 and sellcond then sell(1,1,thisclose);
if holding<0 and buycond then sellshort(1,1,thisclose);
if holding=0 and n=0 and buycond then  buy(1,1,thisclose);
if holding=0 and m=0 and sellcond then  buyshort(1,1,thisclose);

 

if enterbars=1 and enterprice-l>=5 then begin
 sell(holding>0,holding,market);
 n:=1;
 end
if enterbars=1 and h-enterprice>=5 then begin
sellshort(holding<0,holding,market);
m:=1;
end

if enterbars=2 and c1-l>=2 then begin
 sell(holding>0,holding,market);
 n:=1;
 end
if enterbars=2 and h-c1>=2 then begin
 sellshort(holding<0,holding,market);
 m:=1;
 end
if enterbars=3 and c2-l>=0 then begin
 sell(holding>0,holding,market);
 n:=1;
 end
if enterbars=3 and h-c2>=0 then begin
sellshort(holding<0,holding,market);
m:=1;
end

if enterbars=4 and h-enterprice>=0.1*enterprice then begin
sell(holding>0,holding,market);
n:=1;
end
if enterbars=4 and enterprice-l>=0.1*enterprice then begin
 sellshort(holding<0,holding,market);
m:=1;
end
if time=CLOSETIME(0) then begin//止损后不开仓第二天再开仓
 n:=0;
 m:=0;
end

[此贴子已经被作者于2015/1/15 9:45:01编辑过]

 回到顶部