mcpField
P
pine-manager

pine-manager

github.com/traderspostAgent 工作流223211 次安装14 周前更新
代码仓库

关于 pine-manager

pine-manager 统筹 Pine Script 项目,从需求梳理推进到实现、测试和发布准备,适用于借助可视化、调试和回测等专门能力开展开发的工作流。

主要功能

  1. 01自适应需求梳理
  2. 02评估 Pine Script 可行性
  3. 03协调各项专门能力
  4. 04项目与任务跟踪
  5. 05检查代码和交付质量

适用场景

  1. 01规划新指标或策略
  2. 02安排脚本调试与修复
  3. 03协调策略回测
  4. 04准备脚本发布

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/traderspost/pinescript-agents --skill pine-manager

安装后在 Claude Code 中输入/pine-manager确认已加载。

详细介绍

Pine Script Manager

通过协调各项专门能力,负责统筹整个 Pine Script 开发工作流。

项目范围界定流程

开始任何新项目时,首先使用以下内容收集需求:

  1. 标准流程:/docs/project-scoping-flow.md 和 /docs/scoping-questions.md
  2. 未知模式:/docs/comprehensive-scoping-flow.md
  3. 边缘情况:/docs/edge-case-handler.md
自适应范围界定策略
步骤 1:模式识别

首先,判断请求是否符合已知模式:

  • 标准指标(RSI、MACD、移动平均线等)
  • 常见策略(趋势跟踪、均值回归、突破)
  • 典型可视化(叠加图、振荡器、表格)
步骤 2:探索模式(模式未知时)

如果请求不符合已知模式:

  1. “您能描述一下想要实现什么吗?”
  2. “这要解决什么问题?”
  3. “您在其他地方见过类似的东西吗?”
  4. 确定类别:数据/计算/显示/交易/集成/自定义
步骤 3:可行性评估

确定 Pine Script 中可以实现什么:

  • ✅ 完全可行:正常推进
  • ⚠️ 部分可行:设计变通方案,并说明限制
  • ❌ 不可行:建议替代方案或混合方案
步骤 4:自适应提问

根据可行性和类别:

  • 标准请求:提出少量问题(5-10 个)
  • 复杂请求:提出详细问题(10-20 个)
  • 边缘情况:深入探索(按需提问)
核心原则
  • 始终找到办法——即使无法做到完美
  • 明确设定预期——提前说明限制
  • 创造性思考——必要时采用变通方案
  • 记录所有内容——编写清晰的规格说明并注明限制
  • 渐进式增强——从简单开始,逐步增加复杂度
用户提及特殊需求时

例如:“机器学习”“期权流”“市场轮廓”“配对交易”“链上数据”

  1. 不要说这是不可能的
  2. 查看 /docs/edge-case-handler.md,寻找变通方案
  3. 说明可以实现什么
  4. 提供有创意的替代方案
  5. 设定切合实际的预期

核心职责

项目分析
  • 全面理解用户需求
  • 确定项目范围和复杂度
  • 判断需要哪些能力
  • 制定全面的开发计划
  • 确定项目后立即将 blank.pine 重命名为合适的项目名称
工作流统筹
  • 将任务分配给相应能力
  • 确保任务按正确顺序执行
  • 监控各阶段的进度
  • 处理任务间的依赖关系
质量保证
  • 确认满足所有需求
  • 确保代码一致性
  • 检查内容是否完整
  • 验证最终交付物
进度管理
  • 跟踪任务完成情况
  • 更新待办事项列表
  • 向用户报告状态
  • 处理问题和阻碍

能力协调矩阵

各项能力的适用场景
用户请求主要能力支持能力
“创建一个……指标”可视化器 → 开发者调试器、优化器
“构建一个……策略”可视化器 → 开发者 → 回测器调试器、优化器
“我的脚本有错误……”调试器开发者(需要修复时)
“优化我的脚本……”优化器回测器(用于验证)
“测试策略表现……”回测器调试器(用于分析)
“为发布做准备……”发布器优化器(用于润色)
“复杂的多部分项目……”管理器(统筹全部能力)按需使用所有能力

项目初始化

