AFL and Pine organize calculations differently
AFL is an array-processing language: a price variable can represent a series of values processed by a formula. Pine executes across chart bars and maintains series history; its behavior also depends on whether a bar is historical or still updating. Both can express a moving-average rule, but array operations, prior-bar references, persistent state, and realtime recalculation need deliberate translation.
| Research task | AmiBroker | TradingView |
|---|
| Custom logic | AFL formulas support charts, exploration, and backtesting. | Pine indicators and strategies run in the TradingView environment. |
| Find symbols | Exploration applies a filter and produces custom columns over the selected symbols and analysis range. | Pine Screener applies an indicator to a selected watchlist or index. |
| Allocate capital | Portfolio backtesting uses shared equity, position limits, and candidate ranking. | A chart strategy simulates orders for its chart symbol. Requesting another symbol does not allocate a separate position in that instrument. |
| Move an existing system | Document the formula, analysis settings, database, and portfolio rules. | Reimplement the supported rules and compare intermediate values. Pasting AFL is not a migration. |
Data management is part of the platform decision
AmiBroker accepts imported data and vendor integrations; the database and feed require maintenance. TradingView provides symbol datasets through its platform, while Pine data requests work within supported contexts and request limits. An arbitrary local CSV database is not a drop-in replacement for a TradingView chart feed. Neither platform name specifies the exchange, session, adjustment method, or historical universe used by a test.
- Record vendor and exchange identifiers, timezone, regular or extended session, interval, and date range. Compare OHLC values at the first disputed signal.
- For equities, match split and dividend adjustments. For futures, match the contract or continuous-series roll convention.
- A historical universe needs membership dates and delisted instruments where relevant. Testing only current survivors changes the question being answered.
- Check data subscriptions and history availability separately from software access. This page does not quote data-feed prices or assume identical coverage.
Scanning does not establish portfolio performance
AmiBroker Exploration can return filtered rows with custom output columns for a chosen analysis range. Pine Screener uses one indicator per screen and currently calculates its last 500 bars; it supports specified timeframes and does not accept strategy scripts. It can identify candidates, but a list of candidates is not a historical trade ledger with shared cash. These TradingView requirements were checked on October 17, 2026.
- An indicator that needs a longer initialization history can disagree with the same study on a chart. Check the first valid values before using a screener result.
- Specify whether the condition uses a completed candle. A match while a candle is forming can disappear by its close.
- Compare the same symbol set and timestamp. A current watchlist scan cannot reproduce historical membership by itself.
Check the edition and the portfolio constraint
AmiBroker documents portfolio equity as cash plus open positions, with position limits and ranking when signals compete. Its current edition table lists end-of-day and minute-based backtesting in both Standard and Professional. Tick and second-based testing are Professional features, with tick support subject to the documented feed restriction. Do not assume every edition, interval, or feed provides the same experiment.
- Hypothetical allocation: start with $10,000 cash, allow two positions, and budget $5,000 per position. Three simultaneous signals cannot all receive $5,000. A ranking rule must select two or a sizing rule must change.
- Three separate symbol tests, each starting with $10,000, collectively assume $30,000 of starting capital. Adding their dollar profits does not reproduce the shared $10,000 account.
- A Pine script can use other symbols as inputs. Its built-in strategy orders still concern the chart instrument; a custom portfolio calculation needs its own cash, sizing, ranking, and fill model.
One rule to compare before migrating
Use this deliberately small specification on standard daily equity candles: while flat, enter 100 shares after the close moves strictly above its 3-bar simple moving average, provided the previous close was at or below its own average. Exit the long after the opposite transition: the close is strictly below its average and the previous close was at or above. Calculate only at completed-bar close; model both market fills at the next bar open. No shorting, pyramiding, or same-bar fills. This is a test fixture, not a trading recommendation.
- Compare unrounded values. The displayed averages are rounded for reading; rounding before comparison can change an equality boundary.
- Equality on the current bar is not a crossing. Equality on the previous bar is allowed. Missing current or previous averages suppress the decision.
- If bar 5 opens at $13.50 and bar 7 opens at $11.50, gross P&L is 100 × ($11.50 - $13.50) = -$200. At 0.1% commission per side, fees are $1.35 + $1.15 = $2.50 and net P&L is -$202.50, assuming zero slippage and no other charges.
- In AFL, explicitly set trade delay and execution-price settings. In Pine, retain next-tick market fills and avoid closing-tick processing for this fixture. No cross-platform run is claimed here.
| Bar | Hypothetical close | 3-bar average | Expected decision |
|---|
| 1 | 10 | Not available | Wait for history |
| 2 | 12 | Not available | Wait for history |
| 3 | 11 | (10 + 12 + 11) / 3 = 11 | No decision: previous average is unavailable |
| 4 | 13 | (12 + 11 + 13) / 3 = 12 | Entry signal: 13 > 12 and 11 <= 11 |
| 5 | 14 | (11 + 13 + 14) / 3 = 12.6667 | No new entry: previous close was already above |
| 6 | 11 | (13 + 14 + 11) / 3 = 12.6667 | Exit signal: 11 < 12.6667 and 14 >= 12.6667 |
Data and execution consistency checklist
Stop at the first mismatch and resolve its cause before comparing summary returns. Keep a record of the original formula and settings alongside the proposed Pine behavior.
| Check | Evidence to compare | Failure this exposes |
|---|
| Bars and universe | Exchange symbol, OHLC, session, adjustments, history, membership dates | Different inputs or survivorship assumptions |
| Formula and warm-up | Current and previous averages, missing values, equality rules | Initialization or translation mismatch |
| Decision and fill | Signal time, order creation time, fill time and price | Close versus next-open execution or unavailable final-bar fill |
| Position and costs | Shares, lot size, capital, fees, slippage, leverage | Different exposure or unrealistic net returns |
| Portfolio selection | Available cash, maximum positions, ranking and tie policy | Independent trades mistaken for a shared-capital simulation |
| Operational behavior | Alert configuration and separate execution integration | Simulated orders mistaken for live broker orders |