Master Candle Exploration AFL with Breakout Levels

Master Candle is a proven price action pattern that accurately identifies the possible breakouts in the chart. It’s used by professional traders to speculate market movements and enter long or short trades. We have developed a master candle exploration AFL which can exponentially reduce your analysis time by signaling the breakouts. This exploration shows the master candle levels of the stocks in your watchlist, along with the Open, High, Low, and Close values.

A Quick Recap about Master Candle

In case you are new to master candle, it is a combination of 4 candles, a long mother candle, and 3-4 baby candles which are engulfed by the mother candle.

Master Candle Setup

Any breakout above or below the mother candle high/low should be considered as a trading opportunity.

Check out this article to understand in detail about master candle, its interpretation, and examples.

Master Candle Exploration AFL – Overview

The master candle exploration does the following things:

  1. For a given symbol, it identifies all the master candles based on the below conditions:

Master Candle High > Highs of subsequent 4 candles

Master Candle Low < Lows of subsequent 4 candles

  1. Once the master candles are identified, it checks the most recent candle to see if it’s high or low is above/below the master candle high or low respectively. This recent candle should be first, second, or third candle after the last child candle of master candle setup.

Master Candle Exploration AFL Code – Download Link

You may download the exploration code from the below link. The file is in zip format, you’ll have to unzip it before use.

Master Candle AFL Exploration Code

The code has been tested in Amibroker version 6 and above. The trial version of Amibroker can be downloaded from this link.

How to use this Exploration Code?

Step 1: Open Amibroker, Click on File –>New –>Formula and copy-paste the exploration code you downloaded.

Step 2: Click on File –>New –>Analysis. Set timeframe appropriately

Step 3: In the “Apply to” drop-down select ‘All symbols’ or filter based on the list of stocks you want to watch. In the range drop-down, select ‘1 recent day(s)’ to run exploration only for the recent candle. And select the AFL code in the “Formula” box.

Master Candle Exploration AFL

Note – You can use this exploration AFL in any timeframe.

Understanding the Exploration Code

Let’s understand the exploration code in detail.

First of all, this is purely an exploration code, so you won’t be able to use it in Amibroker charts.

The below line identifies all master candles from your database:

Master Candle Exploration AFL1

The logic is simple – if the candle high is greater than the highs of next 4 candles, and the candle low is less than the lows of next 4 candles, then it will be marked as a master candle (MC).

Next, we’ll store the high and low values of the master candle in the variable MCHigh and MCLow respectively. The difference between MCHigh and MCLow is the MCRange (the range of master candle).

Master Candle Exploration AFL2

The breakout candle should be the first, second, or third candle after the last child candle of master candle setup. This is coded using the below line:

Master Candle Exploration AFL3

A long breakout occurs if the breakout candle condition is satisfied and high is greater than the high of master candle. While a short breakout occurs if the breakout candle condition is satisfied and low is less than the low of master candle. Its code as below:

Master Candle Exploration AFL4

The filter statement filters only those symbols where the LongBreakout or ShortBreakout condition is satisfied.

Master Candle Exploration AFL5

Finally, all the calculated variables are added to the exploration using AddColumn() or AddTextColumn() functions.

Master Candle Exploration AFL6

The values are appropriately color-coded for easy interpretation.


All the AFL’s posted in this section are for learning purpose. Trading Tuitions does not necessarily own these AFL’s and we don’t have any intellectual property rights on them. We might copy useful AFL’s from public forums and post it in this section in a presentable format. The intent is not to copy anybody’s work but to share knowledge. If you find any misleading or non-reproducible content then please inform us at support@tradingtuitions.com

Related Posts

One Comment

  1. Hi Sir,
    Very Simple and Easy coding . Thank you for the code. I have 2 queries regarding this AFL code .

    1. Which timeframe was this exploration results based on ? Was it 30 mins tf or 1 hour tf.

    2. Can we incorporate a buy and sell signal for Long breakout and short breakout.

    Thank you

Leave a Reply

Your email address will not be published.