0% found this document useful (0 votes)
67 views

Simple Moving Average SMA Crossover Strategy With

This document discusses using a simple moving average crossover strategy to generate buy and sell signals from historical price data. It explores the effectiveness of this strategy when applied to different financial instruments and timeframes. While the strategy can be useful for identifying trends, its performance depends on the parameters used and it is prone to producing false signals in volatile markets.

Uploaded by

kerimbayevaa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views

Simple Moving Average SMA Crossover Strategy With

This document discusses using a simple moving average crossover strategy to generate buy and sell signals from historical price data. It explores the effectiveness of this strategy when applied to different financial instruments and timeframes. While the strategy can be useful for identifying trends, its performance depends on the parameters used and it is prone to producing false signals in volatile markets.

Uploaded by

kerimbayevaa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Asia-Pacific J.Mgmt. Tech.

Volume 3(4) 26- 40


https://doi.org/10.46977/apjmt. 2023.v03i04.004

Asia-Pacific Journal of Management and


Technology
Online ISSN: 2652-6840

journal homepage www.ajmt.org


Original Article
Simple Moving Average (SMA) Crossover Strategy with Buy Sell
Indicator

Sabyasachi Mazumder, Sayan Neogy*, Sahana Das

School of Computer Science, Swami Vivekananda University, Barrackpore, 700121, India

Correspondence E-mail: [email protected], [email protected]*, [email protected]

Abstract
This project explores the effectiveness of a Small Moving Average (SMA) crossover trading strategy
implemented on the TradingView website using Pine Script. The study investigates the potential
profitability of the strategy by backtesting it on historical price data for various financial instruments. The
project also examines the impact of different parameter values and timeframes on the performance of
the SMA crossover strategy. The findings suggest that the SMA crossover strategy can be an effective
tool for identifying potential buy and sell signals, but the results are highly dependent on the specific
parameter values and timeframes used. This project provides a practical example of how to implement
and test a trading strategy using Pine Script on TradingView.

Keywords: Simple Moving Average (SMA); Crossover Strategy; Stock Market Analysis; TradingView

Introduction
In the financial markets, technical analysis is a common strategy to examine price trends and forecast
future market moves (Nabriya, 2020). In technical analysis, moving averages are often used to smooth
out price data's volatility and find underlying trends. In the current turbulent competitive environment,
financial analysis is an essential tool to help diverse stakeholder groups make better decisions (Islam
et al., 2022).
By averaging a predetermined number of prior prices, a moving average is created. Moving averages
are of different types, simple moving averages (SMA), exponential moving averages (EMA), and
weighted moving averages (WMA). The simple moving average is the moving average that is most
frequently employed in technical analysis.
A straightforward and well-liked technical analysis approach based on moving averages is the SMA
Crossover strategy. This strategy's fundamental premise is to spot trend changes by looking for crosses
between two moving averages.
In the procedure, two moving averages—one with a shorter time frame and the other with a longer time
period—are employed. The shorter-term moving average displays the price trend that has occurred
more recently, while the longer-term moving average displays the trend as a whole. A buy signal is
created when the shorter-term moving average crosses above the longer-term moving average,
indicating that the upward price trend is beginning to take hold. When the shorter-term moving average
goes below the longer-term moving average, it shows that the price trend has changed from going up
to going down. This is a sell signal.

Received 18 February 2023; Received in revised form 01 March 2023; Accepted 15 March 2023

26
Neogy et al.
Asia-Pacific J.Mgmt. Tech. Volume 3(4) 26- 40

