MindLayer TradingView MCP Agent

by MindLayer25
MIT License
  • Linux
  • Apple

Integrations

  • Processes signals from Pine Script indicators that analyze RSI and Stochastic RSI to generate buy/sell signals with confidence ratings for cryptocurrency trading

  • Connects TradingView's Pine Script indicators to receive cryptocurrency trading signals based on RSI and Stochastic RSI analysis through webhook alerts

MindLayer TradingView MCP 代理

一个强大的集成系统,将 TradingView 的 Pine Script 指标与 MindLayer 的 MCP(模型上下文协议)连接起来,以获得基于 RSI 和随机 RSI 的高级加密货币交易信号。

概述

该系统由三个主要部分组成:

  1. Pine Script 指标:TradingView 指标,通过分析 RSI 和随机 RSI 来生成买入/卖出信号。
  2. MCP 代理:处理这些信号并与支持 MCP 的系统通信的 Python 应用程序。
  3. REST API :允许以编程方式访问所有 MCP 代理功能的 HTTP API。

特征

  • 📊 RSI 和随机 RSI 分析:根据这些强大的动量指标生成信号
  • 🔄多时间框架分析:使用更高时间框架数据确认信号
  • 📱实时警报:通过 TradingView 的 webhook 系统发送警报
  • 🤖 MCP 集成:与 MindLayer 的模型上下文协议无缝集成
  • 📈自适应置信水平:每个信号都包含一个强度指标(1-5)
  • 🛡️风险管理:根据您的交易风格配置风险概况
  • 🌐 RESTful API :通过 HTTP API 以编程方式访问所有功能

设置说明

TradingView 指标设置

  1. 登录您的TradingView账户
  2. 转到 Pine 编辑器
  3. 创建一个新的指标并粘贴MindLayer_MCP_Signal.pine的内容
  4. 保存并添加到图表
  5. 根据您的喜好配置指标设置

系统设置

  1. 克隆此存储库
  2. 安装所需的依赖项:
    pip install -r requirements.txt
  3. 配置您的设置(编辑config.py或使用环境变量)
  4. 使用启动脚本启动系统:
    # Run just the MCP agent python run.py agent # Run just the API server (which includes the agent) python run.py api # Run both the agent and API server separately (advanced) python run.py both

命令行选项

run.py脚本接受几个命令行参数:

# Set custom API port python run.py api --port 8080 # Set custom webhook port python run.py agent --webhook-port 9000 # Run in debug mode python run.py api --debug # Display help python run.py --help

