I want to tell you how to use indicators when developing trading systems.
And it will be a series of posts about it. Reading this series you will discover many indicators, both standard and not so. And also how to use them
at your algotrading.
Today it is Moving Average. The most common indicator is able to give profit by trend strategies.
W-Why all this?
I' m a programmer. And I have been developing mechanical trading systems for several years as well.
As it turns out, I am periodically asked to write a robot with a non-working strategy. The robot's specification is being dropped off, and this trading robot
will not earn 100%.
So, for example, last week a message came with a request to write a robot. The algorithm that the client wanted to order consisted of SMA signals at
entrance plus use of tags(takeprofit) and stops. But the profit was not "leaking". There was a hard stoploss that broke all principles of trend trading.
Oh, i'm a good programmer, i had to tell user that this is a "loss-making strategy" and refuse to implement it.
This is how I came up with the idea to write a series of posts about indicators and strategies based on them. Probably, it will help more than one
Moving Average. What is it?
Moving average (MA) - a common name for a family of functions, the values of which in each point of determination are equal to average value of
original function for the previous period.
For simple SMA(Simple Moving Average) formula will look like this -
It is the sum of values for the period divided by number of values. For a number of values in our case, you can take Close, Maximum, Minimum,
Opening, Volume, Open and Close Differences, Average Candle Price, etc. That's all. SMA is the average value for period. If you want to speed up the
approximation of the average MA price to current instrument price, you should reduce the period value or use EMA (Exponential Moving Average). For
its calculation the following formula is used
and smoothing is done by coefficient
The idea of EMA is that weight of last values for the period is higher than the first ones and weight of exponent increases.
Besides these two, you can draw several more types of Moving Average. But I will not consider them further. This does not change their meaning in
The idea in trading
Usually indicator is used in trend trading. To do this, you take two ma, one slow and other fast.
And then we test following market inefficiencies:
1) The tendency will remain rather than change;
2) The ordinary mortals can' t hold position. And it is necessary to give profit to leak.
Searching for a trend
To do that, we'll use crossover of slower ma by faster. Nothing could be simpler. However, this allows us to determine the beginning of tendency.
Give profit to leak
To do this, simply use Moving Average as a floating stop. So, at moments when market is going upwards, we will be able to take all movement.
As can be seen from the picture, profit taking is a bad idea prematurely. You can also see that this strategy has more loss-making trades than profitable
ones, but visually we can say that profit from profitable trades will cover a lot of loss-making ones.
Let's test strategy.
Using Take Profit and Stop Loss.
It's the same without stoploss and takeprofit, just crossing ma.
Despite the fact that Moving Average is a very simple indicator - it cannot be replaced in trend
trading. And you can easily convince yourself of it, if you find the energy to start algorithmize your strategies.
I have seen working trend strategies with hard take Profit. But this is very rare. In most cases, you shouldn't strictly limit your profit.
Strategies with a large number of losing trades are hard to trade mentally. Even if risk/profit ratio is excellent, you can give up before time. And I do not
recommend to trade them by hand. It will end sadly(