You are on page 1of 94

PREDICTING STOCK MARKET PRICES USING

BUSINESS INTELLIGENCE TOOLS AND TECHNICAL


INDICATORS

Research Mentor:

Mr. SHAMS NAVEED ZIA

Submitted by:

S.M. FAHAD HASNIE


ERP ID: 10084
MBA EXECUTIVE- 7

1
1st Project Report
February, 2018

Table of Contents
Page No.

List of Figures……………….……………….……………………….……………… I
List of Tables ………………………………….……………………….…………… II
Acknowledgements…………………………...………….………………………… III
Executive Summary…………………………………………………..…….……... IV
Chapter 1
Introduction……………………………………..……………….…………………...1
Introduction….…………………………………………………………….....2
Machine Learning…………………….………………..…………..………..5
Background and Problem statement…………………..…………..……...5
Research Objectives.………………………………………..……………...5
Research Question…….……………………..……………………….…….6
Significant of research……………………………………….………….…..6
Limitations of the study..…………………………………….………….…..6

CHAPTER 2
Literature Review…………..…………………………………………...…………….7
Technical analysis Fundamentals...……………….…..……..……………..8
Time Series Analysis……….………………………………..…….…………9
ARIMA Forecasting Model………….……………….………..…………….11
Holt Winter Model ……………………….……………………..……………13
Box-Jenkins approach to modeling and forecasting time series data.…15
Double Seasonal ARIMA model forecasting techniques ……………...16
Holt Winter forecasting for utility loads and traffic flows……...………….16
Stock market forecasting using machine learning algorithms...……….. 16

CHAPTER – 3
Research Methodology……………………………………………………………...13

II
Research Methodology and Purpose…….……………………………..…14
Hypothesis………………………………..….…………………………….…15
Evaluation Method…………………………………………...………..……..18
Classification Percentage…………..……………………………….………20

CHAPTER – 4
Review of Cement industries of Pakistan …………..………………..…….….22
Pakistan Construction industry Outlook……………………………….……23
Future Prospects of Cement industry………………........……………..…. 23
Top cement companies and their financial performance..………………. 24

CHAPTER – 5
Data Analysis and Design …………………..………..………...…………….……25
Data Analysis of selected Cement companies on PSX...………………..26
Data Design of Selected Cement Scripts………………….……………...34
Model development and Forecasting using ARIMA model……………...35
Model Development and Forecasting using Holt Winter model…………42
Technical Indicators Forecasting model……………….……………….….61

CHAPTER – 6
Conclusion and Recommendations……………..…………………………….....71
Summary of Findings………………..…………………………………..…72
Conclusion………………..………………………………………………....73
Recommendations ………………..……………………………………..…75
References……………………………………………………………….……….…77
Questionnaire…………………………………………….….…………..….……….79
Interview scripts…………………………………………….….…………..….….....81

II
List of Figures
Page No.

Figure No.1 ……………………….(Flowchart of the Research Report).………...……18


Figure No.2 ……… (Pie Chart for Cement Production Capacity in Pakistan)...…….21
Figure No.3 ………...………..…… (Age group of respondents)……………..………..29
Figure No.4 ………...…….……….… (Gender of respondents)………………………..29
Figure No.5 ……………………… (Qualification of respondents)…...…………………30
Figure No.6 ………………..……. (Occupation of respondents)……………………..…31
Figure No.7 ……………….…… (Entry barriers for novice traders)……………………31
Figure No.8 …………………….. (Sector with highest potential returns)……..……….32
Figure No.9 …………....….. (Trading methods of respondents)……………………….32
Figure No.10 ……………..…..... (Trading strategy of respondents) …………....….….33
Figure No.11 …...................(Concern related to recent market volatility) ….................33
Figure No.12 ……..……...(Knowledge of big data tools for stock market) …..….….…34
Figure No.11 …...................(Concern related to recent market volatility) ….................34
Figure No.12 ………..…...(Knowledge of big data tools for stock market) …..….….…34
Figure No.13 ………….…… (Respondents on using BI tools in PSX)…...….…………34
Figure No.14 …………………... (ARIMA Forecasting Flowchart)………..…………..…36
Figure No.15 ……….……… (Close Price of Attock Cement Script)……………………37
Figure No.16 ………..………. (ARIMA Filtering and ACF residue)…………………..…38
Figure No.17 ………..……… (ARIMA Forecasting of Attock Script)……………………40
Figure No.18 …………………….... (ARIMA Forecasting in EXCEL)…………..……….41
Figure No.19 ……….....…. (Line graph of Actual and Forecasted Values)…………….41
Figure No.20 ………………..... (Close Price Index of past five years) …………...….….42
Figure No.21 …..............(Holt Winter Forecasting on Attock Cement Script) …….........43
Figure No.22 ………..……...(Holt Winter Error Forecasting using MS EXCEL) …..…..….…44
Figure No.23 …………..….…. (Holt Winter forecasted and Actual Values)….…………44
Figure No.24 ………….…. (Close price of Lucky Cement for Past five years).……..….46
Figure No.25 …………..……..…. (ARIMA Filtering and ACF residue)…..……….....…..47
Figure No.26……………. (ARIMA Forecasting on Lucky Cement Script) .………....…..48
Figure No.27 ………………….(ARIMA Forecasting in EXCEL).…………….…........49
Figure No.28 ………..……(Lucky Cement ARIMA Forecasting) ….………...….…..51
Figure No.29 ……….… ...…(Close Price Index of past five years)……..…………...51
Figure No.30………..(HW Filtering and Forecasting on Lucky Script)……….……..51
Figure No.31…………….……. (Holt Winter Forecasting in EXCEL)….………….…52

II
Figure No.32 …………………...(HW Forecasting Lucky Script)……………..………53
Figure No.33……………….. (Close Price Index of past five years)……………..…..54
Figure No.34 ……………….…. (ARIMA Filtering and ACF residue) .……….......…..55
Figure No.35 …………..(ARIMA Forecasting on D.G. Cement Script).……...….......56
Figure No.36…………….….…. (ARIMA Forecasting in EXCEL) ……..…….……….57
Figure No.37 ………………..….(Actual vs Forecasted Values) ……..…….………..58
Figure No.38 …….………. (Close Price Index of D.G. Cement) …..…....……….…59
Figure No.39 ………….. (HW Filtering and Forecasting on D.G. Script)………...…59

Figure No.40 ………. (HW Forecasted and Actual value graph) …………….……..60
Figure No.41 ……..…………... (HW Forecasted and Actual value graph) …..…….61
Figure No.42…………….… (Technical Indicators Flow Chart) ……………….…….62
Figure No.43 ……………………..…… (RSI on Attock Cement) ….……………..…..63
Figure No.44…………….... (Bollinger Bands on Attock Cement) ……………...…...64
Figure No.45.....….(Exponential Moving Average on Attock Cement)…..………….65
Figure No.46 ………………….. (RSI on Lucky Cement)………………………...…..66
Figure No.47 ……………………. (Bollinger Bands on Lucky Cement) ……....….67
Figure No.48……….. .(Exponential Moving Average on Lucky Cement) ……..…..68
Figure No.49 ……….……………….(RSI on D.G. Cement)……………………..…..69
Figure No.50 ……………(Bollinger Bands on D.G. Cement) ………………...……70
Figure No.51 ………….…. (Simple Moving Average on D.G. Cement) …………..71

List of Tables
Page No.

Table No.1:……..….……………Income Range of respondents……………………....30

II
Table No.2:……..….…………ARIMA Model Parameter Values……………………....40

Table No.3 .…………….. ARIMA Model Parameter Values……….........…..…49

Table No.4 ……………… ARIMA Model Parameter Values……………..….....57

Acknowledgements

First of all, I would like to thank the entire faculty of IBA Karachi for increasing my
knowledge and proficiency. I am extremely pleased by the professionalism of

II
individuals that I have remained associated during my MBA program at IBA Karachi.

My family, friends and office colleagues have always supported me during my


degree program. Last but not the least; I am highly thankful to my Mentor for this
research project, Mr. Shams Naveed Zia (Visiting faculty of IBA) for his innumerable
support and guidance. It provided me great strength and enthusiasm to complete this
research study.

II
Executive Summary
Timely forecasting of stock market may serve as an early recommendation for novice
and short term investors as well as the early financial distress warning for
seasoned/long term investors. Most of the stock predicting studies focus of the
macroeconomic indicators such as CPI and GDP to harness the prediction forecasting
model. However the daily data of these macroeconomic indicators is practically
impossible to obtain making it difficult for the model deployment .

In this research report an extensive empirical study of the available forecasting


methodologies have been reviewed and proposed a method for forecasting using
business intelligence tools. The methodology adopted for preparing prediction model
comprises of Business Intelligence tools as well as technical indicators so that the
results can be compared for greater profit returns. The research and analysis is
primarily focused on cement sector of Pakistan as this is most rapid growing sector of
Pakistan’s economy. The research study on this topic will be beneficial in identifying the
various aspects related to the profitability of cement industry in Pakistan.

The research in this paper helps in identifying a correlation between past price
movements of share prices and the future profitability of cement industries operating in
Pakistan.

The results of this research would be valuable in identifying the strategies for high gain
rather than conventional buy-and-hold approach along with other crucial aspects related
to profitability of cement industry in Pakistan.

IV
CHAPTER 1

INTRODUCTION

 Introduction
 Machine Learning
 Background and Problem Statement
 Research Objectives
 Research Questions
 Significance of research
 Delimitations
INTRODUCTION

Stock market is considered to be a backbone of emerging economies such as Pakistan.


Major financial infusion of the companies operating across the country is dependent thru
the shares sold to people. Affluent growth of our country is bounded with the efficiency
and performance of Pakistan Stock Market. Today Pakistan suffers from one for the
lowest participation by general population in stock market. Total number of investors
who ever invested in stock market is close to 400,000 or 0.2% of such a big economy.
This would translate in to 2.2 investors for every 1000 individuals, much lower than 17.8
in India, 18.6 in Bangladesh and 27.8 in Sri Lanka. The main aspect of such a low
involvement of people in Pakistan stock exchange is the fear of capital loss due to the
volatile nature of the Stock market. Taking into consideration the lack of people’s
awareness and knowledge the early stock market prediction techniques can play a vital
role in bringing in more people into the market as well as giving benefits to the existing
investors.
Due to non-linear, highly volatile and non-parametric behavior of the stock market it is
extremely hard to model the market with certain accuracy. There have been many
methods available to find the right stocks with right time of buying and selling.
Fundamental analysis is generally based on the assumption that share prices are
dependent of its intrinsic value along with expected return on investment. This method
not only comprises of crunching numbers but it also analyzes more subjective qualities
of a firm. Technical analysis had gained popularity in the recent times this method
forecast future prices based on the continuous value technical primary indicators as a
source of input to predictor models which causes prediction model to make
classification dependent on the continuous values of those indicators. Another which is
used actively is quantitative analysis which uses numerical and quantitative methods.
Both fundamental and quantitative analysis are suitable for long term basis however for
short term market speculations technical analysis is used with a some percentage of
inaccuracy in it.

Page | 2
Advancements in Artificial intelligence techniques for data predicting models has taken
the world by storm new methods of forecasting are adding in world biggest stock
exchanges such as NASDAQ and DOW JONES for stock market predictions. Business
intelligence is one such growing field in which new algorithms are implemented to seek
the greater returns on the profits. BI can be define as extracting useful information from
the available data. Now is the high time to implement these advanced models in
Pakistan Stock Exchange for accurate and timely predictions of the stock prices for
short and medium term investors.

Machine learning:
Improvements in the machine learning algorithms have immensely helped the traders in
evaluating and implementing the potential predictive algorithms to get optimum profit in
financial security markets. Machine learning is segregated into two classes, the first
class is supervised learning, in which output corresponding to that feature set. This
means that the algorithm is given features and outputs for a particular dataset (training
data), and must apply what it “learns” from this dataset to predict the outputs (labels) for
another dataset (test data).
On the other hand unsupervised machine learning, consists of data variable where the
feature set is unlabeled. The background algorithms generally try to cluster the data into
distinct groups.

