tradingview strategy tutorial

How to build a TradingView automated trading strategy that actually runs live

A full-lifecycle guide to building a TradingView automated trading strategy: Pine Script, backtesting, alerts, webhooks, and live broker execution.

Jonathan FillEdge 12 min read
How to build a TradingView automated trading strategy that actually runs live — FillEdge
In this article
  1. What "automated" actually means in TradingView
  2. The five stages of a TradingView automated trading strategy
  3. Where a TradingView automated trading strategy breaks in real life
  4. A TradingView automated trading strategy: how to do it with FillEdge
  5. What changes if you're running this on a prop firm account
  6. FAQ

You've got a TradingView chart open, a Pine Script that prints buy and sell arrows in roughly the right places, and the vague sense that somewhere between this chart and your broker account, real money should start moving without you touching it. That's the gap this article is about.

A TradingView automated trading strategy is five steps, not one. Most guides collapse it into "write Pine Script, connect to broker, profit." Then you try it and something goes wrong in step four, and you don't know whether the problem is your script, your alert, the webhook, or your execution tool. This guide walks through the entire pipeline, names the specific points where it breaks, and shows what a working version looks like.

What "automated" actually means in TradingView

TradingView is a charting and signal-generation platform. It's not a broker. Your Pine Script can decide when to buy EURUSD, but TradingView itself doesn't place the order with your broker. That responsibility sits outside TradingView, and figuring out where it sits is the part most new algo traders underestimate.

A handful of brokers have direct integration with TradingView's "Trade" panel, so you click a button, and the order goes live. That's the exception. For the long tail of brokers people actually use, including most offshore and prop-firm-friendly ones, you need an external execution layer. That layer is the bridge between TradingView's signal and your broker's order book.

So when someone says "TradingView automated trading strategy," they really mean two stacked systems: the signal generator, which lives on TradingView, and the execution layer, which lives somewhere else. Understanding the split is the difference between a strategy that works on a backtest and one that holds up live.

The five stages of a TradingView automated trading strategy

Before we drill in, here's the whole pipeline on one page.

Each stage has its own tools, its own jargon, and its own failure modes. Skip any of them, and the whole thing breaks.

Stage 1. Write the strategy in Pine Script

Pine Script is TradingView's built-in language for strategies and indicators. It's easier to learn than Python or MQL5, it runs server-side, so you don't need a VPS to backtest, and the entire TradingView community writes in it. For 95% of retail algo traders, it's the right choice.

Your strategy script does two things. It defines the conditions that trigger an entry and those that close the position. Everything else is wrapping. If you've written your first strategy, you've seen the two core calls: strategy.entry() and strategy.close() (or strategy.exit() for exits tied to stop loss and take profit).

Pine Script is also where you'll hit the first wall of what TradingView can actually do for you. The language was designed for chart analysis, not for reaching out to external servers or managing account state. That's why execution has to happen elsewhere, which is a major Pine Script limitation. Another route some traders consider is converting the entire strategy into MQL5.

Stage 2. Backtest and forward-test

TradingView's Strategy Tester lets you run your Pine Script against historical data and see what would have happened. The report shows net profit, drawdown, win rate, profit factor, and a trade-by-trade list. This is useful. It's also misleading in a specific way.

The backtester assumes your order filled at the price your strategy asked for. Live execution doesn't work like that. You'll see slippage, spreads, and sometimes rejections. A strategy that shows a 32% annual return on the backtester might show an 18% return live, and the 14-point gap is mostly the friction the backtester ignored.

Use the bar replay feature to step through recent price action with your strategy active. It's the closest you'll get to a forward test without risking real money. Run a demo account for at least a week before putting capital behind anything.

Stage 3. Convert signals to alerts

An alert is how Pine Script talks to the outside world. When your strategy calls strategy.entry(), you can configure an alert to fire at the same moment with a payload describing the trade. This is the hinge of the whole pipeline.

One thing that catches new users: webhooks require a paid TradingView plan. The free tier gives you on-screen alerts, but the webhook feature, which sends the alert as an HTTP request to a URL you specify, starts at the Essential plan. If you're on the free plan, you're stuck at Stage 3 until you upgrade.

