DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
The Finance Base
The Money Desk · Blog
Re:

Top 10 AmiBroker AFL Strategy Templates for 2022-Style Markets

Ten transparent AmiBroker AFL strategy templates for trend, breakout, reversion and intraday trading, with practical backtesting and risk checks.
From TheFinanceBase Team9 min to read
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

There is no credible, universal ranking showing which AmiBroker formulas were the ten most profitable in 2022. The useful answer is a set of transparent strategy templates—covering trends, breakouts, mean reversion and intraday trading—that you can test against your own instruments, data and costs. Here, “top” means reproducible, educational and relevant to the volatility and reversals traders encountered in 2022, not proven winners.

AmiBroker Formula Language (AFL) can define indicators, entries, exits, scans, position sizing and portfolio rules. A signal plotted on a chart is not, by itself, a complete trading system. Every example below is illustrative AFL logic, not a verified or ready-to-trade strategy. AFL overview

What “top” means—and what 2022 can tell you

2022 is useful as a historical case-study regime: markets saw macro-driven moves, sharp reversals, volatile periods, bear-market rallies and breakouts that sometimes failed quickly. That mix makes it a sensible context for comparing strategy ideas, but it does not establish that any particular system outperformed, or that it will work in a different market.

The ten templates are selected for clear rules, reproducibility in AFL, relevance to changing conditions, adaptability across liquid markets and the ability to define risk. No performance ranking is available for them. A serious comparison needs a specified instrument universe, timeframe, data source, corporate-action treatment, execution model, costs, position sizing and out-of-sample period.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
How to Day Trade for a Living: A Beginner’s Guide to Trading Tools and Tactics, Money Management, Discipline and Trading Psychology (Stock Market Trading and Investing)
  • As a day trader, you can live and work anywhere in the world. You can decide when to work and when not to work.
  • You only answer to yourself. That is the life of the successful day trader. Many people aspire to it, but very few succeed. Day trading is not gambling or an online poker game.
  • To be successful at day trading you need the right tools and you need to be motivated, to work hard, and to persevere.

Evaluate more than net profit: consider CAGR or CAR, maximum drawdown, CAR/MDD, profit factor, expectancy, trade count, exposure, average trade, longest losing streak, and sensitivity to costs. A strong-looking single result can hide too few trades, excessive exposure or fragile parameters.

Ten AFL strategy templates

These are archetypes, not claims about the objectively best systems of 2022. The short code examples show core logic; add and test sizing, stops, costs and execution assumptions before relying on them.

1. EMA crossover trend following

A faster exponential moving average crossing above a slower one signals a long entry; the reverse cross exits. AmiBroker’s backtesting tutorial demonstrates the basic EMA() and Cross() pattern. AmiBroker backtesting tutorial

FastEMA = EMA( C, 20 );
SlowEMA = EMA( C, 50 );

Buy  = Cross( FastEMA, SlowEMA );
Sell = Cross( SlowEMA, FastEMA );

Buy  = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy );

Twenty/50 averages are one swing-trading starting point; 50/100 or 50/200 can define slower systems. The hypothesis is that persistent trends can continue after a crossover. Sideways markets generate whipsaws, while sharp reversals can leave entries late. Test a long-term trend filter, ATR or ADX condition, stop, time exit and sizing as separate design choices rather than assuming they improve results.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

2. ATR-based trailing trend (SuperTrend-style)

This family uses volatility-derived bands to indicate direction and a trailing level. It can suit directional markets with expanding ranges, but may flip repeatedly in consolidation. “SuperTrend” is not one uniquely standardized formula: document the ATR period, multiplier, price source or midpoint, signal timing and gap treatment in any implementation. Do not compare results from different versions as if they were the same system.

Rank #2
Trading: Technical Analysis Masterclass: Master the financial markets
  • Language: english
  • Book - trading: technical analysis masterclass: master the financial markets
  • It is made up of premium quality material.

3. Donchian-channel breakout

Enter when price breaks the prior lookback period’s high or low. Referencing the previous bar keeps the current bar from changing the breakout threshold being tested.

Lookback = 20;

Upper = Ref( HHV( H, Lookback ), -1 );
Lower = Ref( LLV( L, Lookback ), -1 );

Buy   = H > Upper;
Short = L < Lower;

Sell  = C < EMA( C, 20 );
Cover = C > EMA( C, 20 );

Breakouts may capture volatility expansion after consolidation, but false breaks can produce repeated small losses. A confirmation close, volume or volatility filter, market-regime rule, or limit on trades can be tested; each changes the system and must be evaluated rather than presumed beneficial.

4. ADX-filtered trend entry

ADX measures trend strength, not direction. Pair it with directional logic, such as moving averages or price structure, before using it as an entry filter.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
TrendUp = EMA( C, 20 ) > EMA( C, 50 );
StrongTrend = ADX( 14 ) > 20;

Buy  = TrendUp AND StrongTrend AND Cross( C, EMA( C, 20 ) );
Sell = Cross( EMA( C, 20 ), C );

This design may avoid some entries in weak conditions, but a strength threshold can also delay entries or miss abrupt trend starts. Treat 14 and 20 as example parameters, not established optima.

