What settings do TradingView indicators and strategies share?
What settings do TradingView indicators and strategies share?
Section titled “What settings do TradingView indicators and strategies share?”TL;DR
indicator()andstrategy()both accepttitle,shorttitle,overlay,precision, andmax_labels_count(among others). Strategies add trading-specific fields likepyramidingandcommission.
At a Glance
Section titled “At a Glance”| Setting | Indicator | Strategy | Purpose |
|---|---|---|---|
title, shorttitle | ✅ | ✅ | Names shown on charts and in dialogs. |
overlay | ✅ | ✅ | Draw on price chart or separate pane. |
precision / format | ✅ | ✅ | Control numerical formatting. |
max_labels_count, max_lines_count | ✅ | ✅ | Guard against excessive drawings. |
pyramiding | ❌ | ✅ | Allow multiple entries per direction. |
calc_on_every_tick, calc_on_order_fills | ❌ | ✅ | Advanced strategy evaluation modes. |
commission_*, initial_capital, default_qty_* | ❌ | ✅ | Backtest configuration and order sizing. |
timeframe, timeframe_gaps | ✅ | ❌ | Indicators can request alternative timeframes directly. |
Quick Actions
Section titled “Quick Actions”- Open any script and locate the declaration line (
indicator(...orstrategy(...). - List the shared options you rely on—consider converting when you need strategy-only features.
- Use code snippets below to switch between indicator and strategy versions.
Shared Options Cheat Sheet
Section titled “Shared Options Cheat Sheet”//@version=5indicator(title="My Indicator", shorttitle="MI", overlay=false, precision=2, max_labels_count=50)//@version=5strategy(title="My Strategy", shorttitle="MS", overlay=true, precision=2, max_labels_count=50)These options behave identically in both declarations, making it easy to port an indicator into a strategy shell (or vice versa) when you need to.
Indicator-Only Settings
Section titled “Indicator-Only Settings”timeframe– evaluate indicator logic on another resolution.timeframe_gaps– control how gaps are filled when using a custom timeframe.
If you require these settings in a trading system, consider building a hybrid: indicator for visualisation + alerts feeding a strategy elsewhere.
Strategy-Only Settings
Section titled “Strategy-Only Settings”| Category | Key options |
|---|---|
| Order sizing | default_qty_type, default_qty_value, currency, initial_capital |
| Order behaviour | pyramiding, calc_on_order_fills, calc_on_every_tick, process_orders_on_close, backtest_fill_limits_assumption |
| Costs & risk | commission_type, commission_value, slippage, close_entries_rule |
When you convert an indicator to a strategy, make sure to populate these or TradingView defaults will apply (e.g., 1 contract share, zero commission).
Upgrading an Indicator to a Strategy
Section titled “Upgrading an Indicator to a Strategy”indicator("Baseline MA", overlay=true)ma = ta.sma(close, 34)plot(ma)→ becomes
strategy("Baseline MA", overlay=true, pyramiding=1, initial_capital=10_000, default_qty_type=strategy.percent_of_equity, default_qty_value=10)ma = ta.sma(close, 34)plot(ma)Add order commands and risk controls once the declaration is converted.
Key Takeaways
Section titled “Key Takeaways”- Shared settings (
title,overlay,precision, drawing limits) behave the same for both script types. - Indicator-only settings revolve around multi-timeframe calculations; strategy-only settings configure trading, sizing, and costs.
- Converting between script types is mostly about swapping the declaration and supplying the extra strategy fields.
Keep Going
Section titled “Keep Going”- Open AI Editor to refactor scripts between indicator/strategy form
- Review strategy-only options for deeper backtesting control
- Consult indicator guides when building pure visual tools
Adapted from tradingcode.net, optimised for Algo Trade Analytics users.