You are on page 1of 6

2017 4th International Conference on New Media Studies

Yogyakarta, Indonesia, November 08-10, 2017

Phatsa: A Web-Based Application for Forecasting


using Conventional Moving Average Methods
Marcel Bonar Kristanda, Seng Hansun
Informatics Department
Universitas Multimedia Nusantara
Tangerang, Indonesia
marcel.bonar@umn.ac.id, hansun@umn.ac.id

Abstract— Forecasting with time series was made by As a part of time series analysis , Zargham and Sayeh
hypothetical study that historical data related with the future introduced the implementation of MA methods in a web-based
data. Moving average (MA) is one of the well-known methods to information system in 1999 in order to select and evaluate
be used in forecasting technique. Although there are several stock market [8, 9]. Since then, the development of web-based
methods that already developed like soft computing and modified moving average software went through different kind of
methods, conventional moving average methods still usage. Researches in 2000s decade showed that conventional
implemented in recent researches because of its simplici ty. Th i s methods of MA can be useful to predict macroeconomic
study conducts a development of web-based application called
statistic [10], viewer’s location in a virtual reality environment
Phatsa (PHP Application for Time S eries Analysis) that
[11], workload prediction of web-based systems [12] and more
implements three conventional moving average methods, i.e . th e
S MA, WMA and EMA. All the calculation tested in 100 – 5000
variety researches conducted in recent 2010s [13-16].
rows of time series dataset with the maximum calculating time Although there are several methods that already developed
below 0.4 seconds. Calculating time is relatively linear with the like soft computing [17] and modified methods [18],
complexity of its equation, EMA has the biggest amount of time conventional methods still implemented in recent researches
while S MA has the lowest one. because of its simplicity [19].
Web-based system is used to deliver the data visualization
Keywords—application; web-based; moving; average;
of moving average results on its usage context. Moreover, a
forecasting
software that conduct data visualization on moving average
often used as a research simulation tool [19]. Based on several
I. INT RODUCTION researches that have been done, the necessity of web-based
Many researchers have been developed varieties of time application that can cover variety of dataset was identified.
series analysis methods to achieve some goals in analyzing This study conducts a development of web -based
and forecasting data. Forecasting with time series was made application called Phatsa (PHP Application for Time Series
by hypothetical study that historical data related with the Analysis) that implements three conventional moving average
future data [1]. This technique widely-known to be used by methods, i.e. the SMA, WMA and EMA. The application
investors as an consideration for trading business. However, tested on three aspects, calculating moving average time,
since 21st century, it has been used for many purposes and calculating error time, and overall calculating time.
usage contexts.
Moving average (MA) is one of the well-known methods II. CONVENT IONAL M OVING A VERAGE M ET HODS
to be used in forecasting technique [2]. This method can be
delivered in many types, but the core purpos e remains the A fixed range of data span that shifted over time is
same, i.e. determining trend in the specified dataset [3]. The calculated in MA methods, then it adds a new value and
foundation of this method called the simple moving average replaces the oldest value [20]. The length of this window of
(SMA) where each data point is weighted the same regardless data, also called as ‘lookback’ or ‘averaging’ or in this study
of where it occurs in the sequence. Improved version of SMA ‘span’ period, is the time interval over s hich the moving
is weighted moving average (WMA) which calculates a average is computed [20]. In this section, three commonly
weighting factor for each data point in the given dataset. used MA methods, i.e. SMA, WMA, and EMA discussed.
Another well-known moving average family member is the
exponential moving average (EMA) or also known as A. Simple Moving Average
exponentially weighted moving average (EWMA) method
which uses an exponential function as the basis in forming the SMA is the most basic form of moving average methods. It
weighting factors. Kapgate [4], Zhuang et al. [5], Ren et al. is simply just an average of previous data points in time
[6], and Cadenas et al. [7] used this variety of MA methods in series data. In SMA, each data point is equally weighted, so
their researches in time series forecasting fields. there are no weighting factors applied to any of the data points
[21].

978-1-5090-6284-3/17/$31.00 ©2017 IEEE 38


