How do I learn AFL?

newbie
Tags: #<Tag:0x00007f2d7b6e7008>

#1

Programming in AmiBroker Formula Language (AFL) is not that different from programming in any other language. If you are looking for general introduction to programming any language tutorial would do because programming is not about the syntax but about general concepts such as variables, functions, loops, etc.

AmiBroker Formula Language is syntactically similar to plain old C and JScript but easier to use. It also has lots of functions that are trading related but general concepts are common in languages.One thing that is worth understanding is concept of array processing explained here: http://www.amibroker.com/guide/h_understandafl.html

Contrary to many general-purpose languages, AmiBroker is able to process entire arrays (data series) without using loops which makes it both faster and easier to use than "regular" language. Getting this concept right is fundamental to write efficient AFL code, so please start with the above mentioned "Understand AFL" tutorial.

The only way to learn is to keep practicing.

If you are "visual" person, do not forget YouTube. There are plenty of videos with great "hands-on" exercises for you to follow: https://www.youtube.com/results?search_query=lets+learn+amibroker

If you need formal specification please see AmiBroker Formula Language part of the manual.


How do I debug my formula?
New to coding need AFL codeing help
RSI > 70 and RSI <30 with exploration
How to code below strategy please help
Scanner for Intraday
Easy Language / Multicharts user wishing to convert
Array always return 0
How can I get current bar?
How to get moving-average value with AFL?
AFL Context Execution Order
How to find the size of an array
Need Rectification In This code
Watchlist names in Exploration output
New to Community
Is it possible to run Python on Amibroker?
#2

#3

This post is similar to one from the old forum as I was not sure if old posts will be accessible. This may also belong on the “how to learn AmiBroker post” if there is one.

There are many resources available to help get you started.

As mentioned above by TJ, the books by Howard Bandy are geared towards learning to trade and learning AmiBroker.

(1) Probably the most popular beginners books is Free for download. Intro to Amibroker by Howard Bandy
This forum is not allowing me to post more than two “links”, so go to BlueOwlPress dot com for more info on those books.

(2) You should work your way through the official tutorials (scroll down for afl code writing tutorials),
https://www.amibroker.com/guide/tutorial.html

(3) You should work your way through the official Knowledge Base
http://www.amibroker.com/kb/toc/

(4) consider reading Technical Analysis of Stocks and Commodities (TASC) and review the ~150 articles written by many traders and the afl codes written by AmiBroker founder Tomasz Janeczko.
http://www.amibroker.com/members/traders/

After you’ve mastered those steps there are commercial instructors who you can pay to teach you Amibroker and/or trading.

Welcome to the AmiBroker community, and good luck.

Larry


Help coding a trend following system
Start with AmiBroker
How to create multiple chart layout
#4

2 posts were split to a new topic: ValueWhen - how to use


#5

A post was merged into an existing topic: ValueWhen - how to use


#6

If you’re a complete beginner and are finding that things are ‘going over your head’, you may benefit from watching the many free videos at the following helpful and informative site:

Free Amibroker Videos

They show you how to enter the AFL language and its results in action. Most are easy to follow and copy to your own AFL editor, and will give you a starting insight into how to get going with AFL.


#7

Hi Tomasz,
Thank you and your team setting up this excellent forum in which i learn everyday reading it. i dont know if there is a search facility in the forum so that the intellect buildup here could be referred to easily. It hopefully save experts valuable time answering too.
jimmy


#8

Search functionality is to be found at the very top right corner of the
forum left of your account avatar. It is the “reading glass” icon. If you
click it a text field opens up. On the right side of that field an "options"
link can be followed leading you to advanced search.


#9

Than you fxshrat for making the effort to answer trivial question like mine. As always the Amibroker team have thought about everything possible ahead of the crowd.
BIG THUMB UP.
jimmy


#10

You know the motto ?
There is no trivial question, when the student is ready the professor arrives.
Fx is a good one. :sunglasses:


