If you are reading this, then you are interested in creating an Algorithmic Trading Strategy that will automatically open and close trades and manage your risk even while you sleep at night.
"If you think you are going to make easy money with an Algorithmic Strategy then think again"
What is a Trading Strategy?
A Trading Strategy is a pre-planned set of instructions that will achieve a profitable return by submitting a Buy or Sell order in the markets. The strategy can be based on technical analysis, fundamental news-based events and good risk management. A typical trading strategy would include multiple technical indicators which signal the buy or sell together with some rules to exit the trade with a profit. A fully automated strategy also takes away any human emotions that prevent the trader from closing a position early or letting a loser run too long and blowing their account, some pre-defined rules for risk management well thought out in advanced will limit the risk.
Why It Is Important to Document The Strategy
The words "Failing to Plan, Plan to Fail", are just as true when it comes to algorithmic automated strategy development, the biggest part of your time should be spent on documenting the strategy, if you are using a well-known system that you have downloaded from the internet then this should already be documented. If you start coding your strategy with just a rough idea in your head, then you are doing what's known in the software engineering world as Heroic Programming which is a big no-no, avoid this at all costs and work smart.
Do I need to Know Mathematics to Trade?
There is no simple answer to this as what you really need is a reliable high-probability system which is able to capture gains regularly and also the psychology to execute your system and stick to it, which is an emotional rather than logical skill, an understanding of maths will always be a big bonus, but many successful traders do not have or even need a strong understanding of maths The most important aspect of day trading is an unwavering, rock-solid mental attitude followed by a good understanding of the technical parameters, general economic environment and lastly, some analytical abilities.
"Good critical thinking skills and a decent grasp of statistics will go a long way in helping you succeed"
- Do you need calculus? No.
- Do you need algebra? Yes.
- Do you need to understand logic? Yes.
- Do you need to understand the correlation? Yes.
- Fundamentals will be conceptual and abstract
Market Theories
To start you need to understand how the markets work, you need to understand the market inefficiencies, relationships between different assets, products and price behaviour.
Designing Your Strategy
The first steps with any strategy are to have a good design, the idea needs to be documented, if you skip this step then you will fail before you even start, the biggest amount of your time should be the design taking into account all the trade rules, risk management and uncontrollable market events like world war 3. Creating a working robot requires an understanding of how automated systems work which consists of 3 components: (a) Entry signals, (b) Exit signals and (c) Position sizing, you will need to design these components in relation to the market inefficiencies and this is no simple task.
Software Development
The programming language will depend on what you are trying to achieve, if you are using complex mathematics then you would want a language that has been built for this particular task, with some of the new modern programming languages like Microsoft C#, F#, Java, R, MATLAB and Python. If it is the speed you want for High-Frequency Trading (HFT) then you may be looking at C++ for faster code execution.
We use Microsoft C# which is a very powerful modern programming language used by both cTrader and NinjaTrader it is fast, easy to maintain, robust and a rich selection of mathematical and business-orientated libraries.
Trading Platform API
Just understanding the programming language is not enough, you also need to understand the trading platform's Application Programming Interface (API), this interface provides access to get the account and trading data through the platform to your broker. you can also bypass the platform and use a common protocol Financial Information eXchange (FIX) where you can communicate with the broker direct making your executions even faster, but this is only useful if you want to save a few milliseconds.
Data Management
Accurate data in the form of back-test data will really help when you forward test with live data, if the back-test data is inaccurate then as they say "Garbage In - Garbage Out", your strategy is doomed to failure. The problem with the data from cTrader is that it just does not go far enough back, you really need to pay for good quality historical data and load that instead.
Risk Management
This is one of the most overlooked aspects of algorithmic trading, just as much time should be spent on managing your risk as your rules for entry and exiting trades. There are two types of risk management for a trader:
- Market Risk: This involves risk relating to your trading strategy.
- Operational Risk: This is when a black swan event happens like a European war
Execution of Trades
We all know that back-testing and live trading are very much different unless you use an ECN Broker, which you should have with cTrader.
Virtual Private Server (VPS) - This is a must if you are running your robot 24/7 365 days a year, most virtual servers boast 99.96% up-time.
You will also need to monitor the robot’s performance and make adjustments where necessary throughout its lifetime.
Strategy Considerations
Catch Big Trends
The whole idea of the strategy is to make money when the market is trending and a good trend will last about 15-20% of the time and this is when all the types of traders are active. if your strategy is based on trend then let your winners run, do not intervene, remember you have already thought out the logic of pre-defined rules.
Managing Winners & Losers
Many people build a system which has an excellent win/loss ratio and this is not the correct approach, an example would be a robot which wins 70% of the time with an average profit of £100.00 per trade and an average loss of £200.00 per trade will only make £100.00 per 10 trades (£10/trade net), where a robot which wins 30% of the time with an average profit of £500.00 per trade and loss of £100.00 per trade will make a net profit of £800.00 for 10 trades (£80.00/trade). So, in a nutshell, it is not always good to make a high win/loss ratio.
"Keep your losses small and let your winners run"
Drawdown
We all know that drawdown is unavoidable and we always state that anything higher than 5% is risky, this is just our view, but this is not always the case as it could act as a roadblock when your robot catches a big trend which may affect the performance of your strategy.
More Risk Management
Yes, we are talking about risk management again. When you design your strategy, you should always have a way out, an exit that will execute no matter what the market throws at it, you need to protect all that capital you have built up. Everyone has a different view on risk, from the most cautious traders to the high-end gamblers, there is no right or wrong approach, but if you are a low-risk trader then you need to make sure you get out of a trade as soon as it exceeds your risk rule. An automated strategy will make sure your human emotions do not get involved and will exit a position as soon as the risk is too high, this alone is a huge benefit of automated trading.
Testing Your Strategy
Ok, so your automated strategy has been developed and is now ready for testing, how do you test it? This is where your requirements document or the blueprint of your strategy is needed, you can run the strategy and refer to the document to make sure the logic is correct on each logical pathway as well as predicted trade entry and exit points, so you cross-reference the document logic against the actual results of the algorithm.
Slippage
This is an overlooked area when you test your strategy with historical data, you are under the assumption that the order will be executed at the exact price by the automated strategy, this will not be the case as you have to deal with the High-Frequency Algo’s and Market Makers, who push the price so fast your order is not filled until it is your turn. There will always be slippage so you will need to factor this into your testing.
Optimisation
A lot of traders suggest that you do not do curve fitting and over-optimisation and they are probably right as the market is like a wild random snake where you never really know where it will go next, you are better off doing what is known as Zonal Optimisation which identifies zones which have similar characteristics in terms of volatility and volume, just optimise these areas separately, rather than the whole period.
Major News Impact Events
Major news events, especially with Forex, cannot be back-tested with cTraders cAlgo, you will just see huge blips of drawdown when they occur, this makes testing any algo with cTrader very difficult.
Running Your Strategy
When you have tested your strategy and you are happy it is working in accordance with your pre-defined rules from your strategy requirements, what is the next step? The next step should be to let it run on a demo account for a period of time, I would say minimum 3 months, there are traders who just want to go live straight away as they want to make money now, this type of attitude will lose your money fast. Remember that this is a business and you want to be in it for the long run, so it is better to learn to walk before you can run.
Demo Account
Most brokers offer a demo account for as long as you want so you can perfect your manual or automated trading skills before using real money, this is very helpful, but demo accounts also take away the human fear of actually losing real money, it is not the same. From the start, you should have a starting capital that is realistic and trade realistic amounts, this would reflect the real environment when you go live.
When you finally go live with your automated strategy, you will need to keep a close watch on the trading, but do not interfere with the robot, remember you have set the trade rules after much thought and it has already been tested on a demo account for many months, let it do its job and trade. Intervene only when you know some event outside the strategy's boundaries is about to happen or is happening.
Join our free online Algorithmic Course
We offer free online courses to help traders learn how to code and build their own automated trading systems and technical indicators.
Our Programming Services
We offer a Professional Programming Service for the cTrader trading platform