
Binarium
Best Binary Options Broker!
Perfect For Beginners!
Free Trading Education!
Free Demo Account!
Signup Bonus:
Moving Average
Contents
DEFINITION
Moving Average (MA) is a price based, lagging (or reactive) indicator that displays the average price of a security over a set period of time. A Moving Average is a good way to gauge momentum as well as to confirm trends, and define areas of support and resistance. Essentially, Moving Averages smooth out the “noise” when trying to interpret charts. Noise is made up of fluctuations of both price and volume. Because a Moving Average is a lagging indicator and reacts to events that have already happened, it is not used as a predictive indicator but rather an interpretive one, used for confirmations and analysis. In fact, Moving Averages form the basis of several other wellknown technical analysis tools such as Bollinger Bands and the MACD. There are a few different types of Moving Averages which all take the same basic premise and add a variation. Most notable are the Simple Moving Average (SMA), the Exponential Moving Average (EMA) and the Weighted Moving Average (WMA)
TYPES
Moving Averages visualize the average price of a financial instrument over a specified period of time. However, there are a few different types of moving averages. They typically differ in the way that different data points are weighted or given significance.
Simple Moving Average (SMA)
Simple Moving Average is an unweighted Moving Average. This means that each day in the data set has equal importance and is weighted equally. As each new day ends, the oldest data point is dropped and the newest one is added to the beginning.
CALCULATION
Weighted Moving Average (WMA)
Weighted Moving Average is similar to the SMA, except the WMA adds significance to more recent data points. Each point within the period is assigned a multiplier (largest multiplier for the newest data point and then descends in order) which changes the weight or significance of that particular data point. Then, just like the SMA, once a new data point is added to the beginning, the oldest data point is thrown out.
CALCULATION
Exponential Moving Average (EMA)
Exponential Moving Average is very similar to (and is a type of) WMA. The major difference with the EMA is that old data points never leave the average. To clarify, old data points retain a multiplier (albeit declining to almost nothing) even if they are outside of the selected data series length.
CALCULATION
Double Exponential Moving Average
CALCULATION
Triple Exponential Moving Average
CALCULATION
THE BASICS
Moving Averages takes a set of data (closing prices over a specified time period) and outputs their average price. Now, unlike an oscillator, Moving Averages are not restricted to a number within a band or a set range of numbers. The MA can move right along with price.
The timeframes or periods used can vary quite significantly depending on the type of technical analysis being done. One fact that most always be remembered however, is that Moving Averages have lag inherently built into them. What this means is actually pretty simple. The longer the timeframe being used, the more lag there will be. Likewise, the shorter the timeframe, the less lag there will be. Basically, Moving averages with shorter timeframes tend to stay close to prices and will move right after prices move. Longer timeframes have much more cumbersome data and their moves lag behind the market’s move much more significantly. As for what time frames should be used, it really is up to the trader’s discretion. Typically any period under 20 days would be considered short term, anything between 20 and 60 would be medium term and of course anything longer than 60 days would be viewed as long term.
Another option which boils down to the trader’s preference is which type of Moving Average to use. While all the different types of Moving Averages are rather similar, they do have some differences that the trader should be aware of. For example, the EMA has much less lag than the SMA (because it puts a greater importance on more recent prices) and therefore turns quicker than the SMA. However, since the SMA gives an equal weighting to all data points, no matter how recent, the SMA has a much closer relationship to areas of significance such as traditional Support and Resistance.
WHAT TO LOOK FOR
When examining some of these common uses for Moving Averages, keep in mind that that it is the trader’s discretion which Moving Average in particular they wish to use. In the following examples, there will be written instances of; Moving Averages (MA), Simple Moving Averages (SMA), Exponential Moving Averages (EMA) and Weighted Moving Averages (WMA). Unless otherwise specified, these indicators can be considered interchangeable in terms of the governing principles behind their basic uses.
Basic Trend Identification
Using a Moving Average to confirm a trend in price is really one of the most basic, yet effecting ways of using the indicator. Consider that by design, Moving Averages “report” on what has already happened and that they also take into consideration a whole range of past events when calculating their formula. This is what makes a Moving Average such a good technical analysis tool for trend confirmations.