5. RSI mean-reversion swing

A short-period RSI below a threshold can flag a pullback for a possible long entry; a recovery threshold can provide an exit. A long-term trend filter helps define the intended context, but cannot prevent losses in every falling market.

Rank #3
Sale
The Psychology of Money: Timeless lessons on wealth, greed, and happiness
  • Ideal for Gifting
  • Ideal for a bookworm
  • Compact for travelling
R = RSI( 2 );

Buy  = R < 10 AND C > EMA( C, 200 );
Sell = R > 70;

Test maximum holding time, stop policy, gap behavior and whether orders are assumed at the close or next session. RSI can remain oversold while a downtrend continues, so repeated entries are a central failure mode.

6. Bollinger Band reversion or breakout

Bollinger Bands support two opposite hypotheses. A reversion system buys below the lower band and exits near the middle band; a breakout system buys a close above the upper band and exits when price returns inside or loses a trend filter. A 20-period average and two standard deviations are common research starting points, not a universal optimum.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Reversion risk: fading a genuine volatility expansion can put a trade against a developing trend.
  • Breakout risk: a close outside a band can reverse rather than continue.
  • Testing choice: define one hypothesis, then test a regime filter such as ADX, long-term trend or bandwidth behavior.

7. Connors RSI short-term reversion

Connors RSI combines a short-period RSI, RSI applied to the length of consecutive up or down closes, and a percentile rank of recent price changes. It is a distinct composite indicator, not simply standard RSI with better accuracy. Define each component, entry threshold, exit and holding period explicitly. Fixed holding-period exits can produce materially different results from indicator-based exits.

The hypothesis is short-term pullback behavior, especially in liquid equities or ETFs. Sustained momentum, illiquidity, wide spreads and regime changes can undermine it. Do not claim an edge without testing the exact implementation on the intended universe.

8. VWAP pullback

This intraday idea trades a pullback toward session VWAP after an established move. A valid test depends on the session start and end, daily reset, overnight handling, premarket volume policy and the earliest permitted signal time. Regular-session equities and continuous futures data need not use the same session definition.

Rank #4
Sale
Trading in the Zone: Master the Market with Confidence, Discipline and a Winning Attitude
  • Prentice Hall Press
  • Great one for reading
  • It's a great choice for a book person

VWAP needs reliable intraday price and volume data; end-of-day bars cannot establish a genuine intraday VWAP test. Directional sessions may suit the hypothesis, while choppy sessions can produce repeated crossings. Include realistic spread, commission and slippage.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

9. Opening-range breakout (ORB)

Define the high and low of a fixed opening window—such as 5, 15 or 30 minutes—then trade a confirmed break. The range must stop updating when that window ends; a formula that keeps adding later bars is not testing the intended opening range.

  • Specify the exchange, time zone, calendar and opening-range duration.
  • Define confirmation, stop placement, a one-trade-per-day rule and end-of-day liquidation.
  • Model gaps, halts and the order price available after a break.

Strong, high-volume opens may fit the premise; quiet or mean-reverting sessions may not. These are conditions to test, not a performance promise.

10. Intraday ATR or SuperTrend scalping

A short-timeframe volatility-adjusted trend signal can be combined with an EMA, VWAP or time-of-day filter. Sustained intraday movement is the intended environment. Whipsaws, bid/ask spread, commission, slippage and execution latency can erase an apparent edge. Bar-close signals do not prove a trade could have filled at the assumed price, so this template needs especially realistic execution assumptions.

Which template fits your constraints?

Reader constraint or goal Templates to investigate Main concern
Less screen time EMA trend, Donchian breakout, daily RSI Overnight gaps and delayed exits
Persistent trends EMA, ATR trailing trend, ADX-filtered trend Whipsaws when the trend fades
Range-bound conditions RSI, Bollinger reversion, Connors RSI Losses during trend expansion
Volatility expansion Donchian breakout, ORB, Bollinger breakout False breakouts
Intraday directional trading VWAP pullback, ORB, intraday ATR trend Session definitions, data quality and slippage
Learning AFL EMA crossover, RSI, basic breakout Simple code is not proof of robustness
Automation Any fully mechanical system with defined orders and exits Broker connectivity and operational failures
Manual decision support VWAP, ADX or trend overlays Discretion may invalidate backtest assumptions

Holding period, account size and instrument constraints matter as much as the indicator. A portfolio test can behave differently from a single-symbol test because capital, maximum positions, ranking, correlated holdings, exposure and cash limits interact.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Build the complete system: exits, stops and sizing

AmiBroker uses Buy, Sell, Short and Cover for long and short rules. A system also needs position sizing, risk exits, portfolio constraints and an execution assumption. AmiBroker backtesting tutorial

Choose the exit type that matches the hypothesis: signal reversal, fixed percentage or point stop, ATR stop, trailing stop, profit target, time stop or session-end exit. AmiBroker documents ApplyStop() for stops, including ATR-based point stops:

ApplyStop(
    stopTypeLoss,
    stopModePoint,
    2 * ATR( 10 ),
    True
);

