Four reasons a working script stops working
A copied script that disappoints has usually failed for one of four reasons, and only two of them are the script's fault.
1. The backtest was never measuring something possible
Future leak, a non-standard chart, or no costs at all. The result was fiction before you copied it. The checks in the next section find this in about two minutes.
2. It was written for v5 and pasted into a v6 chart
This produces the most confusing version of the problem, because the script may
compile and still behave differently. In v6 the and operator short-circuits,
so a ta.* call after a false condition is skipped and its internal history
breaks; margin_long now defaults to 100 instead of 0, so margin is enforced
where it was not; and timeframe.period returns "1D" where v5 returned
"D", so a comparison against "D" silently never matches.
None of those raise an error. See the v5 to v6 changes for the full list — the section on changes that do not error is the relevant one.
3. You are running it on a different instrument
This is the most common cause and the least discussed. A script built on a
liquid index future and applied to an exotic FX pair inherits none of the
assumptions it was tuned against: spread, tick size, session hours, typical
range. A slippage = 1 that was honest on one instrument understates costs by
an order of magnitude on another, because slippage is measured in ticks and a
tick is not the same size.
Nothing in the script tells you this. The author's instrument is usually not even recorded.
4. It was fitted to the history it was tested on
A strategy with enough parameters will fit any sample. This is the failure mode that leaves no trace in the source — the code is clean, the costs are real, the backtest is honest, and the parameters happen to be the ones that worked on that exact stretch of history.
The only defence is out-of-sample evidence: does it hold on a date range the author did not tune on, and on a second instrument. If you cannot test that, you do not know.
What to do with a script you want to keep
Rebuilding the logic rather than reusing the file solves 1, 2 and 4 at once: you get current v6 output, costs you set deliberately, and parameters you chose rather than inherited. It does not solve 3 — nothing does except testing on the instrument you actually trade.
Vetting a script you did not write
You do not need to read a published script line by line to know whether its backtest can be trusted. Five text searches answer most of it, in this order — cheapest and most decisive first.
1. Search for lookahead
If barmerge.lookahead_on appears, find the expression being requested and
check whether it is offset. high[1] with lookahead on is the documented safe
pattern; high with lookahead on is a future leak, and the historical half of
the backtest had prices the live half cannot have [2].
TradingView does not permit publishing scripts that leak future data into history [2], which tells you how often it is attempted.
2. Search for request.security
Even without lookahead, a higher-timeframe request returns an unconfirmed value on realtime bars and a confirmed one on history [1]. That is not fraud, but it means the equity curve you are looking at was produced under different conditions from the ones you will trade.
3. Search for strategy( and read the declaration
This is where the backtest is actually decided, and it takes ten seconds:
| If you see | Then |
|---|---|
no commission_value and no slippage | the result is from a market that charges nothing |
default_qty_type = strategy.percent_of_equity | the curve compounds, which flatters a weak edge over a long test |
pyramiding above 1 | the strategy stacks positions; check whether the risk figures account for that |
calc_on_every_tick = true | realtime and historical execution differ by design [1] |
process_orders_on_close = true | fills assume you can trade the close of each bar |
A script with no costs in its declaration has not been backtested in any meaningful sense, whatever its reported profit factor.
4. Check the chart type it was published on
Non-standard charts — Heikin Ashi, Renko — produce results TradingView itself describes as unrealistic by default [1]. A strategy screenshot on a Heikin Ashi chart is not evidence about anything tradeable.
5. Look at the trade count and the date range
Fewer than a hundred trades is not a sample. A spectacular result over six months on one symbol is one market regime, not a strategy.
What none of this tells you
That the strategy is profitable. These checks only establish whether the backtest is measuring something possible. A script that passes all five can still be curve-fitted to the exact history it was tested on — and that failure mode leaves no trace in the source at all.
The surveyed academic evidence on technical trading rules is much weaker once transaction costs are included [3]. A published script showing otherwise is making a strong claim, and the burden of proof sits with it.
Tactix AI on this workflow
AlfaTactix includes Tactix AI: use Tactix Studio to describe your idea in plain language and draft timeframes, signals, filters, and risk into the same six-step Strategy Builder form — or open Tactix Guide on any step when you only need a field explained. Review every value, then export MQL5 or Pine Script from Code Generator (form-first — not untested prompt-to-code).

