Home › Guides › TradingView Strategy

TESTING TRAPFREENO ACCOUNTAUTOMATED TRADE BOTSTradingView StrategyWhy a good backtest can lieEDUCATION ONLY | NO SIGNALSEXAMPLE NUMBERS ARE LABELLEDAUTOMATED TRADE BOTSautomatedtradebots.com
A free page on tradingview strategy. Education only, with example numbers labelled.
TESTING TRAP

TradingView Strategy

Short answer

A strategy script is a program on a charting site that holds rules for entries and exits and then lists the trades those rules would have made. An indicator only draws values. It places no trades, even on paper.

A strategy is a set of written rules that a chart can replay on old prices. See how the rules are built and what the replay quietly assumes.

The page explains the idea in plain words, works through the arithmetic with a table, and shows how it hits grid, martingale and DCA bots, then tells you what to check before you run one.

  • A worked example with real arithmetic
  • How it hits grid, martingale and DCA bots
  • How to check for it before you run a bot
  • No advice, no signals, no profit promises

Last reviewed 28 October 2026. Education only, not advice.

Free, no account Runs in your browser Worked numbers shown Not advice Examples labelled

Ready to go further

Next: read the report the tester gives you

The strategy tester guide covers the report fields, the figures worth a second look and the ones that mislead.

Read the tester guideFree, no account
Reading time5 minutes
Worked exampleExact arithmetic
Tools linked0 on this page
Reviewed28 Oct 2026

What is included

  • What it is, in plain words
  • The formula or mechanism, with exact arithmetic
  • How it hits grid, martingale and DCA bots
  • A check you can run before you switch a bot on

Who it is for

  • People who run or plan to run a trading bot
  • Anyone reading a backtest or a bot sales page
  • Readers who want the numbers, not the pitch
  • Not advice, and not a signal service
Made-up result of eight trades under three assumptions$410.00Grossno costs$378.00After costs$2.00 an order$138.00Worse fills0.15 each wayA made-up example. Eight invented trades of 100 units. Not a real result. Calculated by us on 30 Oct 2026, exact.
The picture for this page. Example numbers are made up unless the page says they were calculated.

Key facts

  • A strategy script is a program on a charting site that holds rules for entries and exits and then lists the trades those rules would have made. An indicator only draws values. It places no trades, even on paper.
  • Entries and exits are written as conditions that are true or false on each bar. Everything else, such as size and stops, is a setting around those conditions.
  • The chart tester has to assume things the script does not say: where an order fills, what a trade costs, and what happens when one bar touches both the stop and the target. Your result depends on those assumptions.
  • In a made-up set of 8 trades the gross result is $410.00, after a $2.00 cost per order it is $378.00, and with fills 0.15 worse each way it is $138.00 (calculated by us on 30 Oct 2026, exact).
  • A short run of trades says very little. Eight trades is a demonstration of the arithmetic, not evidence about any rule.

Strategy versus indicator

A charting site lets people write small programs. The Pine Script page covers the language in general terms. Two kinds of program matter here. An indicator calculates a value on every bar and draws it, such as an average or a momentum line. It has no idea what a position is. A strategy goes further. It tracks a pretend account, opens and closes pretend positions when its rules say so, and builds a list of trades with a result for each one.

That list is what the site's tester reads. The TradingView strategy tester page explains how to read the report. This page covers the step before it: how the rules are written, and what the tester quietly assumes while it replays them.

How entries and exits are written as rules

A rule is a statement that is true or false on each bar, using only data that already exists on that bar. A strategy usually has four parts.

  • Entry condition. When it turns true and the strategy is flat, open a position.
  • Exit condition. When it turns true and a position is open, close it.
  • Protective exit. A stop at a fixed distance or percent, and sometimes a target.
  • Size. A fixed number of units, a fixed amount or a percent of the pretend account.

Here is a made-up rule set in plain words. It is an example of how rules are written, not a suggestion.

  1. Enter long at the next open after a bar closes above its 20-bar average, if no position is open.
  2. Exit at the next open after a bar closes below its 20-bar average.
  3. Exit at once if price falls 2 percent below the entry price.
  4. Trade 100 units each time. Charge $2.00 for each order, so $4.00 a round trip.

