Learn AFL Code: Basic Structure of an AFL code Part 1

Every Amibroker AFL starts with a section. A section is nothing but a block, that contains your AFL codes. Syntax of your AFL section is like this

_SECTION_BEGIN(“Name of the section”);

// Your Code

_SECTION_END();

You can use any name your like to identify your section purpose.

Comment Line in AFL code starts with “//”. If you wish to make comment of your logic or code purpose then put a “//” before that line.
Use /* ……. */ as block commnet. It will make multple lines comment.

Sample
//This is a comment line
/* This is start of our comment
second line of comment
third line
.
.
.
End of my comments */

You may have seen many hefty block of codes of AFL. But What is the main purpose of AFl code? We wants to generate Buy or sell signals from them. So every AFL has 4 main parts

Buy = Your entry signal for long trade;

Sell = You exit signal for long trade;

Short = Your entry signal for short trade;

Cover = You exit signal for short trade;

Well now traders have their own trading plans for different Buy or sell signals. So now decide your signal and put in here.

Now take an example

_SECTION_BEGIN(“price section”);

//Buy Logic AFL
Buy= Cross(EMA( C, 20 ), EMA( C, 50 ));
//Sell logic for AFL
Sell= Cross(EMA( C, 50 ), EMA( C, 20 ));

_SECTION_END();

Debarghya Mukherjee
Mobile: (+91)-9038787021
Email: debarghya_mkr@yahoo.com

 

Learn AFL Code: Introduction

Hello Friends,
I have been trading since 2008. When I started trading with my first account, I had very little idea about algotrading, Metastock, Amibroker etc. I used to take decision from fundamental reasons, and once in a while I learned technical trading and was looking for my trading plan tester. Then one day I was introduced with Amibroker and AFL coding. I started lot of googling but I have not yet found any good site that helps “How to write AFL codes from Amibroker”. I know there is a site contains AFL Library but it is not sufficient. New users can learn from step by step process, not from some bulky AFL sample codes.

Most traders try to download AFL codes from internet, then try to follow them. My intention is that, users must learn “How to write his own AFL code for good”.

I am an MCA (Masters in Computer Application) and having both technical trading knowledge and computer background I understand how the process goes. So I started my own AFL code writing tutorial site for users who really wants to learn AFL coding.

Happy Trading,

Debarghya Mukherjee
Email ID: debarghya_mkr@yahoo.com
Mobile:(+91)-9038787021

This WordPress.com site is the cat’s pajamas