The SMA Crossover strategy's simplicity is one of its benefits. All levels of traders can utilize it because
it is simple to comprehend and put into practice. The approach can be utilized in any time frame, from
intraday to weekly or monthly, and it can be employed with any financial instrument, including stocks,
currencies, commodities, and indices.
The adaptability of the SMA Crossover method is another asset. By adjusting the lengths of the moving
averages utilized, traders can modify the technique to suit their unique requirements and preferences.
For instance, when trading in more turbulent markets or more stable markets, traders may utilize
shorter-term moving averages or longer-term moving averages, respectively.
The SMA Crossover technique does have some drawbacks, though. One of its key flaws is its tendency
to produce misleading signals in choppy or sideways markets, which can result in losses for traders
who blindly follow the signs. In these circumstances, it's crucial to apply additional technical analysis
tools and indicators to verify the veracity of the signals the method has produced.
Another drawback is that the method has a tendency to produce whipsaws, which are losing trades that
happen when moving averages cross and produce a signal but then immediately cross again in the
opposite direction. This can be reduced by adding extra indicators to filter out spurious signals or by
using a longer-term moving average.
In conclusion, the SMA Crossover technique is a well-liked and straightforward technical analysis
method that can be utilized to spot trend changes and produce trade signals. While it offers advantages
like simplicity and adaptability, it also has drawbacks like misleading signals and whipsaws that must
be considered. Before using a trading strategy in real trading, it's important to come up with a good plan
for managing risks and carefully evaluate how well the strategy works.

Review of Literature
The use of moving averages in technical analysis has been widely studied in literature. In general, the
literature suggests that moving averages are a useful tool for identifying trends and potential buy or sell
opportunities in the market. For example, a study by Wilder (1978) found that moving averages were
effective in identifying trends in commodity prices, while a study by Murphy (1999) found that moving
averages were useful in identifying trends in stock prices.
The Simple Moving Average Crossover strategy, in particular, has been the subject of several studies.
For example, in a study by Rapach, Strauss and Zhou (2013), researchers found that the SMA
Crossover strategy was effective in identifying trends in the US stock market and provided returns that
were similar to those of a buy-and-hold strategy.
However, the literature also highlights some limitations and weaknesses of the SMA Crossover strategy.
For example, a study by Lo and MacKinlay (1988) found that the SMA Crossover strategy performed
poorly in the foreign exchange market. Another study by Garcia‐Feijoo and Jensen (2014) found that
the SMA Crossover strategy alone was not effective in identifying trends in the Spanish stock market.
Moving Average Convergence Divergence (MACD) approaches were utilized by Sudheer (2015) in his
article titled "Trading through technical analysis: an empirical study from the Indian stock market" to
determine whether a stock is technically strong or not. Investors can recognize the present trend and
stock-related risk thanks to MACD.
In their paper titled "Profitability of Oscillators used in Technical analysis for Financial Market" by Naved
and Srivastava (2015), the researchers look at the profitability of various oscillator types used in
technical analysis on the S&P CNX Nifty 50 market index of the NSE. Commodity Channel Index (CCI),
Stochastic oscillator, and RSI oscillator were the three oscillators employed by the researcher, and the
results clearly show that the CCI performs better than the other two oscillators.
Peachavanish (2016), suggested a way to find the stocks with the strongest trend and momentum at
any given time. The favourite equities from the Thai stock market can be used with this method.

27
Neogy et al.
Asia-Pacific J.Mgmt. Tech. Volume 3(4) 26- 40

One of the main criticisms of the SMA Crossover strategy is that it is a lagging indicator and may not
provide early signals about future price movements. Additionally, the strategy is based on past data,
which means it may not be effective in volatile market conditions. Also, the strategy may give off a lot
of false signals and whipsaws, which can cause losses.
In summary, the literature suggests that the Simple Moving Average Crossover strategy can be a useful
tool for identifying trends and potential buy or sell opportunities in the market. However, the strategy
also has its limitations, and it is essential to be aware of them before using it. It's important to keep in
mind that past performance does not guarantee future results and that research and testing are
essential when using any strategy.
Methodology
The historical data for a particular stock or asset is typically analyzed in order to judge the efficiency of
the Simple Moving Average (SMA) Crossover approach. The data used for the analysis should be large
and cover a wide time span to ensure that the results are correct and statistically significant. The data
should contain information on the stock's or asset's price and volume in addition to other crucial market
data, like economic indicators.
Any item or stock that is traded on a public exchange, such as those listed on a stock exchange or a
currency sold on the foreign exchange market, is the subject of research. Depending on the study
question and the analysis's goals, a stock or asset is selected.
Time Frame of Analysis
Another significant factor to take into account is the time frame of analysis. The research topic and the
analysis's goals will determine how long the time frame will be. When evaluating the SMA Crossover
strategy's performance over a lengthy period of time, one study may use a time frame of several years,
while another study may use a time range of several months.
The time frame picked for the analysis is another important consideration. The duration will change
depending upon the subject of the study and the objectives of the analysis. For example, a study
evaluating the SMA Crossover technique over a long time horizon might use a time horizon of several
years, whereas a study evaluating the strategy over a short time horizon, for example, may use a time
horizon of several months.
Implementing the plan on a back testing platform is a typical methodology. A strategy's success can be
measured in terms of returns, risk, and other variables through the use of backtesting, which simulates
the strategy's performance using historical data. Using historical data, the strategy is applied during the
backtesting process, and trade simulations based on the rules of the strategy are run. Following that,
the effectiveness of the strategy is assessed by contrasting the simulated transactions with the actual
price changes of the stock or asset. Typical performance indicators used to assess the approach
include:

