金字塔决策交易系统

 找回密码
 

微信登录

微信扫一扫,快速登录

搜索
楼主: 袁林

止损

[复制链接]

32

主题

178

帖子

178

积分

等级: 免费版

注册:
2023-3-7
曾用名:
 楼主| 发表于 2024-3-12 13:32 | 显示全部楼层
技术006 发表于 2024-3-12 11:21
你的意思是,移动止损后,不在开多单。而是等待空单条件成立做空?

是的

补充内容 (2024-3-12 13:37):
麻烦老师帮看下怎改,用了全局变量,感觉很难修改
回复

使用道具 举报

44

主题

1万

帖子

1万

积分

Rank: 8Rank: 8

等级: 超级版主

注册:
2021-5-18
曾用名:
发表于 2024-3-12 13:42 | 显示全部楼层
if c>o   then
begin
        sellshort(1,holding,marketr);
        buy((type(1)=4 or type(1)=0),1,marketr);
END


if c<o   then
begin
        sell(1,holding,marketr);
        buyshort((type(1)=2 or type(1)=0),1,marketr);
END
金字塔提供一对一VIP专业技术指导服务,技术团队实时响应您的日常使用问题与策略编写。联系电话:021-20339086
回复

使用道具 举报

44

主题

1万

帖子

1万

积分

Rank: 8Rank: 8

等级: 超级版主

注册:
2021-5-18
曾用名:
发表于 2024-3-12 13:42 | 显示全部楼层
参考上面例子自己看下,开仓条件中加一个判断上次的交易信号类型
开多要求上次交易信号是平空
开空要求上次交易信号是平多
金字塔提供一对一VIP专业技术指导服务,技术团队实时响应您的日常使用问题与策略编写。联系电话:021-20339086
回复

使用道具 举报

32

主题

178

帖子

178

积分

等级: 免费版

注册:
2023-3-7
曾用名:
 楼主| 发表于 2024-3-13 11:24 | 显示全部楼层
技术008 发表于 2024-3-12 13:42
参考上面例子自己看下,开仓条件中加一个判断上次的交易信号类型
开多要求上次交易信号是平空
开空要求上 ...

variable:zs:=c,hl:=c;//声明全局变量zs、hl
ma5:=ma(c,5);
ma20:=ma(c,20);
atr:ma(h-l,20);//市场平均波动幅度
buycond:=cross(ma5,ma20);//平空开多条件
sellcond:=cross(ma20,ma5);//平多开空条件

h1:=hhv(h,enterbars+1);//注意 这里是用h统计,你也可以考虑用c  
if holding>0  and hl then begin
多止损:zs;
if l<zs and h1-avgenterprice>=50*mindiff then 多回撤止损1:sell(1,1,limitr,min(o,zs)-mindiff);
else if sellcond then sell(1,1,limitr,c);
buyshort((type(1)=2 or type(1)=0),1,marketr);
end
l1:=llv(l,enterbars+1);//注意 这里是用l统计,你也可以考虑用c
if holding<0 then begin
空止损:zs;
if h>zs and avgenterprice-l1>=50*mindiff then 空回撤止损1:sellshort(1,1,limitr,max(o,zs)+mindiff);
else if buycond then sellshort(1,1,limitr,c);
buy((type(1)=4 or type(1)=0),1,marketr);
end

if holding=0 and buycond then begin//多头开仓
buy(1,1,limitr,c);
zs:=c-2*atr;
hl:=c;//hl开仓后的最有利价位,刚买入时,最有利价位为开仓价
end

if holding=0 and sellcond then begin//空头开仓
buyshort(1,1,limitr,c);
zs:=c+2*atr;
hl:=c;
end

if holding>0 and enterbars>0 and h>hl  then begin//最高价抬升,止损位相应地抬升
hl:=h;
zs:=hl-2*atr;
end

if holding<0 and enterbars>0 and l<hl  then begin//最低价下降,止损位相应地下移
hl:=l;
zs:=l+2*atr;
end



补充内容 (2024-3-13 11:26):
老师,我把buyshort((type(1)=2 or type(1)=0),1,marketr);与buyshort((type(1)=2 or type(1)=0),1,marketr);放上去,不知对不,但信号全显示不出了
回复

使用道具 举报

44

主题

1万

帖子

1万

积分

Rank: 8Rank: 8

等级: 超级版主

注册:
2021-5-18
曾用名:
发表于 2024-3-13 13:06 | 显示全部楼层
variable:zs:=c,hl:=c;//声明全局变量zs、hl
ma5:=ma(c,5);
ma20:=ma(c,20);
atr:ma(h-l,20);//市场平均波动幅度
buycond:=cross(ma5,ma20);//平空开多条件
sellcond:=cross(ma20,ma5);//平多开空条件

