The world of traders is divided into two groups; those who trade using algorithms and those who don’t. Those who trade using algorithms, aka algotraders, are well aware of the advantages of trading with an algo… And for those who don’t use algos? They are equally aware of the algo advantages but are reluctant to dive into its complexity; they are deterred from learning how. But the road to success in trading is not by avoiding challenges, but overcoming them, perhaps in baby steps.
First Baby Step to becoming an Algo trader
Let me ask you a question. What do you think is the first thing you’d need to do to become an algotrader? You might respond, “Learn programming, sudah tentu! How else?” Well, you’d be wrong.
If you plan to learn programming for the sole purpose of becoming an algotrader, you’re likely to get lost. Akhirnya, in despair or frustration, you’ll give up on algotrading.
There are numerous languages, from MQL to R to Python, and you have to decide which one to start with. You might find yourself wasting valuable time learning far too many trivial functions. It may take quite a long time before you even create a trading algo, let alone a profitable one.
But there’s another way, which I call reverse engineering.
The first step is to figure out which trading algo you want to make. Dalam erti kata lain, what are the functions and strategy it should implement? Then you test it and finally, move on to the programming part. Dengan cara ini, you’re focused like a spotlight. You know exactly what your algo should do and can focus on the exact functionalities you need to learn to make it happen.
Everything will just come intuitively; which language, how and in what. All the pieces will fall much quicker into place because you already know what to look for.
The best way to start is by using a flowchart. It is actually one of the first things you learn in programming schools.
And what determines the flow? Sudah tentu, it’s the conditions. What we call the “ifs.” “Ifs” can be one condition or have many “ands” and “ors.” That’s how you decide what your algo should do in any given circumstances. The conditions to the algo are what the brain is to the body; they do the thinking.
Second Baby Step: Use Excel
Once you’ve made a flowchart of conditions, rather than using a complex tool, use Microsoft Excel or some other spreadsheet software.

Sumber: MT4
Extract historical data of a price data; start by using only the closing price. If you want to trade on a daily interval, extract daily data and so on. Use a separate column for each of the conditions in the flowchart, that way it’s easy to write and figure out. Add another column for a buy and sell output to mark when you “opened” and when you “closed” a position. And finally add one column of accumulated profit/ loss.
Use separate columns for each conditions and fill the chart. All you need now is to run a linear chart on one column, accumulated profit/loss, and look at the algo’s historical performance.
Once you master the basics you can move on to move advanced back-testing and curve fitting. But for a start that will do.
Akhirnya, Learn to Program
ok, you’re not a “baby” anymore; you have a good idea of what an algo trader needs to do. Now that you’ve got the concept down pat, you’re ready to begin learning programming.
In terms of which language to start with, that will depend on the circumstances. If you are already using an MT4 platform, it’s a no brainer; learn MQL which runs on MT4. The MQL website is filled with “how to” materials. And since you already have a diagram of your algo and an idea what you want to do, finding your way should be simple.
But if you trade with a different broker, you’ll have to decide which best suits. Secara peribadi, I recommend starting with MQL, just because it’s easier. Kemudian, you can move into Python, which is a rather easy language to learn or C++ if your algo needs to work fast. If you algo is heavy on the math then perhaps R would fit.
Here are some places you can learn online:
Atau, sudah tentu, you can learn from a book. I am more of a book person, but that’s just me.
Then there is another issue—API. API is the mechanism that enables your algo to communicate with your broker and execute your trades. Some brokers work better with certain programming languages than others. Most large brokers have communities and forums that can go into detail as to the best way to use an API.
Unlike the first two baby steps, no one would ever say that learning to program was a baby step. Sebaliknya, it’s more of a giant leap. It takes time to learn and to master, though it is worth it in the long run. Sementara itu, you can always use libraries of codes on the web for more complex algos. The thing is that once you’ve accomplished the first two baby steps, making the final leap into programming is a no brainer.
“Akhirnya, Learn to Program” – finally – forget everything written above.
1) instead to learn programming – learn math.
2) forget about imperative programming languages – all of them (SEMUA!) are low-level languages..
3) learn declarative programming languages – try to cover the semantic gap between specs language & implementation language.
4) Try to describe the 1st simplest your problem in the formal terms – the most common formal generic language to describe most of our problems in our crazy life, is algebra.
5) Malangnya, most of problems should be represented in the terms of non-linear algebra (despite linear one is preferable because of easy available linear solvers in public domain) – try to approximate your non-linear model to linear one (in many cases it should be MIP LP model).
6) Try to find out in public domain any linear/non-linear constraint solvers, learn a little bit how to use them, & try to solve your 1st simplest problem purely in the terms of declarative programming.
7) Ask the question again – do you need all this shit just to generate some money? If YES -> forget all this bullshit & start to write comics, make as much money as you want & be happy…
I find that programming is the best way to learn math, provided that you don’t rely on libraries to do all the work for you. If someone is trying to get involved in forex to make a quick buck, I agree there are much better and more likely ways to succeed.
Hi Lior,
Perkara besar.
Is there any commercially available trading platform that uses Python as it algo language?
Terima kasih,
Daniel
Quantopian uses Python, but it doesn’t support forex.
How about Oanda API? it’s in JAVA.
Tetapi, what call my attention is: they allow to trade even one unit. (0,001 banyak? wow!)
Jadi, it’s good to do the called “Loss Recovery Stragy EA” (do you know?)
You’re better off using Oanda’s REST API, which is language neutral.
The Loss Recovery Strategy sounds an awful lot like Martingale.
Yes it does. tetapi, Joseph Nemeth is sucessfull with it, isn’t he? (do you know him/his work as trader?)
I’m not familiar with him.
hai di sana, I really like your blog. I am reading it for a few months and it is great. I agree with this post as well. So we can’t use Python for forex?. Please keep up the good work!
Ya, you can use Python for forex trading. Ia adalah pilihan yang hebat, assuming your broker supports a Python based API.