1. Net profit: the overall gain or loss resulting from the plan
2. Annualized return: the average yearly return that the approach produces
3. A measure of risk-adjusted return is the sharpe ratio.
4. Maximum drawdown: The equity of the strategy's biggest peak-to-trough decrease.
5. Win-loss ratio: The proportion of profitable deals to unsuccessful ones

Walk-forward analysis is another technique that may be used to assess the effectiveness of the SMA
Crossover approach in addition to backtesting. A more complex technique is called walk-forward
analysis, which entails testing the strategy on various subsets of historical data and modifying the
approach's parameters in response to the results. The robustness and dependability of the technique
may be enhanced by using this method.

28
Neogy et al.
Asia-Pacific J.Mgmt. Tech. Volume 3(4) 26- 40

The individual stock or asset being examined, the time range, and the moving average lengths will all
have an impact on the performance evaluation's outcomes. In order to determine whether the technique
is solid and reliable, it is crucial to thoroughly evaluate it utilizing a number of stocks or assets, time
frames, and moving average lengths. Additionally, it's important to keep in mind that past performance
does not guarantee future results and that the strategy should be regularly reviewed and modified as
necessary.
The risk management part of the strategy also needs to be taken into account when figuring out how
well it works. Any strategy must effectively manage risk, and having a plan in place is essential. This
can require putting stop-loss orders in place, diversifying the portfolio, and keeping a close eye on the
portfolio's performance.
In conclusion, assessing the Simple Moving Average Crossover strategy's performance is a crucial
stage in figuring out how reliable and effective it is. The approach's potential can be fully understood by
conducting a thorough examination of the strategy using historical data, a variety of performance
indicators, strong backtesting, and walk-forward analysis. The strategy's resilience can be increased
and its performance can be better gauged by testing it in various market situations, employing a variety
of stocks or assets, time periods, and moving average lengths, as well as by putting a risk management
plan into place.

ALGORITHM
The "SMA Crossover Strategy" script is an indicator that produces buy and sell signals by using two
Simple Moving Averages (SMA) of various lengths. The user may adjust the lengths of the two moving
averages using the script's two user parameters, "Short MA Length" and "Long MA Length." The graph
displays the short moving average in green and the long moving average in red.
The short and long moving averages are calculated by the script's SMA () function, SMA () function
consists of the formula given below and their visualization on the chart is handled by plot() function. The
buy and sell signals are produced by the if-else statements depending on the crossover of the two
moving averages. When the short moving average crosses above the long moving average, a long
position is taken, and when it passes below, a short position is taken.
The Formula for SMA is:

SMA = (A1 + A2 + A3 + … + An)


n
where:
An = the price of the asset at period n
n = the number of total periods

In order to find probable buy or sell opportunities in the market, the Simple Moving Average (SMA)
Crossover method analyses moving averages. The strategy's step-by-step algorithm is provided below:

Step 1: Choose the stock or other asset you wish to trade. Any stock or asset that is traded on a public
exchange can be used with the technique.

