金字塔决策交易系统

 找回密码
 

微信登录

微信扫一扫,快速登录

搜索
查看: 2832|回复: 3

5%止损

[复制链接]

60

主题

193

帖子

193

积分

等级: 免费版

注册:
2021-7-30
曾用名:
发表于 2023-5-8 20:41 | 显示全部楼层 |阅读模式
我是专业版用户,请问老师,我要实现5%止损,以下写法有什么问题吗,后台程序化不执行止损。应该如何写

a20:=a10 and a11;
a21:=jdma515f<=0 and jdma20<=0;
a22:=(c-tenterprice)/tenterprice*100>=0.5;

tbuyshort(a20 and tsellholding(1)=0 ,ss ,lmt,dynainfo(28));
if c<tenterprice then tsellshort(a21 ,tsellholding(1) ,lmt,dynainfo(34));
if c>tenterprice then tsellshort(a22 ,tsellholding(1) ,lmt,dynainfo(34));

b20:=b10 and b11;
b21:=jdma515f>=0 and jdma20>=0;
b22:=(tenterprice-c)/tenterprice*100>=0.5;

tbuy(b20 and tbuyholding(1)=0 ,ss ,lmt,dynainfo(34));
if c>tenterprice then tsell(b21 ,tbuyholding(1) ,lmt,dynainfo(28));
if c<tenterprice then tsell(b22 ,tbuyholding(1) ,lmt,dynainfo(28));

回复

使用道具 举报

21

主题

1万

帖子

1万

积分

Rank: 8Rank: 8

等级: 超级版主

注册:
2021-5-18
曾用名:
FireScript
发表于 2023-5-9 09:13 | 显示全部楼层
a22:=(c-tenterprice)/tenterprice*100>=0.5;  

你这样写是涨幅大于 0.5% 了。

另外你在后台上是走完K还是固定时间间隔呢?如果是走完K,信号是无法实时下单的,你改成固定时间间隔模式进行下单。
金字塔提供一对一VIP专业技术指导服务,技术团队实时响应您的日常使用问题与策略编写。联系电话:021-20339086
回复

使用道具 举报

37

主题

1万

帖子

6万

积分

Rank: 8Rank: 8

等级: 超级版主

注册:
2021-5-18
曾用名:
wenarm
发表于 2023-5-9 09:20 | 显示全部楼层
代码写法上除了冗余外,逻辑判断上没有问题。(如果是5%,应该是5而不是0.5)

可以调整下代码,并通过debugfile输出结果看下。
[PEL] 复制代码
a22:=(c-tenterprice)/tenterprice*100>=5;
tbuyshort(a20 and tsellholding(1)=0 ,ss ,lmt,dynainfo(28));
if c<tenterprice then tsellshort(a21 ,tsellholding(1) ,lmt,dynainfo(34));


b20:=b10 and b11;
b21:=jdma515f>=0 and jdma20>=0;

b22:=(tenterprice-c)/tenterprice*100>=5;
tbuy(b20 and tbuyholding(1)=0 ,ss ,lmt,dynainfo(34));
if c>tenterprice then tsell(b21 ,tbuyholding(1) ,lmt,dynainfo(28));

//输出参与止损的各个因子结果。
DEBUGFILE('d:\'&STKLABEL&'.TXT','close='&NUMTOSTR(close,2)& '   tenterprice='& NUMTOSTR(tenterprice,2) & '   tbuyholding='& NUMTOSTR(tbuyholding(1),0),1);
if a22=1  then tsellshort(1 ,tsellholding(1) ,lmt,dynainfo(34));
if b22=1 then tsell(1 ,tbuyholding(1) ,lmt,dynainfo(28));
金字塔提供一对一VIP专业技术指导服务,技术团队实时响应您的日常使用问题与策略编写。联系电话:021-20339086
回复

使用道具 举报

12

主题

56

帖子

56

积分

等级: 免费版

注册:
2024-4-26
曾用名:
发表于 2024-5-31 09:23 | 显示全部楼层
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-7-28 04:51 , Processed in 0.080698 second(s), 21 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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