In the documented ATR-stop behavior, the stop amount is sampled at entry and held for that trade; it does not automatically follow each later ATR value. AmiBroker backtesting tutorial

PositionSize can specify a dollar allocation or a percentage of available equity. For example, AmiBroker documents PositionSize = 1000; as a fixed dollar allocation and PositionSize = -50; as 50% of available equity. These are allocation examples, not risk-based sizing instructions. Risk-based sizing instead relates the number of shares or contracts to the planned loss at the stop. AmiBroker backtesting tutorial

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Also decide whether a signal fills at the same bar’s close, the next bar’s open, a limit or stop price, or an intrabar price inferred from high/low data. AmiBroker’s settings affect periodicity, trade prices, commissions, stops and related assumptions. Same-bar exits and immediate stop activation can change results, particularly for entries at the open. AmiBroker backtesting tutorial

Run a backtest without mistaking it for proof

  1. In AmiBroker, open the Formula Editor and write a formula with the appropriate trading-rule variables.
  2. Choose Tools → Send to Analysis in the Formula Editor, then open Automatic Analysis.
  3. Select the intended symbols and date range; set periodicity, initial equity, commission, trade price, stops and other relevant settings.
  4. Click Back test, then inspect the results and trade list rather than relying only on the headline profit figure.
  5. Repeat on unseen dates and an appropriate universe, then examine parameter stability and portfolio constraints.

This is the documented basic workflow. AmiBroker also supports scanning, portfolio backtesting, optimization, walk-forward testing and Monte Carlo simulation; these are analysis tools, not guarantees of future performance. Backtesting tutorial · AmiBroker product capabilities

Control bias and data problems

  • Look-ahead bias: avoid future-confirmed pivots or any data unavailable when the signal would have been made. Do not use a current bar’s high or low to claim a fill at that same level without modeling intrabar order and execution.
  • Survivorship bias: a test of today’s surviving stocks may omit delisted companies. Establish whether the historical universe includes delisted securities and reflects what was known at each date.
  • Corporate actions: document how equity data handles splits, dividends, rights issues, symbol changes and delistings.
  • Intraday data: check time zones, session boundaries, missing bars, volume quality, spreads, halts, overnight sessions and bar compression. VWAP and ORB results depend on these choices.
  • Costs: include commissions and slippage, with more conservative assumptions during volatile periods. Frequent trading is especially sensitive to costs.
  • Repeated signals: AFL conditions may remain true on consecutive bars. ExRem() can remove repeated signals, but that changes trade behavior and needs testing.
  • Portfolio effects: capital limits, position caps, ranking, sector concentration, correlation, cash and position-size shrinking can make portfolio results differ from a single-symbol backtest.

Optimize for robustness, not a lucky peak

AmiBroker’s Optimize() syntax is Optimize( "Description", default, min, max, step ). Multiple optimization variables multiply the number of runs. Its documentation advises caution with sharp performance spikes: broad regions of comparable results are generally more robust than one isolated best parameter. AmiBroker optimization guide

Quick Recap

Bestseller No. 2
Trading: Technical Analysis Masterclass: Master the financial markets
Trading: Technical Analysis Masterclass: Master the financial markets
Language: english; Book - trading: technical analysis masterclass: master the financial markets
$7.56
SaleBestseller No. 3
The Psychology of Money: Timeless lessons on wealth, greed, and happiness
The Psychology of Money: Timeless lessons on wealth, greed, and happiness
Ideal for Gifting; Ideal for a bookworm; Compact for travelling
$10.99
SaleBestseller No. 4
Trading in the Zone: Master the Market with Confidence, Discipline and a Winning Attitude
Trading in the Zone: Master the Market with Confidence, Discipline and a Winning Attitude
Prentice Hall Press; Great one for reading; It's a great choice for a book person
$23.00
SaleBestseller No. 5
  • Optimize only parameters with a defensible reason, and examine a broad range.
  • Separate in-sample from out-of-sample dates; do not keep adjusting rules after inspecting the full test period.
  • Test multiple relevant instruments and include realistic costs and execution.
  • Compare objectives beyond profit, including drawdown, trade count, profit factor, exposure and risk-adjusted return.
  • Use walk-forward or Monte Carlo analysis as additional checks, not as proof that a system will work live.

Before putting an AFL system at risk

  • Understand every rule and confirm that signals use only information available at the time.
  • Test the instruments, session and timeframe you actually intend to trade.
  • Specify fills, costs, sizing, stops and portfolio limits before judging results.
  • Validate on unseen data and check whether modest parameter changes destroy the result.
  • Paper trade first; compare live-like fills and slippage with the model.
  • Set a risk limit and a rule for stopping the system if real execution diverges from assumptions.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More post from the Money Desk

  1. The Money DeskBlogTheFinanceBase07 MAR 2625 minWhat Is a 457 Plan?
  2. The Money DeskBlogTheFinanceBase07 MAR 2621 minTime Value of Money: What It Is and How It Works
  3. The Money DeskBlogTheFinanceBase07 MAR 2627 minAre You Living in One of These Top 10 Most Expensive Cities to Retire?
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.