Binarium
Best Binary Options Broker!
Perfect For Beginners!
Free Trading Education!
Free Demo Account!
Signup Bonus:
The general rules of thumb are as follows:
A LongTerm Moving Average that is clearly on the upswing is confirmation of a Bullish Trend. A LongTerm Moving Average that is clearly on the downswing is confirmation of a Bearish Trend.
Because of the large amounts of data considered when calculating a LongTerm Moving Average, it takes a considerable amount of movement in the market to cause the MA to change its course. A LongTerm MA is not very susceptible to rapid price changes in regards to the overall trend.
Support and Resistance
Another fairly basic use for Moving Averages is identifying areas of support and resistance. Generally speaking, Moving averages can provide support in an uptrend and also they can provide resistance in a downtrend. While this can work for shorter term periods (20 days or less), the support and resistance provided by Moving Averages, can become even more readily apparent in longer term situations.
Crossovers
Crossovers require the use of two Moving Averages of varying length on the same chart. The two Moving averages should be of two different term lengths. For example a 50 Day Simple Moving Average (mediumterm) and a 200 Day Simple Moving Average (longterm) The signals or potential trading opportunities occur when the shorter term SMA crosses above or below the longer term SMA.
Bullish Crossover – Occurs when the shorter term SMA crosses above the longer term SMA. Also known as a “Golden Cross”.
Bearish Crossover – Occurs when the shorter term SMA crosses below the longer term SMA. Also known as a “Dead Cross”.
 It is imperative however, that the trader realizes the inherent shortcomings in these signals. This is a system that is created by combining not just one but two lagging indicators. Both of these indicators react only to what has already happened and are not designed to make “predictions”. A system like this one definitely works best in a very strong trend. While in a strong trend, this system or a similar one can actually be quite valuable.
Price Crossovers
If you take the two Moving Averages setup that was discussed in the previous section and add in the third element of price, there is another type of setup called a Price Crossover. With a Price Crossover you start with two Moving Averages of different term lengths (just like with the previously mentioned Crossover). You basically use the longer term Moving Average to confirm long term trend. The signals then occur when Price crosses above or below the shorter term Moving Average going in the same direction of the main, longer term trend. Just like in the previous example, let’s use a 50 Day Simple Moving Average and a 200 Day Simple Moving Average.
Bullish Price Crossover – Price crosses above the 50 SMA while the 50 SMA is above the 200 SMA. The 200 SMA is confirming the trend. Price and short term SMA are generating signals in the same direction as the trend.
Bearish Price Crossover – Price crosses below the 50 SMA while the 50 SMA is below the 200 SMA. The 200 SMA is confirming the trend. Price and short term SMA are generating signals in the same direction as the trend.
SUMMARY
An experienced technical analyst will know that they should be careful when using Moving Averages (Just like with any indicator). There is no doubt about the fact that they are trend identifiers. That can be quite a valuable bit of information. However, it is important to always be aware that they are lagging or reactive indicators. Moving Averages will never be on the cutting edge when it comes to predicting market moves. What they can do though, is just like many other indicators that have withstood the test of time, provide an added level of confidence to a trading strategy or system. When used in conjunction with more active indicators, you can at least be sure that in regards to the long term trend, you are looking to trade in the correct direction.
HOW TO USE IN TRADINGVIEW
 Navigate to https://www.tradingview.com/
 On the landing page, enter a symbol and click “Launch Chart”
 Within the Toolbar along the top of the chart select “Indicators” and choose the one you would like to add to your chart.
 To make changes to your Indicator you will need to access the Formatting Window.
 You can access the Formatting Window by either clicking on the Blue “Format” button in the Chart Header next to the Indicator name, or by right clicking on the Indicator in the chart itself and selecting “Format”.
INPUTS
Length
The time period to be used in calculating the Moving Average. 9 days is the default.
Source
Determines what data from each bar will be used in calculations. Close is the default.
Offset
Changing this number will move the Moving Average either Forwards or Backwards relative to the current market. 0 is the default.
STYLE
Can toggle the visibility of the MA as well as the visibility of a price line showing the actual current value of the MA. Can also select the MA’s color, line thickness and line style.
PROPERTIES
Last Value on Price Scale
Toggles the visibility of Last Values for the Moving Average on the Price Scale.
Arguments in Header
Toggles the visibility of the indicator’s name and settings in the upper left hand corner of the chart.
Scaling
Scales the indicator to either the Right or to the Left.
Simple Moving Average (SMA) Model in Python
The previous article was about market neural strategies. In this article we are going to discuss how to construct your first trading algorithm in Python. We will use simple moving average (SMA) model as the fundamental trading strategy. Based on the model we can decide whether to open a long position or a short position.
Long Position and Short Position
First of all let’s discuss the differences between long and short.
 long position: long position in a security (stock, commodities or currencies) means that you own the security.