TradingView 警报设置

  1. 使用 MindLayer MCP 信号指标打开您的图表
  2. 右键单击指标并选择“添加警报”
  3. 设置触发“MindLayer MCP 买入信号”或“MindLayer MCP 卖出信号”的条件
  4. 在 webhook URL 字段中,输入您的 MCP 代理的 webhook URL(例如, http://your-server:8000 )或 API webhook 端点(例如, http://your-server:5000/api/webhook
  5. 在消息字段中,粘贴以下 JSON 模板:
    { "ticker": "{{ticker}}", "type": "{{strategy.order.action}}", "confidence": {{plot("Buy Signal")}} or {{plot("Sell Signal")}}, "price": {{close}}, "rsi": {{rsi}}, "stoch": {{stoch}}, "htf_rsi": {{plot("HTF RSI")}}, "htf_stoch": {{plot("HTF Stoch")}} }
  6. 保存警报

配置

环境变量

您可以使用环境变量配置系统(创建.env文件):

# API Configuration API_KEY=your_api_key_here API_SECRET=your_api_secret_here # Webhook Configuration WEBHOOK_SECRET=your_webhook_secret_here WEBHOOK_PORT=8000 # API Configuration API_PORT=5000 DEBUG=false # MCP Connection Settings MCP_API_URL=https://api.mindlayer.io/v1 MCP_WEBSOCKET_URL=wss://api.mindlayer.io/ws # Trading Configuration TRADING_ENABLED=false RISK_TOLERANCE=moderate MIN_CONFIDENCE=3 # RSI/Stochastic RSI Configuration RSI_OVERSOLD=30 RSI_OVERBOUGHT=70 STOCH_OVERSOLD=20 STOCH_OVERBOUGHT=80

Pine 脚本定制

TradingView 指标具有高度可定制性:

  • 风险状况:保守、中等或激进
  • RSI 参数:变化长度和超买/超卖阈值
  • 随机 RSI 参数:调整 K、D 周期和阈值
  • 视觉设置:自定义颜色和显示选项

信号解释

买入信号

  • 强力买入:绿色箭头,信心评级高(4-5)
  • 中度买入:浅绿色箭头,中等置信度评级(2-3)
  • 弱买入:绿色虚线箭头,置信度评级较低 (1)

卖出信号

  • 强力卖出:红色箭头,信心评级高(4-5)
  • 中等卖出:浅红色箭头,中等置信度评级(2-3)
  • 弱卖出:红色虚线箭头,置信度评级较低 (1)

工作原理

  1. Pine Script 指标使用 RSI 和随机 RSI 分析价格走势
  2. 当条件满足您配置的标准时,它会在图表上显示买入/卖出信号
  3. TradingView 通过 webhook 向您的 MCP 代理或 API 发送警报
  4. MCP 代理处理信号并与支持 MCP 的系统进行通信
  5. (可选)代理可以根据这些信号执行交易

REST API 文档

该系统包括一个全面的 REST API,可通过编程访问所有功能。

API 端点

信号管理
  • GET /api/signals - 获取所有交易信号
  • GET /api/signals?symbol=BTCUSDT - 获取特定符号的信号
  • POST /api/signals - 手动创建新信号
指标值
  • GET /api/indicators - 获取所有指标值
  • GET /api/indicators?symbol=BTCUSDT - 获取特定符号的指标值
代理控制
  • GET /api/status - 获取当前代理状态
  • POST /api/start - 启动 MCP 代理
  • POST /api/stop - 停止 MCP 代理
配置
  • GET /api/config - 获取当前配置
  • PUT /api/config - 更新配置设置
Webhook
  • POST /api/webhook - 从 TradingView 接收 webhook
API 文档
  • GET /api/docs - 获取详细的 API 文档

API 使用示例

获取当前代理状态
curl http://localhost:5000/api/status
获取所有信号
curl http://localhost:5000/api/signals
创建手动信号
curl -X POST http://localhost:5000/api/signals \ -H "Content-Type: application/json" \ -d '{ "symbol": "BTCUSDT", "type": "BUY", "price": 50000.0, "confidence": 4, "rsi": 25.5, "stoch": 15.2 }'
更新配置
curl -X PUT http://localhost:5000/api/config \ -H "Content-Type: application/json" \ -d '{ "trading_enabled": true, "min_confidence": 4, "rsi_oversold": 25 }'

要求

  • Python 3.7+
  • TradingView 账户(建议使用专业版计划以获取 webhook 警报)
  • 用于运行 MCP 代理和 API 的服务器或云实例(如果使用 webhook)

系统架构

┌─────────────────┐ ┌──────────────────┐ ┌────────────────┐ │ TradingView │ │ MCP Agent or │ │ MCP/Trading │ │ Pine Script │────▶│ API Server │────▶│ System │ └─────────────────┘ └──────────────────┘ └────────────────┘ ▲ ▲ │ │ │ │ ┌──────┘ └────────┐ │ │ ┌───────────┐ ┌─────────────┐ │ External │ │ Manual │ │ API │ │ Commands │ │ Clients │ │ (CLI/Config)│ └───────────┘ └─────────────┘

最佳实践

  • 在使用真实资金之前,务必在纸质交易环境中进行彻底测试
  • 将这些信号与其他分析和风险管理技术结合起来
  • 较高时间范围的信号往往比非常短的时间范围更可靠
  • 考虑可能影响信号可靠性的市场条件
  • 如果 API 服务器暴露在互联网上,请进行适当的身份验证以确保其安全

支持

如果您遇到问题或有疑问,请在此存储库上打开一个问题。

执照

该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅 LICENSE 文件。

免责声明

加密货币交易涉及高风险。该指标的过往表现并不能保证未来的结果。请务必采取适当的风险管理措施,切勿使用您无法承受损失的资金进行交易。

-
security - not tested
A
license - permissive license
-
quality - not tested

将 TradingView 的 Pine Script 指标与 MindLayer 的 MCP 连接起来,以获得基于 RSI 和随机 RSI 分析的加密货币交易信号。

  1. 概述
    1. 特征
      1. 设置说明
        1. TradingView 指标设置
        2. 系统设置
        3. 命令行选项
        4. TradingView 警报设置
      2. 配置
        1. 环境变量
        2. Pine 脚本定制
      3. 信号解释
        1. 买入信号
        2. 卖出信号
      4. 工作原理
        1. REST API 文档
          1. API 端点
          2. API 使用示例
        2. 要求
          1. 系统架构
            1. 最佳实践
              1. 支持
                1. 执照
                  1. 免责声明

                    Related MCP Servers

                    • -
                      security
                      A
                      license
                      -
                      quality
                      An MCP server providing a range of cryptocurrency technical analysis indicators and strategies.
                      Last updated -
                      64
                      JavaScript
                      MIT License
                    • A
                      security
                      A
                      license
                      A
                      quality
                      An MCP server that delivers cryptocurrency sentiment analysis to AI agents.
                      Last updated -
                      5
                      1
                      Python
                      MIT License
                    • -
                      security
                      A
                      license
                      -
                      quality
                      An MCP server that integrates with the Freqtrade cryptocurrency trading bot.
                      Last updated -
                      16
                      Python
                      MIT License
                    • -
                      security
                      A
                      license
                      -
                      quality
                      An MCP server for tracking and managing cryptocurrency portfolio allocations, enabling AI agents to query and optimize portfolio strategies in real time.
                      Last updated -
                      Python
                      MIT License

                    View all related MCP servers

                    ID: 5ahgz8fynj