AFL or Amibroker Formula Language is one of the most powerful formula language, widely used for technical analysis in the stock market. It allows traders to customize a trading system, define own personal indicators. You can find various articles on Amibroker AFL code writing on our site. Today, we come with more specific details and example of Amibroker AFL on MACD(Moving Average Convergence Divergence). There are ways by which you can create Amibroker AFL (the language of Amibroker). Once you learn the language, it’s become easier.
Though you get different content on MACD oscillator in our site, still I will give you an introductory note on MACD. Moving Average Convergence Divergence is a momentum indicator. It builds a relationship between two MA of prices. The calculation is quite simple, 26 days EMA (Exponential moving average) is to be subtracted from the 12 days EMA. As a result, a nine-day EMA of the MACD (signal line) stays on the top of the MACD. It triggers the buy-sell signals in a detailed way.
Now, I am gonna describe you step by step the process of putting a simple Amibroker AFL code writing.
Amibroker AFL Code Writing – Simple Example
There are two ways by which you can generate your individual AFL code. These are by the Drag and Drop Interface and By writing individual components. The first one is quite easy. Today we are dealing with the second one.
To make the steps easier, I attach a screenshot of Amibroker. If you see carefully, you can notice in the top toolbar, there is an option, Formula Editor. From there you can attach your formula. The left side of this page, various charts, and indicator options are available. I choose the EMA (Exponential Moving Average) on this script. A plain EMA indicator is applied to the script.
Coding the AFL
Now let’s come to the main step. How to perform Amibroker AFL code writing. In order to make your concept clear, I personally made a buy-sell signal by coding. An image of it is attached below:
You can generate your own formula here. If you are a newbie in Amibroker AFL, you can go through the Help option over there. After completing the code, press the Apply Indicator option and your own indicator or signals will automatically come to the chart.
The above buy sell formula represents when the EMA 5 cross the 20, it creates a buy signal. On the other hand, when EMA 20 cross the 5, sell signal generates. Therefore, in this way, you can apply an AFL code to get your customizable indicators. Let me gift you an advanced colored MACD indicator that is an example of professional formula writing. See the screenshot below:
Download and Usage
You can use colored MACD for your trading purpose. You just need to copy the formula and put it in the formula editor to see the colored MACD. For example, I attached a screenshot of colored MACD on ADANIPORTS share price chart.
A link is provided below, from there you can download colored MACD Amibroker AFL code.
Indrajit is a professional blogger and trading system developer. Amibroker expert, WordPress expert, SEO expert and stock market analyst.Trading since 2002, he has started the journey of StockManiacs.net on 2008. He follows Indian and world stock markets closely.