金字塔决策交易系统

 找回密码
 

微信登录

微信扫一扫,快速登录

搜索
查看: 6393|回复: 22

关于本地预警连续推送多个信息问题

[复制链接]

6

主题

35

帖子

35

积分

Rank: 1

等级: 新手上路

注册:
2023-1-19
曾用名:
发表于 2023-1-31 10:37 | 显示全部楼层 |阅读模式
老师,我是新手,我的这个交易预警程序因为设置的K线走完前5秒推送结果,所以会在K线走完前,只要价格不停变化,就会连续推送预警信息,请帮我改一下,只需要推送一次预警信息,就不再推送,谢谢


MA5:=MA(C,5);

MA10:=MA(C,10);

MA20:=MA(C,20);

MA30:=MA(C,30);

MA60:=MA(C,60);

L1:=MIN(MIN(MIN(MA10,MA20),MA30),MA60) ;

L2:=MAX(MAX(MAX(MA10,MA20),MA30),MA60) ;

A:MA5>L1&&(C< REF(C,1) || REF(C,1)< REF(C,2)
|| MA5<MA10 )&&(MA5>MA20 || MA5>MA60) &&(( ( L1>( L-(HHV(H,5)-L)*0.30) AND  REF(C,1)> REF(L1,1) )
  ||( L<L1 AND (REF(C,1)> REF(L1,1) || C>L1)))) ;

B:MA5<L2&&(C> REF(C,1) || REF(C,1)> REF(C,2)
|| MA5>MA10 )&&(MA5<MA20 || MA5<MA60) &&(( ( L2<( H+(H-LLV(L,5))*0.30) AND  REF(C,1)< REF(L2,1) )
  ||( H>L2 AND (REF(C,1)< REF(L2,1) || C<L2)))) ;


sellcond:=A;

BUYCOND:=B;


if sellcond=1 then

  BEGIN

   DEBUGFILE2('D:\AAA\AAA.TXT',stklabel&'   sellcond:%.0f'&' 周期类型='&NUMTOSTR(datatype,0),-2,1);

   END;

    if BUYCOND=1 then

    BEGIN

      DEBUGFILE2('D:\AAA\AAA.TXT',stklabel&'  BUYCON:%.0f'&' 周期类型='&NUMTOSTR(datatype,0),2,1);

     end;

回复

使用道具 举报

21

主题

1万

帖子

1万

积分

Rank: 8Rank: 8

等级: 超级版主

注册:
2021-5-18
曾用名:
FireScript
发表于 2023-1-31 10:51 | 显示全部楼层
ma5:=ma(c,5);

ma10:=ma(c,10);

ma20:=ma(c,20);

ma30:=ma(c,30);

ma60:=ma(c,60);

l1:=min(min(min(ma10,ma20),ma30),ma60) ;

l2:=max(max(max(ma10,ma20),ma30),ma60) ;

a:ma5>l1&&(c< ref(c,1) || ref(c,1)< ref(c,2)
|| ma5<ma10 )&&(ma5>ma20 || ma5>ma60) &&(( ( l1>( l-(hhv(h,5)-l)*0.30) and  ref(c,1)> ref(l1,1) )
  ||( l<l1 and (ref(c,1)> ref(l1,1) || c>l1)))) ;

b:ma5<l2&&(c> ref(c,1) || ref(c,1)> ref(c,2)
|| ma5>ma10 )&&(ma5<ma20 || ma5<ma60) &&(( ( l2<( h+(h-llv(l,5))*0.30) and  ref(c,1)< ref(l2,1) )
  ||( h>l2 and (ref(c,1)< ref(l2,1) || c<l2)))) ;


sellcond:=a;
buycond:=b;

abb:time0-timetot0(dynainfo(207)),NODRAW;//K线结束倒计时 这里数值要和你选择的提前N秒保存一致

t1:extgbdata('t1');
t2:extgbdata('t2');
if  sellcond and t1<time and abb<=5 then
begin
平预警:1;//预警条件1
extgbdataset('t1',time);
end

if  buycond and t2<time and abb<=5 then
begin
开预警:1;//预警条件2
extgbdataset('t2',time);
end
这样试下。预警条件 我在注释里已经标记了。
金字塔提供一对一VIP专业技术指导服务,技术团队实时响应您的日常使用问题与策略编写。联系电话:021-20339086
回复

使用道具 举报

6

主题

35

帖子

35

积分

Rank: 1

等级: 新手上路

注册:
2023-1-19
曾用名:
 楼主| 发表于 2023-1-31 13:28 | 显示全部楼层