Step 2: Decide on the analysis's time frame. The length of the time frame, which may be short term or
long term, depends depend on the research topic and the analysis's goals.
Step 3: Choose the moving average lengths. The strategy typically uses a short-term moving average
and a long-term moving average. The length of the moving averages will depend on the research
question and the objectives of the analysis. Commonly used lengths are 50 and 200 days moving
averages.
Step 4: Place the moving averages on the stock or asset's chart. Plotting will place the short-term
moving average above the long-term moving average.

29
Neogy et al.
Asia-Pacific J.Mgmt. Tech. Volume 3(4) 26- 40

Step 5: Identify the crossover points. When the short-term moving average crosses above the long-
term moving average, it is a bullish signal, indicating that the stock or asset is likely to rise in value.
Conversely, when the short-term moving average crosses below the long-term moving average, it is a
bearish signal, indicating that the stock or asset is likely to decrease in value.
Step 6: Based on the crossover points, take action. It is a buy signal when the short-term moving
average crosses above the long-term moving average. It is a sell signal when the short-term moving
average crosses below the long-term moving average.
The chart of Nifty50 depicts SMA crossover Strategy applied with the Buy and Sell indicators (2023-02-
16):

Source: https://in.tradingview.com/
Figure 1: Nifty50 Chart when SMA crossover strategy is applied

Results:
All the figures [1 - 13] in this paper are taken [on 16th Feb, 2023] from Pine Script code implemented
through TradingView website. Figure 1 is the chart of Nifty 50 Index in 1D time frame and this strategy
is applied to.
Some sample of result of prediction of trends are shown below with their respective Performance
Summary and Properties:

30
Neogy et al.
Asia-Pacific J.Mgmt. Tech. Volume 3(4) 26- 40

Nifty50

Source: https://in.tradingview.com/
Figure 2: Overview of Nifty50 when SMA crossover strategy is applied

31
Neogy et al.
Asia-Pacific J.Mgmt. Tech. Volume 3(4) 26- 40

Source: https://in.tradingview.com/
Figure 3: Performance Summary of Nifty 50 when SMA crossover strategy is applied

Source: https://in.tradingview.com/
Figure 4: Properties of Nifty 50 when SMA crossover strategy is applied

BankNifty

Source: https://in.tradingview.com/
Figure 5: Overview Summary of BankNifty when SMA crossover strategy is applied.

32
Neogy et al.
Asia-Pacific J.Mgmt. Tech. Volume 3(4) 26- 40

Source: https://in.tradingview.com/
Figure 6: Performance Summary of Nifty 50 when SMA crossover strategy is applied

Source: https://in.tradingview.com/
Figure 7: Properties of BankNifty when SMA crossover strategy is applied

33
Neogy et al.

Asia-Pacific J.Mgmt. Tech. Volume 3(4) 26- 40

Bitcoin

Source: https://in.tradingview.com/
Figure 8: Overview of Bitcoin when SMA crossover strategy is applied

34
Neogy et al.
Asia-Pacific J.Mgmt. Tech. Volume 3(4) 26- 40

Source: https://in.tradingview.com/
Figure 9: Performance Summary of Bitcoin when SMA crossover strategy is applied

Source: https://in.tradingview.com/
Figure 10: Properties of Bitcoin when SMA crossover strategy is applied

35
Neogy et al.

Asia-Pacific J.Mgmt. Tech. Volume 3(4) 26- 40

Sensex

Source: https://in.tradingview.com/
Figure 11: Overview of Sensex when SMA crossover strategy is applied

36
Neogy et al.
Asia-Pacific J.Mgmt. Tech. Volume 3(4) 26- 40

Source: https://in.tradingview.com/
Figure 12: Performance Summary of Sensex when SMA crossover strategy is applied

Source: https://in.tradingview.com/
Figure 13: Properties of Sensex when SMA crossover strategy is applied

