Tuesday, December 6, 2011

AFL Code Writing : Lesson 1

I assume that you have no any knowledge in programing language even AmiBroker code. Okay, let's start.

Today, we will  :
(1) Open AmiBroker Formula Editor.
(2) Write our first afl code.
(3) Check for error.
(4) Save our afl code.
(5) Display our chart in AmiBroker.
In our next lesson we will explain our first afl code.

(1) How to open AmiBroker Formula Editor ?
Pls. follow the below steps :
=> Open your AmiBroker.
=> Click "Analysis" from Manu bar.

=> Click "Formula Editor..." or Click directly "Formula Editor" icon directly from Toolbar.

Now you have done your first step. You have able to open AmiBroker Formula Editor.

(2) Now, you will write your first code. We will explain each line of the code in our next lesson. Okay write down the below code in your AmiBroker Formula Editor :

Or Copy the below code and paste your Formula Editor :

_SECTION_BEGIN("Price");
Plot( Close, "Close", ParamColor("Color", colorGold ), styleCandle);
_SECTION_END();


Wow!!! you have written your first afl code.

(3) If you make any mistake in your afl code even miss a semicolon ";", you will not able to see the chart. How you will check your code? It's easy. Just Click "Tools" and then "Verify Syntax" or click the Verify Syntax icon in the Toolbar directly. Confused? Okay see the below image :
After clicking the Verify syntax, have you seen any change? No change? Really? Wow!!! you have able to write a error free code. 

Okay, if you make a mistake then what will be happened? After clicking the Verify syntax, it will show us error with with line number. The error line will be marked by yellow and in the bottom, you will find the details including the line number of the error.  Pls. see the below image :
I hope, you have already found my mistake. I've missed to put the semicolon at end of the line 3 _SECTION_END();

If   Verify syntax finds any error, you will not able to see your chart.  


(4) I hope, you know how to save a file. So, I'm not going to in details. Just keep in mind that you have to save the file in   ........\AmiBroker\Formulas\Custom   folder. Like. C:\Program Files\AmiBroker\Formulas\Custom
Okay, Click File menu of your Formula Editor then Click Save As and then save the file in the name of "Price" in the   ....\AmiBroker\Formulas\Custom   folder. Pls. see the below Image :

After saving the file, pls. close your Formula Editor by clicking File and then Exit.


(5) Now, we will see our created chart. Pls. see the below image :

1. Click "Chart" and 2. expand the Custom folder by clicking the "+" sign and then you will see your saved first afl code name Price, finally 3. double click on your Price afl and then you will see your own created chart. Wow!!!!. Congratulation!!!!!

After expanding the custom folder, if you don't able to see your Price afl you may assure that you could not save the file in the right place. Pls. save your Price afl in   ........\AmiBroker\Formulas\Custom   folder. First find where have you installed your AmiBroker. In AmiBroker you will find the Formulas Folder. In Formulas folder you will find the Custom Folder. Always save your afl here.

In our next lesson, I will explain the code. Later on we will create our own afl even trading system. Allah Hafiz.

5 comments:

  1. THNX, BUT AFL MADE ER SYSTEM TA KI? JEMON AMI AFL ER CANDLE COLOR CHANGE KORBO OR AFL ER BUY OR SLAE SIGNAL CHANGE KORBO? KIBABE?PLS SAY.

    ReplyDelete
  2. I'll show you everything In Shaa Allah. In the next lesson you will get your ans. BUY/SELL signal ta ektu porey alochona korbo. Step by step na geley oney key-e buztey parbey na. Amar kaz holo basic ta clear kora. Baki ta aponara egiye niye jaben. Ami-o aponader kach thekey shikhtey parbo.

    ReplyDelete
  3. http://www.facebook.com/AdminNeha/posts/274681995915694

    ReplyDelete
  4. nice job.. it is so much helpful to begineer. god bless thanks

    ReplyDelete