Investors maintain long positions in the expectation that the stock will rise in value in the future
In these cases we expect that the given currency will rise so the value at t+dt is greater than at t. The profit is the difference so S(t+dt)S(t).
 short position: short position is generally the sale of a given security (such as stocks or currencies)
Investors who maintain short position believe the price of stock will decrease in value
In these cases we expect that the given currency will fall so the value at t+dt is smaller than at t. The profit again is the difference so S(t+dt)S(t).
Random Walk
The standard assumption of quantitative finance is that assets (stock prices) follow a random walk. In a random walk the direction of the steps is determined probabilistically. In quantitative finance we use Wienerprocesses to describe random walk. The famous BlackScholes model uses the following stochastic differential equation for modeling the S(t) stock price:
This is the continuous model. It is more convenient to use the discrete approach instead.
In this formula the S(t) is the actual value of the given stock. The ε is random term, the socalled white noise. So basically a random walk is the sum of white noise series. This model is not the best one possible. We are after a model thats capable of explaining all the serial correlation.
Simple Moving Average (SMA) Model
So random walk model is not the best model possible. Simple moving average (SMA) model is a bit better. SMA combines white noise terms in the past.
So in this case we combine white noise terms in the past. As you can see the S(t1) previous value of the stock is not present in the formula. Note: this is the mathematical formulation of moving average model.
FOREX traders define moving average a bit easier: we just have to calculate the average of the prices within a given range.
SMA is an arithmetic moving average calculated by adding the closing prices of the security for a number of time periods and then dividing this total by the number of periods
A 5day simple moving average is the five day sum of closing prices divided by five. As its name implies, a moving average is an average that moves. Old data is dropped as new data comes available.
Moving Average Trading Strategy
The first question arises: why moving averages? Is it a good indicator? It turns out to be that moving averages (with period 30, 50 and 100) are good indicators of trends. Upward trends and downward trends as well.
Here we use SMA(50) which means moving average with period 50. As you can see if the SMA(50) is above the price it is a downward trend (so we should open a short position). If SMA(50) is below the price then it is an upward trend (so we should open a long position). This can be the first trading strategy.
def onBars(self,bars): bar = bars[self.instrument] if self.sma[1] is None: return if self.position is None: if self.sma[1] bar.getPrice(): self.position.exitMarket() self.position = None
Crossover Trading Strategy
Using a single moving average indicator is working fine usually but we may enhance this strategy. Instead of a single SMA indicator we can use 2 out of them.
 slow moving average indicator: with high period value to be able to monitor longterm trends
 fast moving average indicator: with low period value to be able to monitor shortterm trends
The trading signals of the crossover moving average model are when the SMA lines cross each other
The most basic trading algorithm relies heavily on moving averages. These moving average values will determine whether to open short position or long position.
The algorithm exits the long trade when SMA(10) crosses SMA(40) from top. The algorithm exits the short trade when SMA(10) crosses SMA(40) from bottom. By the way you can use different model orders (so instead of 10 and 40).
As you can see the illustration above, the SMA(10) and SMA(40) curves determine when to trade. We just have to find these crosses in MetaTrader4 or Python. Let’s take a look at the implementation:
Learn The 5 and 10 Simple Moving Average Trading Strategy
Just about any simple moving average trading strategy needs a good trending market to be an effective trading strategy.
Once a trading chart starts showing consolidating price action, the moving averages become virtually useless although moving averages converging can help you objectively identify a market in chop.
There are trading strategies that take advantage of consolidations and those are either trading the range or using a breakout trading strategy. Understanding various methods of technical analysis to identify favorable range trading conditions are something traders should learn so they are not caught up trading consolidations when they think they are trading a trending market.
This moving average trading strategy is going to focus on trading pullbacks in a trending market and we will combine it with measures of:
 The strength of the trend we are trading
 If price is either oversold or overbought
You can use this trading strategy in Forex or other markets and as either a day trading approach, swing trading, and even position trading.
Difference Between Simple Moving Averages And Others
In reality, the differences between various forms of moving averages will not improve a trading strategy to any measurable result. We are using simple moving averages as a matter of course and by using the SMA, we will just be using the last X days average of price.
Exponential moving averages takes into account more data than the period used although the impact of historical price data decays over time.
Let’s keep things simple and stick to the SMA
Time frames – You can use lower time frames such as 5 minute charts higher time frames (4 hours – daily chart) are my favorite time frames for trading Forex
Currency – Any currency pair but stick to the currency pairs that move such as EURJPY, EURUSD, GBPUSD
Indicators – 5 and 10 simple moving averages (SMA), stochastic oscillator 14,3,3, and RSI setting of 9
We are using stochastic at 80/20 for oversold and overbought markets
RSI (relative strength index) – Measure of trend strength
Trend Determination Using Moving Averages
The 5 SMA is a fast moving average and we will combine it with the slightly slower 10 period SMA. When the 5 crosses the 10 to the upside, we will assume we are in an uptrend
When the 5 crosses to the downside over the 10 simple moving average, assume we are in a down trend.
This is a nice objective way to measure the trend although using any technical indicator, you will have a lag between the price action and the indicator showing the trend change.
Trading Strategy Rules
As with any trading strategy, you must follow the rules or you will not find much success. Even better, make sure you put together a trading plan that dictates every move you will make in the markets.
Let’s take a look at how a sell signal will show up on the chart and how you will trade the signal.
 The first thing we look for is a crossing of the 5 period simple moving average over the 10 SMA to the downside
 Look to see that the RSI is either crossing or has crossed the 50 level which indicates the momentum is to the downside
 Has the stochastic left the overbought area or in the process and trending to the downside?
 IF all the above are yes, place a sell stop order below the low of the candlestick that turned the moving averages
That is how you will determine a short trade and before you trade the sell signal, ensure you know where you will get out if wrong. We will cover stop loss positions later. The candlestick shown as the setup candlestick may NOT be the one that actually turned the moving averages.
Remember, moving averages are lagging indicators and it may have been the next one that showed the clear turn.
A buy signal is the opposite of the sell signal.
 Noted the moving averages have crossed over and the 5 period SMA is above the 10 period
 Relative strength index has already crossed over the 50 level indicating an uptrend
 Stochastic has crossed from oversold and is heading upwards
 A buy stop order is placed above the high of the candlestick that turned the moving averages
The only difference between a sell signal and a buy signal is the direction the indicators must show.
Stop Loss For Simple Moving Average Trading Strategy
I am not a believer in a set number of pips for a stop loss. You have various techniques you can use for a protective stop loss:
 Use the high or low of the setup candlestick and place your stop below (above) that candlestick. This is dynamic as every candlestick will have a different range in price.
 Use an average true range to place your stop loss. I’ve covered this and other stop loss placement methods in another blog post.
Whichever method you use, the key is to be consistent with all your trading setups. This is why you need a trading plan to ensure you stay on the right track.
Take Profit Strategies
Like stop loss placement, taking your profits is not one size fits all.
You can read this article, Let Profits Run, to see how to take full advantage of what the market is offering instead of taking only a few pips from the move
Some traders will target various support or resistance levels to exit their trade. Here is a support and resistance indicator for Metatrader you can download.
Fibonacci Price Targets
I must say that one of my favorite ways of finding profit targets for any strategy including a moving average trading strategy is Fibonacci extentions
As you can see in this chart, price found all 3 targets including finding the top at the 200% level measured from the previous swing.
I may do an article on how to use Fibonacci in terms of taking profits. I find it incredibly useful as the various levels also act as areas to scale out partial profits.
Summary
As you can see, this is a simple moving average trading strategy that takes into account trend and momentum for your trading signals.
Ensure you use proper stop losses, risk control, and you find ways to take what the market is offering without kneejerking out of your trades.
Don’t forget to share this article with your friends by clicking those buttons below. Thanks

Binarium
Best Binary Options Broker!
Perfect For Beginners!
Free Trading Education!
Free Demo Account!
Signup Bonus: