
Pine Script v6 strategies can do more than generate backtest results on a chart. When connected to TradersPost, every entry and exit signal your strategy produces can automatically execute as a real trade on your broker account1. No copy-pasting signals. No watching charts all day. Your strategy runs on TradingView, fires an alert, and TradersPost routes the order to your broker in seconds.
This guide covers the complete pipeline from writing an automation-ready v6 strategy to executing live trades through TradersPost, including v6-specific features that make your strategies easier to configure, debug, and maintain in production.
Manual trading introduces three problems that automation eliminates. First, you miss signals. Markets move while you sleep, commute, or work. A strategy that generates a signal at 2:47 AM does you no good if you see it at 8:00 AM. Second, you hesitate. Even when you see a signal in real time, emotions interfere. You second-guess the entry, delay the exit, or skip the trade entirely. Third, you make mistakes. Entering the wrong quantity, selecting the wrong symbol, or clicking buy instead of sell are human errors that automation prevents.
TradersPost solves all three by acting as the bridge between your TradingView strategy and your broker. The strategy generates signals. TradingView sends them as webhook alerts. TradersPost receives the webhooks and places the corresponding orders at your broker. The entire chain runs without manual intervention.
The automation flow has four components that work together.
Your Pine Script v6 strategy runs on TradingView's servers. Every time a bar closes and your strategy calls strategy.entry(), strategy.exit(), or strategy.close(), TradingView evaluates whether to fire the alert you configured.
You create an alert on TradingView tied to your strategy. The alert includes a webhook URL (provided by TradersPost) and a JSON message payload that describes the trade action. When the strategy triggers, TradingView sends this payload to the webhook URL.
TradersPost receives the webhook, validates the payload, and maps the signal to your configured trading rules. You can set position size limits, restrict trading hours, enable or disable specific actions, and apply other risk controls at this layer.
TradersPost sends the order to your connected broker account. The order executes according to the broker's rules, and TradersPost logs the result for your review.
Not every strategy that backtests well is ready for automation. Here is a v6 strategy built specifically for automated execution with TradersPost.
//@version=6
strategy("Automated EMA Cross", overlay = true, default_qty_type = strategy.percent_of_equity, default_qty_value = 100)
// Use enums for clean input settings
enum TrendFilter
none = "No Filter"
sma200 = "Above 200 SMA"
ema50 = "Above 50 EMA"
TrendFilter filterType = input.enum(TrendFilter.sma200, "Trend Filter")
int fastLen = input.int(9, "Fast EMA Length", minval = 1)
int slowLen = input.int(21, "Slow EMA Length", minval = 1)
// Calculate indicators
float fastEMA = ta.ema(close, fastLen)
float slowEMA = ta.ema(close, slowLen)
// Calculate trend filter
float filterMA = switch filterType
TrendFilter.sma200 => ta.sma(close, 200)
TrendFilter.ema50 => ta.ema(close, 50)
=> na
bool trendOK = na(filterMA) or close > filterMA
// Entry and exit logic
bool longEntry = ta.crossover(fastEMA, slowEMA) and trendOK
bool longExit = ta.crossunder(fastEMA, slowEMA)
if longEntry
strategy.entry("Long", strategy.long)
if longExit
strategy.close("Long")
// Plots
plot(fastEMA, "Fast EMA", color.green, 2)
plot(slowEMA, "Slow EMA", color.red, 2, linestyle = plot.linestyle_dashed)
This strategy uses several v6 features that improve the automation experience. The enum input creates a clean dropdown in the strategy settings instead of a string input with manual validation2. The switch statement handles the enum matching. And the dashed linestyle on the slow EMA provides clear visual feedback when monitoring the strategy on the chart3.
Several aspects of this strategy make it automation-friendly:
With your strategy on a TradingView chart, create an alert that sends signals to TradersPost.
Log in to TradersPost and create a new webhook. TradersPost generates a unique URL for this webhook. Copy it. This URL is where TradingView will send the trade signals.
On TradingView, right-click the chart or use the Alerts panel to create a new alert. Set the condition to your strategy (for example, "Automated EMA Cross"). Under Notifications, enable "Webhook URL" and paste the URL from TradersPost.
The alert message is a JSON payload that TradersPost parses to determine what trade to place. A basic payload looks like this:
{
"ticker": "{{ticker}}",
"action": "{{strategy.order.action}}",
"sentiment": "{{strategy.market_position}}",
"quantity": "{{strategy.order.contracts}}"
}
TradingView replaces the double-brace placeholders with actual values when the alert fires. The ticker field contains the symbol. The action field contains "buy" or "sell". The sentiment field contains "long", "short", or "flat". The quantity field contains the number of shares or contracts.
Each field in the webhook payload serves a specific purpose in the TradersPost execution flow:
Pine Script v6 introduces several features that make strategies more robust for automated execution.
The enum type replaces string-based input options with structured, type-safe selections2. When you use input.enum() instead of input.string() with a list of options, the Pine Script compiler catches typos at compile time instead of letting them cause runtime issues4.
//@version=6
strategy("Enum Config Example", overlay = true)
enum OrderType
market = "Market Order"
limit = "Limit Order"
enum RiskLevel
conservative = "Conservative (1%)"
moderate = "Moderate (2%)"
aggressive = "Aggressive (5%)"
OrderType orderType = input.enum(OrderType.market, "Order Type")
RiskLevel riskLevel = input.enum(RiskLevel.conservative, "Risk Level")
float riskPct = switch riskLevel
RiskLevel.conservative => 1.0
RiskLevel.moderate => 2.0
RiskLevel.aggressive => 5.0
float positionSize = strategy.equity * (riskPct / 100) / ta.atr(14)
if ta.crossover(ta.ema(close, 9), ta.ema(close, 21))
strategy.entry("Long", strategy.long, qty = positionSize)
The dropdown inputs created by input.enum() are cleaner than string inputs and prevent invalid selections4. When sharing strategies with other traders or switching settings before deploying to TradersPost, enum inputs reduce configuration errors.
Pine Script v6 adds the log.info(), log.warning(), and log.error() functions3. These write messages to the Pine Logs pane, which is invaluable for debugging automated strategies in production2.
//@version=6
strategy("Logged Strategy", overlay = true)
float fastEMA = ta.ema(close, 9)
float slowEMA = ta.ema(close, 21)
if ta.crossover(fastEMA, slowEMA)
strategy.entry("Long", strategy.long)
log.info("ENTRY: Long at {0} | Fast EMA: {1} | Slow EMA: {2}",
close, fastEMA, slowEMA)
if ta.crossunder(fastEMA, slowEMA)
strategy.close("Long")
log.warning("EXIT: Close Long at {0} | Fast EMA: {1} | Slow EMA: {2}",
close, fastEMA, slowEMA)
if strategy.opentrades > 0
float entryPrice = strategy.opentrades.entry_price(0)
float unrealizedPnL = strategy.opentrades.profit(0)
log.info("OPEN TRADE: Entry {0} | Unrealized P&L: {1}",
entryPrice, unrealizedPnL)
When your automated strategy fires a signal and TradersPost places the trade, the Pine Logs show exactly what conditions triggered the signal. If a trade seems unexpected, you can review the logs to see the indicator values at the time the signal was generated. This is far more efficient than adding plot() statements and reading values off the chart.
Logs persist across bars during both historical and realtime execution. On realtime bars, log messages are created for every available tick and are not subject to rollback5, which means you can monitor the full decision-making process of your strategy as it evaluates incoming data.
In v6, request.security() accepts series string arguments for the symbol and timeframe parameters2. This means a single strategy can dynamically change which symbol it requests data from based on runtime conditions3.
//@version=6
strategy("Dynamic Symbol Strategy", overlay = true)
string symbols = input.text_area("AAPL\nMSFT\nGOOGL", "Symbols (one per line)")
string currentSymbol = array.get(str.split(symbols, "\n"), bar_index % 3)
float otherClose = request.security(currentSymbol, timeframe.period, close,
ignore_invalid_symbol = true)
if not na(otherClose)
float ratio = close / otherClose
if ta.crossover(ratio, ta.sma(ratio, 20))
log.info("Ratio breakout vs {0}: {1}", currentSymbol, ratio)
While this specific example is simplified, the dynamic request capability opens the door to rotation strategies, pairs trading systems, and multi-asset scanners that were not possible in v54. When combined with TradersPost automation, a single strategy can generate signals for different symbols based on real-time conditions1.
TradersPost connects to a wide range of brokers for automated execution1. The broker you choose depends on what asset classes you trade and your geographic location.
Each broker integration handles the translation from TradersPost's standardized order format to the broker's specific API requirements1. You write your strategy once, configure it in TradersPost, and the platform handles the execution details for your chosen broker.
Before connecting a v6 strategy to a live broker account, run it in paper trading mode. TradersPost offers paper trading for most connected brokers, and TradingView provides its own paper trading functionality within the strategy tester.
Paper trading catches problems that backtesting cannot reveal:
Run your strategy in paper mode for at least two weeks before going live. During this period, verify the following:
When automation is not working as expected, these are the most common issues and their solutions.
The most common cause is that the alert condition is set to "Once Per Bar Close" but your strategy generates signals mid-bar. For automated trading, always use "Once Per Bar Close" to match your backtest behavior. If alerts stop firing entirely, check that your TradingView plan supports the number of active alerts you have configured.
Verify that the webhook URL in your TradingView alert exactly matches the URL from TradersPost. A single extra character or missing trailing slash can cause delivery failures. Check the TradersPost webhook log to see if the payload was received but rejected due to formatting issues.
If TradersPost is placing trades with unexpected quantities, check three places. First, verify the quantity value in your webhook payload. Second, check your TradersPost subscription settings for any position size overrides. Third, confirm that your strategy's default_qty_type and default_qty_value produce the correct sizes in the strategy tester.
If your strategy generates duplicate entry signals while already in a position, the strategy.entry() function in Pine Script handles this by modifying the existing order rather than creating a new one3. However, TradersPost may interpret duplicate webhooks as new signals. Use the sentiment field in your webhook payload to help TradersPost understand your intended position state1.
Setting up automated trading with TradersPost takes about 15 minutes once your strategy is ready.
Pine Script v6 strategies combined with TradersPost automation give you a complete system for developing, testing, and executing trading strategies. The v6 improvements in enums, logging, and dynamic requests make your strategies more maintainable and easier to debug in production2. TradersPost handles the execution layer so you can focus on strategy development rather than broker API integration1.
Whether you are automating a simple EMA crossover or a complex multi-symbol rotation system, the combination of TradingView's strategy engine and TradersPost's execution infrastructure provides everything you need to take your Pine Script strategies from backtest to live trading.
1 TradersPost - Automated Trading Platform
2 Pine Script Release Notes
3 Pine Script v6 Language Reference
4 Pine Script v5 to v6 Migration Guide
5 Pine Script User Manual