金字塔决策交易系统

 找回密码
 

微信登录

微信扫一扫,快速登录

搜索
查看: 3352|回复: 15

语言转换

[复制链接]

18

主题

60

帖子

70

积分

Rank: 4

等级: 专业版

注册:
2022-1-11
曾用名:
发表于 2024-4-17 18:09 | 显示全部楼层 |阅读模式
ma1 = AverageFC(Close,Length*X);
  MidLine = AverageFC(Close,Length);
  Band = StandardDev(Close,Length,2);
  UpLine = MidLine + Offset * Band;
  DownLine = MidLine - Offset * Band;
  
  cond1=IIF(MidLine>MidLine[1] and C>MidLine,MidLine,cond1);  // 根据条件判断更新cond1的值
  cond2=IIF(UpLine>UpLine[1] and H>UpLine ,UpLine,cond2);  // 根据条件判断更新cond2的值
  cond3=IIF(DownLine<DownLine[1] and L<DownLine ,DownLine,cond3);  // 根据条件判断更新cond3的值
  cond4=IIF(ma1>ma1[1] and C>ma1 ,ma1,cond4);  // 根据条件判断更新cond4的值
  
  kcond1=IIF(MidLine<MidLine[1] and C<MidLine,MidLine,kcond1);  // 根据条件判断更新kcond1的值
  kcond2=IIF(UpLine>UpLine[1] and H>UpLine ,UpLine,kcond2);  // 根据条件判断更新kcond2的值
  kcond3=IIF(DownLine<DownLine[1] and L<DownLine ,DownLine,kcond3);  // 根据条件判断更新kcond3的值
  kcond4=IIF(ma1<ma1[1] and C<ma1 ,ma1,kcond4);  // 根据条件判断更新kcond4的值

能不能帮我把这个TB和代码转成金字塔的,

VARIABLE:cond1=0,cond2=0, cond3=0,  cond4 =0, kcond1=0,   kcond2=0,  kcond3=0, kcond4=0;
ma1:= ma(Close,n*2);
MidLine :=  ma(Close,m);
Band:= std(Close,m);
UpLine:=  MidLine + n * Band;
DownLine:=  MidLine - n* Band;
cond1:= IIF(MidLine>ref(MidLine,1) and C>MidLine,MidLine,cond1);  // 根据条件判断更新cond1的值
cond2:= IIF(UpLine>ref(UpLine,1) and H>UpLine ,UpLine,cond2);  // 根据条件判断更新cond2的值
cond3:= IIF(DownLine<ref(DownLine,1) and L<DownLine ,DownLine,cond3);  // 根据条件判断更新cond3的值
cond4:= IIF(ma1>ref(ma1,1) and C>ma1 ,ma1,cond4);  // 根据条件判断更新cond4的值
kcond1:= IIF(MidLine<ref(MidLine,1) and C<MidLine,MidLine,kcond1);  // 根据条件判断更新kcond1的值
kcond2:= IIF(UpLine>ref(UpLine,1) and H>UpLine ,UpLine,kcond2);  // 根据条件判断更新kcond2的值
kcond3:= IIF(DownLine<ref(DownLine,1) and L<DownLine ,DownLine,kcond3);  // 根据条件判断更新kcond3的值
kcond4:= IIF(ma1<ref(ma1,1) and C<ma1 ,ma1,kcond4);  // 根据条件判断更新kcond4的值

我自已改的,好像不太对,帮我看一下哪个地方有问题 ,
回复

使用道具 举报

37

主题

1万

帖子

6万

积分

Rank: 8Rank: 8

等级: 超级版主

注册:
2021-5-18
曾用名:
wenarm
发表于 2024-4-17 20:55 | 显示全部楼层
std函数计算差异造成。
金字塔提供一对一VIP专业技术指导服务,技术团队实时响应您的日常使用问题与策略编写。联系电话:021-20339086
回复

使用道具 举报

18

主题

60

帖子

70

积分

Rank: 4

等级: 专业版

注册:
2022-1-11
曾用名:
 楼主| 发表于 2024-4-18 22:33 | 显示全部楼层
技术006 发表于 2024-4-17 20:55
std函数计算差异造成。

我这种转化是正确的吗?
回复

使用道具 举报

37

主题

1万

帖子

6万

积分

Rank: 8Rank: 8

等级: 超级版主

注册:
2021-5-18
曾用名:
wenarm
发表于 2024-4-18 23:10 | 显示全部楼层
是正确的
金字塔提供一对一VIP专业技术指导服务,技术团队实时响应您的日常使用问题与策略编写。联系电话:021-20339086
回复

使用道具 举报

18

主题

60

帖子

70

积分

Rank: 4

等级: 专业版

注册:
2022-1-11
曾用名:
 楼主| 发表于 2024-4-22 15:52 | 显示全部楼层
