Pine Script Strategy Builder

v1.0.0

Write, fix, test, and backtest Pine Script v5 strategies and indicators for TradingView. Use when asked to create trading strategies, indicators, Pine Script...

0· 106·0 current·0 all-time

Install

OpenClaw Prompt Flow

Install with OpenClaw

Best for remote or guided setup. Copy the exact prompt, then paste it into OpenClaw for shailendartigga16-collab/pine-script-strategy.

Previewing Install & Setup.
Prompt PreviewInstall & Setup
Install the skill "Pine Script Strategy Builder" (shailendartigga16-collab/pine-script-strategy) from ClawHub.
Skill page: https://clawhub.ai/shailendartigga16-collab/pine-script-strategy
Keep the work scoped to this skill only.
After install, inspect the skill metadata and help me finish setup.
Use only the metadata you can verify from ClawHub; do not invent missing requirements.
Ask before making any broader environment changes.

Command Line

CLI Commands

Use the direct CLI path if you want to install manually and keep every step visible.

OpenClaw CLI

Bare skill slug

openclaw skills install pine-script-strategy

ClawHub CLI

Package manager switcher

npx clawhub@latest install pine-script-strategy
Security Scan
Capability signals
Crypto
These labels describe what authority the skill may exercise. They are separate from suspicious or malicious moderation verdicts.
VirusTotalVirusTotal
Benign
View report →
OpenClawOpenClaw
Benign
high confidence
Purpose & Capability
Name/description (Pine Script strategy/indicator authoring) matches the SKILL.md and the included reference files: templates, patterns, risk management, visuals, and examples. Nothing requested (no env vars, no binaries) is out of scope for a code-writing/reference skill.
Instruction Scope
SKILL.md contains concrete Pine Script templates, coding rules (non-repaint, risk rules), testing/backtest guidance and a clear output format. It does not instruct the agent to read local files, query external endpoints, exfiltrate data, or access unrelated system state.
Install Mechanism
There is no install spec and no code files that would be executed. This instruction-only skill writes nothing to disk and pulls no external binaries — minimal installation risk.
Credentials
No environment variables, credentials, or config paths are requested. All required inputs are domain-appropriate (strategy parameters, timeframe, instrument) and declared references are local docs.
Persistence & Privilege
The skill is not marked always:true and does not request persistent system privileges or modify other skills' configurations. Model invocation is allowed (default), which is normal for skills and not a concern here.
Assessment
This skill appears coherent and focused on producing Pine Script v5 code and guidance. Before using scripts it generates: (1) review and test them thoroughly on TradingView's paper/backtest environment (do not run on live funds immediately), (2) verify non-repaint and risk-management settings are implemented as you expect, and (3) be cautious with any code you plan to connect to real trading accounts — this skill does not request credentials, but generated scripts could be adapted to trade automatically if you attach them to automation tools. If you want higher assurance, ask the skill to produce short comments in the code explaining each trade rule and include unit/backtest settings so you can validate behavior.

Like a lobster shell, security has layers — review code before you run it.

latestvk97cvgvjc3mf87wkyspw2a00cx84p9hh
106downloads
0stars
1versions
Updated 2w ago
v1.0.0
MIT-0

Pine Script Strategy Builder

Write production-ready Pine Script v5 strategies and indicators for TradingView.

Workflow

  1. Understand the request — What instrument, timeframe, style (scalping/intraday/swing)?
  2. Choose typestrategy() for backtesting + signals, indicator() for visual-only
  3. Follow architecture — Data → Signal → Score → Filter → Risk → Execute → Visual
  4. Apply non-repaint rules — MANDATORY, no exceptions
  5. Run pre-flight checklist — Before finalizing ANY script
  6. Test mentally — Walk through edge cases, verify logic on paper
  7. Deliver — Complete script + explanation + suggested backtest settings

Non-Negotiable Rules

Non-Repaint (ALWAYS)

  • Wrap signals in barstate.isconfirmed
  • strategy() must have calc_on_every_tick=false, process_orders_on_close=false
  • request.security() → use barmerge.gaps_off, barmerge.lookahead_on with [1] offset
  • NEVER use current bar data for signal generation without confirmation

Risk Management (ALWAYS)

  • Every trade MUST have a stop loss — no naked positions
  • Use ATR-based or swing-based SL
  • RR ratio ≥ 1:2 preferred
  • Max trades per day filter
  • Cool-off after loss

