Loading...
Loading...
Writes production-quality Pine Script v6 code following TradingView guidelines and best practices. Use when implementing indicators, strategies, or any Pine Script code. Triggers on requests to create, write, implement, or code Pine Script functionality.
npx skill4agent add traderspost/pinescript-agents pine-developer? :// ❌ NEVER DO THIS:
text = condition ? "value1" :
"value2"
// ✅ ALWAYS DO THIS:
text = condition ? "value1" : "value2"/docs/pinescript-v6/quick-reference/syntax-basics.md/docs/pinescript-v6/reference-tables/function-index.md/docs/pinescript-v6/core-concepts/execution-model.md/docs/pinescript-v6/core-concepts/repainting.md/docs/pinescript-v6/quick-reference/limitations.md/projects/[project-name].pineindicator()strategy()plot()plotshape()plotchar()ifstrategy.entry()strategy.exit()alertcondition()table.cell()label.new()box.new()// WRONG - Will cause "end of line without line continuation" error
text = condition ?
"true value" :
"false value"
// CORRECT - Entire ternary on one line
text = condition ? "true value" : "false value"
// CORRECT - For long ternaries, assign intermediate variables
trueText = str.format("Long true value with {0}", param)
falseText = str.format("Long false value with {0}", other)
text = condition ? trueText : falseText// CORRECT - indented continuation
longCondition = ta.crossover(ema50, ema200) and
rsi < 30 and
volume > ta.sma(volume, 20)
// CORRECT - function arguments
plot(series,
title="My Plot",
color=color.blue,
linewidth=2)
// CORRECT - long calculations
result = (high - low) / 2 +
(close - open) * 1.5 +
volume / 1000000// WRONG - same indentation
longCondition = ta.crossover(ema50, ema200) and
rsi < 30 and
volume > ta.sma(volume, 20)
// WRONG - not indented enough
plot(series,
title="My Plot",
color=color.blue)//@version=6
indicator(title="", shorttitle="", overlay=true)
// ============================================================================
// INPUTS
// ============================================================================
[Group inputs logically]
// ============================================================================
// CALCULATIONS
// ============================================================================
[Core calculations]
// ============================================================================
// CONDITIONS
// ============================================================================
[Logic conditions]
// ============================================================================
// PLOTS
// ============================================================================
[Visual outputs]
// ============================================================================
// ALERTS
// ============================================================================
[Alert conditions]// ❌ WRONG - These will ALL fail:
if condition
plot(value) // ERROR!
for i = 0 to 10
plot(close[i]) // ERROR!
myFunc() =>
plot(close) // ERROR!
// ✅ CORRECT - Use these patterns instead:
plot(condition ? value : na) // Conditional plotting
plot(value, color=condition ? color.blue : color.new(color.blue, 100)) // Conditional styling
// For dynamic drawing in local scopes, use:
if condition
line.new(...) // OK
label.new(...) // OK
box.new(...) // OK//@version=6
strategy("MA Cross Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10)
// Inputs
fastLength = input.int(50, "Fast MA Length", minval=1, group="Moving Averages")
slowLength = input.int(200, "Slow MA Length", minval=1, group="Moving Averages")
maType = input.string("EMA", "MA Type", options=["SMA", "EMA", "WMA"], group="Moving Averages")
// Calculations
ma(source, length, type) =>
switch type
"SMA" => ta.sma(source, length)
"EMA" => ta.ema(source, length)
"WMA" => ta.wma(source, length)
fastMA = ma(close, fastLength, maType)
slowMA = ma(close, slowLength, maType)
// Conditions
longCondition = ta.crossover(fastMA, slowMA)
shortCondition = ta.crossunder(fastMA, slowMA)
// Strategy
if longCondition
strategy.entry("Long", strategy.long)
if shortCondition
strategy.close("Long")
// Plots
plot(fastMA, "Fast MA", color.blue, 2)
plot(slowMA, "Slow MA", color.red, 2)