金字塔决策交易系统

 找回密码
 

微信登录

微信扫一扫,快速登录

搜索
查看: 2430|回复: 10

求助一个程序的编写

[复制链接]

1

主题

2

帖子

2

积分

Rank: 1

等级: 新手上路

注册:
2025-3-20
曾用名:
发表于 2025-3-20 15:03 | 显示全部楼层 |阅读模式
条件1:在一段期货交易的盘面图形中,如果出现一个连续线段(a-b),在其幅度(价格)上达到 x(参数)
条件2:在线段顶底点b(最低点或最高点)发生回撤时,如果回撤幅度大于该线段内之前回撤幅度3倍以上,且k线根数大于该线段内之前回撤的k线根数2倍,则认为该回撤线段(b-c)顶点为c;
条件3:当c线段折返至b-c线段0.3倍幅度时,提示。

本帖子中包含更多资源

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

x
回复

使用道具 举报

44

主题

1万

帖子

1万

积分

Rank: 8Rank: 8

等级: 超级版主

注册:
2021-5-18
曾用名:
发表于 2025-3-20 15:25 | 显示全部楼层
这种没有具体定义的不好写的
金字塔提供一对一VIP专业技术指导服务,技术团队实时响应您的日常使用问题与策略编写。联系电话:021-20339086
回复

使用道具 举报

1

主题

2

帖子

2

积分

Rank: 1

等级: 新手上路

注册:
2025-3-20
曾用名:
 楼主| 发表于 2025-3-20 23:09 | 显示全部楼层
技术008 发表于 2025-3-20 15:25
这种没有具体定义的不好写的



条件1: 当期货价格走势形成一个明显的上涨或下跌段(比如从点a涨到点b,或从a跌到b),这段的价格变化幅度达到设定的x个点(比如涨了50点或跌了30点)。

条件2:当价格走到这段的顶点或底点b后,开始反向调整(比如上涨后的下跌,或下跌后的反弹)。如果这次调整的幅度,比之前a到b这段走势中任何一次小调整的幅度都要大至少3倍,并且调整所用的K线数量(时间)也比之前任何一次小调整多至少1倍,那么这次调整的终点就是新的点c。

举例:假设a到b是上涨,中间有两次小回调:第一次回调跌了5点用了3根K线,第二次回调跌了8点用了5根K线。那么当价格到b后,如果出现一波下跌幅度≥24点(8×3)且K线数≥10根(5×2),这波下跌的终点就是c。

条件3:当价格从c点再次反向(比如c是下跌后的低点,开始反弹),涨到或跌到b到c这段幅度的30%位置时,系统提示信号。

举例:如果b是100点,c是80点(下跌20点),那么从c反弹到86点(20×0.3=6,80+6=86)时,触发提示。
回复

使用道具 举报

44

主题

1万

帖子

1万

积分

Rank: 8Rank: 8

等级: 超级版主

注册:
2021-5-18
曾用名:
发表于 2025-3-21 08:55 | 显示全部楼层
这种都不行,都是描述性语句不足以直接写成策略的
金字塔提供一对一VIP专业技术指导服务,技术团队实时响应您的日常使用问题与策略编写。联系电话:021-20339086
回复

使用道具 举报

0

主题

5

帖子

5

积分

Rank: 1

等级: 新手上路

