金字塔决策交易系统

 找回密码
 

微信登录

微信扫一扫,快速登录

搜索
查看: 3989|回复: 4

老师麻烦帮忙把这个代码改成条件选股,谢谢。

[复制链接]

5

主题

16

帖子

16

积分

Rank: 1

等级: 新手上路

注册:
2022-5-26
曾用名:
发表于 2022-5-26 15:31 | 显示全部楼层 |阅读模式
老师麻烦帮忙把这个代码改成条件选股,谢谢。


variable:gsum=0;  
variable:glong=0;
variable:glow=0;   

DIFF := EMA(CLOSE,12) - EMA(CLOSE,26);
DEA  := EMA(DIFF,9);
MACD := 2*(DIFF-DEA);

gnum:=barslast(ref(macd>0,1) and macd<0);   
bnum:=barslast(ref(macd<0,1) and macd>0);   

if ref(macd,1)>0 and macd<0 then
begin
   gsum:=0;                                                            
   glong:=0;                                                        
   glow:=low;                                                      
end


if macd<0 then
begin
   gsum:=gsum+macd;                                          
   if abs(macd)>abs(glong) then glong:=macd;
   if low<glow then glow:=low;                           
end
numb:=max(gnum,bnum)+1;
con1:=abs(gsum)<abs(ref(gsum,numb));      
con1.2:=abs(gsum)<(abs(ref(gsum,numb)))/2;  
con2:=abs(glong)<abs(ref(glong,numb));   
con3:=glow<ref(glow,numb);        

//下单模块

if all(macd<0,3) and ref(macd,1)<macd and ref(macd,1)<ref(macd,2) then
begin
   if con1.2 and con2 and con3 then buy(1,1,market);      
end

if ref(macd<0,1) and macd>0 and holding>0 then
begin
    if con1 and con2 and con3  then 加:buy(1,1,market);   
end

回复

使用道具 举报

21

主题

1万

帖子

1万

积分

Rank: 8Rank: 8

等级: 超级版主

注册:
2021-5-18
曾用名:
FireScript
发表于 2022-5-26 16:13 | 显示全部楼层
你把下单的条件
xgtj:all(macd<0,3) and ref(macd,1)<macd and ref(macd,1)<ref(macd,2) ;

直接改成选股条件就行了呀。
金字塔提供一对一VIP专业技术指导服务,技术团队实时响应您的日常使用问题与策略编写。联系电话:021-20339086
回复

使用道具 举报

5

主题

16

帖子

16

积分

Rank: 1

等级: 新手上路

注册:
2022-5-26
曾用名:
 楼主| 发表于 2022-5-26 16:23 | 显示全部楼层
file:///C:/Users/Administrator/Desktop/1653553070(1).jpg

改了后提示使用了交易函数,可能无法正常工作
而且我改后没有一个结果,选了历史也没有一个结果
回复

使用道具 举报

5

主题

16

帖子

16

积分

Rank: 1

等级: 新手上路

注册:
2022-5-26
曾用名:
 楼主| 发表于 2022-5-26 16:24 | 显示全部楼层
改了后提示使用了交易函数,可能无法正常工作
而且我改后没有一个结果,选了历史也没有一个结果
截图202205261623535315.jpg
回复

使用道具 举报

21

主题

1万

帖子

1万

积分

Rank: 8Rank: 8

等级: 超级版主

注册:
2021-5-18
曾用名:
FireScript
发表于 2022-5-26 16:37 | 显示全部楼层
[PEL] 复制代码
variable:gsum=0;  
variable:glong=0;
variable:glow=0;   

DIFF := EMA(CLOSE,12) - EMA(CLOSE,26);
DEA  := EMA(DIFF,9);
MACD := 2*(DIFF-DEA);

gnum:=barslast(ref(macd>0,1) and macd<0);   
bnum:=barslast(ref(macd<0,1) and macd>0);   

if ref(macd,1)>0 and macd<0 then
begin
   gsum:=0;                                                            
   glong:=0;                                                        
   glow:=low;                                                      
end


if macd<0 then
begin
   gsum:=gsum+macd;                                          
   if abs(macd)>abs(glong) then glong:=macd;
   if low<glow then glow:=low;                           
end
numb:=max(gnum,bnum)+1;
con1:=abs(gsum)<abs(ref(gsum,numb));      
con1.2:=abs(gsum)<(abs(ref(gsum,numb)))/2;  
con2:=abs(glong)<abs(ref(glong,numb));   
con3:=glow<ref(glow,numb);        

选股1:all(macd<0,3) and ref(macd,1)<macd and ref(macd,1)<ref(macd,2) and con1.2 and con2 and con3;
选股2:ref(macd<0,1) and macd>0 and con1 and con2 and con3;
选股:选股1 or 选股2;


建议学习下基本语法。否则后续是无法更深入使用的。
金字塔提供一对一VIP专业技术指导服务,技术团队实时响应您的日常使用问题与策略编写。联系电话:021-20339086
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-5-29 06:44 , Processed in 0.110285 second(s), 24 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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