🔄通过 3Commas 自动化 Infinity Algo 警报 Automating Infinity Algo Alerts via 3Commas

将 Infinity Algo 信号直接连接到 3Commas,实现自动化交易执行。


🎯 三种集成方法

自动交易方向切换

功能说明:

  • 自动切换多头 (Long) ↔ 空头 (Short)

  • 单个机器人处理双向交易

  • 开启新仓位前关闭相反仓位

最适用于:

  • ✅ 趋势行情

  • ✅ 活跃交易

  • ✅ 最大化效率

  • ✅ 减少警报管理

设置需求
方向: 反向 (Reversal - 双向)
交易对: 单对或多对 (最多 200 个)
警报: 总共 2 个
- 买入信号 (Buy Signal) → enter_long
- 卖出信号 (Sell Signal) → enter_short

反向交易行为 (Reversal Behavior):

  • 现货 (Spot): 启用反向仓位 (Reverse position ON) 时,相反信号会关闭并翻转; 禁用时忽略相反信号

  • 期货对冲模式开启 (Futures Hedge Mode ON): 启用"反向仓位"来翻转交易

  • 期货对冲模式关闭 (Futures Hedge Mode OFF): 机器人在开启新仓前自动关闭相反仓位

为了简化起见,我们建议对反向交易工作流使用一个交易对配对一个机器人。


⚙️ 步骤 1:配置信号机器人 (Signal Bot)

导航至 3Commas:

  1. 登录 → 3Commas.io

  2. 机器人 (Bots)信号机器人 (Signal Bot)创建机器人 (Create Bot)

  3. 使用以下设置进行配置:

设置 (Setting)
值 (Value)

名称 (Name)

例如:Infinity Algo BTC

交易所 (Exchange)

选择你的交易所

交易对 (Pairs)

单对或多对 (最多 200 个)

警报类型 (Alert Type)

自定义信号 (Custom Signal)

方向 (Direction)

多头 (Long) / 空头 (Short) / 反向 (Reversal - 双向)

止盈/止损 (TP/SL)

在此设置或通过 webhook 设置

风险上限 (Risk Caps)

最大投资额、杠杆 (Leverage)

对于多对机器人,还需设置最大活跃智能交易 (Max active SmartTrades)


📩 步骤 2:获取 Webhook 凭证

保存机器人后,找到**"Message for deal start signal"**并复制:

你的唯一凭证 (Your Unique Credentials)
{
  "secret": "ab12cd34.ef56gh78…", // 保持私密!
  "bot_uuid": "f1a2b3c4-…-9d0e1f2a", // 你的机器人 ID
  "action": "enter_long",
  "tv_exchange": "{{exchange}}",
  "tv_instrument": "{{ticker}}"
}

📊 步骤 3:创建 TradingView 警报

警报配置

字段 (Field)
值 (Value)

条件 (Condition)

精确匹配你的 Infinity Algo 信号

选项 (Options)

柱子收盘时触发一次 (Once Per Bar Close) (不是 "Once Per Bar")

Webhook URL

https://api.3commas.io/signal_bots/webhooks

消息 (Message)

JSON 模板,包含你的 YOUR-SECRET 和 YOUR-UUID

重要提示: 警报条件必须精确匹配你的 Infinity Algo 信号名称,包括任何数字前缀


📝 JSON 模板

enter:long.json
{
  "secret": "YOUR-SECRET",
  "bot_uuid": "YOUR-UUID",
  "action": "enter_long",

  "tv_exchange": "{{exchange}}",
  "tv_instrument": "{{ticker}}",

  "order": {
    "amount": 150,
    "currency_type": "quote",
    "order_type": "market"
  },

  "take_profit": {
    "enabled": true,
    "steps": [
      { "order_type": "limit", "price_percent": 1, "volume_percent": 25 },
      { "order_type": "limit", "price_percent": 2, "volume_percent": 25 },
      { "order_type": "limit", "price_percent": 3, "volume_percent": 25 },
      { "order_type": "market", "price_percent": 4, "volume_percent": 25 }
    ]
  },

  "stop_loss": {
    "enabled": true,
    "order_type": "market",
    "trigger_price_percent": 1
  },

  "max_lag": 300,
  "timestamp": "{{timenow}}"
}

注意: 对于限价入场,添加 "price""price_percent",以及可选的 "price_percent_ref_type"


⚡ 快速参考

参数 (Parameter)
用途 (Purpose)
值和规则 (Values & Rules)

price_percent

止盈距离 (TP distance)

整数:1 = 1%, 2 = 2%

volume_percent

仓位平仓百分比 (% of position to close)

总和必须为 100%

trigger_price_percent

止损触发距离 (Stop loss distance)

整数:1 = 亏损 1%

currency_type

订单规模单位 (Order size unit)

quotebasemargin_percentposition_percent

amount

仓位大小 (Position size)

基于 currency_type 设置的数字

max_lag

拒绝过期信号 (Reject stale signals)

秒数 (300 = 5 分钟)

timestamp

信号新鲜度 (Signal freshness)

始终使用 {{timenow}}

price_percent_ref_type

限价的价格参考 (Price reference for limit)

current_pricebase_entry_priceavg_entry_price


