Skip to content

TheFractalyst/PineOptimizer

Repository files navigation

PineOptimizer

License: MIT Chrome Extension Manifest V3 TradingView Version

Professional strategy optimization for TradingView. Uses Bayesian, TPE, Annealing, and Random algorithms to find optimal strategy parameters automatically.

Warning

This tool is not affiliated with, endorsed by, or associated with TradingView Inc. It interacts with the TradingView web application via DOM manipulation in your browser. Review the Disclaimer before use.

Important

Requires a valid TradingView account. This tool does not bypass or circumvent any TradingView paywall or access control. It reads from and controls the TradingView web app already loaded in your browser tab.

Note

All data processing occurs locally in your browser. No TradingView data is transmitted, stored, or redistributed externally by this extension.

Caution

This tool interacts with TradingView's DOM structure, which can change without notice in any TradingView update. The extension uses self-healing selector fallback chains to mitigate this, but breakages may still occur.

How It Works (and why it's safe to run)

This extension does not connect to TradingView's servers, modify any TradingView files, or intercept any network traffic. It interacts exclusively with the TradingView web page loaded in your browser tab via standard DOM APIs — the same APIs available to any browser extension with activeTab permission.

Nothing happens without your explicit action. The extension only activates when you click its icon on a TradingView tab, and all processing happens locally in your browser.

What This Tool Does Not Do

  • Connect to TradingView's servers or APIs
  • Store, transmit, or redistribute any market data externally
  • Work without a valid TradingView account and a strategy applied to a chart
  • Bypass any TradingView paywall or access restriction
  • Execute real trades (parameter optimization only)
  • Collect analytics, tracking data, or personal information
  • Make any external network requests

Features

  • Multiple Optimization Algorithms: Bayesian, TPE (Tree-structured Parzen Estimator), Simulated Annealing, Random, Sequential, Brute Force
  • Real-time DOM Interaction: Reads and sets strategy parameters directly on TradingView's chart
  • Deep Backtesting Support: Optimizes with TradingView's Deep Backtesting feature for full historical accuracy
  • Multi-Timeframe Optimization: Test strategies across multiple timeframes in a single run
  • Filter Conditions: Apply metric-based filters (e.g., Net Profit >= $1000 AND Max Drawdown <= 20%)
  • Parameter Editor: Visual in-page editor for setting parameter ranges before optimization
  • Results Visualization: 3D surface plots, heatmaps, sensitivity analysis, convergence charts
  • CSV Export/Import: Export optimization results, import saved parameter settings
  • Preset Management: Save and load parameter range presets per strategy
  • Pause/Resume: Pause optimization mid-run and resume later
  • Auto-save: Progress saved every 10 iterations

Installation

From Chrome Web Store (Recommended)

Install from Chrome Web Store

From Source (Developer)

  1. Clone this repository
  2. Open chrome://extensions/ in Chrome
  3. Enable Developer mode (top right toggle)
  4. Click Load unpacked
  5. Select the repository folder
  6. The extension icon should appear in your toolbar

Quick Start

  1. Navigate to a TradingView chart with a strategy applied
  2. Click the extension icon to open the popup
  3. Verify the chart info (symbol, timeframe, strategy name) is detected
  4. Select optimization method, target metric, and direction (maximize/minimize)
  5. Click Test Strategy to open the parameter editor
  6. Set parameter ranges (min/max/step for numeric, toggle for dropdowns)
  7. Set number of iterations
  8. Click Start to begin optimization
  9. Watch progress in the in-page overlay
  10. When complete, best parameters are automatically applied to your strategy

Supported Metrics

  • Net Profit, Net Profit %
  • Max Drawdown, Max Drawdown %
  • Profit Factor
  • Sharpe Ratio
  • Total Trades, Winning Trades, Losing Trades
  • Percent Profitable
  • Open P&L
  • Average Trade
  • And more (see popup dropdown for full list)

Architecture

manifest.json              - Extension manifest (MV3)
background.js              - Service worker (lifecycle management)
popup/
  popup.html               - Extension popup UI
  popup.js                 - Popup logic and message passing
  popup.css                - Popup styles
src/content/
  selectors.js             - TradingView DOM selectors with fallback chains
  page.js                  - DOM utilities (click, setInputElementValue, waitForSelector)
  storage.js               - chrome.storage.local wrapper
  selectorRegistry.js      - Self-healing selector cache
  elementDiscovery.js      - Dynamic element finding by text/role
  selectorMonitor.js       - Selector health monitoring
  telemetry.js             - Local usage tracking (no remote calls)
  utils.js                 - Utility functions
  tv.js                    - TradingView interaction (dialog, params, report parsing)
  model.js                 - Parameter range generation
  file.js                  - CSV export/import
  backtest.js              - Optimization algorithms (Bayesian, TPE, Annealing, etc.)
  dom.js                   - XSS prevention utilities
  ui.js                    - In-page overlays (parameter editor, progress, charts)
  debug.js                 - Debug utilities (disabled in production)
  main.js                  - Message handler dispatching popup actions
assets/
  icon16.png, icon48.png, icon128.png

Permissions

Permission Why it's needed
activeTab Interact with TradingView's DOM to read/set strategy parameters
storage Save optimization results, presets, and user settings locally
*://*.tradingview.com/* Content scripts run only on TradingView charts

No remote code execution, no external API calls, no tracking. All data stays local. The extension does not request tabs, cookies, webRequest, history, or any other host permissions.

Privacy

See privacy-policy.html for the full privacy policy. The extension:

  • Stores all data locally in chrome.storage.local
  • Never sends data to any server
  • Never makes external network requests
  • Never collects analytics or tracking data

Testing

# Syntax check all JS files
for f in src/content/*.js popup/popup.js background.js; do node -c "$f"; done

# Check for prohibited content
grep -rn 'eval(' src/content/ popup/ && echo "FAIL: eval found" || echo "OK: no eval"
grep -rn 'onclick=' src/content/ popup/ && echo "FAIL: inline handlers" || echo "OK: no inline"

# Validate manifest
node -e "JSON.parse(require('fs').readFileSync('manifest.json','utf8')); console.log('OK')"

Attributions

This project is not affiliated with, endorsed by, or associated with:

  • TradingView Inc. - TradingView is a trademark of TradingView Inc.
  • Google - Chrome and Chrome Web Store are trademarks of Google LLC.

This extension is an independent browser extension that runs on the Chromium platform. It does not contain or modify any TradingView or Google software.

Contributing

See CONTRIBUTING.md for development setup, code style, and pull request guidelines.

License

MIT - see LICENSE for details.

The MIT license applies to the source code of this project only. It does not grant any rights to TradingView's software, data, trademarks, or intellectual property.

Security

See SECURITY.md for the security policy and vulnerability reporting.

Disclaimer

This project is provided for educational and research purposes only.

How this tool works: This extension uses standard browser DOM APIs to interact with the TradingView web application loaded in your browser tab. It does not reverse engineer any proprietary TradingView protocol, connect to TradingView's servers, or bypass any access controls.

By using this software, you acknowledge and agree that:

  1. You are solely responsible for ensuring your use of this tool complies with TradingView's Terms of Use and all applicable laws.
  2. TradingView's Terms of Use restrict automated data collection, scraping, and non-display usage of their platform and data. This extension programmatically interacts with the TradingView web interface, which may conflict with those terms.
  3. You assume all risk associated with using this tool. The authors are not responsible for any account bans, suspensions, legal actions, or other consequences resulting from its use.
  4. This tool must not be used for, including but not limited to:
    • Redistributing, reselling, or commercially exploiting TradingView's market data
    • Circumventing TradingView's access controls or subscription restrictions
    • Performing automated trading or algorithmic decision-making using extracted data
    • Violating the intellectual property rights of Pine Script indicator authors
    • Connecting to TradingView's servers or infrastructure
  5. Market data accessed through this tool remains subject to exchange and data provider licensing terms. Do not redistribute, store, or commercially exploit any data obtained through this tool.
  6. This tool accesses TradingView's DOM structure, which may change at any time without notice.

Use at your own risk. If you are unsure whether your intended use complies with TradingView's terms, do not use this tool.

About

Professional TradingView strategy optimization Chrome extension. Bayesian, TPE, Annealing algorithms. Find optimal parameters automatically.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages