Thursday, August 30, 2012

How to program AFL in Amibroker and MQL for MT4

I’m a self taught programmer, the only classes I ever took part in were in high school.  Back in the day of the cards – you had to use a pencil on some cards then feed them into a machine and it ran your program.  I learned Fortran first.  Then a tried basic language on a Commodore 64 or something, long time ago, can’t remember the details.

If you want to learn Amibrokers AFL or MT4 here are a few suggestions:

Take a night course in programming, not sure which language is close to either of these but if you ask in some forums or Google for similarities you’ll find answer.  If you already know a language, don’t bother with school, jump to step 2.  

You first need to learn logic flow and what functions are and what object programming means, your looking learn to the concept of programming and how you write a program, run it, and debug it.  Then you can cross utilise this skill with any other language.  It takes some self learning. 

The next step, load up a small program and try to understand it. If you put your cursor on a function (which usually highlighted in blue) and press F1 help opens up and you can read about the function.  Then read the help docs on program flow to understand how the program executes. 

Next – load up a bigger program and understand the flow.  Make some small changes, maybe try to print stuff to the screen or alerts menu, or send en email. 

Next – read a tutorial, free one are always offered on line.  You can start with this as step one as well but after you play with code you should go back to a tutorial and read it again.  Read the tutorial once a week for 3 weeks, read it to understand it.  Read it when the kids are in bed, you need to focus un-interrupted.

Next – have an idea of what you want to do, then steel some code as a starting point and modify it to suit your coding goal.  here’s an example.  Load up the stochastic indi.  Make an indicator in one single window with 3 stochastic, with either K or D.  Set them to 8, 21, and 55 periods.  Run it on a 15 minute timeframe.  Now add another that is set to a forced time frame of 4 hours and is an average of the 8, 21, and 55 periods.  Plot the four lines.  Use the same colour for the 15 minute and a thicker and different color for the 4 hour.

Then, ask yourself this – am I coding because I like it and trading is secondary, or am I coding for a purpose? I got into the rut of coding because it was a challenge. I wasn’t learning to trade.  Then I decided to just watch the screen and price action and learn to trade. Then code for what I wanted to do.

And the best for last – I don’t think I have ever written a program from scratch – I always start with something that has been done already, then change it, add to it, delete stuff, and make adjustments.  After a while there might not be anything left of the original, but it sure make it easier to start.

Disclaimer

The information presented on this site is for educational and entertainment purposes only. This site contains no suggestions or instructions that you must follow, do your own research and due diligence before committing your cash to the markets. Your on your own.