{"id":982,"date":"2013-03-08T00:22:54","date_gmt":"2013-03-08T05:22:54","guid":{"rendered":"http:\/\/www.craigperler.com\/blog\/?p=982"},"modified":"2024-06-06T23:25:57","modified_gmt":"2024-06-07T03:25:57","slug":"analysis-of-technical-analysis","status":"publish","type":"post","link":"https:\/\/www.craigperler.com\/blog\/2013\/03\/08\/analysis-of-technical-analysis\/","title":{"rendered":"Analysis of Technical Analysis"},"content":{"rendered":"\n<p>I&#8217;ve put together a small framework for testing out technical-based trading strategies. &nbsp;You can create indicators, generate trading signals, calculate P&amp;L, and chart the results. &nbsp;I know there are a bunch of mature packages out there that do this, but it&#8217;s a fun thought experiment. &nbsp;<a title=\"cperler\/trading repo on github\" href=\"https:\/\/github.com\/cperler\/trading\" target=\"_blank\" rel=\"noopener\">The code<\/a> is public in case it&#8217;s of interest. &nbsp;I may throw a few random studies up here showing the futility of technical analysis, which is the consistent result of my experience with it.<\/p>\n\n\n\n<p>As an example, consider this strategy:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Buy when the price &gt; VWAP * 1.005<\/li><li>Sell when the price &lt; VWAP * .995 (and there&#8217;s an open position)<\/li><li>Long only, starting cash of $10000, run from 1\/1\/2012 through 1\/3\/2013, trading just SPY, no transaction costs<\/li><\/ul>\n\n\n\n<p>Strategy P&amp;L = $871 vs Buy &amp; Hold = $2028<\/p>\n\n\n\n<p>In addition to showing the price movement and signals, this chart demos some other random indicators.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/i0.wp.com\/www.craigperler.com\/blog\/wp-content\/uploads\/2013\/03\/basic_ta.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"569\" src=\"https:\/\/i0.wp.com\/www.craigperler.com\/blog\/wp-content\/uploads\/2013\/03\/basic_ta.png?resize=1024%2C569&#038;ssl=1\" alt=\"\" class=\"wp-image-985\" title=\"Technical Analysis, Demo\" srcset=\"https:\/\/i0.wp.com\/www.craigperler.com\/blog\/wp-content\/uploads\/2013\/03\/basic_ta.png?resize=1024%2C569&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.craigperler.com\/blog\/wp-content\/uploads\/2013\/03\/basic_ta.png?resize=300%2C166&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.craigperler.com\/blog\/wp-content\/uploads\/2013\/03\/basic_ta.png?w=1267&amp;ssl=1 1267w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>If you reverse the strategy and go contrarian (buy with a price dip instead of buying on the trend movement), the strategy beats the Buy &amp; Hold performance, earning $2129 (that&#8217;s above and beyond the initial $10k outlay). &nbsp;The contrarian strategy, if run from 1\/1\/2005 actually earns a profit of $17K compared to $4.6K for just buying and holding! &nbsp;Anyway, this framework makes it easy to backtest strategies, test a universe of securities, and look at how different indicators perform. &nbsp;It&#8217;d also be easy to extend the backtester to note additional interesting stats, such as max drawdown.<\/p>\n\n\n\n<p>Happy to help test out any strategies &#8211; feel free to drop them in the comments.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve put together a small framework for testing out technical-based trading strategies. &nbsp;You can create indicators, generate trading signals, calculate P&amp;L, and chart the results. &nbsp;I know there are a&hellip;<\/p>\n","protected":false},"author":1,"featured_media":1645,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[149],"tags":[],"powerkit_post_featured":[],"class_list":{"0":"post-982","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-finance-trading"},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.craigperler.com\/blog\/wp-content\/uploads\/2013\/03\/pexels-photo-11798250.jpeg?fit=1880%2C1253&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p1SwZ6-fQ","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.craigperler.com\/blog\/wp-json\/wp\/v2\/posts\/982","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.craigperler.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.craigperler.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.craigperler.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.craigperler.com\/blog\/wp-json\/wp\/v2\/comments?post=982"}],"version-history":[{"count":4,"href":"https:\/\/www.craigperler.com\/blog\/wp-json\/wp\/v2\/posts\/982\/revisions"}],"predecessor-version":[{"id":1646,"href":"https:\/\/www.craigperler.com\/blog\/wp-json\/wp\/v2\/posts\/982\/revisions\/1646"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.craigperler.com\/blog\/wp-json\/wp\/v2\/media\/1645"}],"wp:attachment":[{"href":"https:\/\/www.craigperler.com\/blog\/wp-json\/wp\/v2\/media?parent=982"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.craigperler.com\/blog\/wp-json\/wp\/v2\/categories?post=982"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.craigperler.com\/blog\/wp-json\/wp\/v2\/tags?post=982"},{"taxonomy":"powerkit_post_featured","embeddable":true,"href":"https:\/\/www.craigperler.com\/blog\/wp-json\/wp\/v2\/powerkit_post_featured?post=982"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}