Problem Statement:
Due to the unpredictable behavior of stock market many experienced investors in
Pakistan feared for making bigger investments in stock market as they do not suitably
know as to which stocks to buy, sell or hold to reap greater margin returns and rather
prefer to investment in real estate businesses. In order to accelerate the growth of this
potential field there is a dire need of automated predicting model on short term basis
which can be used for making more money off securities rather than traditional buy and
hold strategy also to lessen the risk involved in doing such investments. Most of the
models available and use today are based on predicting long term values which
includes greater margin of error due to rapid fluctuation of stocks based on world
events.

Page | 3
Research Objective:
Objective of this research work is to develop a stock prediction model using Business
Intelligence tools which can successfully trade securities for greater gain thus beating
the conventional buy-and-hold market strategies. The proposed model will incorporate
technical features as well as market and environmental sentiments for predicting the
share prices with greater accuracy.

Technical Objective:
Technical objectives of the model will be implemented using R programming language.
The system should be able to access the historical prices and must calculate the
estimated prices stock based on historical data and current events. The model must
understand data properties and provide s the instantaneous visualizations of the share
prices thru charts and graphs.

Experimental Objective:
The model will be implemented using two different approaches; one using basic
technical indicators which incorporate Moving Averages (MA), Moving Exponential
Averages (EMA), Bollinger Bands and other using Time Series ARIMA and HOLT
WINTER model. Results of the both the approaches will be analyzed to find prediction
accuracy of both.

Research questions:
Proposed research study will answer the following research questions:
Q1) Prediction of future stock prices of Cement Sector of Pakistan
Q2) Produce effective patterns from past data for analysis.
Q3) Analyze the trading patterns of new and seasoned traders and economic factors
affecting the stock prices in Pakistan.
Q4) Bring in novice and feared investors into the market.
Q5) To use Business Intelligence tools for developing a best strategy which could
outperform the conventional buy-and-hold strategy.

Page | 4
Significance of research:

Forecasting of stock market scripts may provide as an early recommendation for short
term investors these market predictions may serve as early distress warnings for long
term stake holders also. Many stock forecasting studies focus on macroeconomic
indicators such as CPI and GDP, to train and develop the prediction model but in order
to predict the market movement on short term basis daily data of all the major
macroeconomic indicators is impossible to attain timely making it difficult on short term
basis. In this research study we propose a method that directly uses prices data to
predict stock price direction. An extensive empirical study of the proposed method will
be presented on cement sector of Pakistan Stock Exchange (PSX).The research study
on this topic will be beneficial in identifying the various aspects related to the profitability
of cement industry in Pakistan.

Limitations of the Project Report:

 Abundance of Forecasting Models


 Abundance of trading platforms/programming languages
 Abundance of technical indicators
 Use of financial data relating to stock market indices
 This research study can be used only for making short term forecasting decisions

Page | 5
CHAPTER 2

LITERATURE REVIEW

 Technical Analysis Fundamentals


 Time Series Analysis
 ARIMA forecasting Model
 Holt Winter Model
 Box-Jenkins approach to modeling and forecasting time
series data
 Double Seasonal ARIMA Model forecasting techniques
 Holt Winter and double seasonal Holt Winter forecasting for
both utility loads and traffic flows
 Stock marketing forecasting using machine learning
algorithms
 Data mining technology to discover hidden pattern from the
stock market historic data.
 Influence of seasonality factor on Holt Winter model

Page | 6
BACKGROUND INFORMATION AND LITERATURE
REVIEW

This chapter refers to the literature referred for the scrutiny of the research study from
various research papers, Journals, online articles and books from different sources.
Currently, a lot of work has been done which focuses technical analysis as well as on
Machine Learning algorithms for analyzing stock pricing patterns and predicting stock
prices. Many stock traders rely on Smart/Intelligent trading systems which helps in
prediction based on different situations. Some of the literature related to research is
summarized below:

Technical Analysis:
Technical analysis is often referred as study of financial market movements. Stock
traders generally analyzing technical indicators uses historical prices along with security
volume which is often depicted in terms of graphical depiction to make future based
efficient market decisions. Over decades, stock traders have found many complex and
profitable formulas which help in simplifying decisions. The indicators of technical
analysis provide guidance to the investors in identifying major turning points of the stock
market.

The main indicators which are incorporated in this research report are:

RSI (Relative Strength Index)

The Relative Strength Index (RSI) is an indicator which measures the speed relative to
its change in price s. The RSI fluctuates between zero and 100 point scale.
Conventionally the RSI is considered to be an overbought when its face value is above
70 and an oversold when the price value is below 30.

If a market is bullish, the RSI inclines in between the range of 40 to 90 points (varies
from industry to industry) while the support resistance range in between 40-50 point
level. If the market is a bearish in nature the RSI declines between the 10 to 60 point
ranges with support resistance range in between 50-60 point levels. The ranges of
Relative Strength indexes vary based on RSI setting and the strengths and weakness of
security’s underlying past behavior.

Page | 7
The basic working formula of this technical indicator is represented below;

RSI = 100 – [100 / (1 + (Average positive price change / Average of negative price
Change))]

MA (Moving Average)
A moving average (MA) indicator is generally used for identifying the trend directions
along with support and resistance levels based on historic price movements. There are
two different versions of Moving Averages exist in which are described as

Simple Moving Average; this indicator is a simple average of a stock prices over a
pre-defined number of time periods,

Exponential Moving Average; It gives more weight age to more current prices of the
indexes.

Bollinger Bands
This technical indicator generally contains a center line and two price channels normally
called bands located above and below that central line. Central line is composed of
exponential moving average and the side bands are standard deviations of the selected
script. The price value of both bands increases or decreases depending of the price
change of stock script.
When the script continually touches/overlap the upper Bollinger Band, then it is
considered to be in overbought condition representing a selling indication, conversely
when it continually touches/overlap the lower standard deviation band it triggers a
strong selling signal.

Basic Assumption of Technical Analysis:


Price Movements can be forecasted:
Traders using technical analysis acknowledge there are some short periods in which the
prices of the stock scripts moves randomly but there are also some traceable patterns
periods in which the prices can be traced out to gain higher profit returns in the market.
By using efficient pricing parameters the movements of the prices can be traced out for
both short and long term trends.
Time Series Analysis:

Page | 8
Modern methods of time series forecasting are developed on the idea that past prices
movements can be explain about its future behavior
The approach of building a time series forecasting is to first specify a model. The model
used in forecasting generally composed of statistical formulation based on the dynamic
relationships between variables that we infer from (also known as information set) and
variables closely related to which we observe. The most common approach of time
series forecasting is derived from regression analysis. A regression model includes a
linear parametric relation between an explanatory variables set and dependent
variables.

ARIMA (p,d,q) forecasting equation

 Auto-Regressive Integrated Moving Average models are efficient class of models


used for forecasting time series data which can be transformed to be “stationary” by
differencing. A random variable is said to be stationary if the statistical properties of that
variable remains constant over the whole time series.  A series that is stationary in
nature has a negligible trend and the fluctuations around its mean have similar constant
amplitude and it squirm in a regular patterns i.e. its short term random patterns of time
always look similar. The stationary series Autocorrelation factor also remain constant
over that particular period of time and the power spectrum remain constant over the
entire series. A random variable composed of Autocorrelation factor and power
spectrum series and contains both signal and noise, the signal pattern could be fast or
slow reversion or a sinusoid oscillation or it could be a rapid alteration in sign containing
a seasonal component. ARIMA model is considered as “filter” that segregates the signal
from noise to gain valuable information for the future movements.

Auto Regressive (AR) part in ARIMA model represents a regressed variable having a
lagged values while the Moving Average (MA) variable represents a regression error of
its historic values. Integrated part (I) represents the data values after differencing
process of present and the historic values. The purpose of all these different variables is
to make the model efficient, precise and fit for the data as well as possible.

Non seasonal, random and non-cyclic ARIMA models are generally represented by
ARIMA (p,q,d) where p represents an order of the autoregressive model, d is actual
Page | 9
degree of differencing (it denotes the number of times the data values have been
subtracted from its past values) and q represents the order of moving averages in the
model. When two variables out of tree are zero the model is referred to be based on
non-zero parameters, example ARIMA (1, 0, 0) represents a model in which AR(1), I (0)
and MA(0).

Holt winter model:

Holt Winter model is generally referred to as a procedure rather than statistical tool, the
methodology was first proposed in the early 1960s. It is based on the methodology
termed as exponential smoothing. All data values in a series add to the calculation of
the prediction model.

Exponential smoothing is mostly used where the given data time series is mostly non-
seasonal, non-cyclic and containing a random pattern for analysis and it gives more
weight age to the recent and less weight to past values. This series is easily applicable
technique for creating determination of predications based upon the prior assumptions
of the users like seasonality. Exponential smoothing technique is used for calculations
and analysis of financial time series data and also in the field digital signal process.

This technique is used to smooth the distorted data series. The collection of data is
generally in a raw form then by applying this technique the data is converted in an
exploratory form for analysis of future values.

U.S. Bureau of Census X-11 developed initial ARIMA forecasting models known as X-
11 ARIMA and X-12 ARIMA to extract season and further cyclic components from a
given series by using method of iteration on finite moving average procedures. Later the
developments on these initial models improved its efficiency and general method of
extraction.
Kannan, Sekar, Sathik and P. Arumugam (2009) applied data mining techniques to
discover the hidden pattern of the historic data that have probable predictive ability to
earn higher profits in their investments decision. The prediction of stock market
performed by them mostly composed of time series forecasting methodology. The
parameters that they incorporated in their model were Typical Price (TP), Bollinger
Bands, Relative Strength Index (RSI), CMI and Moving Averages (MA) to analyze and

Page | 10
forecast the stock index. In their research paper they proposed a profitability signal of
84.24% using Bollinger Bands and other technical indicators.

ShunrongShen and Tongda(2007) performed stock market forecasting using machine