Discussion:
● The Pine Script for performing Simple Moving Average (SMA) crossover strategy implemented
on the TradingView website (https://in.tradingview.com/) upon various types of index produced
variety of net profit margin across them. The website basically Backtests the strategy using
historical data till date. The website implements the strategy according to the code on realtime
time series data on the selected Index and gives us an overview, performance summary and
properties of the selected index while strategy is applied. According to the Figure 3 & 9
Performance Summaries [taken on 2023-02-16 through implementation of the code from
TradingView website], while we get a Net profit of 9.18% on Nifty50, there is stark contrast on
the Net profit on Bitcoin with 51.91%.
● A common technical analysis method that traders use to find prospective trading opportunities
in the financial markets is the Simple Moving Average (SMA) Crossover strategy. Using two or
more moving averages from various time periods is part of this method. The shorter moving
average is usually faster, whereas the longer moving average is slower.

37
Neogy et al.
Asia-Pacific J.Mgmt. Tech. Volume 3(4) 26- 40

● The trend is likely to continue heading upward when the shorter moving average crosses above
the longer moving average, which is known as a bullish indication. On the other hand, it is
regarded as a bearish indicator, indicating that the trend is likely to continue moving downward,
when the shorter moving average crosses below the longer moving average.
● Stocks, commodities, and currencies are just a few examples of the many financial assets to
which the SMA Crossover method can be applied. It can assist traders in avoiding misleading
signals and is particularly beneficial for spotting trends in markets that are not significantly
trending.
● The SMA Crossover technique has certain drawbacks, though. First of all, because it is a
lagging indicator, it might not offer early warnings of upcoming price swings. However, because
the technique is based on historical data, it could not work well in choppy market situations.
Moreover, the technique could produce a lot of false signals and whipsaws, which could result
in losses.
● Traders frequently combine the SMA Crossover approach with other trading strategies, such
as support and resistance levels, trend lines, or chart patterns, to get around some of the
drawbacks of the SMA Crossover strategy.
● In conclusion, the SMA Crossover method may prove to be a helpful instrument for spotting
prospective trading opportunities in the financial markets. To increase its efficiency, it is
necessary to be aware of its limitations and combine it with other technical indicators and
trading strategies. Prior to using the method in actual trading, traders should undertake
adequate study and testing.
Conclusion:
The key findings of the research on the Simple Moving Average (SMA) Crossover strategy are:

1. It is indicated that according to Simple Moving Average (SMA) Crossover Strategy an indicator
has been successfully developed to buy or sell Stocks using Pine Script in TradingView.
2. The SMA Crossover Strategy based buy-sell indicator can be used to identify potential trend
changes in any stock or security that has a price chart that can be analyzed using technical
analysis tools.
3. The SMA based Buy-sell indicator [with Short MA length =10 & Long MA length=50] in a time
frame of 1 day produced a Percentage Profitability of 39% - 45 % in 9 :
a. Nifty50 in 173 trades
b. BankNifty in 122 trades
c. Bitcoin(cryptocurrency) in 95 trades
d. Sensex in 219 trades.
4. The SMA Crossover Strategy based buy-sell indicator described in this paper can find
applications in different types of stocks, including:
a. Individual stocks: Traders and investors can use the SMA crossover strategy to
discover prospective trend alterations in individual stocks.
b. Exchange-Traded Funds (ETFs): ETFs are a type of pooled investment security that
holds multiple underlying assets, rather than only one. The SMA crossover strategy
can be implemented to discover future buying or shorting opportunities in ETFs.
c. Indexes: The SMA crossover strategy can also be used to discover future trend
development in stock market indexes, such as the NIFTY 50 or FTSE 250.
5. The profitability of the SMA crossover strategy can depend on a number of factors such as the
time-frame used, market conditions, and the specific parameters of the SMA lines. However,

38
Neogy et al.
Asia-Pacific J.Mgmt. Tech. Volume 3(4) 26- 40

the SMA crossover strategy tends to be most profitable when the market is trending strongly
on an unidirectional order.
6. The SMA Crossover Strategy is based on the concept that when a short-term moving average
(SMA) crosses over a long-term moving average (SMA), it is a positive signal, indicating that
the stock or asset will probably increase in value. In contrast, when a short-term moving
average crosses below a long-term moving average, it is a bearish indicator, indicating that the
stock or asset's value will possibly decline.
7. Analyzing historical data for a particular stock or asset, using a backtesting platform, and
monitoring the strategy's success in terms of returns, risk, and other metrics are all necessary
when evaluating the strategy's performance. It's important to note that the SMA crossover
strategy is not infallible and can result in losses during turbulent or volatile markets. Additionally,
the profitability of the strategy can also depend on the specific securities being traded and the
trader's skill in implementing the strategy effectively. Therefore, it's always important to
thoroughly backtest and evaluate any trading strategy before using it with real money.
8. To make sure the approach is solid and reliable, it is advised for future research to assess the
performance of the strategy using a number of stocks or assets, time frames, and moving
average lengths. Also, by combining the SMA Crossover method with additional indicators or
by experimenting with various time frames and moving average lengths, further research might
be done on how to enhance it. How to enhance the risk management component of the plan is
yet another topic for investigation.

It's crucial to remember that implementing any technique requires research and testing because past
performance does not guarantee future outcomes. To improve the robustness of the strategy and gain
a better knowledge of its performance, it's also crucial to analyze the approach in a variety of market
situations, employing various stocks or assets, time frames, and moving average lengths, as well as
putting a risk management plan into action.

Acknowledgment
The authors are thankful to the Supervisor and Management of Swami Vivekananda University for
providing all kinds of facilities along with encouragement.

Conflicts of Interest
The authors declare that they do not have any conflict of interest.
References
Garcia‐Feijoo, L., & Jensen, G. R. (2014). The monetary environment and long‐run reversals in stock
returns. Journal of Financial Research, 37(1), 3-26.
Islam, M., Dhar, P., Poddar, S., & Bhowmik, A. (2022). A Theoretical Study of Financial Literacy with Financial
Analysis. International Journal of Management and Human Science (IJMHS), 6(1), 41-49.
https://doi.org/10.31674/ijmhs.2022.v06i01.004
Lo, A. W., & MacKinlay, A. C. (1988). Stock market prices do not follow random walks: Evidence from a simple
specification test. The Review of Financial Studies, 1(1), 41-66. https://doi.org/10.1093/rfs/1.1.41
Mazumder, S. (2023) SMA Crossover Strategy, https://in.tradingview.com/script/jo6Ep2lI-SMA-corssover-strategy/
Murphy, J. J. (1999), Technical Analysis of The Financial Market | A Comprehensive Guide To Trading Methods
And Applications, (pp. 195-223).
Nabriya, P. (28th August, 2020). Generating Trade Signals using Moving Average (MA) Crossover Strategy — A
Python implementation. https://towardsdatascience.com/making-a-trade-call-using-simple-moving-average-sma-
crossover-strategy-python-implementation-29963326da7a
Naved, M. & Srivastava, P. (2015) Profitability of Oscillators used in Technical Analysis for Financial Market, 2(9),
925-931. http://dx.doi.org/10.2139/ssrn.2699105

39
Neogy et al.
Asia-Pacific J.Mgmt. Tech. Volume 3(4) 26- 40

Peachavanish, R. (2016, March). Stock selection and trading based on cluster analysis of trend and momentum
indicators. In Proceedings of the International MultiConference of Engineers and Computer Scientists (Vol. 1, pp.
317-321). IMECS. https://www.iaeng.org/publication/IMECS2016/IMECS2016_pp317-321.pdf
Rapach, D. E., Strauss, J. K., & Zhou, G. (2013). International stock return predictability: what is the role of the
United States?. The Journal of Finance, 68(4), 1633-1662.
Sudheer, V. (2015). Trading through technical analysis: an empirical study from Indian stock market. International
Journal of Development Research, 5(8), 5410-5416. https://www.journalijdr.com/sites/default/files/issue-
pdf/3916.pdf
Wilder, J.W. (1978). New Concepts in Technical Trading Systems. Trend Research, pp. 53-54.
https://books.mec.biz/tmp/books/218XOTBWY3FEW2CT3EVR.PDF

40

You might also like