h1:=hhv(h,enterbars+1);//注意 这里是用h统计,你也可以考虑用c  
if holding>=0  and hl then begin
多止损:zs;
if l<zs and h1-avgenterprice>=50*mindiff then 多回撤止损1:sell(1,1,limitr,min(o,zs)-mindiff);
else if sellcond then sell(1,1,limitr,c);
buyshort((type(1)=2 or type(1)=0),1,marketr);
end
l1:=llv(l,enterbars+1);//注意 这里是用l统计,你也可以考虑用c
if holding<=0 then begin
空止损:zs;
if h>zs and avgenterprice-l1>=50*mindiff then 空回撤止损1:sellshort(1,1,limitr,max(o,zs)+mindiff);
else if buycond then sellshort(1,1,limitr,c);
buy((type(1)=4 or type(1)=0),1,marketr);
end

if holding=0 and buycond then begin//多头开仓
buy(1,1,limitr,c);
zs:=c-2*atr;
hl:=c;//hl开仓后的最有利价位,刚买入时,最有利价位为开仓价
end

if holding=0 and sellcond then begin//空头开仓
buyshort(1,1,limitr,c);
zs:=c+2*atr;
hl:=c;
end

if holding>0 and enterbars>0 and h>hl  then begin//最高价抬升,止损位相应地抬升
hl:=h;
zs:=hl-2*atr;
end

if holding<0 and enterbars>0 and l<hl  then begin//最低价下降,止损位相应地下移
hl:=l;
zs:=l+2*atr;
end
金字塔提供一对一VIP专业技术指导服务,技术团队实时响应您的日常使用问题与策略编写。联系电话:021-20339086
回复

使用道具 举报

44

主题

1万

帖子

1万

积分

Rank: 8Rank: 8

等级: 超级版主

注册:
2021-5-18
曾用名:
发表于 2024-3-13 13:07 | 显示全部楼层
if holding>=0然后开空
金字塔提供一对一VIP专业技术指导服务,技术团队实时响应您的日常使用问题与策略编写。联系电话:021-20339086
回复

使用道具 举报

32

主题

178

帖子

178

积分

等级: 免费版

注册:
2023-3-7
曾用名:
 楼主| 发表于 2024-3-13 17:21 | 显示全部楼层
技术008 发表于 2024-3-13 13:07
if holding>=0然后开空

即一次开多,够50点后,才移动止损,之后就不能开仓了,等下个开仓信号

补充内容 (2024-3-13 17:22):
回复

使用道具 举报

32

主题

178

帖子

178

积分

等级: 免费版

注册:
2023-3-7
曾用名:
 楼主| 发表于 2024-3-13 17:23 | 显示全部楼层
图中所示,移动止损后就不可出现开仓,只能等下个信号

补充内容 (2024-3-13 17:26):
图中移动止损后不是我预设的信号,是移动止损带来的,我是想这些移动止损后的信号不可出现

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号? 微信登录

x
回复

使用道具 举报

44

主题

1万

帖子

1万

积分

Rank: 8Rank: 8

等级: 超级版主

注册:
2021-5-18
曾用名:
发表于 2024-3-13 17:31 | 显示全部楼层
你看下是哪个开空语句触发的呢?
你上面代码其实是由两个开空语句的,下面一个开空语句只要符合条件就会开空的
金字塔提供一对一VIP专业技术指导服务,技术团队实时响应您的日常使用问题与策略编写。联系电话:021-20339086
回复

使用道具 举报

32

主题

178

帖子

178

积分

等级: 免费版

注册:
2023-3-7
曾用名:
 楼主| 发表于 2024-3-13 19:34 | 显示全部楼层
技术008 发表于 2024-3-13 17:31
你看下是哪个开空语句触发的呢?
你上面代码其实是由两个开空语句的,下面一个开空语句只要符合条件就会开 ...

buy((type(1)=4 or type(1)=0),1,marketr);
buyshort((type(1)=2 or type(1)=0),1,marketr);
这两句触发的,开空,同样在空方时,又会开多
问题是移动止损执行后,怎样不让它开仓,等cross(ma5,ma20);或cross(ma20,ma5)才开仓
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 微信登录

本版积分规则

手机版|小黑屋|上海金之塔信息技术有限公司 ( 沪ICP备13035422号 )

GMT+8, 2025-8-2 04:08 , Processed in 0.181232 second(s), 20 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表