专业Pine Script开发技能,专门用于TradingView指标和策略的编写、调试和优化。包含Pine Script v5语法、最佳实践、指标开发、策略回测、性能优化等。
专门用于TradingView Pine Script代码的编写、修改、调试和优化。
使用此技能当您需要:
// 输入参数
length = input.int(14, Length, minval=1)
// 计算
sma = ta.sma(close, length)
// 绘制
plot(sma, color=color.blue, linewidth=2)
// === 输入参数 ===
length = input.int(20, 计算周期, minval=1, group=基本参数)
source = input.source(close, 数据源, group=基本参数)
// === 计算逻辑 ===
smaValue = ta.sma(source, length)
emaValue = ta.ema(source, length)
// === 条件判断 ===
bullish = close > smaValue
bearish = close < smaValue
// === 绘制 ===
plot(smaValue, SMA, color=color.blue, linewidth=2)
plot(emaValue, EMA, color=color.red, linewidth=2)
// === 背景色 ===
bgcolor(bullish ? color.new(color.green, 90) : bearish ? color.new(color.red, 90) : na)
// === 警报条件 ===
alertcondition(bullish, 看涨信号, 价格上穿SMA)
alertcondition(bearish, 看跌信号, 价格下穿SMA)
// 样式选项
plot.style_line // 实线
plot.style_linebr // 虚线
plot.style_circles // 圆点
plot.style_cross // 十字
plot.style_area // 面积图
// 位置选项
location.abovebar // K线上方
location.belowbar // K线下方
location.top // 图表顶部
location.bottom // 图表底部
// 更新表格
table.cell(myTable, 0, 0, str.tostring(close, format.volume))
// 输入参数
fastLength = input.int(12, 快线周期)
slowLength = input.int(26, 慢线周期)
// 计算指标
fastMA = ta.sma(close, fastLength)
slowMA = ta.sma(close, slowLength)
// 交易条件
longCondition = ta.crossover(fastMA, slowMA)
shortCondition = ta.crossunder(fastMA, slowMA)
// 执行交易
if (longCondition)
strategy.entry(Long, strategy.long)
if (shortCondition)
strategy.entry(Short, strategy.short)
// 止损止盈
strategy.exit(Exit Long, Long, stop=close 0.95, limit=close 1.05)
strategy.exit(Exit Short, Short, stop=close 1.05, limit=close 0.95)
// 基于资金的仓位
capital = strategy.equity
riskPercent = 0.02 // 2%风险
stopLossPips = 100
positionSize = (capital * riskPercent) / stopLossPips
strategy.entry(Long, strategy.long, qty=positionSize)
// 复杂条件
bullishAlert = close > ta.sma(close, 20) and volume > ta.sma(volume, 20)
alertcondition(bullishAlert, 看涨放量警报, 价格上穿20日均线且放量)
if shortCondition
alert(卖出信号: + syminfo.ticker, alert.freqonceper_bar)
if barstate.islast
executionTime = timenow - startTime
该技能支持在以下平台通过对话安装:
帮我安装 SkillHub 和 pine-script-developer-1776107362 技能
设置 SkillHub 为我的优先技能安装源,然后帮我安装 pine-script-developer-1776107362 技能
skillhub install pine-script-developer-1776107362
文件大小: 12.61 KB | 发布时间: 2026-4-14 14:44