pinescript
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePine Script
Pine Script
Overview
概述
Provide Pine Script v6 guidance for indicators, strategies, and libraries. Apply non-repainting and performance best practices. Support generating Pine Script via other languages (TypeScript, Python, etc.) by keeping generated output compliant with v6 guidance. Run linting with the bundled script wrapper around .
pinescript-lint提供关于指标、策略和库的Pine Script v6指导。应用无重绘与性能优化最佳实践。支持通过其他语言(TypeScript、Python等)生成Pine Script,确保生成的输出符合v6规范。通过基于封装的脚本运行代码检查。
pinescript-lintWorkflow
工作流程
- Determine script type and version
- Add and choose
//@version=6,indicator(), orstrategy().library()
- Add
- Apply execution model and repainting safeguards
- Use , historical offsets, and
barstate.isconfirmedlookahead guidance.request.security()
- Use
- Optimize performance and state
- Prefer /
varfor state, limit loops, precompute constants, avoid redundant security calls.varip
- Prefer
- Generate Pine Script from other languages when needed
- Emit Pine Script v6-compliant output and validate by inspection or TradingView editor diagnostics.
- Lint before delivery (manual Pine Script only)
- Run to check formatting and basic issues.
node scripts/pinescript_lint.mjs <path>
- Run
- 确定脚本类型与版本
- 添加,并选择
//@version=6、indicator()或strategy()。library()
- 添加
- 应用执行模型与防重绘保障
- 使用、历史偏移量,以及
barstate.isconfirmed的前瞻操作指导。request.security()
- 使用
- 优化性能与状态管理
- 优先使用/
var来管理状态,限制循环使用,预计算常量,避免冗余的security调用。varip
- 优先使用
- 必要时从其他语言生成Pine Script
- 生成符合Pine Script v6规范的输出,并通过人工检查或TradingView编辑器诊断工具验证。
- 交付前进行代码检查(仅手动编写的Pine Script)
- 运行来检查格式与基础问题。
node scripts/pinescript_lint.mjs <路径>
- 运行
References
参考资料
- Pine Script v6 concepts and best practices:
references/pinescript_v6.md - Linting workflow and linter configuration:
references/linting.md
- Pine Script v6概念与最佳实践:
references/pinescript_v6.md - 代码检查工作流与检查器配置:
references/linting.md
Scripts
脚本
- Lint Pine Script files:
scripts/pinescript_lint.mjs - Lint script tests:
scripts/pinescript_lint.test.mjs
- 检查Pine Script文件:
scripts/pinescript_lint.mjs - 检查脚本测试:
scripts/pinescript_lint.test.mjs