INPUT:M(35,5,300,30),N(2,0.1,10,0.1), trs(50,1,100,1)   ;
VARIABLE:X:=50  ,LIQKA:=0,cond1:=0,cond2:=0, cond3:=0,  cond4: =0, kcond1:=0,   kcond2:=0,  kcond3:=0, kcond4:=0  ,dliqpoint:=0 ,kliqpoint:=0   ;
VARIABLE:lowafterentry:=0,highafterentry:=0;

        if ENTERBARS =0 then begin
   
                highafterentry:= high;
                lowafterentry:= low;
        end
        if ENTERBARS >0 then begin
                highafterentry:= min(highafterentry,high); // 空头止损,更新最低的最高价
                lowafterentry:= max(lowafterentry,low);    // 多头止损,更新最高的最低价
        end
ma1:= ma(Close,n*3);
MidLine :=  ma(Close,m);
Band:= std(Close,m);
UpLine:=  MidLine + n * Band;
DownLine:=  MidLine - n* Band;

cond1:=IIF(MidLine>ref(MidLine,1) and C>MidLine,MidLine,cond1);  // 根据条件判断更新cond1的值
cond2:= IIF(UpLine>ref(UpLine,1) and H>UpLine ,UpLine,cond2);  // 根据条件判断更新cond2的值
cond3:= IIF(DownLine<ref(DownLine,1) and L<DownLine ,DownLine,cond3);  // 根据条件判断更新cond3的值
cond4:= IIF(ma1>ref(ma1,1) and C>ma1 ,ma1,cond4);  // 根据条件判断更新cond4的值

kcond1:= IIF(MidLine<ref(MidLine,1) and C<MidLine,MidLine,kcond1);  // 根据条件判断更新kcond1的值
kcond2:= IIF(UpLine>ref(UpLine,1) and H>UpLine ,UpLine,kcond2);  // 根据条件判断更新kcond2的值
kcond3:= IIF(DownLine<ref(DownLine,1) and L<DownLine ,DownLine,kcond3);  // 根据条件判断更新kcond3的值
kcond4:= IIF(ma1<ref(ma1,1) and C<ma1 ,ma1,kcond4);  // 根据条件判断更新kcond4的值


BB1:=((C-DownLine)/(UpLine-DownLine)); //布林极限(BB)=(收盘价-布林下轨价格)/(布林上轨价格-布林下轨价格)








开多平空条件:= (ref(cond1,1) >ref(cond1,2) and ref(cond2,1) >ref(cond2,2)  and ref(cond3,1) >ref(cond3,2) and ref(cond4,1) >ref(cond4,2))  ;//
开空平多条件:= (ref(kcond1,1)<ref(kcond1,2) and ref(kcond2,1)<ref(kcond2,2)  and ref(kcond3,1)<ref(kcond3,2)  and ref(kcond4,1)<ref(kcond4,2)) ;
zssk2:=1;
zssd2:=1;
if  开多平空条件 then BEGIN
        平空:SELLSHORT( HOLDING<0,zssk2,MARKETR);
        开多:BUY( HOLDING=0,zssd2,MARKETR);
        lowafterentry:=ENTERPRICE;
       
    END

if  开空平多条件 then  BEGIN
        平多:SELL( HOLDING>0,zssd2,MARKETR);
        开空:BUYSHORT( HOLDING=0,zssk2,MARKETR);
        highafterentry:=ENTERPRICE;
       
    END
帮我看一下,这个为什么没有信号。

补充内容 (2024-4-22 15:54):

        if  holding=0 then begin  // 自适应参数默认值;
                liqka:= 1;
        end
        if  holding<>0 then begin                                 //当有持仓的情况下,liqka会随着持仓时间的增加而逐渐减小,即止损止盈幅度乘数的减少。
                liqka:=liqka - 0.1;
                liqka:=max(liqka,0.5);
        end


        if  holding>0 then begin
         
        dliqpoint:=lowafterentry - (open*trs/1000)*liqka; //;
       
        end
        if holding<0 then begin
        kliqpoint:=highafterentry + (open*trs/1000)*liqka; //

        end
        //------------------------------------------------------------------------------------------------
        //跟踪止损
        //------------------------------------------------------------------------------------------------
        aa:ref(dliqpoint,1), colorred ;
        bb:ref(kliqpoint,1), colorgreen ;
        // 持有多单时 价格下破自适应出场均线,平多单
        if holding > 0 and enterbars >0   and ref(c,1) <= aa and ref(c,2) >= ref(dliqpoint,1) and dliqpoint>0 then begin
                独孤九剑止多:sell(1,holding,marketr);
               
                平多价格:min(aa,open);
               
        end
        // 持有空单时 价格上破自适应出场均线,平空单
        if holding < 0 and enterbars >0  and ref(c,1)>= bb and ref(c,2) <= ref(kliqpoint,1) and kliqpoint>0 then begin
                独孤九剑止空:sellshort(1,holding ,marketr);
                平空价格:max(bb,open);
        end