Quality Gates (ALWAYS)

  • ADX chop filter (ADX > 20 to trade)
  • Session filter for appropriate trading hours
  • Volume confirmation (1.2x+ average)
  • Score threshold ≥ 70 for entries

Strategy Architecture

Layer 1: Data — Collect indicators (EMA, RSI, ATR, VWAP, ADX, Volume, BB, Pivots)
Layer 2: Signal — Generate signals (trend direction, breakouts, pullbacks, sweeps)
Layer 3: Score/Filter — Score + filter (multi-factor score, chop filter, session, cool-off)
Layer 4: Risk — SL/TP calculation (ATR/swing-based, partial exits, trailing)
Layer 5: Execute — Entry/exit logic (NON-REPAINT, barstate.isconfirmed)
Layer 6: Visual — Labels, boxes, tables, alerts, backgrounds

Pre-Flight Checklist

Before delivering ANY strategy, verify:

  • Non-repaint logic (barstate.isconfirmed)?
  • Chop filter (ADX > 20)?
  • Session filter?
  • Cool-off after loss?
  • Score threshold ≥ 70?
  • Strong breakout confirmation?
  • Full EMA alignment (3+ EMAs)?
  • Volume confirmation (1.2x+)?
  • RR ≥ 1:2?
  • Max trades per day?
  • SL always set?
  • Partial exit or trailing?

Templates

Strategy Template

//@version=5
strategy("Name", overlay=true,
     initial_capital=10000,
     default_qty_type=strategy.percent_of_equity,
     default_qty_value=10,
     commission_type=strategy.commission.percent,
     commission_value=0.05,
     slippage=1,
     pyramiding=0,
     process_orders_on_close=false,
     calc_on_every_tick=false)

Indicator Template

//@version=5
indicator("Name", overlay=true, max_lines_count=500, max_labels_count=500)

Key Patterns

Non-Repaint Entry

var bool longSignal = false
if barstate.isconfirmed
    longSignal := <conditions>
else
    longSignal := false

if longSignal and strategy.position_size == 0 and barstate.isconfirmed
    strategy.entry("Long", strategy.long)

Multi-Timeframe Non-Repaint

htfClose = request.security(syminfo.tickerid, "60", close[1], barmerge.gaps_off, barmerge.lookahead_on)

ATR-Based SL/TP

atrVal = ta.atr(14)
slLong = close - atrVal * 1.5
tpLong = close + atrVal * 1.5 * rrRatio

Score System (0-100)

score = 0
if close > ema50 and close > ema200  // Trend: 0-25
    score += 25
if rsi > 60                          // Momentum: 0-20
    score += 20
if volume > ta.sma(volume, 10) * 1.2  // Volume: 0-15
    score += 15
if close > high[1] and close > open   // Breakout: 0-20
    score += 20
if ta.atr(14) > ta.atr(14)[1]        // Volatility: 0-10
    score += 10
if close > ta.vwap(hlc3)              // VWAP: 0-10
    score += 10
totalScore = math.min(score, 100)

Cool-off After Loss

var int barsSinceLoss = 999
if strategy.closedtrades > 0
    if strategy.closedtrades.profit(strategy.closedtrades - 1) < 0
        barsSinceLoss := 0
barsSinceLoss += 1
coolOffOK = barsSinceLoss > 5

Common Errors & Fixes

ErrorFix
Cannot call ta.dmi().adx[diPlus, diMinus, adxVal] = ta.dmi(len, len)
Undeclared identifierDeclare with var before use
Cannot call operator [] on boolStore in var variable first
Script could not be translatedCheck commas, parentheses, v5 syntax
Too many plot callsMax 64 plots — use tables/labels
Loop takes too longMax 500K iterations — reduce loop
Variable type mismatchUse float() or int() casting

Detailed References

Output Format

When delivering a Pine Script:

  1. Complete, copy-paste-ready code
  2. Brief explanation of what it does
  3. Suggested TradingView backtest settings (timeframe, dates, instrument)
  4. Known limitations or things to watch for
  5. Ideas for improvement

Fixing Errors

When fixing Pine Script compilation errors:

  1. Read the error message carefully
  2. Match to known error patterns above
  3. Fix the specific issue — don't rewrite the whole script
  4. Verify the fix doesn't break other logic
  5. Re-check non-repaint compliance

Optimization Notes

  • Don't overfit to historical data
  • Test across multiple timeframes
  • Verify with walk-forward (test on different date ranges)
  • Keep strategies simple — complex ≠ profitable
  • If win rate < 50% or profit factor < 1.3, strategy needs work

Comments

Loading comments...