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.

Tuesday, August 28, 2012

Canadian Forex Accounts

If you have the option to open an account in Canada for Forex, you will gain a great protection plan!

IIROC is the regulator in Canada, here's the blurb from there site.

Investment dealer insolvency doesn’t happen very often, but if it does, the Canadian Investor Protection Fund (CIPF) is here to ensure your cash and securities are returned to you, within defined limits.

If you have an account with a CIPF Member you have CIPF protection - coverage is automatic for all eligible customers. For more information, go directly to our Coverage Policy.CIPF is sponsored by the Investment Industry Regulatory Organization of Canada (IIROC) and is the only compensation fund approved by the Canadian Securities Administrators for IIROC Dealer Members. All IIROC Dealer Members are CIPF Members.

So, for anyone outside of Canada, take a look at this page.... it tells you what and who is covered under CIPF. ... olicy.aspx

The sad part for US residents is that the Canadian regulator respects the US regulaor.  US regulator does not allow US residents from opening accounts outside the US.

From the CIPF web site

Question: Does it matter if I do not live in Canada, or if I am not a Canadian citizen or a Canadian resident?

Answer: No. CIPF coverage does not depend upon residency or citizenship. CIPF coverage is available to you when you open an account with a CIPF Member.

Canadian Brokers offering MT4

FXCM uses a company called Friedburg Direct.  I have an account with them.  Here is the MT4 FXCM page.
Over 5K you also get a free VPS. 1:50 leverage - and that's OK with me!! 

I know that Questrade is going to be introducing MT4 some time in the near future. (Gain Capitol) - good spreads. free VPS with 5K or more.

Monday, August 27, 2012

Tipster Trendlines - Amibroker

Update - I've closed my Interactive Brokers account where I use Amibroker and Tipster Trendlines (for Amibroker).  I'm using MT4 now and TT2P found at forum.  You can find the link at the top of this blog.  I will be dropping the price of the Amibroker code shortly and the support will be limited.  The code still works for the current version of IB TWS and Amibroker.

Sunday, August 26, 2012

My Brokers

I was MF Global and they blew up - I got all my money back thanks to the Canadian regulation system.  I'll write about that shortly.

I was then with PFGBest and they blew up - the account was in the US and my money is stuck in the bankruptcy fiasco.

I'm now with Forex.Com (Gain Capitol) and FXCM Canada.

Both accounts are held in Canada and have no hedging restrictions or FIFO rules.  Leverage is 100:1.
I use MT4 on both.  Both allow comments and magic numbers for full MT4 functionality.  Spreads are better on the majors at

So far, so good.  I just started trading the accounts and I'll post links to performance on the page listed at the top of this blog.


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.