当前持仓:holding,colorgray,linethick0;








        if  holding=0 then begin  // 自适应参数默认值;
                liqka:= 1;
        end
        if  holding<>0 then begin                                 //当有持仓的情况下,liqka会随着持仓时间的增加而逐渐减小,即止损止盈幅度乘数的减少。
                liqka:=liqka - 0.1;
                liqka:=max(liqka,0.5);
        end


        if  holding>0 then begin
         
        dliqpoint:=lowafterentry - (open*trs/1000)*liqka; //;
       
        end
        if holding<0 then begin
        kliqpoint:=highafterentry + (open*trs/1000)*liqka; //

        end
        //------------------------------------------------------------------------------------------------
        //跟踪止损
        //------------------------------------------------------------------------------------------------
        aa:ref(dliqpoint,1), colorred ;
        bb:ref(kliqpoint,1), colorgreen ;
        // 持有多单时 价格下破自适应出场均线,平多单
        if holding > 0 and enterbars >0   and ref(c,1) <= aa and ref(c,2) >= ref(dliqpoint,1) and dliqpoint>0 then begin
                独孤九剑止多:sell(1,holding,marketr);
               
                平多价格:min(aa,open);
               
        end
        // 持有空单时 价格上破自适应出场均线,平空单
        if holding < 0 and enterbars >0  and ref(c,1)>= bb and ref(c,2) <= ref(kliqpoint,1) and kliqpoint>0 then begin
                独孤九剑止空:sellshort(1,holding ,marketr);
                平空价格:max(bb,open);
        end
当前持仓:holding,colorgray,linethick0;









回复

使用道具 举报

18

主题

60

帖子

70

积分

Rank: 4

等级: 专业版

注册:
2022-1-11
曾用名:
 楼主| 发表于 2024-4-22 15:53 | 显示全部楼层
这是把TB 改成了金字塔 的,为什么没有信号,是哪个地方搞错了吗?
回复

使用道具 举报

18

主题

60

帖子

70

积分

Rank: 4

等级: 专业版

注册:
2022-1-11
曾用名:
 楼主| 发表于 2024-4-22 15:54 | 显示全部楼层

        if  holding=0 then begin  // 自适应参数默认值;
                liqka:= 1;
        end
        if  holding<>0 then begin                                 //当有持仓的情况下,liqka会随着持仓时间的增加而逐渐减小,即止损止盈幅度乘数的减少。
                liqka:=liqka - 0.1;
                liqka:=max(liqka,0.5);
        end


        if  holding>0 then begin
         
        dliqpoint:=lowafterentry - (open*trs/1000)*liqka; //;
       
        end
        if holding<0 then begin
        kliqpoint:=highafterentry + (open*trs/1000)*liqka; //

        end
        //------------------------------------------------------------------------------------------------
        //跟踪止损
        //------------------------------------------------------------------------------------------------
        aa:ref(dliqpoint,1), colorred ;
        bb:ref(kliqpoint,1), colorgreen ;
        // 持有多单时 价格下破自适应出场均线,平多单
        if holding > 0 and enterbars >0   and ref(c,1) <= aa and ref(c,2) >= ref(dliqpoint,1) and dliqpoint>0 then begin
                独孤九剑止多:sell(1,holding,marketr);
               
                平多价格:min(aa,open);
               
        end
        // 持有空单时 价格上破自适应出场均线,平空单
        if holding < 0 and enterbars >0  and ref(c,1)>= bb and ref(c,2) <= ref(kliqpoint,1) and kliqpoint>0 then begin
                独孤九剑止空:sellshort(1,holding ,marketr);
                平空价格:max(bb,open);
        end
当前持仓:holding,colorgray,linethick0;








回复

使用道具 举报

18

主题

60

帖子

70

积分

Rank: 4

等级: 专业版

注册:
2022-1-11
曾用名:
 楼主| 发表于 2024-4-22 15:55 | 显示全部楼层
这是后面的一些代码,帮我看一下是哪里出问题 了吗/
回复

使用道具 举报

37

主题

1万

帖子

6万

积分

Rank: 8Rank: 8

等级: 超级版主

注册:
2021-5-18
曾用名:
wenarm
发表于 2024-4-22 16:24 | 显示全部楼层
本帖最后由 技术006 于 2024-4-22 16:31 编辑
103982 发表于 2024-4-22 15:55
这是后面的一些代码,帮我看一下是哪里出问题 了吗/

开仓条件恒不成立。需要分析这些条件的逻辑是否符合你本质的交易条件。如果条件符合你的需求,那就是条件过于苛刻了造成的横不成立。
开多平空条件: (ref(cond1,1) >ref(cond1,2) and ref(cond2,1) >ref(cond2,2)  and ref(cond3,1) >ref(cond3,2) and ref(cond4,1) >ref(cond4,2))  ;//
开空平多条件: (ref(kcond1,1)<ref(kcond1,2) and ref(kcond2,1)<ref(kcond2,2)  and ref(kcond3,1)<ref(kcond3,2)  and ref(kcond4,1)<ref(kcond4,2)) ;



金字塔提供一对一VIP专业技术指导服务,技术团队实时响应您的日常使用问题与策略编写。联系电话:021-20339086
回复

使用道具 举报

18

主题

60

帖子

70

积分

Rank: 4

等级: 专业版

注册:
2022-1-11
曾用名:
 楼主| 发表于 2024-4-23 11:47 | 显示全部楼层
但是在TB 上是有交易信号,我把它转换金字塔 就不行了,
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-8-3 10:11 , Processed in 0.105315 second(s), 22 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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