🎯 应该选择哪种方法?

功能特性 (Feature)
🔄 反向机器人 (Reversal Bot)
🎯 清洁退出 (Clean Exit)
⏹️ 紧急停止 (Panic Stop)

最适用于 (Best For)

趋势行情

连续交易

紧急停止

需要的警报 (Alerts Needed)

2 个 (最少)

3 个 (入场/出场/重新入场)

1 个 (停止所有)

仓位状态 (Position State)

始终在仓

灵活间隔

完全平仓

机器人状态 (Bot Status)

✅ 始终活跃

✅ 始终活跃

❌ 已禁用

重新入场 (Re-entry)

自动

自动

手动必需

理想交易者 (Ideal Trader)

活跃/自信

灵活/谨慎

风险厌恶

如果你满足以下条件,选择反向机器人:

  • 交易趋势对

  • 相信你的信号

  • 想要一劳永逸

如果你满足以下条件,选择清洁退出:

  • 需要仓位控制

  • 交易多个对

  • 需要间隔期


🚀 高级功能

最多 8 个止盈级别

  • UI 支持最多 4 个级别

  • JSON 支持最多 8 个级别

  • 交易量必须总计 100%

  • 可以混合限价和市价订单

  • 尾随平仓仅在最后一步

示例:8 级止盈含尾随平仓 (Example: 8-Level TP with Trailing)
"take_profit": {
  "enabled": true,
  "steps": [
    { "order_type": "limit", "price_percent": 1, "volume_percent": 20 },
    { "order_type": "limit", "price_percent": 2, "volume_percent": 20 },
    { "order_type": "limit", "price_percent": 3, "volume_percent": 15 },
    { "order_type": "limit", "price_percent": 4, "volume_percent": 15 },
    { "order_type": "limit", "price_percent": 5, "volume_percent": 10 },
    { "order_type": "limit", "price_percent": 6, "volume_percent": 10 },
    { "order_type": "limit", "price_percent": 7, "volume_percent": 5 },
    { "order_type": "market", "price_percent": 8, "volume_percent": 5,
      "trailing": { "enabled": true, "percent": 0.2 }
    }
  ]
}

🛠️ 故障排查检查清单 (Troubleshooting Checklist)

✅ 检查 (Check)
详情 (Details)

有效的凭证 (Valid Credentials)

JSON 必须包含有效的 secretbot_uuid

必需字段 (Required Fields)

始终在所有信号中包含 tv_exchangetv_instrument

正确的 Webhook URL (Correct Webhook URL)

必须完全是 https://api.3commas.io/signal_bots/webhooks

警报时间 (Alert Timing)

警报在柱子收盘时触发一次 (Once Per Bar Close) (不是 "Once Per Bar")

每个操作一个警报 (One Alert Per Action)

永远不要在一个 JSON 中合并入场和出场

字段名称 (Field Names)

使用 price_percent 而不是 price_deviation

交易量总计 100% (Volumes Sum to 100)

所有 volume_percent 必须精确总计 100

退出订单 (Exit Orders)

出场信号仅使用市价执行 - 无限价订单

信号新鲜度 (Signal Freshness)

包含 max_lagtimestamp 以防止过期信号

机器人重新启用 (Bot Re-enabling)

如果使用 disable,必须手动重新启用机器人

出场不工作 (Exit Not Working)

检查机器人的最小利润/平仓条件


📖 JSON 字段词汇表 (JSON Field Glossary)

字段 (Field)
用途 (Purpose)
值和规则 (Values & Rules)

secret

私人机器人令牌 (Private bot token)

必需 - 从步骤 2 精确复制

bot_uuid

唯一信号机器人 ID (Unique Signal Bot ID)

必需 - 从步骤 2 复制

action

机器人命令 (Bot command)

必需 - enter_longenter_shortexit_longexit_shortdisable

tv_exchange

TradingView 交易所 (TradingView exchange)

必需 - 始终为 {{exchange}}

tv_instrument

TradingView 交易对 (TradingView pair)

必需 - 始终为 {{ticker}}

positions_sub_action

当操作为 disable 时 (When action is disable)

market_close → 平仓并禁用 cancel → 仅取消

order.amount

仓位大小 (Position size)

基于 currency_type 设置

order.order_type

入场订单类型 (Entry order type)

marketlimit (限价需要 priceprice_percent)

currency_type

金额单位 (Unit for amount)

quotebasemargin_percentposition_percent

price

精确限价 (Exact limit price)

限价订单的精确价格值

price_percent

TP/限价距离 (TP/limit distance)

整数:1 = 1%,2 = 2%

price_percent_ref_type

百分比参考 (Reference for percent)

current_pricebase_entry_priceavg_entry_price

volume_percent

每个 TP 的平仓百分比 (% to close at each TP)

1-100(必须总计 100%)

trigger_price_percent

止损触发 (Stop loss trigger)

整数:1 = 亏损 1%

max_lag

信号年龄限制 (Signal age limit)

秒数(300 = 5 分钟)

timestamp

当前时间 (Current time)

始终为 {{timenow}}


📚 资源 (Resources)

官方 3Commas 文档 (Official 3Commas Documentation):

最后更新于