Stage 4. Send alerts via webhook

A webhook is an HTTP POST request that carries your alert's payload to a URL. The payload is usually JSON, structured so that whatever receives it can parse out the symbol, side, size, and any stop-loss or take-profit levels. If you want to see what a working payload looks like, we have a walkthrough covering TradingView webhook examples with real JSON and real alert setup.

This stage is where most TradingView-to-broker setups fall apart. The webhook fires. It hits the internet. What it hits on the other end determines everything about whether your trade matches what your strategy intended.

Stage 5. Execute on your broker platform

The webhook needs to reach something that can talk to your broker and place orders. For the retail world, this is usually one of three endpoints: the MetaTrader 5 terminal, the MetaTrader 4 terminal, or cTrader. These aren't brokers. They're trading platforms that your broker supports, each running an expert advisor or cBot that listens for incoming signals and executes them.

The bridge between your webhook and one of these platforms is the part you have to build or buy. You can write your own in Python and run it on a VPS. You can use an off-the-shelf bridge service. Which direction you pick is usually the deciding factor in whether your automation ends up reliable or flaky. This is a separate decision worth understanding properly, and we cover the full mechanics in our guide on connecting brokers to TradingView.

Where a TradingView automated trading strategy breaks in real life

Every algo trader with a few months of live experience has a story about a trade that shouldn't have existed, a stop that landed in the wrong place, or a reversal that left two positions open. These aren't random glitches. They're three specific failure modes baked into how most TradingView-to-broker setups work.

The first is ghost positions. TradingView's alert fires the instant your Pine Script calls strategy.entry(). Not when the market actually fills your order. During fast moves, the call happens, but the fill doesn't, or happens at a very different price. Your bridge has already sent the "open long" signal, so MT5 or cTrader opens a position with no matching trade on TradingView. You discover it when you check your account and see a position you don't recognize.

The second is signal reordering. On reversals, your strategy fires two webhooks within milliseconds, close the old position and open the new one. Webhooks travel over the internet as independent HTTP requests. There's no ordering guarantee. If "open short" arrives before "close long," the EA opens the short. Both positions sit on the account briefly. When "close long" arrives a moment later, the EA looks for a long to close and finds two positions tagged with its magic number. If its close logic picks the most recently opened one, it closes the freshly opened short. The long stays. You end up holding the position your strategy was trying to exit.

The third is stop-loss drift. Most bridges transmit the stop as a distance from entry, for example, "50 points below." Your strategy calculated "SL at 43,250" based on an expected entry of 43,300. But you filled at 43,302. The bridge does 43,302 minus 50 and places the stop at 43,252. Two points above where your strategy logic actually wanted it. On one trade, this is nothing. Over hundreds of trades, or on a prop firm account where two points decide whether your position survives a wick, it compounds.

None of these are Pine Script bugs. They're artifacts of how the signal pipeline was designed by the tools most people use. The question is whether your execution layer was built with these problems in mind.

A TradingView automated trading strategy: how to do it with FillEdge

FillEdge is a TradingView-to-broker bridge built specifically around the three failure modes above. It handles the webhook-to-execution layer so your strategy on TradingView and your trades on your broker platform stay in sync.

For ghost positions, FillEdge doesn't let an alert fire until TradingView confirms the fill. If the fill doesn't happen, nothing gets sent to MT5. You don't get positions that shouldn't exist because the architecture makes them impossible to produce. It's a change at the Pine Script template level, not a filter added after the fact.

On signal reordering, FillEdge sequences events at the server level. When a reversal fires two webhooks in the same millisecond, the close always executes before the open, regardless of which HTTP request arrived first. Your strategy's intended order is preserved even when the network doesn't cooperate.

For stop-loss drift, FillEdge lets you choose per strategy. Exact-price mode sends the literal level your script calculated. Distance mode preserves the offset from actual fill, which is what ATR-based strategies need. Either way, your stop lands where your logic intended. Same for take profit.

Every signal carries a status badge. ✓MATCHED means TradingView and your broker agree on the trade. 👻CAUGHT means a ghost was blocked before it reached the broker. 🔀REORDERED means a reversal was delivered in the correct sequence. You don't scroll through two dashboards hoping the numbers line up. The badge is the answer.

If you run multiple strategies on the same broker account, FillEdge keeps each one isolated. Signals from your US30 trend strategy won't touch positions belonging to your EURUSD mean-reversion. Each strategy gets its own lane, its own stats, its own reconciliation log.

FillEdge also monitors the pipeline with synthetic test signals that travel the full path on a regular cadence, without opening a trade. If any leg breaks, you get an email or Telegram alert within minutes. Your EA going offline overnight stops being a surprise you find at breakfast.

What changes if you're running this on a prop firm account

Prop firm accounts compress the timeline on every failure mode above. The reason is simple math: each evaluation costs $100 to $500, has a daily drawdown limit usually around 5%, and a total drawdown limit around 10%. One bad day ends the attempt.

A ghost position on US30 at 0.8 lots, moving 50 points against you, is a $400 loss on a trade that shouldn't exist. On a $50,000 evaluation with a $2,500 daily drawdown, that's 16% of your daily limit gone to a pipeline problem. Not a strategy problem. Not a risk management problem. A tool problem.

FillEdge ships with built-in compliance profiles for firms like FTMO, Funding Pips, and FundedNext. Bind your account to a profile, and the bridge tracks your drawdown, daily loss, and consistency in real time. When an incoming signal would breach a rule, FillEdge either blocks the trade or auto-reduces the lot size to fit inside your remaining risk budget.

That ghost position scenario from earlier never reaches the broker. Neither does the trade that would push you past your daily limit.

Most prop firm traders eventually stop tolerating "it usually works." The cost of one failed evaluation is larger than two years of bridge subscriptions. If your automation fails once per eight weeks, it's already uneconomical.

A few specific things matter more on prop accounts than on personal ones. First, stop-loss placement has to match your strategy's intent. Prop firm price feeds are often tighter than retail brokers, and a two-point drift in the wrong direction can trigger a stop that would have held otherwise. Whether your strategy needs an exact price or a fixed distance from entry, the bridge has to respect that choice. Second, news-time filters in your Pine Script matter more, since prop firms often restrict trading around high-impact events, and an errant trade can breach the rules. Third, running multiple strategies on the same account requires proper isolation; otherwise, a close signal from one strategy can close positions that belong to another.

None of these are solved by picking a better strategy. They're solved by picking an execution layer that was designed for the accuracy that prop accounts demand.

FAQ

How long does it take to set up an automated trading strategy in TradingView?

For a strategy you've already written in Pine Script, expect 2 to 4 hours of real work: writing the alert logic, setting up the webhook payload, installing and configuring the execution tool on MT5 or cTrader, and running at least one test trade on a demo account. First-timers usually spend longer on the execution side because the jargon is unfamiliar. If you're starting from a Pine Script you found in the public library and haven't edited, add another few hours to understand what the script is actually doing before you hand it real money.

Can I run multiple automated strategies on the same broker account?

Technically yes, but most TradingView-to-broker bridges handle this badly. The common failure is that a close signal from one strategy ends up closing positions that belong to another, because signals aren't tagged with which strategy they came from. If you want to run, say, a trend strategy on US30 and a mean-reversion strategy on EURUSD on the same account, you need an execution layer that keeps each strategy's positions logically separate. FillEdge does exactly that. Without that isolation, the strategies interfere and your reported results stop matching your actual account.

Is it worth automating a strategy on a small account?

Usually yes, even when the monthly tooling cost looks high relative to the account size. The real comparison isn't "subscription fee vs account balance" but "subscription fee vs what you'd otherwise do." Without automation, you can't trade sessions that happen while you're asleep, at work, or away from a screen — so a strategy that depends on the Asian session or on news spikes is simply impossible to run manually. Factor in your own time too: if you're sitting in front of the screen waiting to execute entries by hand, that's hours per week you're paying for with attention, not dollars. Automation turns those hours back into free time, which is worth more than $50 a month for most people.

More from FillEdge

Lock the best price before FillEdge opens to general public.

The first 50 traders lock today's price permanently — it never goes up, no matter the features we add. Get early access and we'll email you the moment the bridge is live.

Join and you'll only get FillEdge launch updates. Unsubscribe anytime.