注册:
2025-3-21
曾用名:
发表于 2025-3-21 09:36 来自手机 | 显示全部楼层
// 参数设置 INPUT:x(50,1,1000,1);        // 设置AB段触发点数 INPUT:倍数(3,1,10,1);       // 调整幅度倍数 INPUT:倍时(2,1,10,1);       // 调整时间倍数  // 变量声明 VARIABLE:dir(0);            // 方向 1涨 -1跌 VARIABLE:a(0),b(0);         // AB段起点终点 VARIABLE:max_adj(0);        // AB段最大调整幅度 VARIABLE:max_bars(0);       // AB段最长调整时间 VARIABLE:c(0);              // 调整终点C VARIABLE:bc_ratio(0);       // BC段30%位置 VARIABLE:adj_start(0);      // 调整起点价格 VARIABLE:adj_bars(0);       // 调整持续K线数  // 计算AB段 if dir=0 then begin         // 初始寻找方向     if close>ref(close,1)+x then begin         dir := 1;         a := ref(close,1);         b := close;     end else if close<ref(close,1)-x then begin         dir := -1;         a := ref(close,1);         b := close;     end; end else if dir=1 then begin // 上涨趋势中     // 更新B点     if close > b then b := close;          // 记录回调     if close < ref(close,1) then begin         temp_adj := ref(close,1) - close;         if temp_adj > max_adj then max_adj := temp_adj;         adj_bars := adj_bars + 1;     end else begin         if adj_bars > max_bars then max_bars := adj_bars;         adj_bars := 0;     end;          // 检测顶部调整     if close < b then begin         current_adj := b - close;         if current_adj >= max_adj*倍数 and barssince(close=b) >= max_bars*倍时 then begin             c := close;             bc_ratio := iff(dir=1, c + (b-c)*0.3, c - (c-b)*0.3);             dir := 0; // 重置进入新周期         end;     end; end else if dir=-1 then begin // 下跌趋势中     // 更新B点     if close < b then b := close;          // 记录反弹     if close > ref(close,1) then begin         temp_adj := close - ref(close,1);         if temp_adj > max_adj then max_adj := temp_adj;         adj_bars := adj_bars + 1;     end else begin         if adj_bars > max_bars then max_bars := adj_bars;         adj_bars := 0;     end;          // 检测底部调整     if close > b then begin         current_adj := close - b;         if current_adj >= max_adj*倍数 and barssince(close=b) >= max_bars*倍时 then begin             c := close;             bc_ratio := iff(dir=1, c + (b-c)*0.3, c - (c-b)*0.3);             dir := 0; // 重置进入新周期         end;     end; end;  // 触发信号 if c>0 then begin     if (dir=1 and cross(close,bc_ratio)) or (dir=-1 and cross(bc_ratio,close)) then begin         BUY(dir=1,1,market);         SELLSHORT(dir=-1,1,market);         DRAWICON(1,close,4); // 显示信号图标     end; end;  // 画图辅助 DRAWTEXT(dir=1,a,'A',COLORRED); DRAWTEXT(dir=1,b,'B',COLORRED); DRAWTEXT(c>0,c,'C',COLORGREEN); DRAWNUMBER(1,bc_ratio,bc_ratio,2,COLORCYAN);
回复

使用道具 举报

0

主题

5

帖子

5

积分

Rank: 1

等级: 新手上路

注册:
2025-3-21
曾用名:
发表于 2025-3-21 09:37 来自手机 | 显示全部楼层
老师,你看一下这个代码能跑么?这是用ds做的
回复

使用道具 举报

0

主题

5

帖子

5

积分

Rank: 1

等级: 新手上路

注册:
2025-3-21
曾用名:
发表于 2025-3-21 09:38 来自手机 | 显示全部楼层
技术008 发表于 2025-3-21 08:55
这种都不行,都是描述性语句不足以直接写成策略的

老师烦请看一下
回复

使用道具 举报

44

主题

1万

帖子

1万

积分

Rank: 8Rank: 8

等级: 超级版主

注册:
2021-5-18
曾用名:
发表于 2025-3-21 09:38 | 显示全部楼层
重新整理下,不要堆在一起

另外只能看语法错误,逻辑问题无法查看
金字塔提供一对一VIP专业技术指导服务,技术团队实时响应您的日常使用问题与策略编写。联系电话:021-20339086
回复

使用道具 举报

0

主题

5

帖子

5

积分

Rank: 1

等级: 新手上路

