Best Amibroker AFL Strategy

A lot of people, especially those who are beginners, put up these question-

  • Which is the best Amibroker AFL strategy?
  • Which AFL can be most helpful in my trading?
  • Or, Can you refer a set of good AFLs?

The short answer to this question is that- A good AFL should have all essential ingredients of Technical Analysis + Money Management.


AFL Strategy vs ATM Machine


Can a AFL strategy be like perpetual money printing money? Just think of this- whenever you need money, you can trade the AFL automatically, and money will shower in your bank account. You can start making money just be few clicks, you don’t even need a card with password to withdraw money.

Does this idea sounds logical? Unfortunately, by exploiting the greed of gullible public, many vendors try to spread this notion.  Even though ridiculous, you will find many websites advertising such strategies, and also many beginners looking for such strategies.

The matter of the fact is, howsoever good an AFL formula may be, it requires a discretionary layer + execution layer to make it profitable. You need to accept that an AFL making money for me cannot make money for you without proper deployment. With this perspective, continue reading about the features of best AFL.

Click here for a backtested AFL

Essential TA Features of Best Amibroker AFL

Amibroker has the power to formulate both Quantitative and Technical Analysis strategies via its AFLs. In this article, we will discuss with the perspective of Technical Analysis (TA) only.


Assume a simple trading logic, buying and selling on Moving Average (MA) Crossover signals. The essentialy required TA features are:

  1. Initial SL: allows you to buy on MA crossover, but with pre-defined risk. MAs react slowly to market. What if the market crashes down just when you enter trade? So, you should also have a priced based SL along with MA exit.
  2. Trail SL: MAs move slowly. If the markets spike down sharply, while you are Long, a trail stop is essential to save your PnL
  3. Profit Target: If you are Long, and prices reach resistance level; then as per TA you should book your profits without waiting for downward MA crossover. Profit target should be set in advance at resistance levels
  4. Option for Long Only or Short Only: If the higher time frame shows uptrend, then you should trade Long only in MA crossovers. Similarly, if market is above critical breakout level, you should trade Long only
  5. Buy Above, Sell Below: Above critical/pivotal price levels you should be in Long only mode. Below the price level you should be in Short only mode.
  6. Trade Entry Timing: In many types of intraday strategies, it is not advisable to Buy in the first 15 minute after market open. In first 15-minute the prices move wildly and may trigger false signals. Similarly, it is not suggested to enter trades in last 60/30 min, because there is hardly any time left for market movement.
  7. Trade Exit Timing: If you are trading intraday on open momentum, you may like to exit by lunch hour. Similarly, an exit time is required before market close, regardless of signals by MA crossover

Optional Position Sizing Features of Best Amibroker AFL

  1. Trade Size: Calculate number of shares for each trade based on Account Margin and Risk (stop loss)
  2. Scalein: Rather than buying complete shares at MA crossover; you can buy 50% shares at crossover signal, and 50% shares on price confirmation
  3. Scaleout: Rather than selling complete shares at MA crossover; you can sell 50% at resistance level and 50% at crossover signal
  4. Multiple Profit Targets: For price action based strategies, you can have multiple profit targets

Essential Coding Features of Best Amibroker AFL

  1. AFL code should maintain proper cycle of Buy, Sell, Short and Cover Signals (logically there cannot be a Cover after Buy)
  2. Define BuyPrice, SellPrice, ShortPrice and CoverPrice specifically (If they are not defined Amibroker picks them up automatically which may or may not be correct)
  3. Checking that the strategy does not looks into future and signals do not come and disappear
  4. Programmed strategy should work for all stocks as per Amibroker data

How to Get a Money Making Formula?

The best traders use simple logics like Trend and Support/Resistance. However, there deployment of simple logic is not simple. Rather, its very sophisticated. Simple trading logic can be supplemented with more than a dozen Technical Analysis and Position Management rules as explained above.

So, you should not waste your time trying to find a ATM card, rather invest your time in learning the scientific art of trading.