Notice the words "at the next open" and "after a bar closes". They matter. A rule can only act on a bar once that bar is finished. A script that acts on a close it could not have known yet is guilty of look-ahead bias, and its results mean nothing.

A worked trade table with made-up numbers

The table lists eight invented trades that such a rule set might have produced, at 100 units each. The prices are made up. "Gross" is exit minus entry, times units. "After costs" takes off $2.00 for each of the two orders. "Worse fills" assumes each entry filled 0.15 higher and each exit 0.15 lower than the table price, which is a simple stand-in for slippage and spread.

TradeEntryExitGrossAfter costsWorse fills
150.0052.40$240.00$236.00$206.00
253.1051.80-$130.00-$134.00-$164.00
351.5054.20$270.00$266.00$236.00
454.6053.20-$140.00-$144.00-$174.00
553.0053.90$90.00$86.00$56.00
654.3052.70-$160.00-$164.00-$194.00
752.5056.00$350.00$346.00$316.00
856.2055.10-$110.00-$114.00-$144.00
Total$410.00$378.00$138.00

Read down the last three columns. Of the 8 trades, 4 win before costs, 4 after costs and 4 with the worse fills. The total drops from $410.00 to $378.00 to $138.00 with no change to the rules. The profit factor, total wins divided by total losses, goes from 1.68 after costs to 1.20 with worse fills. That is the point of the table: the same rules give different answers under different assumptions. See slippage.

Net result of each made-up trade after costs$236.00T1win-$134.00T2loss$266.00T3win-$144.00T4loss$86.00T5win-$164.00T6loss$346.00T7win-$114.00T8lossA made-up example. Bar length is the size of the result, the label shows its sign.
Each made-up trade after costs. Two wins are larger than all the losses together, so a small change in costs moves the total.

What the chart tester assumes

  • Fill price. The tester has to pick a price for each order. A common choice is the next bar's open, which may be better or worse than what a live order would get. The settings for this change over time, so check the current ones.
  • Costs. Commission and slippage are often set to zero unless you enter them. A zero-cost test is the first row of the table, and it is the kindest one.
  • Stop and target on the same bar. A bar has a high and a low but the tester cannot see which came first. It uses a fixed rule to guess, and the guess can flip a win into a loss.
  • Repainting. Some scripts change past signals when later bars arrive. The report then shows trades that a live script would not have shown at the time.
  • Limited history. The report covers only the bars loaded. A few trades cannot separate a good rule from luck. See backtesting and overfitting.
  • No account limits. A pretend account has no margin call, no rejected orders and no closed market.

How to check a strategy report

  • Write the rules in plain words, as above, and confirm every condition uses only finished bars.
  • Re-run with a realistic cost and worse fills, and compare with the zero-cost run.
  • Count the trades. A small number says little either way.
  • Test on data the rules were not tuned on. See forward testing.

All the numbers on this page are made up. This is education on how a strategy script is built and tested, not a view on any rule.

FAQ

Frequently Asked Questions

What is a TradingView strategy?

It is a script that holds entry and exit rules and lets the chart replay them on old prices as pretend trades. It produces a list of trades and a report.

What is the difference between a strategy and an indicator?

An indicator calculates and draws values only. A strategy also opens and closes pretend positions and records the result of each trade.

How are entries and exits written?

As conditions that are true or false on each finished bar, plus a size and usually a stop. The strategy acts when a condition turns true.

Why does the same strategy give different results?

The tester assumes a fill price, a cost and an order inside each bar. Changing those assumptions changes the result, even though the rules are the same.

Does a good report mean the strategy works?

No. It means the rules fit the old data under the tester assumptions. Costs, repainting, few trades and tuning can all make a report look better than live trading would.

Are the numbers on this page real?

Example numbers are made up to show how the maths works, and the page says so. A figure only counts as exact when the page says it was calculated on a stated date. Nothing you enter in a calculator leaves your browser.

Can I use this to decide whether to run a bot?

It can show whether a bot's numbers hold together and how much an account can lose. It cannot say what the market will do, and it is not advice. Use it to ask better questions, then read the terms of your own broker or exchange.

Is this financial advice?

No. It is general education about how strategy scripts work. The numbers are made up, and it does not consider your situation.

Know the Risk Before You Run It

Free calculators and guides, added every week. Leave your details and we will email you when new ones go up.

Trading carries a risk of loss