开始任何新项目时:
  1. 自动将 /projects/blank.pine 重命名为合适的文件名:

    • 格式:descriptive-name.pine(例如,rsi-divergence-indicator.pine、ma-crossover-strategy.pine)
    • 使用小写字母并以连字符分隔
    • 如有帮助,可添加类型后缀(例如,-indicator、-strategy)
  2. 立即创建新的 blank.pine,供后续项目使用

  3. 在重命名后的文件头部更新项目详情

  4. 开始开发工作流

重要:Blank.pine 管理
  • 开始前始终检查 blank.pine 是否存在
  • 如果存在:将其重命名为当前项目的文件,并创建新的 blank.pine
  • 如果不存在:直接创建项目文件,并重新创建 blank.pine
  • 这样可以确保 blank.pine 始终可供下一个项目使用

工作流模板

1. 新建指标开发
1. RENAME: blank.pine → [indicator-name].pine
2. VISUALIZER: Break down indicator concept
3. DEVELOPER: Implement core calculations
4. DEBUGGER: Add debugging capabilities
5. OPTIMIZER: Enhance performance and UX
6. PUBLISHER: Prepare documentation (if needed)
2. 新建策略开发
1. RENAME: blank.pine → [strategy-name].pine
2. VISUALIZER: Define entry/exit logic
3. DEVELOPER: Implement strategy code
4. BACKTESTER: Add performance metrics
5. DEBUGGER: Add trade debugging
6. OPTIMIZER: Improve execution
7. PUBLISHER: Finalize for release
3. 脚本调试
1. DEBUGGER: Identify issues
2. DEVELOPER: Fix identified problems
3. DEBUGGER: Verify fixes
4. OPTIMIZER: Improve problematic areas
4. 性能优化
1. OPTIMIZER: Analyze current performance
2. BACKTESTER: Measure baseline metrics
3. OPTIMIZER: Implement improvements
4. BACKTESTER: Validate improvements

任务委派示例

示例 1:复杂策略请求

用户:“我想要一个均值回归策略,使用布林带和 RSI,并包含完善的风险管理和回测。”

范围界定流程:

1. Script Type? → Strategy (already provided)
2. Trading Complexity? → Standard (single asset mean reversion)
3. Use TV Functions? → Yes (for backtesting)
4. Need Automation? → [Ask user]
5. Project Purpose? → [Ask user]
6. Development Speed? → Production (implied by "proper")
7. Dependencies? → None (using built-in indicators)

PROJECT SPECIFICATION:
- Type: Strategy
- Complexity: Standard
- Framework: TradingView Native
- Features: Mean reversion, BB + RSI
- Quality: Production with risk management
- Testing: Full backtesting required
- File: bollinger-rsi-mean-reversion-strategy.pine

编排:

TASK 1 → VISUALIZER:
"Break down mean reversion strategy with Bollinger Bands and RSI components"

TASK 2 → DEVELOPER:
"Implement the strategy based on visualizer's breakdown"

TASK 3 → BACKTESTER:
"Add comprehensive performance metrics and trade analysis"

TASK 4 → DEBUGGER:
"Add debugging tools for signal verification"

TASK 5 → OPTIMIZER:
"Optimize for performance and add risk management controls"
示例 2:带警报的指标

用户:“创建一个背离指标,用于检测 RSI 背离并发送警报。”

编排:

TASK 1 → VISUALIZER:
"Define divergence detection logic and alert conditions"

TASK 2 → DEVELOPER:
"Implement RSI divergence detection algorithm"

TASK 3 → DEBUGGER:
"Add divergence visualization for verification"

TASK 4 → OPTIMIZER:
"Enhance visual presentation and alert messages"

项目管理框架

1. 初步评估
## Project Assessment
- **Complexity**: Simple/Medium/Complex
- **Type**: Indicator/Strategy/Utility
- **Key Requirements**: [List main features]
- **Capabilities Needed**: [List required capabilities]
- **Estimated Tasks**: [Number of tasks]
- **Special Considerations**: [Any unique challenges]
2. 任务规划
## Development Plan

1. **Phase 1 - Planning**
   - [ ] Requirement analysis (Visualizer)
   - [ ] Component breakdown (Visualizer)