As Ellis and Parbery describe in their paper [21], SMA can data. Utilization of this application is publicly available,
be represented by: specified for formatted dataset only with no restrictions of
what kind of data, and can be accessed through multi-device
(1) web browsers.
where is the span data (the number of periods included in Flow of the application design shown in Fig. 1, illustrated
the average), is the relative position of the period currently as user interaction flowchart.
being considered within the total number of periods, and is
the actual value at time .

B. Weighted Moving Average


A simple improve version of SMA is WMA where a
special weighting factor is implemented on the span period
data being observed. It gives a greater weight value to more
recent data than the older ones in a linear manner. Using our
own notation from Zakamulin [20], we can formulate WMA
as:

(2)

where is the span data, is the relative position of the


period currently being considered within the total number of
periods, is the actual value at time , and is the weight
of data . In this study, we use the weighting factor based on
numerator of WMA calculation from the first set span data
(weighted with 1) untill the last one (weighted with )

C. Exponential Moving Average


EMA actually is a means of smoothing random
fluctuations that has the following properties: (1) declining
weight is put on older data, (2) it is extremely easy to
compute, and (3) minimum data is required [22]. It was
originated form Robert G. Brown’s work, who was assigned to
develop a tracking model for fire-control information on the
location of submarines for the US Navy [23].
Same with WMA, EMA puts greater weight to recent data
than the older ones; however the weighting factor used in
EMA is an exponential function. As we can see in Hansun [3],
EMA for time series can be calculated recursively using:
(3)
(4)
where is the value at time period , is EMA value at time Fig. 1. User Interaction Flowchart
, and represents the degree of weighting value decrease
also known as constant smoothing factor with a range value
A. Choose Prediction Method
between 0 and 1. As suggested by Johnston et al. [24], we can
estimate as: In the beginning of application, users are intended to
choose which method they want to apply. The selections must
(5) display three different methods accordingly: SMA, WMA and
EMA. These options give the application decision on which
However, in this study we will try to find the best value equations that needs to be run later after Step D.
using brute force approach, which minimizes the error rate of
forecasting results. B. Configure Method
This step involves method’s required parameters that need
III. A PPLICATION DESIGN to be defined by the users. There are three parameters:
Phatsa is designed based on the variety of target users and
 Span Data: Numerical amount of periods in positive
utilizations. Target user is defined as everyone who has the
dataset and wants to predict in specified period based on their integer to be calculated in the equation.

39
 Start Index: The first index in the dataset in which the Server specification is no limitation on bandwidth and hard
prediction begin. Minimum value for this parameter is disk storage that runs on 768MB Random Access Memory
the same integer value of span data. (RAM).
 Prediction Period: The amount of periods that u ser
A. Application Screenshots
want to predict after the last data from the dataset given
in the Step C. Homepage of the application go through directly
application design’s starting point. Fig. 2 until Fig. 5
C. Upload Dataset File accordingly shows step-by-step user interactions as described
in Fig. 1. Steps are displayed in a web form manner as user
This step requires user to upload a formatted CSV files needs to do some input in most of the steps. Step D: Check
with the formatting rules as follow: Upload is shown as small notification in the right side of file
 Exactly two columns of data in the CSV with no name in Fig. 4.
limitations on amount of rows.
 First row of dataset are the labels that must be in string
value of “Period” for the first column and “Value” for
the second column.
 Rows after labels are data that can be in form of any
string value for first column and integer or float valu e
for the second column.

D. Check Upload
User have to submit the file (.csv), then the application Fig. 2. Implementation of Step A: Choose Prediction Method
notifies user whether the dataset file already correct in the
right format or in the right extension or not. If the upload
succeeded, then application calculates the dataset based on
chosen method and parameters in Step A and B. If it fails, then
users have to re-upload dataset file correctly.

E. View Graphic and Data Results


After application calculates all data with given equation, a
comparable graphic that shows original dataset and predicted
dataset are shoqn. Application also display results that consists
of six calculation results: Mean Square Error (MSE), Mean
Absolute Percentage Error (MAPE), Mean Absolute Scaled
Error (MASE), Calculating Moving Average Time,
Calculating Errors Time, and Overall Calculating Time.

IV. IMPLEMENTATION RESULT S


Fig. 3. Implementation of Step B: Configure Method
Application design then developed into web application
called Phatsa in specified environment:
 Server Development Script: PHP version 7.0
 Server Framework Script: CodeIgniter 3.1.4
 Client Application Script: HTML 5, CSS 3, jQuery 1.12.4,
Bootstrap 3.3.7, FineUploader 5.14.3, Chart.js 2.6.0.
This web-based application deployed in the url
https://www.phatsa.com. It is hosted in virtual server that runs
physically on Intel Xeon E5-2630 (40 CPUs), x86_64
architecture and CloudLinux Operating System (OS). The
resources (CPUs) load administered by hosting services and
the implementation of moving averages calculation itself has
not designed to take the advantage of parallel computing yet. Fig. 4. Implementation of Step C: Upload Dataset File

40
Fig. 5. Implementation of Step E: View Graphic and Data Results

B. Testing Results
 The shortest gap of calculating time between SMA -WMA,
Several datasets are set to be tested in this application on SMA-EMA, and WMA-EMA is found in SMA-WMA,
each implemented moving averages method: while the longest gap found in SMA-EMA.
 Dow Jones Index Dataset: DJI (8200 rows of data in total)
TABLE I. DATASET CALCULATED TIME FOR SMA
 Nasdaq Index Dataset: NSDQ (3817 rows of data in total)
Dataset Calculating Calculating Overall
 Jakarta Stock Exchange Dataset: JKSE (5064 rows of data Name Average Error Time Calculating
in total) Time Time
These datasets then filtered with variations of 100, 500, DJI100 0.0002 s 0.0001 s 0.0003 s
1000, 3000 and 5000 (only for Dow Jones) latest data. Each of DJI500 0.0010 s 0.0005 s 0.0015 s
filtered latest data tested in application with controlled DJI1000 0.0022 s 0.0009 s 0.0031 s
parameters of span data = 10, start index = 10 and prediction
DJI5000 0.0110 s 0.0048 s 0.0158 s
period = 1.
NSDQ100 0.0004 s 0.0002 s 0,0006 s
Testing results for SMA, WMA, and EMA shown in time NSDQ500 0.0009 s 0.0004 s 0.0014 s
calculation manner of Table I, Table II, and Table III. Several
facts can be extracted from these results. NSDQ1000 0.0021 s 0.0009 s 0.0029 s
NSDQ3000 0.0061 s 0.0026 s 0.0087 s
 Application is able to do calculation under 0.4 seconds JKSE100 0.0002 s 0.0001 s 0.0003 s
with maximum data in DJI5000 dataset. This calculation
JKSE500 0.0011 s 0.0005 s 0.0015 s
happens in server side script, so calculating time isn’t
affected by the User Interface (UI) loading time in client JKSE1000 0.0020 s 0.0009 s 0.0029 s
side script. JKSE3000 0.0064 s 0.0027 s 0.0091 s
 The longest time for calculating moving average happened TABLE II. DATASET CALCULATED TIME FOR WMA
in EMA method. Finding best alpha calculation in EMA
affects this result. Dataset Calculating Calculating Calculating
Name Average Error Time Overall
 The shortest time for calculating moving average happened Time Time
in SMA method. The simplicity of this equation is the
DJI100 0.0003 s 0.0001 s 0.0004 s
main factor of this result.
DJI500 0.0013 s 0.0005 s 0.0018 s

