{"id":1923701,"date":"2014-02-20T14:55:16","date_gmt":"2014-02-20T09:25:16","guid":{"rendered":"http:\/\/stockviz.biz\/index.php\/?p=1923701"},"modified":"2014-02-20T14:55:16","modified_gmt":"2014-02-20T09:25:16","slug":"stochastic-macd-model-trading-nifty-stocks","status":"publish","type":"post","link":"https:\/\/stockviz.biz\/index.php\/2014\/02\/20\/stochastic-macd-model-trading-nifty-stocks\/","title":{"rendered":"A Stochastic-MACD Model for Trading Nifty Stocks"},"content":{"rendered":"<p>Glenda Dowie has an interesting post up on <a href=\"http:\/\/www.investopedia.com\/articles\/trading\/08\/macd-stochastic-double-cross.asp\" target=\"_blank\">investopedia<\/a>:<\/p>\n<blockquote><p>Looking for two popular indicators that work well together resulted in this pairing of the <a class=\"zem_slink\" title=\"Stochastic oscillator\" href=\"http:\/\/en.wikipedia.org\/wiki\/Stochastic_oscillator\" rel=\"wikipedia\">stochastic oscillator<\/a> and the moving average convergence divergence (<a class=\"zem_slink\" title=\"MACD\" href=\"http:\/\/en.wikipedia.org\/wiki\/MACD\" rel=\"wikipedia\">MACD<\/a>). This team works because the <a class=\"zem_slink\" title=\"Stochastic\" href=\"http:\/\/en.wikipedia.org\/wiki\/Stochastic\" rel=\"wikipedia\">stochastic<\/a> is comparing a stock&#8217;s closing price to its price range over a certain period of time, while the MACD is the formation of two <a class=\"zem_slink\" title=\"Moving average\" href=\"http:\/\/en.wikipedia.org\/wiki\/Moving_average\" rel=\"wikipedia\">moving averages<\/a> diverging from and converging with each other. This dynamic combination is highly effective if used to its fullest potential.<\/p><\/blockquote>\n<p>To derive a buy signal out of these two indicators, first make sure that the MACD is trading over its signal line and then make sure that the %K crossed the %D in the last couple of days.<\/p>\n<p>The problem with any multi-signal approach is that it requires you to track multiple stocks:<\/p>\n<blockquote><p>Because the stock generally takes a longer time to line up in the best buying position, the actual trading of the stock occurs less frequently, so you may need a larger basket of stocks to watch.<\/p><\/blockquote>\n<p>This is where you can use the StockViz API to make life simpler.<\/p>\n<p>The StockViz Technical API for Equities (<a title=\"stock technicals\" href=\"https:\/\/www.mashape.com\/drona\/stockviz#!endpoint-Equity-Technicals\" target=\"_blank\">doc<\/a>) gives you more that 50 technical stats to play with. The stochastic fields are <small>&#8220;STOCH_FAST_D&#8221;<\/small> and <small>&#8220;STOCH_FAST_K&#8221;<\/small> and the MACD fields are <small>&#8220;MACD&#8221;<\/small> and <small>&#8220;MACD_SIGNAL.&#8221;<\/small><\/p>\n<p>Here&#8217;s how it works.<\/p>\n<h3>Pseudocode<\/h3>\n<p>In order to scan all the Nifty 50 stocks:<\/p>\n<ol>\n<li>grab all the constituents of the index through the <a title=\"Index constituents API\" href=\"https:\/\/www.mashape.com\/drona\/stockviz#!endpoint-Equity-Index-Mapping\" target=\"_blank\">SymbolsOfIndex<\/a> endpoint<\/li>\n<li>iterate through them and get the <a href=\"https:\/\/www.mashape.com\/drona\/stockviz#!endpoint-Equity-Technicals\" target=\"_blank\">technicals<\/a><\/li>\n<li>check if the MACD is over the signal line. If it is, then check if the stochastic cross-over occurred over the last couple of days<\/li>\n<li>If both the conditions are met, then <a href=\"https:\/\/www.mashape.com\/drona\/stockviz#!endpoint-Portfolio-Equity\" target=\"_blank\">place the trade<\/a><\/li>\n<\/ol>\n<h3>Code<\/h3>\n<p>You can find the code on <a href=\"https:\/\/github.com\/shyams80\/StockViz\/tree\/master\/equity\/02-macd-stochastic-trading\" target=\"_blank\">GitHub<\/a>. We have extracted some shared code out into a &#8220;common&#8221; module. The main file reads much cleaner this way.<\/p>\n<p>The code should be run at the beginning of the day and you can track the progress of this system through your StockViz account.<\/p>\n<h3>Stocks picked up today<\/h3>\n<p><a href=\"http:\/\/portalvhds29z8xdrqhczq.blob.core.windows.net\/wordpress\/2014\/02\/stochastic-macd-portfolio-20.02.2014.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/portalvhds29z8xdrqhczq.blob.core.windows.net\/wordpress\/2014\/02\/stochastic-macd-portfolio-20.02.2014.png\" alt=\"stochastic-macd portfolio 20.02.2014\" width=\"444\" height=\"354\" class=\"alignnone size-full wp-image-1923771\" srcset=\"https:\/\/portalvhds29z8xdrqhczq.blob.core.windows.net\/wordpress\/2014\/02\/stochastic-macd-portfolio-20.02.2014.png 444w, https:\/\/portalvhds29z8xdrqhczq.blob.core.windows.net\/wordpress\/2014\/02\/stochastic-macd-portfolio-20.02.2014-300x239.png 300w, https:\/\/portalvhds29z8xdrqhczq.blob.core.windows.net\/wordpress\/2014\/02\/stochastic-macd-portfolio-20.02.2014-376x300.png 376w\" sizes=\"auto, (max-width: 444px) 100vw, 444px\" \/><\/a><\/p>\n<p><strong>Note:<\/strong>\u00a0You have to link your Mashape and StockViz accounts for the Accounts API to work (<a title=\"linking mashape and stockviz\" href=\"http:\/\/stockviz.biz\/index.php\/2014\/02\/17\/linking-mashape-stockviz-accounts\/\" target=\"_blank\">doc<\/a>.)<\/p>\n<h6>Previously<\/h6>\n<ul>\n<li><a title=\"hack your own news reading app\" href=\"http:\/\/stockviz.biz\/index.php\/2014\/02\/18\/news-reading-sentiment-analysis-app\/\" target=\"_blank\">Build your own News Reading and Sentiment Analysis App<\/a><\/li>\n<li><a title=\"Permalink to Building a Cross-Over Trading System\" href=\"http:\/\/stockviz.biz\/index.php\/2014\/02\/19\/building-cross-trading-system\/\" target=\"_blank\">Building a Cross-Over Trading System<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<div class=\"zemanta-pixie\" style=\"margin-top: 10px;height: 15px\"><img decoding=\"async\" class=\"zemanta-pixie-img\" style=\"border: none;float: right\" alt=\"\" src=\"http:\/\/img.zemanta.com\/pixy.gif?x-id=ad537dfa-5fd0-4f94-aa20-66ddfd644d34\" \/><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Glenda Dowie has an interesting post up on investopedia: Looking for two popular indicators that work well together resulted in this pairing of the stochastic oscillator and the moving average convergence divergence (MACD). This team works because the stochastic is comparing a stock&#8217;s closing price to its price range over a certain period of time, &hellip; <\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3131,9],"tags":[3161],"class_list":["post-1923701","post","type-post","status-publish","format-standard","hentry","category-api","category-your-money","tag-api-technical","entry"],"_links":{"self":[{"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/posts\/1923701","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/comments?post=1923701"}],"version-history":[{"count":0,"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/posts\/1923701\/revisions"}],"wp:attachment":[{"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/media?parent=1923701"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/categories?post=1923701"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/stockviz.biz\/index.php\/wp-json\/wp\/v2\/tags?post=1923701"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}