你好,老师,我需要如果条件成立,每根K线只出现一次预警即可,我试了一下,仍然会出现多次预警,请帮我再看看,谢谢
回复

使用道具 举报

21

主题

1万

帖子

1万

积分

Rank: 8Rank: 8

等级: 超级版主

注册:
2021-5-18
曾用名:
FireScript
发表于 2023-1-31 13:35 | 显示全部楼层
1.做一个调整,防止预警多品种时候会产生冲突:
[PEL] 复制代码
ma5:=ma(c,5);

ma10:=ma(c,10);

ma20:=ma(c,20);

ma30:=ma(c,30);

ma60:=ma(c,60);

l1:=min(min(min(ma10,ma20),ma30),ma60) ;

l2:=max(max(max(ma10,ma20),ma30),ma60) ;

a:ma5>l1&&(c< ref(c,1) || ref(c,1)< ref(c,2)
|| ma5<ma10 )&&(ma5>ma20 || ma5>ma60) &&(( ( l1>( l-(hhv(h,5)-l)*0.30) and  ref(c,1)> ref(l1,1) )
  ||( l<l1 and (ref(c,1)> ref(l1,1) || c>l1)))) ;

b:ma5<l2&&(c> ref(c,1) || ref(c,1)> ref(c,2)
|| ma5>ma10 )&&(ma5<ma20 || ma5<ma60) &&(( ( l2<( h+(h-llv(l,5))*0.30) and  ref(c,1)< ref(l2,1) )
  ||( h>l2 and (ref(c,1)< ref(l2,1) || c<l2)))) ;


sellcond:=a;
buycond:=b;

abb:time0-timetot0(dynainfo(207)),NODRAW;//K线结束倒计时 这里数值要和你选择的提前N秒保存一致

str1:STKLABEL&'t1';
str2:STKLABEL&'t2';
t1:extgbdata(str1);
t2:extgbdata(str2);
if  sellcond and t1<time and abb<=5 then
begin
平预警:1;//预警条件1
extgbdataset(str1,time);
end

if  buycond and t2<time and abb<=5 then
begin
开预警:1;//预警条件2
extgbdataset(str1,time);
end


2.前面策略我本地测试过 是不会在一个K上 重复触发预警。

截图202301311333382980.png

我这里触发都是在不同的K上触发的。并且是在K结束前5秒触发的。

另外我选择的预警条件是:
截图202301311335258494.png
如果你预警条件不对也是不行的。
金字塔提供一对一VIP专业技术指导服务,技术团队实时响应您的日常使用问题与策略编写。联系电话:021-20339086
回复

使用道具 举报

6

主题

35

帖子

35

积分

Rank: 1

等级: 新手上路

注册:
2023-1-19
曾用名:
 楼主| 发表于 2023-1-31 14:26 | 显示全部楼层
谢谢老师,已经可以了,没有重复预警了,另外还需要麻烦帮我改一下DEBUGFILE2 调试输出到文件,同样的修改,每根K线只输出一次信息即可,不需要重复输出,谢谢

if sellcond=1 then

  BEGIN

   DEBUGFILE2('D:\AAA\AAA.TXT',stklabel&'   sellcond:%.0f'&' 周期类型='&NUMTOSTR(datatype,0),-2,1);

   END;

    if BUYCOND=1 then

    BEGIN

      DEBUGFILE2('D:\AAA\AAA.TXT',stklabel&'  BUYCON:%.0f'&' 周期类型='&NUMTOSTR(datatype,0),2,1);

     end;
回复

使用道具 举报

21

主题

1万

帖子

1万

积分

Rank: 8Rank: 8

等级: 超级版主

注册:
2021-5-18
曾用名:
FireScript
发表于 2023-1-31 14:40 | 显示全部楼层
你把输出的语句 一样放到前面 2个预警变量所在的if语句内部就行了。
金字塔提供一对一VIP专业技术指导服务,技术团队实时响应您的日常使用问题与策略编写。联系电话:021-20339086
回复

使用道具 举报

6

主题

35

帖子

35

积分

Rank: 1

等级: 新手上路

注册:
2023-1-19
曾用名:
 楼主| 发表于 2023-1-31 16:10 | 显示全部楼层
老师,麻烦您看看,我输出信息还是有问题,

sellcond:=a;
buycond:=b;

abb:time0-timetot0(dynainfo(207)),NODRAW;//K线结束倒计时 这里数值要和你选择的提前N秒保存一致