learning algorithms that deal with the intraday stock prediction using support vector
machines and ARIMA Forecasting models. The Numerical accuracy of their proposed
model was 74.4%` in NASDAQ, 76%in DJIA

The Box-Jenkins methodology for time series data modeling and forecasting is
considered to be eminent in the field of time series forecasting. Box-Jenkins
methodology is commonly known as "ARIMA" model, the acronym standing for
Autoregressive Integrated Moving Average. This terminology is made clear in the above
sections. Exponential smoothing, linear regression, Bayesian forecasting techniques
and generalized adaptive filtering are some of the other techniques which are termed
"extrapolative" estimating (Makridakis et al., 1982). Many of these methods are based
on a generalized element i.e. these methods utilize the past value numbers or series to
predict the future value movements of interest. These models are commonly known as
uni-variate models, since the values of variables used to predict the future values are
single variables like price, sales data and other such variables. On the other hand there
is another methodology called multivariate data models in which variable of interest is
having a strong correlation with the other dependent variables as well.

Taylor (2003) is considered to be a pioneer of double seasonal ARIMA forecasting


models those models were capable of capturing the two different seasonality
components. The methodology used by him in his research paper was based on
exponential smoothing models are popular for forecasting multivariable/multiple
seasonality components in an unknown forecasting series.

Taylor uses the exponential smoothing for forecasting the half hourly electric demand
rate in England and Whales using four different methods. He uses Holt Winter model for
within day seasonality forecast along with the within week seasonality, double Holt
winter model and double ARIMA model. In ARIMA Forecasting he fitted an
autoregressive model to calculate the residual part and to deal with the auto correlated
errors. The results of the proposed research were in line with the objective and he
proposed that the double seasonal Holt Winter model with AR(1) outperform the ARIMA

Page | 11
seasonal model. He also uses the multiplicative version of double seasonal HW model
in which the seasonality is calculated by smoothing ratio of observed values to product
of local levels and local seasonal index. He also incorporated the level equation align
with the series seasonality. The method proposed by him in his research report is still
famous and common, and is implemented where the seasonal variations increases
along the mean values of the series.

Hyndman and Athanasopoulos (2012) explained another formulation that involves


additive seasonality component. In their proposed method the series is adjusted
seasonally by differencing the seasonality in the level equation and then analyzed by
smoothing the difference between the observed values, trends and their local level of
means. This additive version is used where the seasonal fluctuations are mostly
constant throughout the series because the same case methodology was proposed by
Taylor in his research of electricity demand forecasting where he used the double
seasonal Holt Winter model and ARIMA forecasting technique.

Several other researchers used exponential smoothing constant in their researches to


analyze the future values one such complex seasonality model was used by De Livera
and Snyder (2010) in which these both statisticians handle non-integer periodic, high
volatile multiple seasonal patterns and their effects on calendar years.

Another eminent research in forecasting field is carried by Hyndman et al. (2008) that
designed Holt-Winters and the double seasonal Holt-Winters methods for demonstrating
hourly data for both utility loads and traffic flows. In his research report he introduce a
new multiple seasonal process that allows storing the hourly pattern by implementing
different sub-cycles. A sub-cycle was introduce to generate the seasonal patterns from
Monday till Thursday and other sub cycle was used for recording parameters from
Friday till Sunday by introducing the double sub cycles he was able to reduce the initial
parameters that were to be used as input in his forecasting model and also generate a
much smaller forecasted output series that would be easily analyzed for future
purposes.

Page | 12
CHAPTER 3

RESEARCH METHODOLOGY

 Research Methodology and


 Purpose
 Hypothesis
 Evaluation Method
 Classification Percentage

Page | 13
RESEARCH METHODOLOGY

RESEARCH PURPOSE AND METHODOLOGY:

Research carried out for this project report segregated into two categories: Qualitative
and Quantitative research.

For qualitative research analysis surveys are taken into account to provide an in depth
analysis of general trading insights of traders investing in Pakistan Stock Exchange.
Contrary to this the qualitative research performed in this research project is subjective
and here interviews have been conducted from the field experts and a trading software
platform has been designed beating the conventional buy-and-hold strategy.

Secondary research has been performed to analyze the current stock market condition
and to determine the crucial factors that play vital role in short term trading in Pakistan
Stock Exchange. The data used for this secondary research was quantitative.

For primary research of the report both research and hypothesis methodology has been
adopted in order to provide optimum results to the novice traders so that they can make
greater profit returns rather than conventional buy-and-hold strategy.

Respondents:

The respondents identified for this research project were investors, financial acumen
business graduates, subject experts from big data and Pakistan stock exchange
brokers.

SECONDARY RESEARCH DATA:

The first step in performing a hypothesis based research project was to determine the
factors which the traders take into account while performing trading in Stock market.

A thorough research has been conducted to analyze the pattern and behavioral finance
phycology of the investors. The data reveled that main barrier to entry in the stock
market is the fear of loss of hard earned investment due to market volatility and
instability.

PRIMARY RESEARCH DATA:

The purpose of primary research was to analyze the recent trading styles of individuals
to analyze their trading patterns and also to create an automated trading platform which
Page | 14
could efficiently outperform the conventional buy-and-hold strategy and could reduce
the risk involved in conventional trading. Besides this the strategy should also be
effective for any market securities, provided a sufficient amount of historical data.

Sampling Size and Method: The sampling method used for the research report was
“convenience sampling method” which is a non-probability sampling method. This
technique was implemented because it was easier to identify target sample and is a
least expensive method. In this method, the researcher could add or delete the sample
based on accessibility and availability of data.

The sample size used for the questionnaires was 140.

Hypothesis:
Historic price movements give the insights of future market directions. The combination
of different trading strategies such as technical indicators and time series forecasting
can help traders in gaining higher returns than the conventional buy-and-hold strategies.
Evaluation method:
To evaluate this hypothesis, a mechanized trading system will be designed using a
platform of R Studio. This efficient system will be able to take inputs from the historical
database of PSX along with the Min price, Max Price, Closing Price and total volume
trade specified along each date. The system will provide different algorithms and
techniques to forecast the future pricing. In this research hypothesis we are using two
main forecasting models ARIMA and Holt Winter model. Another methodology specifies
the uses technical indicators available for calculating the future price movements and
this hypothesis will also incorporate the mostly use technical indicators like RSI, MA,
EMA to calculate the forecasted prices.

Data Presentation: The data presentation was made using the following forms:

1. Line Graph
2. Pie Charts
3. Tables

Tools: The tools used for analysis were Google Form (Online) and MS Excel.

ETHICAL CONSIDERATION:

It was important to obey the ethical norms of the research participants to conduct
Page | 15
this study. The general considerations adapted for this research were:

 Voluntary Participation: All the participants were requested to participate


voluntarily for this research report.
 Anonymity and Harm: Research questionnaire were made anonymous and did
not pose any harm towards the physical, mental and emotional harm to research
participants.

Page | 16
FLOW CHART:

Project Analysis

Data Req. and Collection

Data Wrangling
Time Series Model
ARIMA, Holt Winter Model

Data Preparation

Technical Indicators:
RSI, MACD, SMA, BB
Data Modeling

No

No
Evaluation

Yes Modification of Model

Deployment

Feedback

Figure 1: Flowchart of the Research Report

Page | 17
CHAPTER 4

REVIEW OF CEMENT INDUSTRIES OF


PAKISTAN

 Pakistan Construction industry outlook


 Future Prospects of Cement industry
 Top Cement companies on PSX and their financial
performance

Page | 18
Review of Cement industries of Pakistan
Manufacturing sector of country add up to the second largest sector in Pakistan’s
economy contributing 13.5% to GDP and thus generating the biggest number of
industrial career opportunities through technology transfer. Cement industry particularly
in manufacturing sector is Pakistan’s one of most flourishing industry in past few years
and will continue to boom in future due to thriving construction industry and a very high
demand for residential and commercial development within the major cities of the
country. The year 2015 was a very progressive year for Pakistan’s cement industry. The
local demand for the cement increases by 12.5% in one year and also the big four
market players (Attock, D.G Khan, Lucky and Cherat cement) announced their
extension in production capacity to cater the needs of the local industry.

In manufacturing the role of APCMA – All Pakistan Cement Manufacturing Association


is impressive where the association is continually upgrading the whole cement sector in
this challenging economic environment. The capacity utilization till this July stood at
impressive 87% as compared to that of 61% of previous year. According to APCMA, the
sale of cement in Pakistan increased by 16.5 percent in the last four months of the 2017
fiscal year. This increase in consumption comes despite the prices hitting an all-time
high in Pakistan, averaging at almost double that of its neighboring countries. 

In the recent years the growth of consumption of cement has been incremented in both
the commercial as well as residential sectors due to the heavy developments. Many
new luxury gated residential housing schemes have been launched in recent years
across the country.

Future Outlook:
 During the current year, the cement sector registers a net escalation of 7% as
compared to same period last year. The local dispatches increased by 17%. The
average capacity Utilization of industry was recorded at 85% as compared to
78% during the last year. In the market of south, during the year, the local
dispatches witnessed a phenomenal growth of 25%. Keeping in view the fast
improvement in law and order situation in Karachi, it is anticipated that there will
be further acceleration in cement demand in the market of South in months to
come.
Page | 19
 Pakistan’s construction market is fastest growing in Asia and is predicted to grow
at an average of 12% per annum for next five years the main reason for the
accelerated growth is China-Pakistan Economic Corridor (CPEC) mega projects.
 Reduced interest rates and overall improved law order situation in the country
would increase the investments in country’s housing and infrastructure.
 Five years anti-dumping duty imposition in South Africa and Iraq affects the sales
of the company due to which the company open its routes to Middle Eastern
market as well as in Syria, Srilanka.
 The upward surge in cement demand and higher margins in very encouraging
and paving the way for further investment in the sector both in terms of capacity
expansion and in process improvements.

CEMENT INDUSTRIES OF PAKISTAN ACCORDING TO THEIR CONSUMPTION

Cement Production capacity as on 1 January 2018


4%
5%

5%
 Askari Cement Limited - Nizampur 
30%  Attock Cement Pakistan - Hub Chowki,
Lasbela
 Dewan Cement Limited - Dhabeji
 D.G.Khan Cement Limited
12%
 Fauji Cement Company Limited - Fateh
Jang 
 Kohat Cement Company Limited - Kohat 
 Lucky Cement Limited
 Maple Leaf Cement Factory Limited -
Daudkhel
 Pioneer Cement Limited - Khushab 
10% Others
6%

10% 8%

11%

Figure 2: Cement Production according to APCMA

Page | 20
TOP CEMENT COMPANIES LISTED ON PSX:

1). D.G. CEMENT COMPANY (D.G.KHAN):

D.G.Khan is one of the top list manufacturers of cement in Pakistan. It has a capacity of
producing 14000 tons of cement per day. All the three plants are equipped with latest
dry technology. Two plants are located at Dera Ghazi khan, one at khairpurDistrict
Chakwal and one is in commissioning phase in Sakran, Baluchistan. Its high quality
cement production and competitive rates makes it a better choice for the mega projects
both in local as well as international market. It is listed on Pakistan stock exchange with
a symbol of DGKC and a current share price of Rs. 148.

Financial performance:

During the past nine months ended March 31, 2017, D.G.’s clinker production raised by
12% and cement production grew by 8%. The financial reports of the company also
depicts that the local dispatch soared by 11% and exports fell by 9%. The overall clinker
production utilization of the company is 106% and cement production utilization is
108%. The overall domestic sales of cement comprise of 87% of the total sales and
export constitutes 13%. The gross profit for the running year and three quarters rose by
3.5% but a sharp decline of 15% is observed in Q3 which is attributed to overall higher
prices of coal due to increased import duties.

2). LUCKY CEMENT COMPANY (LUCKY)

Lucky cement is the biggest cement production company of Pakistan and is responsible
for the contribution of 30% cement production of Pakistan. Lucky comprises of six major
running plants having a production capacity of 7.75 tons/annum and also four of its
plants are in commissioning phase. Lucky Cement is famous for the production of its
largest cement quantity both in local as well as international market segments. The
company possesses ISO 9001:2008 and 14001:2004 certificates. It is listed on Pakistan
stock exchange with a symbol of LUCK and a current share price of Rs. 580.

Financial performance:

Page | 21
During the first quarter of fiscal year 2017-18 the gross profit margin decreased by 7%
however the net profit for the first quarter has been highest among all the cement
sectors Rs. 3700.8 Million the overall growth of the company is healthy with new
projects in pipeline (Brownfield expansion, Fully integrated Cement plant in Punjab,
Investments in coal based power plants, investments in Kia Lucky Motors Pakistan)
which will be inaugurated in starting months of the company thus adding more revenues
for the company.

3). ATTOCK CEMENT COMPANY (ATTOCK CEMENT):

Attock Cement was a gift of General Zia to the local people of Baluchistan due to the
province high illiteracy and unemployment rate. Company started its manufacturing from
1988 right from the beginning Attock Cement has prospered through its rich mineral
quality and steadfast growth in the last 25 years. In addition to the hard work, it has
boosted its efficiency through persistent modernization of the plant. Company has been
a part of various prominent private and semi government schemes. The company has
attained higher criteria in local and regional markets by providing quality products. It is
listed on Pakistan stock exchange with a symbol of ACPL and a current share price of
Rs. 178.

Financial performance:

Overall sales of the ATTOCK CEMENT for the first quarter as compare to same time
frame of previous year had been increased by 7% mainly due to the high local
consumption of cement due to accelerated housing society’s development. Overall
production cost has been increased due to high coal prices but the profits increased
relatively due to high sales in first quarter. The company registered a net profit after tax
Rs. 605 million which is 6% lower than the same period of last year.

4). MAPLE LEAF CEMENT:

Maple leaf is the third biggest cement factory formed as an alliance with West Pakistan
and Canadian government. There are two different production segments of the factory;

Page | 22
gray cement and white cement the manufacturing unit is located at Daudkhel District
Mianwali a rich area of minerals required of cement manufacturing.

5). KOHAT CEMENT LIMITED:

Kohat cement established in 1980 in kohat region located 60 kilometers from Peshawar.
The production facility is producing two products white and gray cement. Production
capacity of gray cement is approximately 2.6 tons/annum and white cement is
0.1tons/annum. The cement is not only consumed locally but also exported to
neighboring countries like Afghanistan and India.

7) DEEWAN CEMENT:

It holds an ISO 9001:2008  certificate. Plant consist of two production lines located at
Karachi (est. 1982) and Hattar (est. 1995) having a production capacity of 5800
tons/day and 3800 tons/day respectively.Deewan cement has always sustained its
excellent quality and has attained a big name in the cement sector

8). FAUJI CEMENT:

Fauji Cement was established In Rawalpindi in year 1992 since past 19 years it has
played a vital role in the economic sustainability and development as most of the
government projects in Pakistan are built using Fauji cement so this cement plant has a
very crucial role in the economic prosperity of the country.

The companies which are included in this research report for analysis are Attock
Cement, Lucky Cement and D.G. Cement

Page | 23
CHAPTER 5

DATA ANALYSIS AND DESIGN

 Data Analysis of cement sector of Pakistan


 Data Design of selected stock companies of PSX
 Model Development and Forecasting using ARIMA
 Model Development and Forecasting using Holt Winter
 Technical Indicators Forecasting Model

Page | 24
DATA ANALYSIS

The secondary research data analysis had been performed by collecting the data from
the PSX website for past 10 years and performed the statistical computations in order to
determine the future pricing of the recommended scripts. The main purpose of this
analysis was to answer the following research questions:

Q2) Produce effective patterns from past data for analysis.

QUALITATIVE ANALYSIS OF INTERTVIEWS:

Qualitative research was conducted through in-depth interviews with two (02) subject
experts belonging to Big Data and Stock market field. The purpose of this primary
research was to identify research question no. 1 and 4 to analyze the future growth
prospects of the cement sector and how implementing the big data tools and business
analytics can help us in forecasting the future stock prices with reduced errors.

The analysis of unstructured interviews is as follows:

The details along with key points discussed during the in-depth interviews are
summarized as follows:

INTERVIEW NO. 01:

Designation: Chief Strategy Officer EFU Life Insurance

The key points of interview no. 1 are as follows:

 The growth of big data driven tools are currently being used worldwide in order to
expand the business opportunities and Pakistan should also accept this
technology at a broader platform. Currently many multinationals in Pakistan are
implementing these tools but the magnitude of this technology is only at very low
scale which should be expanded.
 The scope of business analytics tools would be substantial in our financial
security markets because its impact will be very high and results can be achieve
very quickly. Currently many novice and seasoned investors are not even using
conventional technical analysis but implementing this tool can widen the broader
prospects of our stock markets.

Page | 25
 We can aid our stock exchange by using business analytics this could bring more
efficiency and transparency in day to day transactions. Also gives us better
insights in less time. It will also provide easiness in predicting future performance
of scripts and markets which could eventually bring stability in the market.
 By implementing business intelligence forecasting methodologies novice traders
will no longer trade blindly; rather they will make cognitive decisions based on
Business Intelligence results.
 Most of the new stock market traders mostly rely on their broker’s suggestions by
using such technology they can independently perform their trading decisions so
this new technology will definitely bring more stability and surplus in the market
size.
 Using Business Analytics stock performance can be evaluated on short and long
term basis with higher accuracy. Using these tools the traders can make portfolio
more efficient and profitable and can forecast the bad performing scripts and can
easily curtail our future losses.

INTERVIEW NO. 02:

Designation: Assistant Vice President Arif Habib LTD

The key insights of this interview are as follows:

 Pakistan Stock Exchange is highly speculative and influenced by political


movements of the country, recently there have been many ups and downs in
government these factors largely influence our traders.
In recent months there has been a 20-25% recovery in cement sector share
prices due to a high potential in this sector. In next three years many cement
manufacturers will double their production capacity new projects are in pipe line
like D.G Khan has announced its fourth line of production, power cement has
been purchased by pioneer cement, Fecto cement has announced its new
production line. Besides this government has also issued 10-12 licenses to
various cement plants in mostly in Punjab and KPK areas. All the current cement
production plants are going for expansions to achieve economies of scales due

Page | 26
to larger production capacities they can get cheap labors, heavy machineries at
reduced cost and improving power consumption.
 The rumors and artificial political unrest are the main sources that derive our
stock markets. For example the D.G Khan Stock prices have been reduced to
half to its prices in past 4 months despite the fact the company has very good
financials and constantly showing increasing profits. There are no such fair value
evaluation agencies or companies that could evaluate the company’s
performance and post their performance independently. The scripts are mostly
monopolized by the political unrest of our country.
Government policies definitely impact the prices of the stock scripts. There are
many policies such as anti-dumping, import barriers, government bailout
packages and subsidies that affect the prices of the stock scripts.

Focus Group:
A focus group interviews had been carried out in order to find the main forces
shaping our stock markets and the potential risks involved for novice traders. The
focus group has been carried out by regress discussions and field experts of
Stock markets.
Findings of the focus group are summarized below:
The main determinants shaping our stock markets are:
 Interest rate
 Inflation
 Foreign direct investment
 Major government policies
 Currency rates
 Exchange rates
 Government stability
 Shareholders expectations

Through the focus group interviews the reasons of market instability are found
out to be:
 Political instability
 Big players monopoly
 Lack of market knowledge by investors
 Bank Interest rates
 Speculation

Page | 27
 Political changes
 Tax factors

Main barriers for entry of new entrants are found to be:


 Higher tax rates and transaction costs
 Lack of information about how market works
 Most worst experience of previous traders
 Bank profit rates and other government schemes
 Prize bonds
 Lack of depth

Major forces driving our stock markets are:


 CPEC
 OIL prices
 Other commodities
 Banks
 Panama Papers case which heavily impacted the stock market performance.

Future of big data in our stock market:


 Small investors might get unprotected
 Fair trading practices
 Entrance of new options and products in stock market
 Stock market will be more reliable and transparent

Based on the focus group findings it is clearly evident that our stock market is
weak efficient form of stock market and by using big data we can foster better
results and thus can eliminate the conventional buy-and-hold strategy.

QUANTITATIVE ANALYSIS OF SURVEY:

The findings were derived from the primary research based on collection of
questionnaire from beginners and seasoned stock traders. During the process of
data collection, total 149 questionnaires were collected. After omission of
incomplete and outlier questionnaire, analysis had been performed on 140
questionnaires (n= 140). (93.57% out of total collected).

Respondent Demographics: The Demographic factors in the survey were


divided into age, gender, qualification, monthly income, and occupation.

Page | 28
The age distribution (Figure 3) shows that 32.9% respondents aged between 30
to 40 years, 27.1% respondents aged between 40 to 50 years and 24.3%
respondents aged between 20 to 30 years.

Figure 3: Age group of respondents

The second demographic factor was gender. The gender of the survey was
divided into 79.3% male (n = 111) and 20.7% female (n=29). This imbalance is
mainly due to lower percentage of working women which accounts for only
20.7%

Figure 4: Gender of respondents

The qualification of our sample showed that 45% respondents had Master’s
degree or Above and 43.6% respondents had a Bachelor’s degree (Figure 5).

Page | 29
Although it does not represent the actual literacy rate of Pakistan but it terms of
air travel, it can be justified that low educated are less likely to travel by air.

Figure 5: Qualification of respondents


The income range of the sample (Table 1) showed that majority 43.9%
Respondents had income range between Rs. 100,000 to Rs. 250,000 per month,
while 37.4% respondents had income range between Rs. 50,000 to Rs. 100,000
per month.

Table 1. Income Range of respondents


Income Range No. Of respondents Percentage

Less than Rs, 50,000 14 10.1%


Between Rs. 50,000 and 52 37.4%
Rs. 100,000
Between Rs. 100,000 to 61 43.9%
Rs. 250,000
Between Rs. 250,000 to 8 5.8%
Rs. 500,000
Above Rs 500,000 4 2.9%

The common occupations (Figure 6) included salaried employees (62.6%) while


second largest group was self-employed (23 %).

Page | 30
Figure 6: Occupation of respondents

The most common behavior which was observed during the survey was that majority of
the beginners and inexperienced traders do not trade frequently due to the fear of loss
of investment. There are many other factors also but this one is the most crucial which
proves to be barrier while trading in stock market.

Figure 7: Entry barriers for novice traders

It is observed that Oil and Gas and Cement sector is considered to be most reliable
sector in Stock market.

Page | 31
Figure 8: Sector with highest potential return

A common phenomenon observed that most of the traders perform on simple


fundamental analysis and mostly rely on their broker’s advice while selecting and
trading stocks in Pakistan Stock Exchange.

Figure 9: Trading methods of respondents

A large majority of respondents trading in stock market consider themselves as long


term investors and wants a long term returns on their principal amount.

Page | 32
Figure 10: Trading strategy of respondents

Respondents were very much concerned about the current market volatility and
fluctuations and want a better trading methodology which could reduce the fear of loss
on investment.

Figure 11: Concern related to recent market volatility

Majority of the respondents trading in stock market have not heard of big data and data
analytics tools which are currently available in markets due to the lack of awareness
and usage only at a very limited scale.

Page | 33
Figure 12: Knowledge of Big data tools for Stock market

Majority of the respondents currently trading are willing to accept to trade using
Business Analytics and BI tools.

Figure 13: Respondents on using any business intelligence tools in PSX

DATA DESIGN

After performing the data analysis the next phase includes the data design methodology
used in developing stock price predictive model in line with the research questions and
objectives of the study. Programming platform used for this project is R Studio which is
a free and open source integrated development environment (IDE) for R, a
programming software for statistical analysis, computing and graphical depiction. The
programming has been designed to be flexible thus allowing users to change the stock
scripts according to their needs. The model is programmed to explore the ways of
classification percentage and gaining maximum strategy profits rather than conventional
buy and hold strategy.

The procedures and processes of the two different forecasting techniques used in this
research project are explicitly explained in the literature review section. The statistical
Page | 34
technique employed in this regard is the Auto Regressive Integrated Moving Average
(ARIMA) model. It is widely regarded as one of the most efficient forecasting technique,
and is used extensively especially for time series forecasting. The soft computing
technique used in for this research report is Holt Winter (HW) Model. This model is
explained in literature to have increasingly gained popularity due to its intrinsic
capabilities to approximate any nonlinear function to a high degree of accuracy. Holt
Winter is less sensitive to errors and can tolerate noise and chaotic components with
higher degree of accuracy.

Data Collection:

The historical stock data of three cement companies used in this study were sourced
from the Pakistan Stock Exchange (PSX).The data available on database is from 2004
but for analysis purposes the data of past 5 years (from January 1, 2012 to January 15,
2018) has been imported into our model. The companies incorporated in the forecasting
model are ATTOCK CEMENT, LUCKY and D.G.KHAN the performance
measure/evaluation was done using RMSE and MSE and MAPE in order to determine
the accuracy of the output results of each developed model.

Time Series Forecasting Models:


Model Development and Forecasting- ARIMA Model
The data imported from PSX database consists of six different parameters of the index,
namely: open price, low price, high price and close price respectively. The open price is
the opening price of the index at the start of a trading day, the low price is the minimum
price of the index during the day, high price represents the maximum price of the index
during the trading day, and closing price indicates the price of the stock index when the
market closes. In this research the closing price is chosen because it reflects all the
activities of the index in a day. Procedural steps represented in flow chart attaining to
obtain the forecasted results.

Start
Page | 35

d=0
Yes

No

Figure 14: ARIMA Forecasting Flowchart

ARIMA Forecasting for ATTOCK CEMENT:


The ATTOCK CEMENT stock data used in this research covers the period from January
1, 2012 to January 15, 2018 comprising of 1452 observations. Figure 15 depicts the
Page | 36
original pattern of the time series of the index in order to get a generalize idea of the
movement of the prices during past five years.

Figure 15: Close Price Index of Attock Cement Script

Graph of close price displays the non-seasonal, non-stationary, non-repetitive blueprint


thus depicting a random walk pattern.

In order to check the movement of the above time series correlogram technique is used,
correlogram technique is a common tool for inspection of randomness in a given data
set. In this case this methodology is adopted to check the randomness factor of Attock
cement close price script. If the data is nonrandom then the Autocorrelation factor of the
series would be substantially a non-zero factor. Here I have used an inbuilt function
provided in R Studio

Figure 16. is the ACF and residue of noises left over of the ATTOCK CEMENT script
Close price and the ACF function depicted by remainder graph dies out extremely
slowly thus making it a non-stationary series desirable for ARIMA forecasting.

Page | 37
Now the first step for forecasting require stationary mean of the close price for that
differencing technique is used to obtain the stationary observation from the non-
stationary mean.

Figure 16: ARIMA Filtering and ACF residue

The first step in analyzing the series of Attock cement is the application of Augmented
Dickey-fuller (ADF) unit root test this test is carried to check the unit root of the series
sample it tells about the randomness of the data variable in the complex data series.
The Augmented Dickey-Fuller (ADF) unit root test applied on ATTOCK CEMENT stock
script also confirms that the first-difference of the series becomes stationary.
In order to construct the best ARIMA model for ATTOCK CEMENT stock index.
The next procedural step is to determine how many autoregressive (p) and moving
average (q) parameters/variables are essential in producing an effective model.
The following criteria are used in this study to determine the best model as follows:

Page | 38
 Comparatively small value of BIC (Bayesian or Schwarz Information Criterion
which is calculated by nlog(SEE) + klog(n))
 Moderately small values of SEE (Standrad Error of regression)
 Comparatively higher value of adjusted R^2

Table 02: ARIMA Model Parameter Values

ARIMA BIC Adjusted R^2 SEE


(1,0,0) 5.394 0.991 3.582
(1,0,1) 5.396 0.991 3.581
(2,0,0) 6.106 0.981 5.116
(1,1,0) 5.356 0.002 3.585
(1,1,2) 5.394 0.004 3.5805
(2,0,1) 5.393 0.003 3.581
(2,1,0) 5.396 0.003 3.581

Table 2 shows the different parameters of autoregressive (p) and moving average (q) in
the ARIMA model. ARIMA (2, 1, 0) is the best for ATTOCK CEMENT stock index

Results of ARIMA Forecasting:

Figure 17: ARIMA Forecasting of Attock Script

Page | 39
In order to calculate the accuracy of forecasted error values MAPE (Mean Absolute
Percentage Error) technique is implemented. The results of MAPE for Attock Cement
script are 6.42 representing a deviation of 6.42% deviation in the error accuracy results.

Result analysis using Excel:


An alternate approach is also used for calculating the forecasted results using MS
Excel. The primary purpose of this calculation was to re assess the forecasted results
so that any discrepancy could be eliminated in its initial phase.

ARIMA Time Series model forecasting

Actual Values
T1 95%
Forecaste (Original Data values Forecasted
Date Confidence T3 95& CI
d Value for the forecasted Error
Interval
periods)
1/1/2018 167 175 201 176.98 1%
1/2/2018 165 181 203 177 -2%
1/3/2018 162 179 207 176.86 -1%
1/6/2018 159 177 209 176.03 -1%
1/7/2018 157 179 210 176.99 -1%
1/8/2018 150 175 211 173.6 -1%
1/9/2018 147 167 211 176.5 6%
1/10/201
143 172 209 177.53 3%
8
1/13/201
140 177 215 185 5%
8
1/14/201
136 172 220 176.06 2%
8
1/15/201
131 175 227 177.25 1%
8
1/16/201
127 173 235 177 2%
8
           
           
        Forecasted Error 1%

Figure 18: ARIMA Forecasting in EXCEL

Page | 40
Results of Forecasted ARIMA Model along with 95% Confidence Interval have been
calculated using MS EXCEL and compare it with the actual script values from PSX
website to calculate the forecasted error numerically.
ARIMA Forecasted error for Attock script is 1%.

ARIMA FORECASTING
190

185

180

175
Price Index

170

165

160

155
1 2 3 4 5 6 7 8 9 10 11 12

Figure 19: Line graph of Actual and Forecasted Values

MODEL DEVELOPMENT AND FORECASTING - HOLT WINTER MODEL

The data used for Exponential smoothing (Holt Winter Model) on ATTOCK CEMENT
script comprises of 1452 observations from 1 Jan 2012 to January15, 2018. The data of
ATTOCK CEMENT script is no seasonal, non-cyclic or repetitive thus making is
desirable for Holt Winter forecasting.

Page | 41
Figure 20: Closing Price of ATTOCK CEMENT Data Index

Result analysis:

Page | 42
Figure 21: Holt Winter Forecasting on Attock Cement Script

Holt Winter filtering output results of ATTOCK CEMENT scripts shows the inter day
forecasted results as represented by the red output line while the blue lines shows the
95% confidence interval within the forecasted data range. The forecasted results show
a rising trend in which is a healthy sign for the novice investors trading in this script.
Similar MAPE technique is used in order to calculate the percentage accuracy of error
forecasted values and the MAPE in Holt Winter Model case is calculated as 7.2
representing a deviation of 7.2% from the actual forecasted results.

Result analysis using Excel:


Using similar alternate approach as done in ARIMA forecasting is performed on the Holt
Winter model to calculate the efficiency of the forecasted model us MS EXCEL.

Page | 43
Holt winter Model Series forecasting
Actual Values
T1 95%
Forecaste (Original Data values Forecasted
Date Confidence T3 95& CI
d Value for the forecasted Error
Interval
periods)
1/1/2018 163 163 207 176.98 9%
1/2/2018 161 165 209 177 7%
1/3/2018 160 169 216 176.86 5%
1/6/2018 157 175 221 176.03 1%
1/7/2018 155 169 227 176.99 5%
1/8/2018 150 172 232 173.6 1%
1/9/2018 154 177 235 176.5 0%
1/10/201
152 177 240 177.53 0%
8
1/13/201
148 179 246 185 3%
8
1/14/201
145 175 248 176.06 1%
8
1/15/201
139 172 251 177.25 3%
8
1/16/201
137 174 253 177 2%
8
           
           
        Forecasted Error 3%

Figure 22: Holt Winter Error Forecasting using MS EXCEL

Forecasted values of ATTOCK CEMENT have been calculated using the Holt Winter
Model forecasted graph provided above along with their 95% confidence intervals. And
the actual script values of the same day have been used from PSX website so that the
forecasted error percentage could be calculated.
Holt Winter Forecasted error for Attock Cement script is 3%.

Page | 44
HOLT WINTER MODEL
190

185

180

175
Price Index

170

165

160

155

150
1 2 3 4 5 6 7 8 9 10 11 12

Figure 23: Holt Winter forecasted and Actual Values

ARIMA Forecasting for LUCKY:


January
Similarly, the Lucky Cement stock data used in this study covers the period from 1,
2012 to January 15, 2018 having a total number of 1452 observations. Figure 24
depicts the original pattern of the time series of the index in order to get a general
overview whether the time series is stationary or not. From the graph below the time
series is likely to have random walk pattern.

Page | 45
Figure 24: Close price of Lucky Cement for Past five years

Page | 46
Time Series graph of Lucky cement stock script clearly depicts a non-stationary trend
due to slowing dying out factor of Auto Correlation Function with respect to time similar
to trend found in Attock Cement graph besides this the closing price graph also tells
having no certain impact of seasonality on the pricing trend of Cement Scripts.

Figure 25: ARIMA Filtering and ACF residue

First test performed on LUCKY data’s ‘CLOSE PRICE’ was Augmented Dickey-Fuller
(ADF) unit root test confirms that the first-difference of the series becomes stationary.
Q-statistics of the given data sets show that there is no significant pattern left in the
ACFs and PACFs of the residuals, it means the residual of the selected model are white
noise as depicted in figure 25.
Next step in preparing the ARIMA model was to calculate auto regression (p) and
moving average (q) parameters. The same criteria as used in Attock CEMENT script
was applied here.

Page | 47
 Comparatively small value of BIC (Bayesian or Schwarz Information Criterion
which is calculated by nlog(SEE) + klog(n))
 Moderately small values of SEE (Standrad Error of regression)
 Comparatively higher value of adjusted R^2

Table 03: ARIMA Model Parameter Values

ARIMA BIC Adjusted R^2 SEE


(1,0,0) 5.394 0.991 3.582
(1,0,1) 5.396 0.991 3.581
(2,0,0) 6.106 0.981 5.116
(1,1,0) 5.356 0.002 3.585
(1,1,2) 5.394 0.004 3.5805
(2,0,1) 5.393 0.003 3.581
(2,1,0) 5.396 0.003 3.581

Table 3 shows the different parameters of autoregressive (p) and moving average (q) in
the ARIMA model. ARIMA (2, 1, 0) is the best for Lucky Cement stock script.

Results of ARIMA Forecasting:

Figure 26: ARIMA Forecasting on Lucky Cement Script

Page | 48
In order to calculate the accuracy of forecasted error values MAPE (Mean Absolute
Percentage Error) technique is implemented. The results of MAPE for Lucky Cement
script are 8.1 representing a deviation of 8.1% deviation in the error accuracy results.

Result analysis using Excel:


Similar alternate approach is also used for calculating the forecasted results using MS
Excel. The primary purpose of this calculation was to re assess the forecasted results
so that any discrepancy could be eliminated in its initial phase.

ARIMA Time Series model forecasting

Actual Values
T1 95%
Forecaste (Original Data values Forecasted
Date Confidence T3 95& CI
d Value for the forecasted Error
Interval
periods)
1/1/2018 480 500 520 502.9 1%
1/2/2018 475 510 529 499.76 -2%
1/3/2018 470 51 534 510.36 0%
1/6/2018 462 498 540 511.55 3%
1/7/2018 450 495 547 517.13 4%
1/8/2018 442 505 555 531.84 5%
1/9/2018 437 510 561 531.74 4%
1/10/2018 426 515 575 514.83 0%
1/13/2018 415 517 586 514.51 0%
1/14/2018 407 519 600 516.05 -1%
1/15/2018 392 519 610 517.8 0%
1/16/2018 375 520 625 517.73 0%
           
           
        Forecasted Error 1%

Figure 27: ARIMA Forecasting in EXCEL

Results of Forecasted ARIMA Model along with 95% Confidence Interval have been
calculated using MS EXCEL and compare it with the actual script values from PSX
website to calculate the forecasted error numerically.
ARIMA Forecasted error for D.G. script is 1%.

Page | 49
ARIMA FORECASTING
540

530

520

510
Price Index

500

490

480

470
1 2 3 4 5 6 7 8 9 10 11 12

Figure 28:Lucky Cement ARIMA Forecasting

Holt Winter Forecasting for LUCKY:

The data used for Exponential smoothing on LUCKY script comprises of 1452
observations from January 1, 201 to January 15, 2018. The data of LUCKY script is no
seasonal, non-cyclic or repetitive thus making is desirable for Holt Winter forecasting.

Page | 50
Figure 29: Price Index of past five years

Result analysis:

Page | 51
Figure 30: Holt Winter Filtering and Forecasting on Lucky Script

Holt Winter filtering output results of LUCKY scripts shows the inter day forecasted
results as represented by the red output line while the blue lines shows the 95%
confidence interval within the forecasted data range. The forecasted results show a
rising trend in which is a healthy sign for the novice investors trading in this script.
MAPE technique is used in order to calculate the percentage accuracy of error
forecasted values and the MAPE in Holt Winter Model case is calculated as 6.5
representing a deviation of 6.5% from the actual forecasted results.

Result analysis using Excel:


Using similar alternate approach as done in ARIMA forecasting is performed on the Holt
Winter model to calculate the efficiency of the forecasted model us MS EXCEL.

Holt winter Model Series forecasting


Actual Values
T1 95%
Forecaste (Original Data values Forecasted
Date Confidence T3 95& CI
d Value for the forecasted Error
Interval
periods)
1/1/2018 520 520 530 502.9 -3%
1/2/2018 511 525 539 499.76 -5%
1/3/2018 502 530 547 510.36 -4%
1/6/2018 494 525 560 511.55 -3%
1/7/2018 486 531 570 517.13 -3%
1/8/2018 480 534 582 531.84 0%
1/9/2018 470 537 591 531.74 -1%
1/10/2018 462 538 603 514.83 -4%
1/13/2018 450 535 615 514.51 -4%
1/14/2018 444 538 623 516.05 -4%
1/15/2018 440 530 630 517.8 -2%
1/16/2018 435 540 640 517.73 -4%
           
           
        Forecasted Error -3%

Figure 31: Holt Winter Forecasting in EXCEL

Page | 52
Forecasted values of LUCKY have been calculated using the Holt Winter Model
forecasted graph provided above along with their 95% confidence intervals. And the
actual script values of the same day have been used from PSX website so that the
forecasted error percentage could be calculated.
Holt Winter Forecasted error for Lucky Cement script is -3%.

HOLT WINTER MODEL


550

540

530

520
Price Index

510

500

490

480

470
1 2 3 4 5 6 7 8 9 10 11 12

Figure 32: HW Forecasting Lucky Script

Page | 53
ARIMA Forecasting for D.G.KHAN:

Data used for D.G.KHAN price forecasting covers the period from January 1, 2012 to
January 15, 2018 having a total number of 1452 observations. Figure 33 depicts an
overall generalize view of the price patter. From the figure it is clearly depicted that the
past data comprises of non-cyclic, non-seasonal random pattern.

Figure 33: Close Price Index of D.G. Cement for past five years

Page | 54
Time Series graph of D.G stock script clearly depicts a non-stationary trend due to
slowing dying out factor of Auto Correlation Function with respect to time similar to trend
found in Attock Cement graph besides this the closing price graph also tells having no
certain impact of seasonality on the pricing trend of Cement Scripts.

Figure 34: ARIMA Filtering and ACF residue

The Augmented Dickey-Fuller (ADF) unit root test applied on D.G. CEMENT stock script
also confirms that the first-difference of the series becomes stationary.
For designing fit data model for this script the next step is to determine how many
autoregressive (p) and moving average (q) parameters are necessary to give an
effective model.
Next step in preparing the ARIMA model was to calculate auto regression (p) and
moving average (q) parameters. The same criteria as used in previous stock scripts
were applied here.

Page | 55
 Comparatively small value of BIC (Bayesian or Schwarz Information Criterion
which is calculated by nlog(SEE) + klog(n))
 Moderately small values of SEE (Standard Error of regression)
 Comparatively higher value of adjusted R^2

Table 04: ARIMA Model Parameter Values

ARIMA BIC Adjusted R^2 SEE


(1,0,0) 5.394 0.991 3.582
(1,0,1) 5.396 0.991 3.581
(2,0,0) 6.106 0.981 5.116
(1,1,0) 5.356 0.002 3.585
(1,1,2) 5.394 0.004 3.5805
(2,0,1) 5.393 0.003 3.581
(2,1,0) 5.396 0.003 3.581

Table 4 shows the different parameters of autoregressive (p) and moving average (q) in
the ARIMA model. ARIMA (2, 1, 0) is the best for D.G. CEMENT stock index

Results of ARIMA Forecasting:

Figure 35: ARIMA Forecasting on D.G. Cement Script


Page | 56
In order to calculate the accuracy of forecasted error values MAPE (Mean Absolute
Percentage Error) technique is implemented. The results of MAPE for D.G. Cement
script are 1.07 representing a deviation of 1% deviation in the error accuracy results.

Result analysis using Excel:


Similar alternate approach is also used for calculating the forecasted results using MS
Excel. The primary purpose of this calculation was to re assess the forecasted results
so that any discrepancy could be eliminated in its initial phase.

ARIMA Time Series model forecasting

Actual Values
T1 95%
Forecaste (Original Data values Forecasted
Date Confidence T3 95& CI
d Value for the forecasted Error
Interval
periods)
1/1/2018 160 135 132 138.44 3%
1/2/2018 162 142 135 138.77 -2%
1/3/2018 165 137 115 142.08 4%
1/6/2018 164 141 112 142.02 1%
1/7/2018 170 139 119 140.66 1%
1/8/2018 171 143 117 142.76 0%
1/9/2018 172 139 115 145.92 5%
1/10/2018 173 137 11 142.51 4%
1/13/2018 175 138 119 141.31 2%
1/14/2018 177 140 107 140.92 1%
1/15/2018 180 137 105 140.24 2%
1/16/2018 182 140 103 139.67 0%
           
           
        Forecasted Error 2%

Figure 36: ARIMA Forecasting in EXCEL

Results of Forecasted ARIMA Model along with 95% Confidence Interval have been
calculated using MS EXCEL and compare it with the actual script values from PSX
website to calculate the forecasted error numerically.

Page | 57
ARIMA Forecasted error for D.G. script is 2%.

ARIMA FORECASTING
148

146

144

142

140
Price Index

138

136

134

132

130

128
1 2 3 4 5 6 7 8 9 10 11 12

Figure 37: Actual vs Forecasted Values

Holt Winter Forecasting for D.G.KHAN:

The data used for Exponential smoothing on D.G.KHAN script comprises of 1452
observations from January 1, 2012 to January 15, 2018. The data of D.G.KHAN script
contains non-cyclic random patterns and also does not contain any seasonal element
making it suitable for Holt Winter forecasting.

Page | 58
Figure 38: Close Price Index of D.G. Cement

Result analysis:

Page | 59
Figure 39: Holt Winter Filtering and Forecasting on D.G. Script

Holt Winter filtering output results of D.G.KHAN scripts shows the inter day forecasted
results as represented by the red output line while the blue lines shows the 95%
confidence interval within the forecasted data range. The forecasted results show a
rising trend in which is a healthy sign for the novice investors trading in this script.
MAPE technique is used in order to calculate the percentage accuracy of error
forecasted values and the MAPE in Holt Winter Model case is calculated as 14.67
representing a deviation of 14.67% from the actual forecasted results.

Result analysis using Excel:


Using similar alternate approach as done in ARIMA forecasting is performed on the Holt
Winter model to calculate the efficiency of the forecasted model us MS EXCEL.

Holt winter Model Series forecasting


Actual Values
T1 95%
Forecaste (Original Data values Forecasted
Date Confidence T3 95& CI
d Value for the forecasted Error
Interval
periods)
1/1/2018 140 137 142 138.44 1%
1/2/2018 135 141 145 138.77 -2%
1/3/2018 130 140 150 142.08 1%
1/6/2018 115 139 152 142.02 2%
1/7/2018 110 144 160 140.66 -2%
1/8/2018 115 146 165 142.76 -2%
1/9/2018 119 150 167 145.92 -3%
1/10/2018 117 146 170 142.51 -2%
1/13/2018 110 140 172 141.31 1%
1/14/2018 117 142 175 140.92 -1%
1/15/2018 115 144 171 140.24 -3%
1/16/2018 113 141 170 139.67 -1%
           
           
        Forecasted Error -1%
Figure 40: HW Forecasted and Actual value graph

Page | 60
Forecasted values of D.G.KHAN have been calculated using the Holt Winter Model
forecasted graph provided above along with their 95% confidence intervals. And the
actual script values of the same day have been used from PSX website so that the
forecasted error percentage could be calculated.
Holt Winter Forecasted error for D.G. script is -1%.

HOLT WINTER MODEL


155

150

145
Price Index

140

135

130
1 2 3 4 5 6 7 8 9 10 11 12

Figure 41: HW Forecasted and Actual value graph

TECHNICAL INDICATORS Forecasting Models:

The next part of the research project was to forecast the predictive model using
conventional technical indicators frequently used for short term trading. The technical
indicators used for the research report are RSI, Bollinger Bands and SMA. The data
imported from the PSX historical database has been appended to calculate indicators
as new columns to our input file so that it can be used for further analysis or trading
strategy prototyping in Excel and R Studio.

To calculate Technical Analysis with R an open-source library called “TTR” (Technical


Trading Rules) is used.

Page | 61
FLOW CHART FOR THE TECHNICAL ANALYSIS

START

READ STOCK
DATA

CALCULATE
VARIABLE

CALCULATE
INDICATOR VARIABLE

CREATE DATA INPUT


FRAME

DISPLAY
OUTPUT

STOP

Figure 42:Technical Indicators Flow Chart

Forecasting Model using Technical indicators:

ATTOCK CEMENT:
Page | 62
RSI on STOCK SCRIPTS:

In order to calculate Relative Strength Index of Attock cement RSI () function of R


Studio is used. Function is built in TTR library and generates the parameters
accordingly. It has two required parameters of the forecasted time series first data
variable for which Closing price index of the script is used and the second parameter is
inter value length of number of days n.

Here data parameter represents the ‘CLOSE’ column and integer Value n=14
represents that the spread selection represents 14 days on the close prices of ATTOCK
CEMENT Stock.

RSI on ATTOCK Cement


500

450

400

350

300

250 rsi14
STOCK INDEX

CLOSE
200

150

100

50

0
2 2 2 3 3 4 4 5 5 6 6 7 7
2 0 1 2 0 1 2 0 1 2 0 1 20 1 20 1 2 0 1 20 1 2 0 1 20 1 2 0 1 2 0 1 20 1
/ / / / / / / / / / / / /
10 22 11 23 /8 22 13 25 /8 19 /3 17 17
1/ 6/ 12 / 5/ 1 1 4 / 1 0 / 3 / 9 2 / 8 1/ 7 /

Figure 43: RSI on Attock Cement

Page | 63
The results of rsi-14 on ATTOCK CEMENT stock scripts clearly show an oversold
condition. During the initial months of the current fiscal year the stock price provides the
support resistance levels as it is in the range 50-60s but the later months proved to be
disastrous for the entire stock market and those shocks are easily represented in the
above chart as well as the rsi-14 is constantly under the range of 40 value representing
an oversold status.

BOLLINGER BANDS

To calculate Bollinger Bands indicator BBands() function of R Studio is used. BBands()


function is passed to data frame stream ‘data’ along with the query to use the values of
‘CLOSE’ column the second parameter ‘sd’ takes the number of standard deviations for
upper and lower bands.

In this research a 20 days moving average is used for the calculation. The output
generated of the Bollinger Bands contains several columns: ‘dn’ for lower band ‘mavg’
for the results of moving average ‘up’ for upper band along with pctB which is also an
important parameter to gauge script’s price relative to upper and lower band.

Bollinger Bands plot:

Figure 44: Bollinger Bands on Attock Cement

Page | 64
Forecasted results of Bollinger bands graph is composed of a center line (blue color)
which is located between two other lines (brown and purple). Blue line represent
exponential moving average which the other two lines depict the standard deviations of
upper and lower price bands. Graph of Bollinger bands composed of central line(blue
color) of exponential moving average is actively located between the upper and lower
price channels as depicted by brown and purple color.
In the above graph the blue exponential moving average is continuous along with the
lower band (brown line) during past few months representing an oversold condition
representing an oversold condition, triggering a strong selling signal.

Exponential Moving Average:

The next technical indicator that has been selected for technical analysis was EMA. In
this paper the EMA has been calculated using a 14 day period. The CLOSE price is
incorporated along with the Exponential moving Average to depict the flow of support
and resistance. The function is implied using TTR Library’s Function ‘EMA’.

400 Exponential Moving Average


350

300

250
STOCK INDEX

200
CL
OS
150 E

100

50

0
1/

/
7/

6/
1

1
12

12

11

11
1/

6/

6/

5/

5/

Page | 65
Figure 45: Exponential Moving Average on Attock Cement

The graph of EMA depicted above represents the flow of direction of the trend mostly
the moving average (MA) trend is used to determine the support and resistance level as
the graph is strong correlated with the historic price movements. The graph of ATTOCK
CEMENT script is representing a resistance support depicting the movement of trend in
the upward direction.

Result of technical indicators on ATTOCK CEMENT:

RSI, Bollinger Bands, and Simple Moving Average/Moving Average (MA) indicators
have been implanted on Attock Cement script and on the basis of these indicators the
recommendation for the Attock Cement Script is

The Script of Attock Cement is Bullish (downward) for a medium period of time.

Lucky Cement (LUCK):

RSI on STOCK SCRIPTS:

Same strategy was applied to calculate the relative strength on LUCKY stock. The
results of the RSI are depicted below.The Chart of RSI represents the following trend:

1200 RSI on LUCKY Data


1000

800
Script Index

600 CLO
SE

400

200

0
1/ 3/ 5/ 7 / 10 12 2/ 4/ 6/ 8 / 11 1 / 3/ 5/ 7/ 10 12 2 / 4/ 6/ 9/ 11 1 / 3 / 5/ 7/ 1 0 12 2 / 4 / 6 / 8/ 1 1

Page | 66
Figure 46: RSI on Lucky Cement

Figure 34 represents the results of rsi-14 days on Lucky stock scripts clearly shows an
oversold condition. During the initial months of the current fiscal year the stock price
provides the support resistance levels as it is in the range 50-60s but the later months
proved to be terrible for the entire stock market and those shocks are easily represented
in the above chart as well as the rsi-14 is constantly below 4 value which simply
represents the oversold status.

BOLLINGER BANDS

Similarly Bollinger bands are calculated using BBands() function in R Studio and
passing the data of ‘CLOSE’ column to ‘data.frame’ to calculate upper, lower band and
standard deviation.

Bollinger Bands plot:

Figure 47: Bollinger Bands on Lucky Cement

Page | 67
Forecasted results of Bollinger band graph generated in R Studio composed of a center
line (brown color) which is located between two other lines (purple and green). Brown
line represents exponential moving average which along with other two lines depicts the
standard deviations of upper and lower price bands.
In the above graph the brown exponential moving average is continuous along with the
lower band (green line) during past few months representing an oversold condition
representing an oversold condition, triggering a strong selling signal.

Simple Moving Average/Moving Average:

Moving average of the LUCKY Script is calculated using a 20-day Simple Moving
Average (SMA) of the CLOSE price column using TTR library’s R function “SMA”:

Exponential Moving Average


2500

2000

1500
Stock Index

ema1
4
1000 CLOS
E

500

0
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
/4/ /27 /20 /17 /11 /5/ /24 /19 /13 /7/ /29 /18 /20 /12 /3/ /24 /17 /10 /3/ /24 /18 /14 /2/ /25 /20 /11
1 3 6 9 12 3 5 8 1 1 2 4 7 10 1 4 6 9 12 3 5 8 11 2 4 7 1 0

Figure 48: Exponential Moving Average on Lucky Cement

Page | 68
The graph of MA depicted above represents the flow of direction of the trend mostly the
moving average (MA) trend is used to determine the support and resistance level as the
graph is strong correlated with the historic price movements. The graph of Lucky
CEMENT script is representing a resistance support depicting the movement of trend in
the upward direction.

Result of technical indicators on LUCKY:

RSI, Bollinger Bands, Simple Moving Average/Moving Average (MA) indicators have
been implanted on Lucky CEMENT script and on the basis of these indicators the
recommendation for the this Script is

The Script of Lucky Cement is Bullish (downward) for a medium period of time.

D.G. CEMENT (DGKC):

RSI on STOCK SCRIPTS:

To calculate RSI () function of R Studio is used. Function is built in TTR library and
generates the parametric values accordingly.

The Chart of RSI represents the following trend:

RSI on DGKC
300

250

200

150 CLOSE
Stock Index

rsi14
100

50

0
2 2 2 2 2 3 3 3 3 4 4 4 4 5 5 5 5 6 6 6 6 7 7 7 7
2 01 2 0 1 20 1 20 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 01 2 01 2 01 2 0 1 20 1 20 1 20 1 2 0 1 2 0 1 2 01 2 01 2 0 1
4 / 0 / 8 / 1 / 8 / 6 / 9 / 7 / 9 / 8 / 1 / 1 / 1/ 9 / 3 / 1 / 7/ 4 / 9 / 8 / 7/ 0 / 9 / 7 / 1 /
1/ 3/3 6/2 10/ 2/2 3/2 6/1 9/1 2/1 3/1 6/1 9/1 2/1 3/ 6/ 9/ 1/2 2/2 5/1 8/1 1/1 2/1 5/ 8/ 11/
1 1 1 1 1

Page | 69
Figure 49: RSI on D.G. Cement

The results of rsi-14 on D.G. CEMENT stock scripts clearly show an oversold condition.
During the initial months of the current fiscal year the stock price provides the support
resistance levels as it is in the range 50-60s but the later months proved to be
disastrous for the entire stock market and those shocks are easily represented in the
above chart as well as the rsi-14 is constantly under the range of 50 value which simply
represents the oversold status.

BOLLINGER BANDS

To calculate Bollinger Bands indicator BBands() function of R Studio is used. BBands()


function is passed to data frames stream ‘data’ along with the query to use the values of
‘CLOSE’ column the second parameter ‘sd’ takes the number of standard deviations for
upper and lower bands.

A same approach of 20 days moving average is adopted to calculate BBands. The


output generated of the Bollinger Bands contains several columns: ‘dn’ for lower band
‘mavg’ for the results of moving average ‘up’ for upper band along with pctB which is
also an important parameter to gauge script’s price relative to upper and lower band.

Bollinger Bands plot:

Page | 70
Figure 50: Bollinger Bands on D.G. Cement

Forecasted results produced in R Studio composed of a center line (blue color) which is
located between two other lines ( brown and purple). Blue line represent exponential
moving average which the other two lines depict the standard deviations of upper and
lower price bands. Central line(blue color) of exponential moving average is actively
located between the upper and lower price channels as depicted by brown and purple
color.
In the above graph the blue exponential moving average is continuous along with the
lower band (brown line) during past few months representing an oversold condition
representing an oversold condition, triggering a strong selling signal.

Simple Moving Average/Moving Average:

Exponential Moving Average has been implemented for evaluation Attock Cement and
Lucky Cement scripts. In case of D.G. Cement Simple Moving average had been
adopted in order to check the volatility of script using other parameters as well. The20-
day Simple Moving Average (SMA) of the CLOSE price column using TTR library’s R
function “SMA”:

SMA on DGKC
300

250

200

150 CLOSE
Stock Index

sma20
100

50

0
12 12 12 12 1 3 1 3 1 3 13 1 4 1 4 1 4 14 1 5 15 1 5 1 5 1 6 1 6 16 16 17 17 17
/20 /20 /20 /20 /20 /20 /20 /20 /20 /20 /20 /20 /20 /20 /20 /20 /20 /20 /20 /20 /20 /20 /20
4 4 6 2 5 6 5 3 4 4 3 1 2 5 5 6 8 6 0 4 0 2 6
1/ 4/ 7/ 0/1 1/1 4/1 7/1 0/2 1/2 4/2 7/2 0/3 2/ 5/ 8/ 11/ 2/ 5/ 8/1 1/1 2/1 5/1 8/1
1 1 1 1

Page | 71
Figure 51: Simple Moving Average on D.G. Cement

The graph of MA represents the flow of direction of the trend mostly the moving average
(MA) trend is used to determine the support and resistance level as the graph is
strongly correlated with its past price movements. The graph of DG CEMENT script is
representing a resistance support depicting the movement of trend in the upward
direction.
Result of technical indicators on D.G. CEMENT:

Combination of RSI, Bollinger Bands, and Simple Moving Average/Moving Average


(MA) indicators have been implanted on D.G. Cement script and on the basis of these
indicators the recommendation for the DGKC Script is
The script of D.G. Khan Cement is bullish in short term period of time.

Page | 72
CHAPTER 6

CONCLUSION AND
RECOMMENDATIONS

 Summary of Findings
 Conclusion
 Future Work Prospects

Page | 73
CONCLUSION AND RECOMMENDATIONS
In this research report a new forecasting methodology along with the technical
indicators has been implemented and evaluated in order to find the best combination
suitable for novice and short term stock traders.
This research report provides an in depth analysis of most popular recent day trading
strategies including technical indicators which are used as an input to machine learning
classifiers in attempt to classify the selected script data into recommended strategy and
the other methodology used is forecasting thru business intelligence tools. For this work
I have used R Studio and perform a time series forecasting using ARIMA (Auto
Regressive Integrated Moving Average) and Holt Winter model. Since both these
models take the close price of the trading stock and run the algorithms on that index in
order to predict future prices.
In this paper data has been collected from PSX website. The historical data for the
period of five years since 2012 to 2018 were taken for analysis.
The work performed for forecasting comprises of forecasting models ARIMA and Holt
Winter Model. The first strategy adapted for prediction is ARIMA Model in which the
close price of the day is provided as an input to the model. To calculate the error
accuracy of the forecasted results MAPE (Mean Absolute Percentage Error) method is
used the results of MAPE shows that the forecasting accuracy of ARIMA model in case
of Attock Cement Script is 6.42% and the numerical calculations predicted an error
accuracy of 2%.Similarly the forecasted values of Lucky Cement are evaluated using
MAPE and the error accuracy for ARIMA Model is calculated to be 8.1% while the
numerical calculations represents an error of 1% due to a small size of forecasted
values. The forecasted Value error calculation on D.G. Stock script using MAPE shows
an error of 1% while the numerical calculations represents an error accuracy of 2%.
Besides the ARIMA forecasting another popular method of time series forecasting is
taken into account; Holt Winter (HW) forecasting the error calculations are done using
the same methodology like ARIMA Model.
The MAPE of HW forecasting for Attock Cement is calculated to be 7.2% while the
numerical calculations shows an error accuracy of 5%. Similarly the HW results of
Lucky Cement script are calculated to be 6.5% while its numerical forecasted values
shows an error accuracy of -3%. Holt Winter MAPE results of D.G. Cement Script
Page | 74
shows an error of 14.6% while the numerical error calculations represent an error of
-1%.
This papers inference a new investment decisions or guidelines based on the minimum
error percentage obtained through the mentioned performance measures. The future
forecast of each index for next few days also highlighted in this paper. It is hoped that
more innovative approaches will be conducted to bring the hidden information about
stock market.

Future work
The work performed in this research report comprises of two crucial forecasting
methodologies however for the future work scope, there is still big unfilled room for
testing and refining the projected model by evaluating the model over other companies
listed on Pakistan Stock Exchange there are several other variations of the models that
could be evaluated and implemented to calculate the accuracy of the forecasting
models.
Other implementations that could provide significantly good results are:
 Evaluating and Implementing the Decision tree and Support Vector Machine
(SVM) methodology to forecast the listed scripts on PSX.
 Including the impact of macroeconomic indicators on the selected sector of
Pakistan Stock Exchange.
 Artificial Neural Networks, association rules and genetic algorithms are also
distinguished parameters that signify a rich area/scope for future investigations.
 Using several other technical indicators in forecasting the stock scripts as well as
including the fundamental analysis of the script as well.
 Research what technical/macroeconomic indicators have been shown to yield
good predictive qualities. Use these as inputs to classifiers.
 There are several other technical classifiers available which could produce
interesting results if employed on the same data sets.
 Explore the classification rule and its correlation with the market volatility to
perform the training data sets for forecasting.

Page | 75
REFERENCES
 Michelle de Ruiter, 2 July 2017. Using Exponential Smoothing Methods for
Modelling and Forecasting Short-term Electricity Demand, 414429
 Pawan Kumbhare, Rohit Makhija, Hitesh Raichandani, 2016. Stock Market
Prediction,SANTA CLARA University Research Thesis.
 Jeffrey Allan Caley, 3-14-2013. A Survey of Systems for Predicting Stock
Market Movements, Combining Market Indicators and Machine Learning
Classifiers. Dissertations and Theses. Paper 2001.
 Donganis,R. 201.Quantitative Analysis. [Online]
Available: http://www.investopedia.com/terms/q/quantitativeanalysis.asp [Accessed
5 October 2017]
 Chart School,2001. Moving Averages - Simple and Exponential [Online].
Available:http://stockcharts.com/help/doku.php?
id=chart_school:technical_indicators:moving_averages.
[Accessed 17 October 2017]
 Chart School,201. Moving Average Convergence- Divergence (MACD).
[Online]. Available:http://stockcharts.com/help/doku.php?
d=chart_school:technical_indicators:moving_average_conve
StockCharts.com,
[Accessed 17 October 2017]
 Chart School,201. RelativeStrengthIndex(RSI) [Online]
Available:http://stockcharts.com/school/doku.php?
id=chart_school:technical_indicators:relative_strength_index_rsi.
StockCharts.com [Accessed 17October 2017]
 Pakistan Stock Exchange, PSX. [Online]
Available at: http://psx.com.pk/
[Accessed 25 October 2017]
 Malkiel, Burton G. 2003, "The efficient market hypothesis and its critics."
Journal of Economic Perspectives: pp 59-82.
 Box, G. E. P., Jenkins, G. M., & Reinsel, G. C. 1993.Time Series Analysis:
Forecasting and Control. Prentice Hall, New Jersey S.C. Hillmer, G.C. Tiao
1982 An ARIMA model based approach to seasonal adjustment, Journal of
the American Statistical Association, 77, pp 63-70
 P. Newbold, 1983. The competition to end all competitions, Journal of
Forecasting, 2(3),pp 276-279
 S. Makridakis, M. Hibon, 1979. Accuracy of forecasting: an empirical
investigation (with discussion), Journal of the Royal Statistical Society A, 142,
pp 97-145
 Gardner, E. S.1985. Exponential Smoothing: The State of the Art.
International Journal of Forecasting, 4 , pp 1-28.
 Taylor, J. W. 2010. Exponentially Weighted Methods for Forecasting Intra-
day Time Series with Multiple Seasonal Cycles. International Journal of
Forecasting, 26 , pp 627-646
 Attock Cement Pakistan Limited Quarterly Report, 2017. Annual Report,
 Lucky Cement, Quarterly report 2017. Annual Report,
 D.G.Khan Cement Quarterly Report, 2017. Annual Report,
 Jan Gorecki, 2015. R in Business Intelligence [Online]
Available at: http://R in Business Intelligence _ R-bloggers.asp
[Accessed 7October 2017].
 The Nation, September 2017.Cement industry dispatches 10.34m tons of
cement in Q1 [Online]
Available at:http:// Cement industry dispatches 10.34m tons of cement in
Q1.asp
[Accessed 2 November 2017]
 Selva Prabhakaran, 2016. Holt Winter Implementations in R [Online].
Availabe at:http:/Comparing Holt Winters Implementations in R – Part 1 _ R
Programming Blog.asp
[Accessed 1 November 2017]
 Bill Toomney,2016. Technical Analysis with R [Online]
Available at: http:/Technical Analysis with R Programming Language.asp
[Accessed 5 November 2017]
 Mahantesh Angadi,2017. Time Series Data Analysis For Stock Market
Prediction Using Data Mining Techniques With R. [Online]
Availabe at : http:/Time Series Data Analysis For Stock Market Prediction
Using Data Mining Techniques With R _ Mahantesh Angadi -
Academia.edu.html
[Accessed 7 November 2017]
QUESTIONAIRE
Q1)Have you ever traded in Pakistan Stock Exchange

Yes
No
Never

Q2) What is the main barrier for entry in Pakistan Stock Exchange?
Check all that
apply.

Monopoly of big stock players


Political instability in country
Fear of loss on investment
Other:

Q3) According to you which sector has biggest potential and lowest risk

Cement
Oil and Gas
Manufacturing

Automobile
Other:____________

Q4) what defines your trading style best?

Day trader
Short term investor
Long term investor
None of the above

Other:

Q5) would you concerned with the current market instability


Check all that
apply.

Very concerned
Somewhat concerned
Not at all concern
No opinion

Q6) What according to you are decent gains within short term ( 2,3 months’ time)?

0 -10%
10 – 20%
20% - 30%
30%+

Q7) Have you heard of Big data Analytics and Business Intelligence tools used for Stock trading and Selection?

Yes
No
May be
Q8) Are you willing to trade if any such platform is available that could reduce the error accuracy and fear of loss on
investment?

Yes
No
Maybe
No opinion

Q9).What is your Age?


Mark only one oval.

Below20
20-30
30-40
40-50
50-60
Above60

Q10.What is you Gender?


Mark only one oval.

Female
Male

Q11.What is your highest qualification?


Mark only one oval.

Secondary or Less
Intermediate
Bachelors
Masters and Above

Other:

Q1.What is your Monthly Income?


Mark only one oval.

LessThanRs.50,000
BetweenRs.50,000 and Rs.100,000
BetweenRs.100,000 to Rs.250,000
BetweenRs.250,000 to Rs.500,000
AboveRs500,000

Q13.What Best describes your profession?


Mark only one oval.

Self-Employed
Student
Salaried Employee
Unemployed
Retired
Other:
TRANSCRIPT OF INTERVIEWS

INTERVIEW NO. 01

Q1) Sir how would you regard the acceptance of Big Data in Pakistan.

Ans). I am utterly pleased with the opinion that Pakistan would accept the big
data technology and tools with open hearts and implement this technology in
every aspect of their businesses at an exponential rate. Some well-known big
companies of Pakistan are already using conventional data analytics tools for
their businesses and demand of data analysts is also on a rise these days in
Pakistan.

Q2) How would you see the scope of Business Analytics in our financial
markets?

Ans). The scope of business analytics would be substantial in our financial


markets because its impact will be very high and results can be achieved very
quickly. Currently, most of the investors are not even using conventional
technical indicators. It’s a sad fact, that decisions of investments and day to day
trading in our financial markets are majorly driven by political conditions.
BA software would be easier to use, that too with effective and concrete results.
Therefore, investors would definitely use them for making their investment and
trading decisions that too with very high priority.

Q3) Sir in your opinion how Big Data Analysis can impact Pakistan Stock
Exchange?

Ans). As I have previously said that currently trading decisions are driven by political
conditions. Majority investors and traders are completely ignoring market
fundamentals and technical indicators and are trading blindly. This herd mentality
type strategy has a detrimental effect on PSX and this is causing loss to all
stakeholders.

I am with the opinion that Big Data Analytics will change these traders and investors’
perception. People would start thinking logically and they will take decisions on real
fundamentals rather than political circumstances. Therefore, BDA would impact PSX
very positively.

Q4) How can we aid our financial security markets especially Pakistan stock
exchange from this technology.

Ans). We can aid our financial security markets especially PSX from this technology
in a number of ways mentioned below:

 By bringing more efficiency and transparency in day to day transactions.


 This will give us better insights in less time.
 These will change investors and traders’ perception and will make their thinking
more logical and facts/data based.
 Increase investors’ confidence, which will eventually increase both trading
volume and value of shares.
 Provide easiness in predicting future performance of scripts and market.
 Bring stability.

Q5) Sir in Pakistan the Stock market is mostly manipulated by few biggest
market players do you think that Business Intelligence forecasting tools can
lessen the losses of novice traders?

Ans). Yes definitely. Through business intelligence forecasting, novice traders will no
longer trade blindly, rather they will make cognitive and solid decisions based on BI
results. Therefore, it will be very difficult for big players to manipulate market. This
will also increase competition and will curtail the unusual profits of big players.

Q6) Sir what do you think about the acceptance of stock forecasting models
based on business analytics where mostly the novice stock investors mostly
rely on their traders suggestions/tips?

Ans). Novice stock investors are not confident and they invest very less because
they rely on their broker’s suggestions. And brokers manipulate their clients for their
own benefits.

Novice traders want to learn market fundamentals, technical indicators so that they
could confidently make their decisions. But unfortunately, there is nothing available
in market for them. Therefore, I am sure that novice stock investors will warm
heartedly accept the stock forecasting models. Moreover, BA software would be
easier to use, that too with quantitative results (probability and accuracy of
predictions). Therefore, novice investors would definitely use them for making their
investment and trading decisions that too with very high priority.

Q7) Sir according to you what is an efficient stock trading strategy that we
need to implement in order to reduce the losses in our stock scripts.

Ans). Using BA, we can predict stocks performance on short-term and long-term
basis that too with concrete results, like probability and accuracy of the predictions
will be known. Using these results, we can make our portfolio more efficient and
profitable. Besides, we can easily predict about the bad performing scripts and can
easily curtail our losses.

BA results will give us the rate of change of individual scripts w.r.t. market conditions
in future. Then we can compare incremental rates of different scripts for a definite
period of time and can select the most profitable scripts for our portfolio. In case of
negative change, we can sell those scripts in advance and can buy profitable scripts
with that money. Through this strategy, we can make most profit with limited
investment.

INTERVIEW NO. 02

1. The main reason of uncertainty in market these days?


In my opinion the Stock market of Pakistan is very speculative and is influenced
by the political movements of the country, recently we have seen many up and
downs in political upheaval so these factors influence the market. The main
reason of these markets fluctuations is due to the ending phase of the first term
of the government and monopolies of big stock market players.

2. Do you believe that the market will bounce back sometime sooner or later?
Yes definitely it will and in recent days we have already seen a rebound of 20-
25% recovery of cement sector prices. If you see the cement scripts majority of
them have already started to gain momentum and are further showing healthy
signs of growth. So yes the market will gain its pace in following months.

3. According to you the how would you see the cement sector of PSX
In my opinion it has very potential to accelerate and grow for next 1 to 2 years. In
next three years many cement manufacturers will double their production
capacity new projects are in pipe line like D.G Khan has announced its fourth line
of production, power cement has been purchased by pioneer cement, Fecto
cement has announced its new production line. Besides this government has
also issued 10-1 licenses to various cement plants in mostly in Punjab and KPK
areas. All the current cement production plants are going for expansions to
achieve economies of scales due to larger production capacities they can get
cheap labors, heavy machineries at reduced cost and improving power
consumption. All the leading cement manufacturing companies like Lucky
Cement, D.G Khan Cement are currently trading on a very low prices because of
overall negative market trend but this does not mean that this is there fair value
prices if you see the financial statements these companies are posting greater
profits each year and likely to expand their production capacities. In my opinion
next five years can be very profitable for these cement companies due to higher
demand of construction in local market as well as international markets like Iraq,
Afghanistan and Africa where their product is exported.
4. What are the main news sources that derives these stocks
I believe the rumors and artificial political unrest are the main sources that derive
our stock markets. If you see D.G Khan Stock prices it has been reduced to half
to its prices in past 4 months despite the fact the company has very good
financials and constantly showing increasing profits. If you analyze all the register
companies in Pakistan Stock Exchange majority of them are registering good
yearly profits and very few of them are in loss so why the stocks of all profit
earning companies are lower down. There are no such fair value evaluation
agencies or companies that could evaluate the company’s performance and post
their performance independently. The scripts are mostly monopolized by the
political unrest of our country.

5. How would government policies impact these scripts?

Government policies definitely impact the prices of the stock scripts. In past we
have seen as the import duty on the coal has been increased by the government
that decision has impacted the cement prices and the whole cement sector get
influenced by the news. Besides this there are many other policies such as anti-
dumping, import barriers, government bailout packages and subsidies that affect
the prices of the stock scripts. There is no proper infrastructure and we can only
cater the growing electricity shortage demand by building reservoirs and dams.
So if the government announces any such projects the demand and consumption
of cement will increase drastically.

Focus group Interview script

Q) Main aspects/determinants shaping our stock market?


 Inflation and interest rates
 Exchange rates
 Hype
 Interest rate
 Inflation
 Foreign direct investment
 Major government policies

All these factors have an impact on our stock market performance


Q) Reasons for market fluctuations these days?

 Political instability
 Big players monopoly
 Lack of market knowledge by investors
Our market is mainly driven by news and political turmoil. Recent actions by the
government and the reaction of opposition parties have a huge impact on market
fluctuations
Q) According to you the major sources/news driving our stock market these
days?

The recent news was the Panama Papers case which heavily impacted the stock
market performance.

Q) Do government policies impact the buying decisions of investors?

Yes, they do since the investor return & wealth is based on those policies

Q) Main barrier for entry in stock markets?


 Lack of information about how market works
 Higher tax rates and transaction costs

Q) What will be the future impact of big data in Pakistan stock exchange?

 Stock market will be more reliable and transparent


 The impact will be huge since all the big stock market analysts outside Pakistan
are already using this technology and machine learning and programming is the
future of technology

Q) How it can benefit the new and seasoned traders in recovering their
losses?
Large available data will provide them opportunity to take decisions on the basis
of facts and if used properly and identifying the dependent and independent
variables, one can use this technology to predict stock prices and for portfolio
optimization.

You might also like