## A Simplified Guide to Moving Averages – Part 2: Using Moving Averages in Trading

A Quick Recap…

In our previous article, we covered the basics of moving average. To give you a quick glimpse, moving average is an indicator used to get a comprehensive idea of the trends in a dataset. It adds up the stock price over a specific period and then divides the summation by the total number of data points to get the average.

The reason it is called a ‘moving’ average is because it is continually recalculated based on the latest price data.

We also discussed two types of moving averages: simple and exponential. Read our previous article for a detailed introduction.

Now, let’s come back to how moving averages can be used in trading.

We illustrate some instances for you:

### 1. Determining trends using MA

The direction and position of the moving average gives us crucial information about the price trend of a stock. If the price of the stock is increasing, the moving average rises; whereas, if the price of the stock is declining, the moving average falls.

A price placed above the long-term moving average reflects an overall uptrend, whereas a price placed below the moving average reflects an overall downtrend.

If the stock price rises above its moving average, a ‘buy’ signal is established, whereas when the stock price has dropped below its moving average, it generates a ‘sell’ signal.

In the below picture, we can see the chart of ICICI Bank with the time frame of 1-Day. We have used the 10-day EMA (Exponential Moving Average) for our analysis. When the stock price is above the moving average line, a ‘buy’ signal is generated, and it is the ideal time for a trader to enter a position. Similarly, when the price falls below the moving average line, a ‘sell’ signal is generated and it is a good time to exit.

### 2. Determining support and resistance using Moving Average:

Moving averages can also determine support and resistance. If there is an uptrend in the stock, long-term moving averages such as 50-day, 100-day, or 200-day act as a support level.

This is because once the price of stock touches the moving average line, there is a high chance of it bouncing back. Similarly, during a downtrend, a moving average acts as a resistance level. Here, the moving average acts as a ceiling, and if the price hits this level, there is a high chance of the stock price dropping.

Let us understand this concept with the help of an example. In the below picture, we can see the chart of Wipro Limited and the time frame is 1 day.

The moving average used for the analysis is the 100-day SMA. When there is a downtrend, the moving average acts as a resistance. After consolidation for a few days at the same level, the price declines.

On the contrary, when there is an uptrend, the same moving average line acts as a support, and once the stock price reaches the support level, it bounces back.

### 3. Identifying the crossover

The crossover forms when two different moving averages cross each other. Primarily, two types of crossovers are used in trading: the golden cross and the death cross. In both these crossovers, one moving average is for a shorter duration, while the other is for a longer duration. Generally, 50-day and 200-day moving averages are used to identify these crossovers.

In a golden cross (bullish signal), a short-term moving average crosses above a long-term moving average, whereas in a death cross (bearish signal), the short-term moving average passes below the long-term moving average.

Let us understand this concept with the help of an example. In the below picture, we can see the chart of TATA Motors Limited with a time frame of 4 hours. Also, for our analysis, we use the 50 and 200 SMA.

The death cross forms when the short-term moving average (50 SMA) crosses below the long-term moving average (100 SMA). After the formation of the death cross, the price of the stock declines sharply. Therefore, we can say that most of the time, the death cross shows that there is the potential of a massive sell-off.

Also, in the later part of the chart, we can see the formation of a golden cross. This forms when the short-term moving average (50 SMA) passes above the long-term moving average (100 SMA). After the formation of the golden cross, the price of stock has increased gradually. Therefore, we can say that it is a good time for the trader to buy the stock.

PHI 1 enables easy charting with 120+ technical indicator, including different types of moving averages.

With PHI 1, you are assured that when you trade, you’re only focusing on your trades and not on mundane tasks using multiple tools.

Say NO to multiple tools. PHI 1 will allow charting, screening, strategy creation and testing, and order execution, everything in one place.

## A Simplified Guide to Moving Averages: Part 1

Moving average is one of the most common indicators used by traders. It is an easy-to-use statistical tool primarily used for forecasting trends.

Let us understand the basic definition of moving average.

Moving average is an average of any subset of numbers. In trading, it is an average of closing prices within a time frame and is used for predicting future trends.