str1:STKLABEL&'t1';
str2:STKLABEL&'t2';
t1:extgbdata(str1);
t2:extgbdata(str2);
if  sellcond and t1<time and abb<=5 then



begin
平预警:1;//预警条件1
extgbdataset(str1,time);

and if sellcond=1 then

  BEGIN

   DEBUGFILE2('D:\AAA\AAA.TXT',stklabel&'   sellcond:%.0f'&' 周期类型='&NUMTOSTR(datatype,0),-2,1);

   END;
   extgbdataset(str1,time);

end


if  buycond and t2<time and abb<=5 then
begin
开预警:1;//预警条件2
extgbdataset(str1,time);

and  if BUYCOND=1 then

    BEGIN

      DEBUGFILE2('D:\AAA\AAA.TXT',stklabel&'  BUYCON:%.0f'&' 周期类型='&NUMTOSTR(datatype,0),2,1);

     end;
     
      extgbdataset(str1,time);
end

回复

使用道具 举报

21

主题

1万

帖子

1万

积分

Rank: 8Rank: 8

等级: 超级版主

注册:
2021-5-18
曾用名:
FireScript
发表于 2023-1-31 16:14 | 显示全部楼层
if  buycond and t2<time and abb<=5 then
begin
开预警:1;//预警条件2
extgbdataset(str1,time);
DEBUGFILE2('D:\AAA\AAA.TXT',stklabel&'  BUYCON:%.0f'&' 周期类型='&NUMTOSTR(datatype,0),2,1);
end
直接放进去
金字塔提供一对一VIP专业技术指导服务,技术团队实时响应您的日常使用问题与策略编写。联系电话:021-20339086
回复

使用道具 举报

6

主题

35

帖子

35

积分

Rank: 1

等级: 新手上路

注册:
2023-1-19
曾用名:
 楼主| 发表于 2023-2-1 14:26 | 显示全部楼层
老师,我继续请教一下,固定间隔TICK级别刷新模式下,如何实现预警信息及输出信息不能重复输出,每根K线只输出一次信息即可,麻烦帮我改一下,谢谢

ma5:=ma(c,5);

ma10:=ma(c,10);

ma20:=ma(c,20);

ma30:=ma(c,30);

ma60:=ma(c,60);

l1:=min(min(min(ma10,ma20),ma30),ma60) ;

l2:=max(max(max(ma10,ma20),ma30),ma60) ;

a:ma5>l1&&(c< ref(c,1) || ref(c,1)< ref(c,2)
|| ma5<ma10 )&&(ma5>ma20
|| ma5>ma60) &&(( ( l1>( l-(hhv(h,5)-l)*0.15) and  ref(c,1)> ref(l1,1) )
||( l<l1 and (ref(c,1)> ref(l1,1) || c>l1)))) ;

b:ma5<l2&&(c> ref(c,1) || ref(c,1)> ref(c,2)
|| ma5>ma10 )&&(ma5<ma20
|| ma5<ma60) &&(( ( l2<( h+(h-llv(l,5))*0.15) and  ref(c,1)< ref(l2,1) )
||( h>l2 and (ref(c,1)< ref(l2,1) || c<l2)))) ;


sellcond:=a;
buycond:=b;

abb:time0-timetot0(dynainfo(207)),NODRAW;//K线结束倒计时 这里数值要和你选择的提前N秒保存一致

str1:STKLABEL&' '&NUMTOSTR(datatype,0)&' t1';
str2:STKLABEL&' '&NUMTOSTR(datatype,0)&' t2';
t1:extgbdata(str1);
t2:extgbdata(str2);
if  sellcond and t1<time and abb<=5 then



begin
平预警:1;//预警条件1
   extgbdataset(str1,time);
    DEBUGFILE('D:\AAA\AAA.TXT',stklabel&'   sellcond:%.0f'&' 周期类型='&NUMTOSTR(datatype,0),sellcond);

end



if  buycond and t2<time and abb<=5 then
begin
开预警:1;//预警条件2
extgbdataset(str2,time);
DEBUGFILE('D:\AAA\BBB.TXT',stklabel&'  BUYCON:%.0f'&' 周期类型='&NUMTOSTR(datatype,0),buycond);
end
回复

使用道具 举报

6

主题

35

帖子

35

积分

Rank: 1

等级: 新手上路

注册:
2023-1-19
曾用名:
 楼主| 发表于 2023-2-1 14:29 | 显示全部楼层
我现在执行的是多周期,多模型预警及输出
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-6-9 19:06 , Processed in 0.168068 second(s), 24 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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