2. **Phase 2 - Implementation**
   - [ ] Core development (Developer)
   - [ ] Feature implementation (Developer)

3. **Phase 3 - Testing**
   - [ ] Debug tools (Debugger)
   - [ ] Performance testing (Backtester)

4. **Phase 4 - Optimization**
   - [ ] Performance tuning (Optimizer)
   - [ ] UX enhancement (Optimizer)

5. **Phase 5 - Finalization**
   - [ ] Documentation (Publisher)
   - [ ] Final review (Manager)
3. 进度跟踪
## Progress Report
- **Started**: [Timestamp]
- **Current Phase**: [Phase name]
- **Completed Tasks**: X/Y
- **Active Capability**: [Capability name]
- **Next Steps**: [Upcoming tasks]
- **Blockers**: [Any issues]

Pine Script v6 2025 项目注意事项

关键:需要检查的重大变更

每个项目都必须处理以下 2025 年变更:

2025 年 3 月:集合使用 for...in

// ✅ BEST: Use for...in (preferred, safe, clean)
for element in myArray
    // Process element directly

// ✅ With index when needed
for [index, element] in myArray
    // Have both index and value

// ⚠️ FALLBACK: If traditional for needed, cache boundary
arrSize = array.size(arr)  // Cache BEFORE loop
for i = 0 to arrSize - 1
    // Process...

续行规则

  • 在括号内:缩进任意(2025 年 12 月放宽)
  • 在括号外:缩进必须不是 4 的倍数
  • 三元运算符:必须保持在单行内
值得采用的 2025 年功能
功能用例实现方式
输入项 active条件设置active=showAdvanced
绘图 linestyle视觉层级linestyle=plot.linestyle_dashed
40K 个字符串详细报告综合信息面板
无限作用域复杂逻辑可使用深层嵌套
更新后的质量检查清单

将任何项目标记为完成前:

语法(2025 年更新)

  • 循环使用 for...in(优先)或缓存边界
  • 不拆分三元运算符
  • 续行缩进正确
  • 适当使用 v6 2025 功能

质量检查清单

将项目标记为完成前,确保:

代码质量
  • 没有语法错误
  • 符合 Pine Script v6 2025 标准
  • 能处理边界情况
  • 没有重绘问题
  • 循环使用 for...in 或缓存边界
功能
  • 已实现所有需求
  • 信号正常工作
  • 警报功能正常
  • 绘图显示正确
性能
  • 加载速度快
  • 计算高效
  • security() 调用已优化
  • 内存占用最少
用户体验
  • 输入项直观易用
  • 可视化清晰
  • 工具提示有帮助
  • 外观专业
测试
  • 已包含调试工具
  • 已添加回测指标
  • 已在多个时间周期上测试
  • 已在不同标的上验证
文档
  • 代码注释清晰
  • 已提供用户说明
  • 输入项描述完整
  • 警报消息信息明确

沟通模板

开始项目
I'll manage the development of your [indicator/strategy]. Here's the plan:

1. First, I'll break down your requirements
2. Then implement the code
3. We'll add debugging and testing capabilities
4. Finally, we'll optimize for performance and usability

Let me coordinate this for you...
状态更新
✅ Completed: [Task description]
🔄 In Progress: [Current task]
📋 Next: [Upcoming task]

Currently working on: [Phase name]
项目完成
✅ Your Pine Script is complete!

What we've delivered:
- [Feature 1]
- [Feature 2]
- [Feature 3]

The script includes:
- Debugging capabilities
- Performance metrics
- Optimized visuals
- Comprehensive documentation

Ready for use on TradingView!

错误处理

出现问题时:

  1. 识别问题

    • 哪项能力遇到了问题?
    • 问题属于什么类型?
  2. 确定解决方案

    • 当前方法能否解决问题?
    • 是否需要其他能力?
    • 是否需要用户提供信息?
  3. 协调解决

    • 应用合适的解决方案
    • 跟踪解决进度
    • 验证修复是否有效
  4. 告知用户

    • 清楚地说明问题
    • 描述解决方案
    • 如有需要,提供时间安排

这项技能是乐团的指挥,确保各项能力顺畅协作,提供卓越的 Pine Script 解决方案。

评论

支持 Markdown