Because the moving average is based on past prices, it is a trend-following or lagging indicator. Further, what makes it more dynamic is the customization it offers.

Any time period (such as 15, 20, 30, 50 days) can be chosen by the trader while calculating the moving average. Sensitivity to price changes can be regulated by changing the time period. If the period is short, there will be more sensitivity to price change, and vice versa.

### Trend analysis Using Moving Averages

A rising moving average shows that the stock is in uptrend, whereas a declining moving average confirms a downtrend. Further, traders use two different moving averages to decide whether there is upward momentum or downward momentum in the stock price.

When a short-term moving average crosses above a long-term moving average, a bullish crossover forms (known as golden cross), which confirms that there is an upward momentum.

Similarly, if a short-term moving average crosses below a long-term moving average, then a bearish crossover is created (known as death cross), which confirms downward momentum in the stock.

Types of Moving Averages:

There are two types of moving averages: Simple moving average and exponential moving average.

A) Simple Moving Average

A simple moving average or SMA is an arithmetic moving average calculated by adding the recent prices and dividing the summation by the number of time periods in the calculated average.

Let us understand SMA with the help of an example:

The table above shows the closing price of a stock for 7 days. While calculating the SMA, the first 5 days’ values are considered. Here, the SMA comes out to be 7. Similarly, while calculating the next SMA, the Day 1 value is excluded, and the Day 6 value is considered to calculate the SMA value. Finally, the Day 3 value is excluded and the Day 7 value is taken to calculate the SMA.

### Exponential Moving Average

Exponential Moving Average or EMA gives more weight to the most recent price data, which is considered more relevant than older data.

There are three simple steps that are followed in calculating EMA:

1. First, the SMA is calculated. Suppose you want to use 5 days as the number of observations for the EMA. Then, you must wait until the 5th day to arrive at the SMA. On the 6th day, you can then use the SMA from the previous day as the first EMA for yesterday.

II. After this, the multiplier (k) for weighing the EMA is determined.

Multiplier (k): [2 ÷ (number of observations + 1)]. Here, the number of observations = total time period. Taking the previously discussed example, number of observations = 5. Therefore, the multiplier in this case is k = 2/ (5+1) = 0.33.

III. Finally, the current EMA is calculated.

EMA = Closing price x multiplier + EMA (previous day) x (1 – multiplier)

Generally, 12-day and 26-day EMAs are used to identify short-term trends, whereas 50-day and 200-day EMAs are used to identify long-term trends.

Sensitivity to recent price point changes is more in EMA compared to SMA, making it more responsive to the latest price changes. We can observe how quickly EMA responds to price changes compared to SMA from the below graph.

This feature of EMA makes the results more timely and accurate, thus explaining why many traders prefer to use this indicator for trading.

PHI 1 offers custom moving averages such as SMA, EMA, EMA Cross, and so on among its 120+ technical indicators to choose from when trading.

Scenario analysis is the process of gauging the expected value of a security or portfolio over a specific period, with variations in key factors that may affect the price of the security.

For instance, in trading, scenario analysis could mean evaluating the impact of changing market conditions on your open positions. These scenarios could be a downward or upward trending market or even extremes like a complete market crash.

### How does scenario-based approach to trading help?

Algorithmic trading allows scenario analysis using mathematical models. These assessments are helpful in understanding the risk level within a security with respect to various events that could range from least probable to highly probable.

Based on the results of the analysis, a trader can decide whether the risk levels lie within his/her comfort zone and whether the trading strategy will benefit them.

### Basic and worst-case scenarios to account forwhen trading

When trading, you would obviously want to take into consideration various market scenarios like volatility, choppy trading, bullish trend, bearish trend, and so on. You may also want to have conditions like a complete market crash as a least probable scenario, but one that cannot be ignored.

Further, there are many possibilities such as power failures, hardware failures, Internet connection issues, broker downtime, and overnight positions that could go wrong, and huge opening gaps, which could wreak havoc in your trades.

To be fair, anything could happen. But, the question is how do we avoid this from affecting our trades?

This is where scenario grading comes in.

The entire process involves grading any set of mechanical trading rules in a variety of market conditions.

This can help you fine-tune your strategy before you trade in the live market and avert huge losses. It also helps limit biased trading performance, as you may realize that your trading strategy works only in certain market conditions. It can also be handy to decide when to use a particular strategy.

### PHI 1 offers scenario grading, unique only to the all-in-one platform

PHI 1’s scenario grading feature is a unique mechanism that measures the performance of any arbitrary trading strategy for multiple market scenarios.

Currently, the strategy grader checks for 7 different market scenarios – Uptrend High Volatility (Bull Market), Uptrend Low Volatility (Bull Market), Downtrend High Volatility (Bear Market), Downtrend Low Volatility (Bear Market), Sideways High Volatility, Sideways Low Volatility, and even Market Crash.

PHI 1 takes care of the entire spectrum of trading right from screening, charting, strategy creation, risk controls., backtesting, simulation, and order execution. All on one platform.

You ask what is really fully automated. We say PHI 1!

Before you put your trading strategy to work, it is essential to test it. The fundamental ways to evaluate your trading strategies include backtesting and forward testing.

Backtesting refers to testing your strategy using historical data sets. Forward testing, on the other hand, refers to evaluating your trading strategy using simulated environments.

## Here are some trading platforms you can use for trading strategy evaluation:

### 1. PHI 1:

As an all-in-one algorithmic trading platform, PHI 1 allows multiple testing strategies like bulk backtesting and forward testing (simulations), which you can achieve with the click of a few buttons, on a single dashboard.

All you need to do is select your parameters such as capital, slippage costs, and the risk controls you want to use for the tests.

PHI 1 also offers a unique feature called scenario grading. This is a disruptive offering that scores your strategy for various market scenarios such as volatile, sideways, and crash.

Comes with a form-based strategy creator so you don’t need coding knowledge to get started

### 2. Streak by Zerodha

Allows backtesting to show results for metrics like maximum gain, maximum loss, average gain, average loss, etc. with a look-back period of up to five years.

You can run backtests using various parameters and also adjust for brokerage costs and other charges.

Streak does not offer simulations and scenario grading.

### 3. AmiBroker

AmiBroker allows you to backtest your trade set-up for multiple stocks as well as at the portfolio level, uses some pre-defined values like portfolio size, periodicity (daily/weekly/monthly), commission charges, interest rate, maximum loss and profit target stops, type of trades, price fields which can be changed.

However, you need to type in a strategy formula that contains at least buy and sell trading rules.

Amibroker also allows access to Monte Carlo simulation to check for worst-case market scenarios.You can also test the robustness of your trading strategy by evaluating its out-of-sample performance to avoid over-fitting after in-sample optimization.

Amibroker can be a pricey alternative for Indian traders and requires coding knowledge to use the platform.

NinjaTrader’s Strategy Analyzer tests automated strategies via backtesting and optimization.

It is designed for use of strategies built using NinjaScript, NinjaTrader’s modern C# based trading framework

You can select the Strategy Analyzer parameters like strategy, instrument, interval type and value and time frame.

The results display all performance statistics and metrics, data for various time periods for analysis, and charts.

However, NinjaTrader is available only on Windows.

MetaTrader 5’s Strategy Tester allows back testing, forward testing, and optimizations.

The Strategy Tester offers various testing modes, e.g., its Random Delay mode simulates network delays during the processing of trades

You can use custom settings during strategy testing like trading limits, margin settings, and commissions.

You can view results in graphical view and also perform visual testing

MetaTrader 5 is primarily used by Forex traders. Besides this, the programming language and advanced features might be difficult for beginners.

If you’re willing to try a one-stop trading platform with screening, charting, easy strategy creation, backtesting, forward testing and scenario grading, and deployment, PHI 1 can be a cost-effective option for you.

PHI 1 uses large sets of data to help you bulk backtest your strategy, offers a simulated environment for forward testing, and also ranks your strategies in multiple market scenarios.

Want a first-hand experience of how PHI 1 can elevate your trading?