0% found this document useful (0 votes)
36 views18 pages

FMP Backtesting

Uploaded by

Yash Tiwari
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)
36 views18 pages

FMP Backtesting

Uploaded by

Yash Tiwari
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/ 18

Trading strategy back-testing

Niket Lulla MBA2021- 098


Sourav Das MBA2021-151
Vanshika Kalra MBA2021-174
Yash Tiwari MBA2021-181
Chirag Saxena MBA2021-189

24 Dec 2022 Financial Market & Practice


INDEX
1. Executive Summary…………………………. 2

2. Strategy Used…………………………………. 3

3. Methodologies………………………………. 3

4. Data Kind……………………………………… 4

5. Properties of back-testing trade………… 4

6. Data Analysis…………………………………… 5-9, 11-15

7. Result & Interpretation………………… 10, 16

8. Conclusion………………………………. 17

1
Executive Summary

Futures of Tata Motors and Hindustan Unilever have been back tested using 9 day and 21-
day Exponential Moving Average using Crossover Strategy on Trading View. The tenure for
back-testing is 5 years from 2017 to 2022.

After Back-testing these Strategies, we found that both the stocks provided positive returns.
HUL provided a return of 450% with 55.26% probability of profit. Tata motors provided a
positive return of 576% with 39.13% successful trades.

We concluded that this strategy works better when there is volume to support the signal
provided by the system and there is momentum in the market. This Strategy gives many
false signals and doesn't work well when the market is sideways.

21 day and 9-day Exponential Moving Average Crossover Strategy works best in Volatile
Market. One of the biggest flaws in this strategy is that the maximum drawdown is very
high.

2
Strategy Used:
“EMA Crossover strategy”

The EMA is a moving average that places a greater weight and significance on the most recent data
points. This technical indicator is used to produce buy and sell signals based on crossovers and
divergences from the historical average.

EMA Used: 9 days EMA & 21 days EMA

Strategy:

• Strategy involves the use of 9 and 21 periods average.


• A rule of this strategy is to wait for the price to trade over the two EMAs. We also need to wait
for the EMA crossover for the buy trade till the lower EMA (9) crosses above the higher EMA
(21).
• Long Entry - When the 9 EMA crosses up and over the 21 SMA, we are looking for buy signals
• Long Exit - 9 EMA crossing down through the 21, we want sell signals
• Short Entry – When the 9EMA crosses down through 21EMA, we will short the position
• Short Exit – 9EMA crosses up and over the 21EMA

Methodologies used:
Platform used for back testing – TradingView

Why TradingView:

• Clean & reliable data


• Simple to use
• Highly accurate
• Intuitive and easy to understand
• Not much of coding involved
• Easy to interpret results with good summary & overview it offers

3
Back testing code:
//@version=4
strategy("MA crossover strategy", overlay = true)
Start = timestamp(2017, 1, 1, 0, 0)
End = timestamp(2022, 6, 1, 0, 0)
Ema1 = ema(close,9)
Ema2 = ema(close,21)
plot(Ema1, title = "EMA9", color = color.blue)
plot (Ema2, title = "EMA21", color = color.green)

//strategy
LongEntry = crossover(Ema1, Ema2)
LongExit = crossover(Ema2, Ema1)
ShortEntry = crossover(Ema2, Ema1)
ShortExit = crossover(Ema1, Ema2)

if time >= Start and time < End


strategy.entry("Long", strategy.long, 1,when = LongEntry)
strategy.close("Long", when = LongExit)
strategy.entry("Short", strategy.short, 1, when = ShortEntry)
strategy.close("short", when = ShortExit)

Data Kind:
Stock picked: Hindustan Unilever Ltd. and Tata motors
Timeframe – Daily
Duration for back testing – 5 years
The data range has been selected keeping in mind that we have enough number of instances to test
our strategy and to know all pros and cons. The period from 2017 to 2022 has been chosen because it
replicates all the stock market scenario from having sideways movement in 2017 & 2018, then having
covid pandemic fall and then increasing exponentially and recovering from covid 19 fall in 2021 &
2022 showing highly bullish trends.

Properties of back testing trade:


• Back testing range – 05 Jan 2017 to 23 Dec 2022(current)
• Market – NSE
• Trade type – Stock futures
• Timeframe – 1 day
• Chart type – Candle
• Currency – INR
• Initial capital – Rs 1,00,000
• Order size – 1 lot/contract
• Commission – 0%
• Stoploss used – No

4
Data analysis:
HINDUSTAN UNILEVER LTD FUTURES.

Overview -

Net profit Rs 4,50,600 or 450.6%


Total closed trade 38
Percent profitable (winning trade %) 55.26%
Profit factor* 2.471
Max drawdown* Rs (1,32,615) or 34.01%
Average trade* Rs 11,857.89

*Profit factor - Amount of money strategy made for every unit of money it lost

*Max drawdown - Greatest possible loss the strategy has made

*Average trade - Sum of money gained or lost on an average

5
The strategy works in quiet simple manner, through the chart we can clearly see that we enter into
the long position whenever blue line (EMA9) crosses over green line (EMA21). We exit from the
position and take a short position whenever blue line (EMA9) crosses down to green line (EMA21).
We exit the short position whenever blue line (EMA9) crosses over green line (EMA21).

Performance Summary:

6
List of trades:

7
8
*Purple column bars signifies amount of drawdown each trade suffers; it is a negative figure hence
measured by looking right side of Y-axis

*The green area is the equity curve which signifies how our initial capital moves trade per trade, it
can be either positive or negative. It is measured by looking left side of Y-axis.

Title All Long Short


Total closed trade 38 19 19

Number of winning trades 21 11 10

Number of losing trade 17 8 9

Percent profitable 55.26% 57.89% 52.36%

Average trade 11,857.89 22,220.53 1495.26

Average winning trade 36,045.71 50,781.82 19,836.00

Average losing trade 18,021.18 17,051.25 18,883.33

Ratio Avg. win/Avg. loss 2 2.9 1.05

Largest winning trade 1,05,870.00 1,05,870.00 93,930.00

Largest losing trade 39,225.00 36,270.00 39,225.00

9
Results & Interpretation:
• HUL showed positive returns over 5-year period.
• The strategy gave profit probability of 55.26%.
• HUL provided a return of 450% over 5-year period.
• The most profitable trade gave us the return of Rs 1.05 lakhs where we got an entry
signal when HUL was trading at Rs 826 and strategy gave us the sell signal when
stock was trading at Rs 1179 giving us 105.87% return
• The trade which gave the highest loss was the one where we took a short position at
Rs 2100 and after that stock moved upward to Rs 2230 thus giving us a loss of Rs
39225.
• Through the above data and charts we can interpret that the strategy works well
when stocks have good momentum but fails when stock consolidate
• Most profitable trades were long trade only.
• The Sharpe ratio for the strategy is 0.245 which shows the risk per unit of return. For
HUL, Sharpe ratio is less than 1 which means return doesn’t offset risk well enough.
• The sortino ratio for HUL comes out to be 1.084 which again is low which indicate
lower return per unit of negative risk.

10
TATA MOTORS FUTURES:

Overview -

Net profit Rs 5,76,270 or 576.27%


Total closed trade 46
Percent profitable (winning trade %) 39.13%
Profit factor* 1.867
Max drawdown* Rs 2,70,750 or 50.17%
Average trade* Rs 12,527

*Profit factor - Amount of money strategy made for every unit of money it lost

*Max drawdown - Greatest possible loss the strategy has made

*Average trade - Sum of money gained or lost on an average

11
Performance Summary:

List of trades:

12
13
14
*Purple column bars signifies amount of drawdown each trade suffers; it is a negative figure hence
measured by looking right side of Y-axis

*The green area is the equity curve which signifies how our initial capital moves trade per trade, it
can be either positive or negative. It is measured by looking left side of Y-axis.

Title All Long Short


Total closed trade 46 23 23

Number of winning trades 18 7 11

Number of losing trade 28 16 12

Percent profitable 39.12% 30.43% 47.83%

Average trade 12,527.61 10,839.29 14215.92

Average winning trade 68,962.08 88,889.46 56,281.02

Average losing trade 23,751.70 23,307.66 24,343.75

Ratio Avg. win/Avg. loss 2.90 3.81 2.31

Largest winning trade 2,33,272.15 2,33,272.15 1,31,242.50

Largest losing trade 63,697.50 50,445.00 39,225.00

15
Results & Interpretation:
• Tata Motors showed positive returns over 5-year period.
• The strategy gave profit probability of 39.13%
• HUL provided a return of 576.27% over 5-year period.
• The most profitable trade gave us the return of Rs 2.33 lakhs where we got an entry
signal when Tata motors was trading at Rs 138 and strategy gave us the sell signal
when stock was trading at Rs 302.60 giving us 117.85% return
• The trade which gave the highest loss was the one where we took a short position at
Rs 150 and after that stock moved upward to Rs 182 thus giving us a loss of Rs
46882.
• For Tata Motors as well strategy works well only when stock have good momentum
but fails when stock consolidate
• The Sharpe ratio for the strategy is 0.216 which shows the risk per unit of return. For
Tata Motors, Sharpe ratio is less than 1 which means return doesn’t offset risk well
enough.
• The sortino ratio for Tata Motors comes out to be 0.282 which again is low which
indicate lower return per unit of negative risk.

Suggestions:
To make this strategy more accurate and profitable, stop loss could be set up with target setting to
reduce loss drawdowns. While in open position stop loss can be trailed to increase
profitability.

As during back-testing we encountered that one of the biggest flaws in trades were
drawdowns, these drawdowns usually occurs because there is no stop loss and trade fails as
we didn’t exit even incurring lot of loss. So, introducing stop loss and thereby trailing it may
result in better trade.

16
Conclusion:
• This Strategy is for Risk taking Traders, as the probability of profit is around 50% with
a high maximum drawdown.
• Stock Price needs to be volatile to give us profitable trade.
• The Strategy does not work accurately during sideways market.
• There high chances of false Buy/Sell Signal given by the Strategy if the volume does
not support the trade taken.
• As EMA is lag indicator, it gives strong entry signal but lags in giving us the Exit
Points.
• Strategy works best to take swing trade position, but may not be very accurate in
intraday or BTST trades.

To put everything in a nutshell, moving averages are very popular and is very widely used
technical indicator. Crossover strategies are used for both short-term and long-term trades
and their accuracy can be increased if used along with another technical indicator such as
RSI or MACD.

17

You might also like