agentleFS
udaydeep1992udaydeep1992/pinescript-agents-antigravity/skills/pine-optimizer/SKILL.md

pine-optimizer

Skill0 starsChanged 41 days agoMITView on GitHub

Guides strategy parameter optimization and robustness testing without curve-fitting. Analyzes parameter stability plateaus, multi-dimensional scorecards (drawdown, profit factor, trade count, expectancy), out-of-sample data, and detects overfitting. Use when tuning inputs, optimizing parameters, or assessing strategy robustness.

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 1

    1. TradersPost/pinescript-agents★ 156same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository10 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When reviewing optimized strategy results, audit for these red flags:

    line 26
  2. Distinctive:

    Keep strategy settings clean and easy to test:

    line 38

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Pine Script Optimizer

Specialized in optimizing Pine Script strategies for real-world robustness rather than synthetic in-sample curve fitting.

Core Philosophy: Robustness Over Peak Profit

Never blindly maximize Net Profit. A parameter set that produces the highest backtested profit is almost always an overfitted artifact that fails in live trading.

Multi-Dimensional Robustness Dimensions

  1. Parameter Plateaus (Stability): Optimal parameters must reside on broad, stable performance plateaus. If changing EMA length from 20 to 21 causes profit factor to plummet from 2.5 to 0.9, the setting is dangerously curve-fitted (a "needle peak").
  2. Profit Factor & Expectancy: Prioritize profit factors between 1.4 and 2.2 with healthy sample counts. Extremely high profit factors (>3.0) on hundreds of trades usually indicate lookahead leakage or unrealistic fill assumptions.
  3. Max Drawdown & Pain Index: A strategy with 50% profit and 10% drawdown is vastly superior to one with 70% profit and 45% drawdown.
  4. Trade Count & Statistical Significance: Strategies require sufficient trade sample sizes (ideally > 100-200 trades across diverse market regimes) to establish statistical validity.
  5. Out-of-Sample (OOS) Testing: Validate the candidate parameter set on a reserved date window that was never touched during parameter tuning.

Overfitting Detection Checklist

When reviewing optimized strategy results, audit for these red flags:

  • Too Many Free Parameters: More than 4-5 interrelated parameters being tuned simultaneously creates exponential dimensionality and guarantees curve-fitting.
  • Fragile Parameter Peaks: Performance collapses when adjacent parameters are tested (+/- 10%).
  • Trade Starvation: The strategy filters out so many trades that it only took 15 trades over 3 years.
  • One-Trade Bias: More than 25% of net profit was generated by a single flash-crash or windfall event.
  • Absence of Trading Frictions: 0 commission or 0 slippage configured in the tester.

Pine Script v6 Optimization Design Patterns

1. Grouped Inputs with active Conditional Logic

Keep strategy settings clean and easy to test:

optGroup = "Optimization Parameters"
enableFilter = input.bool(true, "Enable RSI Filter", group=optGroup)
rsiLen = input.int(14, "RSI Length", minval=7, maxval=28, step=1, group=optGroup, active=enableFilter)
rsiThresh = input.int(30, "RSI Oversold Level", minval=20, maxval=40, step=5, group=optGroup, active=enableFilter)

2. Built-in Parameter Stepping Recommendation

Recommend standard step increments for TradingView's strategy optimizer:

  • Fast Moving Averages: Range 5 to 25, Step 2
  • Slow Moving Averages: Range 30 to 100, Step 5
  • ATR Multipliers: Range 1.0 to 3.5, Step 0.25
  • Lookback Periods: Avoid stepping by 1 across wide ranges (e.g. 10 to 200 by 1 tests 190 combinations for a single variable!).

Optimization Report Structure

# Strategy Optimization Report: [Strategy Name]

## 1. Baseline vs Optimized Comparison
| Dimension | Baseline | Candidate A (Plateau) | Candidate B (Peak - Warning) |
| :--- | :--- | :--- | :--- |
| Parameters | Fast: 9, Slow: 21 | Fast: 12, Slow: 26 | Fast: 14, Slow: 22 |
| Net Profit | $X,XXX (XX%) | $X,XXX (XX%) | $X,XXX (XX%) |
| Profit Factor | 1.35 | 1.72 | 2.45 |
| Max Drawdown | 18.2% | 11.4% | 22.1% |
| Total Trades | 184 | 162 | 48 |
| Expectancy | $14.20 | $22.50 | $38.10 |

## 2. Sensitivity Analysis (Adjacent Matrix)
- Fast MA [10, 11, 12, 13, 14]: Returns remain stable within +/- 8%
- Slow MA [24, 25, 26, 27, 28]: Stable plateau confirmed

## 3. Risk Warning & Disclaimer
⚠️ Historical optimization does not guarantee future results in live market conditions. The chosen parameters represent a robust plateau rather than a curve-fitted maximum. Out-of-sample testing and paper trading are strongly advised.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.