41
REFERENCES
DJI1000 0.0027 s 0.0009 s 0.0036 s
DJI5000 0.0135 s 0.0045 s 0.0180 s [1] Y. Asultanny, “Successful Forecasting for Knowledge Discovery by
NSDQ100 0.0002 s 0.0001 s 0.0003 s Statistical Methods,” Proc. of 9 th International Conference on
NSDQ500 0.0012 s 0.0004 s 0.0017 s Information Technology: New Generations, Las Vegas, USA, 2012, p p.
584-588.
NSDQ1000 0.0026 s 0.0009 s 0.0035 s [2] Y. Zhu and G. Zhou, “T echnical Analysis: An Asset Allocation
NSDQ3000 0.0075 s 0.0025 s 0.0100 s Perspective on the Use of Moving Averages,” Journal of Financial
JKSE100 0.0002 s 0.0001 s 0.0004 s Economics, vol. 92, no. 3, pp. 519-544, 2009.
[3] S. Hansun, "A new approach of moving average method in tim e se r ie s
JKSE500 0.0013 s 0.0005 s 0.0018 s analysis," 2013 Conference on New Media Studies (CoNMedia),
JKSE1000 0.0028 s 0.0010 s 0.0039 s T angerang, 2013, pp. 1-4, doi: 10.1109/CoNMedia.2013.6708545.
JKSE3000 0.008 s 0.0027 s 0.0107 s [4] D. Kapgate, “Weighted Moving Average Forecast Model based
Prediction Service Broker Algorithm for Cloud Comput ing,”
International Journal of Computer Science and Mobile Computing, vol.
TABLE III. DATASET CALCULATED TIME FOR EMA 3, no. 2, pp. 71-79, 2014.
Dataset Calculating Calculating Overall [5] Y. Zhuang, L. Chen, X. S. Wang, and J. Lian, “A Weighted Moving
Average-based Approach for Cleaning Sensor Data,” Proc. of 27 th
Name Average Error Time Calculating International Conference on Distributed Computing Systems, To ron to,
Time Time Canada, 2007, pp. 1-8.
DJI100 0.0058 s 0.0001 s 0.0059 s [6] X. Ren, R. Lin, and H. Zou, “A Dynamic Load Balancing Stra te gy f or
DJI500 0.0305 s 0.0005 s 0.0306 s Cloud Computing Platform Based on Exponential Smoothing Forecast,”
Proc. of 2011 IEEE International Conference on Cloud Computing a n d
DJI1000 0.0605 s 0.0009 s 0.0614 s Intelligence Systems, Beijing, China, 2011, pp. 220-224.
DJI5000 0.3017 s 0.0045 s 0.3062 s [7] E. Cadenas, O. A. Jaramillo, and W. Rivera, “Analysis and Forecasting
of Wind Velocity in Chetumal, Quintana Roo, using the Single
NSDQ100 0.0055 s 0.0001 s 0.0056 s Exponential Smoothing Method,” Renewable Energy, vol. 35, no. 5, pp.
NSDQ500 0.0284 s 0.0004 s 0.0288 s 925-930, 2010.
NSDQ1000 0.0988 s 0.0017 s 0.1005 s [8] J.E. Hanke and D. W. Wichern, “Business Forecasting, 8 th ed.,
New Jersey: Pearson Prentice Hall, 2005.
NSDQ3000 0.1703 s 0.0025 s 0.1727 s
[9] M. R. Zargham and M. R. Sayeh, "A Web-based information system for
JKSE100 0.0056 s 0.0001 s 0.0057 s stock selection and evaluation," Proceedings of International Worksho p
JKSE500 0.0312 s 0.0005 s 0.0317 s on Advance Issues of E-Commerce and Web-Based Information Systems.
(Cat. No.PR00334), Santa Clara, CA, 1999, pp. 81 -83. doi:
JKSE1000 0.0613 s 0.0009 s 0.0623 s 10.1109/WECWIS.1999.788191I.S.
JKSE3000 0.2575 s 0.0026 s 0.2601 s [10] M. Ettredge, J. Gerdes and G.Karuga, “Using web-based search dat a to
predict macroeconomic statistics”, Communications of the ACM , 2 005
V. CONCLUSION AND FUT URE W ORKS Nov 1;48(11):87-92.
[11] J. Chim, R. W. H. Lau, H. V. Leong and A. Si, "CyberWalk: a web-
Phatsa, a web-based application for forecasting using based distributed virtual walkthrough environment," in IEEE
conventional moving average method has been successfully Transactions on Multimedia, vol. 5, no. 4, p p. 5 03 -5 15, De c . 2 0 03.
designed and developed. The application implemented three doi: 10.1109/TMM.2003.819094.
conventional moving average methods in a monitor. All the [12] M. Andreolini and S. Casolari, “Load prediction models in we b- ba se d
calculation tested in 100 – 5000 rows of time series dataset systems”, Proceedings of the 1st International Conference on
with the maximum calculating time below 0.4 seconds. Performance Evaluation Methodolgies and T ools (Valuetools '06),
Article No. 27, Pisa, Italy, 2006. doi: 10.1145/1190095.1190129.
Calculating time is relatively linear with the complexity of its
[13] E. Silva, D. Castilho, A. Pereira, and H. Brandao. "A Neur a l Ne two r k
equations. EMA has the biggest amount of time while SMA Based Approach to Support The Market Making St r ategie s in High -
has the lowest one. Frequency T rading", 2014 International Joint Conferenc e o n Ne u ral
Networks (IJCNN), pp. 845-852. IEEE, 2014.
Phatsa developed using extensible web development
framework in which can be extended into more advanced or [14] J. Jiang, J. Lu, G. Zhang and G. Long, "Optimal Cloud Resource Aut o -
Scaling for Web Applications," 2013 13th IEEE /ACM I n tern ation al
hybrid moving average methods. There might also b e a Symposium on Cluster, Cloud, and Grid Computing, Delft, 2013, pp. 58-
possibility to implement these methods in other framework 65. doi: 10.1109/CCGrid.2013.73.
development. Moreover, this application can be used to [15] S. E. Middleton, L. Middleton and S. Modafferi, "Real-T ime Crisis
predict variety of time series datasets or more generic data Mapping of Natural Disasters Using Social Media," in IEEE Intellige nt
rather than stock or index. It can lead to usability evaluation Systems, vol. 29, no. 2, pp. 9-17, Mar.-Apr. 2014.
doi: 10.1109/MIS.2013.126.
for further researches in Phatsa.
[16] S. Shi, D. Jin, and G. T iong-Thye, "Real-time Public Mood T racking o f
Chinese Microblog Streams with Complex Event P ro cessin g. " I E EE
Access 5 (2017): 421-431.
ACKNOWLEDGMENT
[17] G.S. Atsalakis and K.P. Valavanis, “Surveying stock market forecasting
This research was sponsored and fully-funded by techniques – Part II: Soft computing methods”, E xp ert S y ste ms with
Indonesia Government through the Research Grant under Applications, Volume 36, Issue 3, 2009, Pages 5932-5941, ISSN 0 9 5 7 -
‘Applied Product Research’ scheme with contract no. 4174, http://dx.doi.org/10.1016/j.eswa.2008.07.006.
425/LPPM-UMN/IV/2017. [18] A. T apa, S.C. Yean, and S.N. Ahmad, "Modified Moving-average
Crossover T rading Strategy: Evidence in Malaysia Equity Market."
International Journal of Economics and Financial Issues 6, no. 7S
(2016).

42
[19] F. Girond, L. Randrianasolo, L. Randriamampionona, F. Rakotomanana, [22] C. C. Holt, “Forecasting Seasonals and T rends by Exponentially
M. Randrianarivelojosia, M. Ratsitorahina, T .Y. Brou et al. "Analysin g Weighted Moving Averages,” International Journal of Forecasting, vol.
trends and forecasting malaria epidemics in Madagascar using a sentinel 20, no. 1, pp. 5-10, 2004.
surveillance network: a web-based application." Malaria journal 16, no. [23] E. S. Gardner, “Exponential Smoothing: The State of the Art – Part I I , ”
1 (2017): 72. International Journal of Forecasting, vol. 22, no. 4, pp. 637-666, 2006.
[20] V. Zakamulin, “Market Timing with Moving Averages: An atomy and [24] F. R. Johnston, J. E. Boyland, M. Meadows, and E. Shale, “ Some
Performance of T rading Rules,” May 2016. [Online]. Available: Properties of a Simple Moving Average when Applied to Forecasting a
https://ssrn.com/abstract=2585056 T ime Series,” Journal of the Operational Research Society, vol. 50, n o.
[21] C. A. Ellis and S. A. Parbery, “Is Smarter better? A Comparison of 12, pp. 1267-1271, 1999.
Adaptive, and Simple Moving Average Trading Strategies,” Research in
International Business and Finance, vol. 19, no. 3, pp. 399-411, 2005.

43

You might also like