Skip to content

Platforms

AFL (AmiBroker Formula Language)

AFL is AmiBroker Formula Language, the array-based scripting language used to write indicators, scans and trading systems in AmiBroker.

AFL stands for AmiBroker Formula Language. It is the scripting language built into AmiBroker, the Windows charting and analysis program widely used by Indian traders. Anything custom in AmiBroker is written in AFL: indicators, buy and sell rules, explorations, scans and back-tests. An AFL file is a plain text file with the .afl extension.

The language is array-based. A word like Close does not mean one price. It means the whole series of closing prices for the symbol, and an expression such as Close > MA(Close, 20) is evaluated for every bar in one step. That is why AmiBroker is fast over thousands of bars and hundreds of symbols, and why AFL code is short.

AFL uses reserved variables. Buy, Sell, Short and Cover hold trading signals. Filter and AddColumn drive the Exploration output. Plot and PlotShapes draw lines and arrows on the chart. The same formula can therefore draw signals on a chart, list them in a scanner and feed the backtester.

AmiBroker does not come with Indian market data. You need your own AmiBroker licence and a real-time feed from an authorised data vendor for NSE and MCX symbols. The AFL only reads what the feed delivers.

The common mistake is pasting free AFL code from forums without checking it. Many such formulas look into the future, through functions like Zig or a Ref with a positive offset, so their past signals look perfect and their live signals move. Another is applying a formula to a chart whose data has holes and blaming the code.

Worked example

One line of AFL read as an array

Illustrative numbers. Take the line Buy = Cross(Close, MA(Close, 20)); on a 15-minute SBIN chart. AmiBroker computes the 20-period average for every bar at once. On one bar the previous close was ₹848 against an average of ₹849, and the current close is ₹853 against ₹850. Close has crossed from below the average to above it, so Buy is true on that bar and false elsewhere. No loop was written.

In WizeBuySell

The AmiBroker version of WizeBuySell is an AFL formula. We install it remotely over AnyDesk in about 20 minutes on your Windows PC, inside your own licensed AmiBroker with your own real-time feed. It plots buy and sell signals with entry, T1, T2, T3 and the trailing stop-loss, raises popup and sound alerts, and runs as an Exploration across a watchlist. You never need to edit the AFL.

Two market days. Your charts. Then decide.

We install it, you watch the signals fire live on the symbols you already trade.

Start 2-day free trial

No card required. 2-day trial.