Building Your Own Technical Analysis Tool . . . . . . . . . It's As Easy As 123 (Well, Almost!)

Posted on Aug 7, 2016


Technical analysis tools are widely used by professional portfolio managers and traders to help them decide on trading strategies and tactics. They are in great demand as well by amateur traders including apparently a huge number of housewives in Taiwan who are conversant with MACD and Bollinger bands.

This blog describes my effort in building a basic technical analysis app using Shiny/R platform in a relatively short period of time.

The AppAnalyzer

The image on the right is a screenshot of the app. It is a single page app that has a sidebar which is an input area  where you can specify what technical analyses you want to see. The right part of the screen is the output and it shows two graphs one on top of each other. These graphs show the tech analysis charts for the stocks, currencies or items ("Securities")  that have been selected in the input sidebar.

The app is quite simple but provides a lot of flexibility as it was designed to handle up to two  Securities at a time.

The app allows you to look at historical daily prices of the Securities and runs technical analyses on them including candlesticks, MACD, Bollinger Bands, and RSI. There is also an option to use log prices.

Prices are retrieved online courtesy of Yahoo! Finance.


Building The App

Building the app requires knowledge of R and Shiny.

Starting with a working knowledge of R, it took me about 25 working hours to build the app with the bulk of it spent on learning how to use Shiny and making mistakes programming in Shiny (maybe 12 to 16 hours). Layout and formatting also took some time to get right (5 to 7 hours). The actual core of the program to get it running actually took little time (only a few hours) as R and Shiny have many features and accompany packages that simplify the process of pulling in data and displaying the output.

Someone who is accomplished in R and Shiny can produce the app in a few hours.

The three main workhorses of the Shiny app are the quantmod package, the TTR (Technical Trading Rules) package and the CSS.

Quantmod provides access to Yahoo! Finance's database which is extensive and includes indices and securities of foreign markets as well. Quantmod also provides access to other databases including Google. The Shiny code is shown below.

       data2 <- getSymbols(randomVals()[2], src = "yahoo",
       from = input$dates[1],
       to = input$dates[2],
       auto.assign = FALSE)

TTR provides the canned software to produce the technical charts given the data from Yahoo! Finance. Shiny code is shown below.

       if(input$RSI) {plot(addRSI())}
       if(input$Boll) {plot(addBBands())}
       if(input$MACD) {plot(addMACD())}

And CSS provides the canned formatting that makes your app look 5 times better! The Shiny code is shown below. A subdirectory named www has to be created containing the css file that has the theme of your choice which in this case is bootstrap.min.css from

              theme = "bootstrap.min.css"

As you can see, all three are so simple to use yet so powerful.


Going Forward

My experience in building this Shiny app was very positive. I was awed both by how easy it is to get free financial data and by how easy it is to analyse the data using open sourced software and packages.

I could easily have expanded the choices for technical analysis in the app with just a few minutes of additional work but decided against it due to layout constraints. This is something I intend to do in the near future.

Now, go build your own technical analysis app!

About Author

Gregory Domingo

Built his career in the financial services industry (fixed income research and fixed income portfolio management) in New York. and moved back to the Philippines in 1995. Has been involved since then in senior management positions in both...
View all posts by Gregory Domingo >

Leave a Comment

No comments found.

View Posts by Categories

Our Recent Popular Posts

View Posts by Tags

#python #trainwithnycdsa 2019 2020 Revenue 3-points agriculture air quality airbnb airline alcohol Alex Baransky algorithm alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus ames dataset ames housing dataset apartment rent API Application artist aws bank loans beautiful soup Best Bootcamp Best Data Science 2019 Best Data Science Bootcamp Best Data Science Bootcamp 2020 Best Ranked Big Data Book Launch Book-Signing bootcamp Bootcamp Alumni Bootcamp Prep boston safety Bundles cake recipe California Cancer Research capstone car price Career Career Day citibike classic cars classpass clustering Coding Course Demo Course Report covid 19 credit credit card crime frequency crops D3.js data data analysis Data Analyst data analytics data for tripadvisor reviews data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization database Deep Learning Demo Day Discount disney dplyr drug data e-commerce economy employee employee burnout employer networking environment feature engineering Finance Financial Data Science fitness studio Flask flight delay gbm Get Hired ggplot2 googleVis H20 Hadoop hallmark holiday movie happiness healthcare frauds higgs boson Hiring hiring partner events Hiring Partners hotels housing housing data housing predictions housing price hy-vee Income Industry Experts Injuries Instructor Blog Instructor Interview insurance italki Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter las vegas airport lasso regression Lead Data Scienctist Lead Data Scientist leaflet league linear regression Logistic Regression machine learning Maps market matplotlib Medical Research Meet the team meetup methal health miami beach movie music Napoli NBA netflix Networking neural network Neural networks New Courses NHL nlp NYC NYC Data Science nyc data science academy NYC Open Data nyc property NYCDSA NYCDSA Alumni Online Online Bootcamp Online Training Open Data painter pandas Part-time performance phoenix pollutants Portfolio Development precision measurement prediction Prework Programming public safety PwC python Python Data Analysis python machine learning python scrapy python web scraping python webscraping Python Workshop R R Data Analysis R language R Programming R Shiny r studio R Visualization R Workshop R-bloggers random forest Ranking recommendation recommendation system regression Remote remote data science bootcamp Scrapy scrapy visualization seaborn seafood type Selenium sentiment analysis sentiment classification Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau teachers team team performance TensorFlow Testimonial tf-idf Top Data Science Bootcamp Top manufacturing companies Transfers tweets twitter videos visualization wallstreet wallstreetbets web scraping Weekend Course What to expect whiskey whiskeyadvocate wildfire word cloud word2vec XGBoost yelp youtube trending ZORI