#11

I am not proficient by any means, however I can recommend taking some code already written and basically work out how it works. change bits of it and see how the results change.

slowly but surely you will get to grips with it


#12

While there may be some duplication here some of these tips may help newbies:

  1. The fastest and most efficient way to learn afl is to study working code from others. Search for a program that is doing what you want to learn about and study it line-by-line. Start small. For registered users there are thousands of examples linked to on this page:
    http://amibroker.com/support.html
    There are also many other excellent international forums. Google is your friend. Learning where to find code is as important, or even more important, as learning how to code.

  2. The biggest timed saver is to prevent re-inventing the wheel. This starts at the learning level! There is no shame in plagiarizing public code. If you end up using major code sections written by others give credit where credit is due. However, all of us, no exception, thrive on ideas from others and no one would be upset if you forget where you got the code.

  3. The next biggest time saver is to post a question on the forum. All programmers draw a blank now and then; its like writer’s block. Give it a fair try. Depending on your time restraints, this may be hours or days, post the question if you are not getting anywhere. Your time is the most valuable commodity in your life. No need to spend days struggling with a problem when someone on the forum has already solved it or knows the answer and may be willing to type two or three lines to share the solution. Eventually you may be able to pay-back and help others the same way. There is no such thing as a stupid question - if you can’t fine the answer it is a valid question. Do not be intimidated by the odd condescending reply, or be fearful to post because you have seen them on the list. Ignore such comments. Everybody has an occasional bad-hair-day :wink:

  4. A few useful debugging tips can also be found on the UKB, search for “Debug”. Read the post on DebugView.

  5. Many functions have a long list of hard to remember arguments. They popup when you type the “(” after the function name. If this list disappears, delete and retype the “(” and it will reappear. Remember too that you can right-click on any blue function name and click Function-Reference. A full explanation will popup, often with a simple coding example.

Finally, writing afl programs is a lot of fun. Soon you’ll find out that there is no end to the number of trading ideas you’d like to code. If trading is a hobby this is no problem however if you really are intend to make a living as a trader you have to make a plan on how you go about getting there. There is more to it than just learning afl; make a plan and partition your time. One of the first questions to answer is whether you want to invest or trade, and whether you want to trade daily or intraday. Here again, Google is your friend!

Happy coding!
Herman


#13

From selfish point of view - yes. But others have their own lives and their own limited time. Going to forum or support without doing own research is happening way too often.

This is the point that should be typed with bold. But the difference between “being able” and “actually doing” is the key. Unfortunately 90% of people are “takers”. Despite being able to help, they don’t want to spend their “most precious commodity” while thinking that everybody else should give their “precious commodity”.

For what it is worth I have not asked ANY SINGLE C/C++ programming question in my life. I’ve learned everything I know about programming without anybody’s help and it was in pre-internet era and Google did not exist. The method is called trial and error. At the age of 13 I read books about TTL logic and I was barely understanding 10% of it. But it was fascinating because I learned that few transistors connected into AND/OR/NOT gates can do magical things like adding binary numbers, counting, comparing them. Programming was a magical mistery word. Back then Poland was “behind the curtain” and it was real challenge to get books or worse yet any ICs to tinker with hardware. Yet I bought some chips at black market (desoldered from some broken PCBs) and build a microprocessor system and digital synthesiser myself based on Z80 CPU. Two-sided printed circuit was drawn by hand with some water-resistant marker (another nearly impossible to buy item back then in PL). No design “tools”. Just had to do everything by hand and memorizing thousands of connections. That was at the beginning of PC Era (1987). When I went to University at 19, I already knew more about programming than average graduate student. And no, it was not any kind of miracle or any kind of super skill. It is just a question of time spent digging it yourself.
You may read the “Changeling: The Autobiography of Mike Oldfield” book. Why did he become so proficient guitar player? Why he created music-industry-changing work that catapulted Richard Branson’s Virgin business at the age of 18? He just spent thousands of hours learning it all by himself. Just trying over and over the pieces that he heard. Without teacher, without help, without family support, without anything.

There is NO other way to learn anything. You need to spend YOUR time. Not some other person time.

On anecdotal note: when I first came to US and went to bookstore I was surprised to see two bookshelves filled with titles such as “How to learn to play guitar over the weekend”. Hundreds of books how to learn ANYTHING over the weekend. And I wondered who is an idiot: the author doing claims of learning this over the weekend or the buyer who believes it is possible.


#14

Tomasz wrote:

Unfortunately 90% of people are “takers”.

This is true. But all of us visit many other forums where *we *are "takers"
only - it is a requirement to succeed. In my book a 10% contribution rate
is excellent, exceptional in fact. I congratulate you on this.

There are reasons why people shy away from contributing. The main reasons
are that no one likes to be reprimanded, spoken to in condescending form,
made to look dumb, or is expected to follow too many rules. This doesn’t
happen too much on this forum but the fear-factor is still there. Also, a
display of expertise can be intimidating and scare off novice posters. IMO,
there is nothing wrong with an occasional flaky post or someone who failed
to do research as experts would do. Often there are many good reasons for
that. It is counter productive to point out the flaw in public, holding
back on critique and showing how to find a solution is a better approach.
Often it takes as much time to critique a post as it is to answer the
question and make someone happy and stick around.

Happy coding,
Herman


AFL Coding required
#15

I believe that nobody gets reprimanded for contribution (i.e. answering somebody’s question), or for asking a question when he/she clearly shows that search/homework (such as, for example checking relevant function documentation1) was done prior to posting. Just the opposite - an interesting question may bring interesting and valuable answers.

But when you see the user with “1 minute read time, 1 post read, joined 1 minute ago” statistics posting a “question” that says: “I want formula that does this and that” then something is not exactly right.

1 - when you are in the Formula Editor, you can just press the F1 key when the cursor is at the function you have problems with. F1 brings up automatically relevant documentation for the function.


#16

This forum and the resources posted in this thread supply ample information for most users.

A couple of more places for newbies to look for answers. As well as searching this forum why not try the internet. With a simple search you will find some great and some not so great answers to your questions.

For example just recently a couple of posts were about heiken ashi bars and another basic moving average question and a question about coloring bars.

Look at the thousands of potential answers you can find with less than a few seconds of effort.
image

Lastly, I don’t think there has been a recent mention of the User Library where many users have contributed codes over the years. Some great, some not so great. But worth a look.
http://www.amibroker.com/members/library/list.php


#17

Thank you to both Tomasz and Portfoliobuilder for the great advise . I myself am getting back into AFL/AB since last using AFL much back in '07 or so . And even then I was nothing of a programmer . But this site and info has helped greatly . Best advise as Tomasz stated , “practice practice” !
-phil


#18

HI can anyone correct my afl, why it cant work properly, it shows variable ''r'' has invalid type.

i just want to make william's % R with overbought and oversold. i have done well with RSI.
Please someone help me for guidances

r = PercentR( 3 );

OverBought = r > -80;
OverSold = r < -20;

// Explore //
Filter = 1;
AddColumn( r, "PercentR" );
AddColumn( OverBought, "OverBought", 1.0);
AddColumn( OverSold, "OverSold", 1.0);

// Chart //
Plot( r, "PercentR", colorWhite );


#19

@de.yudi.dy, glad to see you posting your code. It would help if you used the Code button ("</>") in the editor for posting code.

Looks to me like you have to define your PercentR function above your code. Then you can call it. I don't see PercentR listed as a built in function. There is an example in the list of Indicators. Note that the example defined the function first. Here is the code:

function PercentR( periods )
{
 return -100 * ( HHV( H, periods ) - C )/( HHV( H, periods ) - LLV( L, periods ) ); 
}

Hope this helps.