注册:
2025-3-21
曾用名:
发表于 2025-3-21 09:40 来自手机 | 显示全部楼层
技术008 发表于 2025-3-21 08:55
这种都不行,都是描述性语句不足以直接写成策略的

// 参数设置
INPUT:x(50,1,1000,1);        // 设置AB段触发点数
INPUT:倍数(3,1,10,1);       // 调整幅度倍数
INPUT:倍时(2,1,10,1);       // 调整时间倍数

// 变量声明
VARIABLE:dir(0);            // 方向 1涨 -1跌
VARIABLE:a(0),b(0);         // AB段起点终点
VARIABLE:max_adj(0);        // AB段最大调整幅度
VARIABLE:max_bars(0);       // AB段最长调整时间
VARIABLE:c(0);              // 调整终点C
VARIABLE:bc_ratio(0);       // BC段30%位置
VARIABLE:adj_start(0);      // 调整起点价格
VARIABLE:adj_bars(0);       // 调整持续K线数

// 计算AB段
if dir=0 then begin         // 初始寻找方向
    if close>ref(close,1)+x then begin
        dir := 1;
        a := ref(close,1);
        b := close;
    end else if close<ref(close,1)-x then begin
        dir := -1;
        a := ref(close,1);
        b := close;
    end;
end else if dir=1 then begin // 上涨趋势中
    // 更新B点
    if close > b then b := close;
   
    // 记录回调
    if close < ref(close,1) then begin
        temp_adj := ref(close,1) - close;
        if temp_adj > max_adj then max_adj := temp_adj;
        adj_bars := adj_bars + 1;
    end else begin
        if adj_bars > max_bars then max_bars := adj_bars;
        adj_bars := 0;
    end;
   
    // 检测顶部调整
    if close < b then begin
        current_adj := b - close;
        if current_adj >= max_adj*倍数 and barssince(close=b) >= max_bars*倍时 then begin
            c := close;
            bc_ratio := iff(dir=1, c + (b-c)*0.3, c - (c-b)*0.3);
            dir := 0; // 重置进入新周期
        end;
    end;
end else if dir=-1 then begin // 下跌趋势中
    // 更新B点
    if close < b then b := close;
   
    // 记录反弹
    if close > ref(close,1) then begin
        temp_adj := close - ref(close,1);
        if temp_adj > max_adj then max_adj := temp_adj;
        adj_bars := adj_bars + 1;
    end else begin
        if adj_bars > max_bars then max_bars := adj_bars;
        adj_bars := 0;
    end;
   
    // 检测底部调整
    if close > b then begin
        current_adj := close - b;
        if current_adj >= max_adj*倍数 and barssince(close=b) >= max_bars*倍时 then begin
            c := close;
            bc_ratio := iff(dir=1, c + (b-c)*0.3, c - (c-b)*0.3);
            dir := 0; // 重置进入新周期
        end;
    end;
end;

// 触发信号
if c>0 then begin
    if (dir=1 and cross(close,bc_ratio)) or (dir=-1 and cross(bc_ratio,close)) then begin
        BUY(dir=1,1,market);
        SELLSHORT(dir=-1,1,market);
        DRAWICON(1,close,4); // 显示信号图标
    end;
end;

// 画图辅助
DRAWTEXT(dir=1,a,'A',COLORRED);
DRAWTEXT(dir=1,b,'B',COLORRED);
DRAWTEXT(c>0,c,'C',COLORGREEN);
DRAWNUMBER(1,bc_ratio,bc_ratio,2,COLORCYAN);
回复

使用道具 举报

0

主题

5

帖子

5

积分

Rank: 1

等级: 新手上路

注册:
2025-3-21
曾用名:
发表于 2025-3-21 09:41 来自手机 | 显示全部楼层
技术008 发表于 2025-3-21 09:38
重新整理下,不要堆在一起

另外只能看语法错误,逻辑问题无法查看

有别的沟通平台吗
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-9-13 07:04 , Processed in 0.272375 second(s), 29 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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