<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Au.Tra.Sy blog - Automated trading System &#187; Code</title>
	<atom:link href="http://www.automated-trading-system.com/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.automated-trading-system.com</link>
	<description>Systematic Trading research and development, with a flavour of Trend Following</description>
	<lastBuildDate>Wed, 08 Sep 2010 20:32:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Bootstrap &#8211; Take 2: Data Mining bias, Code and using geometric mean</title>
		<link>http://www.automated-trading-system.com/bootstrap-take-2-data-mining-bias-code-and-using-geometric-mean/</link>
		<comments>http://www.automated-trading-system.com/bootstrap-take-2-data-mining-bias-code-and-using-geometric-mean/#comments</comments>
		<pubDate>Fri, 13 Aug 2010 06:45:53 +0000</pubDate>
		<dc:creator>Jez Liberty</dc:creator>
				<category><![CDATA[Backtest]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[aronson bootstrap data mining]]></category>

		<guid isPermaLink="false">http://www.automated-trading-system.com/?p=2714</guid>
		<description><![CDATA[
In part 1 of this bootstrap post, we looked at how to apply the method to establish the statistical significance of a single trading rule. In Part 2, we&#8217;ll look at how to deal with the data mining bias, the impact of geometric vs. arithmetic mean return. The code implementing the bootstrap test is available [...]


Related posts:<ol><li><a href='http://www.automated-trading-system.com/bootstrap-test/' rel='bookmark' title='Permanent Link: The Bootstrap Test: How significant are your back-testing results?'>The Bootstrap Test: How significant are your back-testing results?</a></li>
<li><a href='http://www.automated-trading-system.com/monte-carlo-permutation/' rel='bookmark' title='Permanent Link: Monte Carlo Permutation: Test your Back-Tests'>Monte Carlo Permutation: Test your Back-Tests</a></li>
<li><a href='http://www.automated-trading-system.com/evidence-based-technical-analysis-aronson-book/' rel='bookmark' title='Permanent Link: Evidence-Based Technical Analysis'>Evidence-Based Technical Analysis</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.automated-trading-system.com/wp-content/uploads/2010/08/bootstrap2.png" alt="bootstrap2" title="bootstrap2" width="411" height="119" class="aligncenter size-full wp-image-2715" /></p>
<p>In part 1 of this <a href="http://www.automated-trading-system.com/bootstrap-test/">bootstrap post</a>, we looked at how to apply the method to establish the statistical significance of a single trading rule. In Part 2, we&#8217;ll look at how to deal with the <strong>data mining bias</strong>, the impact of <strong>geometric vs. arithmetic</strong> mean return. The <strong>code</strong> implementing the bootstrap test is <strong>available for download</strong> at the bottom of this post.</p>
<h3>Dealing with Data Mining Bias</h3>
<p>The approach described in the single rule test is not valid when performing data mining (whether testing different rules or different parameter values of the same rule). As per the <strong>data mining bias</strong> (<a href="http://www.automated-trading-system.com/evidence-based-technical-analysis-aronson-book/#DataMining">explained previously</a>), the (best) rule selected from the data mining process will invariably owe a large part of its over-performance to random (good) luck. </p>
<p>The way the bootstrap test deals with the data mining bias is by implementing a concept introduced in <strong>White&#8217;s Reality Check</strong>. The Reality Check derives the <span id="more-2714"></span>sampling distribution appropriate to test the statistical significance of the <strong>best rule</strong> found by data mining.</p>
<p>In effect, the concept is fairly simple &#8211; and similar to the single-rule bootstrap: assuming N rules have been tested in the data mining process, each resample iteration will perform a resample with replacement for each rule and the best mean return will be kept as this resample iteration&#8217;s test statistic:</p>
<ol>
<li><em>N </em>back-tests are  run on detrended data. The mean daily return, based on <em>x observations</em>, is calculated for each back-tested rule.</li>
<li>Each rule&#8217;s mean daily return is substracted from the rule&#8217;s set of daily returns (zero-centering), This gives a set of adjusted returns for each rule.</li>
<li>For each &#8220;higher-level&#8221; resample (to form the sampling distribution of the best-performing rule in a universe of N rules), perform a &#8220;lower-level&#8221; resample with replacement on every rule. For each rule select <em>x instances</em> of adjusted returns at random and calculate their mean daily return (rule bootstrapped mean). Compare each rule bootstrapped mean and select the highest one: this is the test statistic of this &#8220;higher level&#8221; resample (bootstrapped best mean).</li>
<li>Perform a large number of &#8220;higher level&#8221; resamples to generate a large number of bootstrapped best means.</li>
<li>Form the sampling distribution of the best means generated in the step above.</li>
<li>Derive the p-value of the best back-test mean return (non zero-centered) based on the sampling distribution derived above</li>
</ol>
<p>In effect: <strong>for each iteration, resample each rule, take the best return, keep it as this iteration test statistic and move on to the next iteration. The sampling distribution is formed of each iteration&#8217;s best return</strong>.</p>
<h3>White Reality Check Related Papers</h3>
<p>I have not yet <del datetime="2010-08-13T00:10:57+00:00">found</del> searched <em>hard </em>for White&#8217;s paper on the Reality Check but I did find the two following papers which seem to be worth a read:<br />
<a href="http://papers.ssrn.com/sol3/papers.cfm?abstract_id=563209" target="_blank">Stepwise Multiple Testing as Formalized Data Snooping &#8211; Romano &#038; Wolf</a></p>
<p><strong>Abstract</strong>:</p>
<blockquote><p>It is common in econometric applications that several hypothesis tests are carried out at the same time. The problem then becomes how to decide which hypotheses to reject, accounting for the multitude of tests. In this paper, we suggest a stepwise multiple testing procedure which asymptotically controls the familywise error rate at a desired level. Compared to related single-step methods, our procedure is more powerful in the sense that it often will reject more false hypotheses.</p>
<p>Unlike some stepwise methods, our method implicitly captures the joint dependence structure of the test statistics, which results in increased ability to detect alternative hypotheses. We prove our method asymptotically controls the familywise error rate under minimal assumptions. Some simulation studies show the improvements of our methods over previous proposals. We also provide an application to a set of real data. </p></blockquote>
<p><a href="http://papers.ssrn.com/sol3/papers.cfm?abstract_id=685361" target="_blank">Re-Examining the Profitability of Technical Analysis with White&#8217;s Reality Check and Hansen&#8217;s SPA Test</a><br />
<strong>Abstract</strong>:<br />
<blockquote>
In this paper, we re-examine the profitability of technical analysis using White&#8217;s Reality Check and Hansen&#8217;s SPA test that correct the data snooping bias. Comparing to previous studies, we study a more complete universe of trading techniques, including not only simple rules but also investor&#8217;s strategies, and we test the profitability of these rules and strategies with four main indices. It is found that significantly profitable simple rules and investor&#8217;s strategies do exist in the data from relatively young markets (NASDAQ Composite and Russell 2000) but not in the data from relatively mature markets (DJIA and S&#038;P 500). Moreover, after taking transaction costs into account, we find that the best rules for NASDAQ Composite and  Russell 2000 outperform the buy-and-hold strategy in most in- and out-of-sample periods. Our results thus suggest that the degree of market efficiency may be related to market maturity. It is also found that investor&#8217;s strategies are able to improve on the profits of simple rules and may even generate significant profits from unprofitable simple rules.</p></blockquote>
<h3>Geometric or Arithmetic Mean?</h3>
<p>In part 1, I introduced the idea that the mean arithmetic return being positive is not equivalent to the strategy being profitable (ie. this is not a <em>sufficient</em> condition). On the other hand, the <strong>mean geometric return being positive is a necessary and sufficient condition to the strategy being profitable</strong> (ie. both conditions are <em>equivalent</em>).</p>
<p>Therefore <strong>bootstrapping using the mean geometric return as the test statistic</strong> should provide a better evaluation of the system&#8217;s profitability statistical siginificance.</p>
<p>I will not go into detail of how the calculation is done as it is very similar to the arithmetic mean return, but using <strong>log of returns</strong> instead. Note that the geometric mean will be a stricter test than the arithmetic mean (a rules can have a significantly positive arithmetic return but a negative geometric return).</p>
<p>To illustrate the multiple applications of the bootstrapping methodology, I decided to run the test on one of the <a href="http://www.automated-trading-system.com/resources/trend-following-wizards-fund-performance/">Trend Following Wizards</a> track record (set of monthly returns). I picked <strong>Chesapeake </strong>and ran the monthly returns (from 1988 to 2009) through the bootstrap test.</p>
<p>The <strong>p-value</strong> calculated using the <strong>arithmetic </strong>mean is <strong>0.000098</strong> (less than 1 chance in 10,000 that this kind of results are due to random luck). Using the <strong>geometric </strong>mean, the <strong>p-value</strong> is <strong>0.00022</strong>. The values are extremely low, which is not surprising given Jerry Parker&#8217;s 20-year track record with only one losing year and a monthly average return of 1.7%.</p>
<p>Many people would point out that survivorship bias should be considered, and obviously it depends on how you look at it. The main point of this dual test is that the <strong>geometric p-value is higher than the arithmetic p-value</strong>, verifying that it is a stricter test of statistical significance.</p>
<h3>Bootstrap Code</h3>
<p>Finally, here is a tool coded to implement the bootstrap test for a single strategy &#8211; available for download. Note that this is distributed &#8220;as is&#8221;, with no guarantee (but that&#8217;s the one I have been using so I still think it does the job&#8230;). It should run on any Windows machine with the .Net framework installed (XP or higher should do fine). </p>
<p>It simply takes three parameters (separated by space): </p>
<ol>
<li>Returns file path and name</li>
<li>Number of resamples</li>
<li>Flag for Arithmetic (A) or Geometric (G) mean calculation</li>
</ol>
<p>It also generates a file in the same directory with all of the resamples test-statistic values (to draw the histogram).</p>
<p>Simply place the bootstrap.exe in your directory of choice and run it from the command prompt as below:</p>
<div id="attachment_2716" class="wp-caption alignnone" style="width: 502px"><img src="http://www.automated-trading-system.com/wp-content/uploads/2010/08/cmd.png" alt="Run the bootstrap.exe from the command line" title="cmd" width="492" height="176" class="size-full wp-image-2716" /><p class="wp-caption-text">Run the bootstrap.exe from the command line</p></div>
<p>Download here:<br />
<a href="http://www.automated-trading-system.com/wp-content/uploads/2010/08/Bootstrap.exe">bootstrap.exe</a><br />
<a href="http://www.automated-trading-system.com/wp-content/uploads/2010/08/Bootstrap.exe"><img src="http://www.automated-trading-system.com/wp-content/uploads/2010/08/bootstrap.exe.png" alt="bootstrap.exe" title="bootstrap.exe" width="104" height="122" class="alignnone size-full wp-image-2720" /></a></p>
<img src="http://www.automated-trading-system.com/?ak_action=api_record_view&id=2714&type=feed" alt="" />

<p>Related posts:<ol><li><a href='http://www.automated-trading-system.com/bootstrap-test/' rel='bookmark' title='Permanent Link: The Bootstrap Test: How significant are your back-testing results?'>The Bootstrap Test: How significant are your back-testing results?</a></li>
<li><a href='http://www.automated-trading-system.com/monte-carlo-permutation/' rel='bookmark' title='Permanent Link: Monte Carlo Permutation: Test your Back-Tests'>Monte Carlo Permutation: Test your Back-Tests</a></li>
<li><a href='http://www.automated-trading-system.com/evidence-based-technical-analysis-aronson-book/' rel='bookmark' title='Permanent Link: Evidence-Based Technical Analysis'>Evidence-Based Technical Analysis</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.automated-trading-system.com/bootstrap-take-2-data-mining-bias-code-and-using-geometric-mean/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>CSI Raw Contract Data Extractor</title>
		<link>http://www.automated-trading-system.com/csi-raw-contract-data-extractor/</link>
		<comments>http://www.automated-trading-system.com/csi-raw-contract-data-extractor/#comments</comments>
		<pubDate>Thu, 10 Jun 2010 09:34:38 +0000</pubDate>
		<dc:creator>Jez Liberty</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Data]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[CSI]]></category>
		<category><![CDATA[Unfair Advantage]]></category>

		<guid isPermaLink="false">http://www.automated-trading-system.com/?p=2374</guid>
		<description><![CDATA[I have mentioned before that I use CSI as my main provider for Futures data. Overall, I judge CSI&#8217;s service as good quality &#8211; however one drawback is the closed aspect of the data access. And I decided to write a utility to make it more &#8220;open&#8221;.
To access the historical data, you have to go [...]


Related posts:<ol><li><a href='http://www.automated-trading-system.com/unfair-advantage-api-code-c-extract-futures-continuous-data/' rel='bookmark' title='Permanent Link: Unfair Advantage API Code (C#): Extract Futures Continuous data'>Unfair Advantage API Code (C#): Extract Futures Continuous data</a></li>
<li><a href='http://www.automated-trading-system.com/csi-data-into-tradersstudio/' rel='bookmark' title='Permanent Link: How-To: CSI Data into TradersStudio'>How-To: CSI Data into TradersStudio</a></li>
<li><a href='http://www.automated-trading-system.com/continuous-contract-options/' rel='bookmark' title='Permanent Link: Continuous Contract options'>Continuous Contract options</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div id="attachment_2376" class="wp-caption alignnone" style="width: 428px"><img src="http://www.automated-trading-system.com/wp-content/uploads/2010/06/CSIExtractor.png" alt="CSI Data Extractor: Utility tool to extract CSI data in plain text files" title="CSIExtractor" width="418" height="241" class="size-full wp-image-2376" /><p class="wp-caption-text">CSI Data Extractor: Utility tool to extract CSI data in plain text files</p></div>
<p>I have mentioned <a href="http://www.automated-trading-system.com/unfair-advantage-csi/">before</a> that I use CSI as my main provider for Futures data. Overall, I judge CSI&#8217;s service as good quality &#8211; however one drawback is the <em>closed</em> aspect of the data access. And I decided to write a utility to make it more &#8220;open&#8221;.</p>
<p>To access the historical data, you have to go through their software (Unfair Advantage), which extracts and decrypts it from their proprietary binary format. You can always &#8220;build&#8221; historical files to disk, but these are usually pre-processed with a special algorithm (ie. back-adjusted, etc.).</p>
<p>What more, if you decide to stop your subscription to CSI&#8217;s data services, you will not be able to access any data any more, even historical data downloaded under the subscription contract.</p>
<p>For some of the reasons above, it might be interesting to be able to extract/store CSI&#8217;s <em>raw data</em> in plain text files. This would allow for:</p>
<ul>
<li>Browsing the data outside of the CSI&#8217;s Unfair Advantage software</li>
<li>Applying back-adjustment or other manipulation algorithms not supported by CSI&#8217;s UA (such as calculating the <a href="http://www.automated-trading-system.com/crude-oil-contango-and-roll-yield-for-commodity-trading/">yield curve</a>)</li>
<li>Keep the historical data independently of your CSI subscription</li>
</ul>
<p><span id="more-2374"></span></p>
<p>Note: what I consider CSI raw data is the actual daily information for each contract traded on any day. For example, in the Corn market, there are currently 15 different contracts trading (with different maturities), each with their own Open, High, Low, Close, Volume and Open Interest.</p>
<h3>CSI API to the rescue</h3>
<p>Now, you could easily go to Unfair Advantage and pick every single historical contract that you want to extract&#8230; but this would be a fairly tedious job</p>
<p>Luckily for us, the API allows for programmatic access to CSI&#8217;s data to automate the process of extracting all contracts that we want &#8211; so I decided to write a little utility to do just that.  And now my data is really mine!</p>
<p>Below is a zip file containing the files to copy to &#8220;install&#8221; the utility:</p>
<p><a href='http://www.automated-trading-system.com/wp-content/uploads/2010/06/CSI-DataExtractor.zip'>CSI-DataExtractor.zip</a></p>
<p>Note that you need to have Unfair Advantage installed on the machine running this exe (which does not come with any guarantee by the way&#8230; but I have been using it fine so far).</p>
<p>The operation is very simple: just enter CSI&#8217;s number for the market you want to extract and choose which path the files need to be extracted to.</p>
<p>Hope you&#8217;re finding this tool useful&#8230;</p>
<img src="http://www.automated-trading-system.com/?ak_action=api_record_view&id=2374&type=feed" alt="" />

<p>Related posts:<ol><li><a href='http://www.automated-trading-system.com/unfair-advantage-api-code-c-extract-futures-continuous-data/' rel='bookmark' title='Permanent Link: Unfair Advantage API Code (C#): Extract Futures Continuous data'>Unfair Advantage API Code (C#): Extract Futures Continuous data</a></li>
<li><a href='http://www.automated-trading-system.com/csi-data-into-tradersstudio/' rel='bookmark' title='Permanent Link: How-To: CSI Data into TradersStudio'>How-To: CSI Data into TradersStudio</a></li>
<li><a href='http://www.automated-trading-system.com/continuous-contract-options/' rel='bookmark' title='Permanent Link: Continuous Contract options'>Continuous Contract options</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.automated-trading-system.com/csi-raw-contract-data-extractor/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>New: Free Code section &#8211; and improved Vortex</title>
		<link>http://www.automated-trading-system.com/free-code-improved-vortex/</link>
		<comments>http://www.automated-trading-system.com/free-code-improved-vortex/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 11:27:38 +0000</pubDate>
		<dc:creator>Jez Liberty</dc:creator>
				<category><![CDATA[Backtest]]></category>
		<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Strategies]]></category>
		<category><![CDATA[avx]]></category>
		<category><![CDATA[Trading Blox]]></category>
		<category><![CDATA[vortex]]></category>

		<guid isPermaLink="false">http://www.automated-trading-system.com/?p=1693</guid>
		<description><![CDATA[15 might be similar to ADX>60).
Vortex to the test
The vortex indicator can be used as an entry signal (go long when VMI+ crosses above VMI- and go short with the opposite cross). In addition, the AVX can be thought of as a measure of the strength of a directional vortex movement. The entry signal could [...]


Related posts:<ol><li><a href='http://www.automated-trading-system.com/vortex-indicator/' rel='bookmark' title='Permanent Link: Vortex indicator'>Vortex indicator</a></li>
<li><a href='http://www.automated-trading-system.com/mmdi-portfolio-filter-trading-blox/' rel='bookmark' title='Permanent Link: MMDI Portfolio Filter in Trading Blox'>MMDI Portfolio Filter in Trading Blox</a></li>
<li><a href='http://www.automated-trading-system.com/unfair-advantage-api-code-c-extract-futures-continuous-data/' rel='bookmark' title='Permanent Link: Unfair Advantage API Code (C#): Extract Futures Continuous data'>Unfair Advantage API Code (C#): Extract Futures Continuous data</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div><div id="attachment_1694" class="wp-caption alignleft" style="width: 210px"><img src="http://www.automated-trading-system.com/wp-content/uploads/2010/02/freeforall_almccon2.png" alt="CC picture by almccon@flickr" title="freeforall_almccon2" width="200" height="298" class="size-full wp-image-1694" /><p class="wp-caption-text">CC picture by almccon@flickr</p></div><br />
&nbsp;<br />
I have been sharing code throughout the blog in various posts. Although there is a &#8220;Code&#8221; category in the blog, a <a href="http://www.automated-trading-system.com/free-code/">dedicated page</a> is probably the best way to organise this, before it starts getting messy. I have therefore added a main page (free code) in the nav bar.<br />
&nbsp;<br />
Hope you find it useful. It has been updated with all pieces of code published so far and I will continue to do so with all further code.<br />
&nbsp;<br />
&nbsp;<br />
&nbsp;
</div>
<h3>Improved Vortex indicator</h3>
<p>As mentioned in the original Vortex indicator post, I thought there were some flaws that needed to be corrected in the original version published by the authors (Etienne Botes &#038; Douglas Siepman). I have since heard from them .</p>
<p>They gave me a detailed explanation regarding the logic of their design. The most important consideration is that <strong>they are using their indicator on Forex</strong> &#8211; which is a 24-hour market and therefore exhibits virtually no gap. Moreover, I believe they favoured a simple moving average (to Wilder&#8217;s exponential one) to add extra lag / beneficial noise filtering.</p>
<p>Anyhow, I still thought that the indicator could be improved for non-Forex markets. I also thought that the process could be taken further by creating the <strong>AVX: the Average Vortex Index</strong> (similarly to Welles Wilder&#8217;s ADX, based on the DMI). Well, I coded that up as well.<span id="more-1693"></span></p>
<p>Trading Blox blocks for all this code can be downloaded at the end of the article (or in the new <a href="http://www.automated-trading-system.com/free-code/">free code</a> section).</p>
<h3>Updated calculation logic</h3>
<p>I started prototyping the calculations in Excel for the original Wilder DMI and ADX, the original Vortex indicator and my improved version. Please find the <a href="http://www.automated-trading-system.com/wp-content/uploads/2010/02/ImprovedVortexCalcs.xls" target="_blank">Excel spreadsheet</a> for your perusal.</p>
<p>As mentioned in the initial <a href="http://www.automated-trading-system.com/vortex-indicator/">Vortex indicator post</a>, the original calculation did not handle gap days appropriately (in my opinion) and was not replicating the smoothing implemented in Wilder&#8217;s DMI by the use of an exponential Moving Average (Wilder&#8217;s to be precise) for the VI/TR calculation.</p>
<p>The logic implemented is as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">VM+ = High - Low[1]</pre></div></div>

<p>(VM+ is today&#8217;s High minus yesterdays&#8217; Low, can be negative, in case of down gaps)</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">VM- = High[1] - Low</pre></div></div>

<p>(VM- is yesterday&#8217;s High minus today&#8217; Low, can be negative, in case of up gaps)</p>
<p>True Range (TR) is calculated as per the <a href="http://www.csidata.com/studies/True_Range_(TR).html" target="_blank" rel="nofollow">standard formula</a>.</p>
<p>These 3 daily indicators are then smoothed using the &#8220;Wilder&#8221; <a href="http://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average" target="_blank">exponential moving average</a> (alpha = 1 / N ). These give us AVM+, AVM- and ATR. </p>
<p>Normalise AVM+ and AVM- by ATR to obtain the improved VI+ and VI-.</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">VI+ =AVM+/ATR
VI- =AVM-/ATR</pre></div></div>

<p>Building upon these calculations, we can just replicate the ADX logic to create the AVX indicator:</p>
<p>Calculate the VX:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">VX = (VI+ - VI-) / (VI+ + VI-) x 100</pre></div></div>

<p>VX is then smoothed (using Wilder moving average) to produce the AVX.</p>
<p><strong>Now we&#8217;re talking!</strong></p>
<p><em>Note that because VM and VI both have higher values than the original DM and DMI, VX and AVX,which express the relative difference of VI+ and VI-) will not register values as high as the ADX. But that&#8217;s ok &#8211; it just means we work on a different scale (where AVX>15 might be similar to ADX>60).</em></p>
<h3>Vortex to the test</h3>
<p>The vortex indicator can be used as an entry signal (go long when VMI+ crosses above VMI- and go short with the opposite cross). In addition, the AVX can be thought of as a measure of the strength of a directional vortex movement. The entry signal could be enhanced by only taking the signals where the AVX breaches a specific strength threshold (note: this is a very similar logic to the ADX system that ships with Trading Blox).</p>
<p><a href="http://www.automated-trading-system.com/e-ratio-trading-edge/">Calculating the e-ratio</a> for the VMI/AVX entry is a great way to measure the edge of that specific entry.</p>
<p>Another great thing is the <em>Blox marketplace</em> where Trading Blox users share their custom code. And guess what? There was a block available for e-ratio calculation. Great! I love it when I can leverage existing code&#8230;</p>
<p>With a bit of updating of the system I managed to run the e-ratio calc on 3 different entry signals:</p>
<ul>
<li>Simple VMI cross </li>
<li>VMI cross with AVX threshold filter (threshold = 10)</li>
<li>VMI cross with AVX threshold filter (threshold = 15)</li>
</ul>
<p>Below are the charts for each of the entries:</p>
<div id="attachment_1716" class="wp-caption alignnone" style="width: 418px"><img src="http://www.automated-trading-system.com/wp-content/uploads/2010/02/chartAVX.png" alt="caption: e-ratio plotted for length of 1 to 100 days" title="chartAVX" width="408" height="361" class="size-full wp-image-1716" /><p class="wp-caption-text">e-ratio plotted for length of 1 to 100 days</p></div>
<p>Notice how the AVX threshold does not seem to help and is completely counter-productive in the &#8220;AVX>15&#8243; case. In a classic example of <em>curve-fitting / data snooping</em>, we could decide to turn around the AVX threshold logic and only take signals for which the AVX is below 15. But we will not do that. Bad practice ;-)</p>
<h3>Conclusion</h3>
<p>I was not expecting much out of this study. I was mostly using it as material for getting to use Trading Blox. I was not surprised by either: I found Trading Blox easy to get a handle on. Definitely a productivity boost compared to TradersStudio, both in terms of development and simulation running time.</p>
<p>With regards to the vortex indicator, it does seem to provide a (small) edge when used as the authors intended to (albeit in a modified form). The AVX filtering, on the other hand, did not seem to improve anything at all. Maybe the edge would have been better, had I not &#8220;messed up&#8221; with the indicator&#8230;</p>
<h4>Code download</h4>
<p>Please find below the individual components (blocks) for download:<br />
<a href="http://www.automated-trading-system.com/wp-content/uploads/2010/02/Au.Tra.Sy-Vortex-AVX-Indicator.tbx">improved Vortex Indicator &#038; AVX auxiliary block file</a> (tbx)<br />
<a href="http://www.automated-trading-system.com/wp-content/uploads/2010/02/AVX-Entry-Exit.tbx">AVX Entry Exit block</a> (tbx)<br />
<a href="http://www.automated-trading-system.com/wp-content/uploads/2010/02/AVX-System.tbs">AVX System</a> (tbs)<br />
<a href="http://www.automated-trading-system.com/wp-content/uploads/2010/02/Au.Tra.Sy-imrpoved-Vortex-AVX.zip">The lot in a zip file</a></p>
<img src="http://www.automated-trading-system.com/?ak_action=api_record_view&id=1693&type=feed" alt="" />

<p>Related posts:<ol><li><a href='http://www.automated-trading-system.com/vortex-indicator/' rel='bookmark' title='Permanent Link: Vortex indicator'>Vortex indicator</a></li>
<li><a href='http://www.automated-trading-system.com/mmdi-portfolio-filter-trading-blox/' rel='bookmark' title='Permanent Link: MMDI Portfolio Filter in Trading Blox'>MMDI Portfolio Filter in Trading Blox</a></li>
<li><a href='http://www.automated-trading-system.com/unfair-advantage-api-code-c-extract-futures-continuous-data/' rel='bookmark' title='Permanent Link: Unfair Advantage API Code (C#): Extract Futures Continuous data'>Unfair Advantage API Code (C#): Extract Futures Continuous data</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.automated-trading-system.com/free-code-improved-vortex/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Vortex indicator</title>
		<link>http://www.automated-trading-system.com/vortex-indicator/</link>
		<comments>http://www.automated-trading-system.com/vortex-indicator/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 10:59:02 +0000</pubDate>
		<dc:creator>Jez Liberty</dc:creator>
				<category><![CDATA[Backtest]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[ADX]]></category>
		<category><![CDATA[DMI]]></category>
		<category><![CDATA[IPV]]></category>
		<category><![CDATA[Trading Blox]]></category>
		<category><![CDATA[vortex]]></category>
		<category><![CDATA[Welles Wilder]]></category>

		<guid isPermaLink="false">http://www.automated-trading-system.com/?p=1600</guid>
		<description><![CDATA[I recently came across the Vortex Indicator, which aims to leverage the chaotic science of fluid mechanics (vortices) into a new indicator. I decided to code up this interesting concept in Trading Blox.
The indicator logic is described in the January issue of TASC (Technical Analysis of Stocks and Commodities) and sounds intriguing (link to PDF [...]


Related posts:<ol><li><a href='http://www.automated-trading-system.com/free-code-improved-vortex/' rel='bookmark' title='Permanent Link: New: Free Code section &#8211; and improved Vortex'>New: Free Code section &#8211; and improved Vortex</a></li>
<li><a href='http://www.automated-trading-system.com/mmdi-portfolio-filter-trading-blox/' rel='bookmark' title='Permanent Link: MMDI Portfolio Filter in Trading Blox'>MMDI Portfolio Filter in Trading Blox</a></li>
<li><a href='http://www.automated-trading-system.com/e-ratio-tradersstudio-excel/' rel='bookmark' title='Permanent Link: e-ratio calculation in TradersStudio and Excel'>e-ratio calculation in TradersStudio and Excel</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I recently came across the <strong>Vortex Indicator</strong>, which aims to leverage the chaotic science of fluid mechanics (vortices) into a new indicator. I decided to code up this interesting concept in Trading Blox.</p>
<div id="attachment_1612" class="wp-caption aligncenter" style="width: 490px"><img src="http://www.automated-trading-system.com/wp-content/uploads/2010/02/VortexbyNASA.png" alt="Vortex is present in chaotic movements such as fluid mechanics - picture courtesy of NASA" title="VortexbyNASA" width="480" height="367" class="size-full wp-image-1612" /><p class="wp-caption-text">Vortex is present in chaotic movements such as fluid mechanics - picture courtesy of NASA</p></div>
<p>The indicator logic is described in the January issue of TASC (Technical Analysis of Stocks and Commodities) and sounds intriguing (<a href="http://www.traders.com/Reprints/PDF_reprints/VFX_VORTEX.PDF" target="_blank" rel="nofollow">link to PDF article</a>). Without rehashing the details of the indicator calculation, it is very similar to Welles Wilder&#8217;s <a href="http://www.csidata.com/studies/Directional_Movement_Index_(DI_and_-DI).html" target="_blank" rel="nofollow">Directional Movement Index Calculation (DMI)</a> except that Wilder&#8217;s Directional Movement (largest part of today&#8217;s range outside of yesterday&#8217;s range) is replaced by calculating the differences between today&#8217;s High and yesterday&#8217;s Low (positive Vortex Movement) and today&#8217;s Low and yesterday&#8217;s High (negative Vortex Movement).</p>
<p><img src="http://www.automated-trading-system.com/wp-content/uploads/2010/02/vortex.png" alt="vortex" title="vortex" width="354" height="164" class="alignnone size-full wp-image-1613" /><br />
<span id="more-1600"></span><br />
TASC provides the Vortex indicator implementations in a wide collection of backtesting platforms (<a href="http://www.traders.com/Documentation/FEEDbk_docs/2010/01/TradersTips.html" target="_blank" rel="nofollow">here</a>). <del datetime="2010-02-14T22:28:05+00:00">Unfortunately</del> the <strong>Trading Blox</strong> implementation is not provided, which provided me a perfect opportunity to test and learn my new &#8220;backtesting toy&#8221; out.<br />
<a name="flaw"></a></p>
<h3>System Logic Flaw?</h3>
<p>The authors of the indicator provide a sample Excel spreadsheet to illustrate their calculation. By replicating the logic in Excel to get a handle on it (<a href="http://www.automated-trading-system.com/wp-content/uploads/2010/02/VortexCalcs0.xls" target="_blank">link to Excel spreadsheet</a>), I uncovered what I think is a flaw in the logic of the indicator of the calculation.</p>
<p>The VM calculations take the absolute value of the difference of opposite price extremes (High and Low) between today and yesterday. The screenshot of this <a href="http://www.automated-trading-system.com/wp-content/uploads/2010/02/VortexFlaws.xls" target="_blank">Excel spreadsheet</a> below clearly illustrates that this is a problem when dealing with gaps.</p>
<p><img src="http://www.automated-trading-system.com/wp-content/uploads/2010/02/Vortex-Flaws.png" alt="Vortex Flaws" title="Vortex Flaws" width="476" height="784" class="alignnone size-full wp-image-1614" /></p>
<p>Additionally, one could argue that the simple summation/averaging of the VMs is different from the original DMI calculations which use <a href="http://www.csidata.com/studies/Welles_Wilder_Moving_Average.html" target="_blank" rel="nofollow">Wilder Moving Averages</a>.</p>
<p>I have emailed the authors of the indicator with a suggestion for a fix. I&#8217;ll relay their answer here.</p>
<h3>Trading Blox implementation</h3>
<p>First and foremost, this is a Trading Blox coding exercise so I was not too concerned about these flaws (although I might be tempted to implement my own version addessing both flaws later).</p>
<p>I suggest you follow the calculation logic on the PDF article or the Excel spreadsheet. Here is how I implemented the Vortex Indicator in Trading Blox:</p>
<h4>1: Create Auxiliary Block</h4>
<p>This will hold all indicators and implement their calculations. Call it Vortex Indicator.</p>
<h4>2: Create parameters</h4>
<p>There is one parameter: the period for the Vortex indicator (VI) calculation:</p>
<p><img src="http://www.automated-trading-system.com/wp-content/uploads/2010/02/viDaysParam.png" alt="viDaysParam" title="viDaysParam" width="399" height="309" class="alignnone size-full wp-image-1615" /></p>
<h4>3: Create Indicators</h4>
<p>These are the first-level calculations: the daily True Range (TR), and VM+ (plusVM) and VM- (minusVM).</p>
<div id="attachment_1616" class="wp-caption alignnone" style="width: 460px"><img src="http://www.automated-trading-system.com/wp-content/uploads/2010/02/plusVM.png" alt="VM+ indicator using a calculated formula" title="plusVM" width="450" height="306" class="size-full wp-image-1616" /><p class="wp-caption-text">VM+ indicator using a calculated formula</p></div>
<p>The code for each of these indicators is:</p>
<p>plusVM (VM+ is the difference between today&#8217;s High and yesterday&#8217;s Low):</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">Abs(instrument.High - instrument.Low[1])</pre></div></div>

<p>minusVM (VM- is the difference between today&#8217;s Low and yesterday&#8217;s High):</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">Abs(instrument.High[1]-instrument.Low)</pre></div></div>

<p>TR (standard True Range calculation):</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">Max(instrument.High-instrument.Low,Abs(instrument.High-instrument.<span style="color: #000080;">Close</span>[1]), Abs(instrument.Low-instrument.<span style="color: #000080;">Close</span>[1]))</pre></div></div>

<h4>4: Create Instrument Permanent Variables (IPV)</h4>
<p>This is for next-level calculations (Sum of TR, Sum of VM+ and VM-, VI+ and VI-). Setting these up as IPV allow for their values to be made available to other blocks (such the Entry block of a system).</p>
<div id="attachment_1618" class="wp-caption alignnone" style="width: 470px"><img src="http://www.automated-trading-system.com/wp-content/uploads/2010/02/plusVI_IPV1.png" alt="Notice how the variable scope has been updated to &quot;System&quot;" title="plusVI_IPV" width="460" height="357" class="size-full wp-image-1618" /><p class="wp-caption-text">Notice how the variable scope has been updated to System</p></div>
<p>The values for these IPVs are updated in the block <em>Update Indicators</em> script:</p>
<p><img src="http://www.automated-trading-system.com/wp-content/uploads/2010/02/UpdateIndicators.png" alt="UpdateIndicators" title="UpdateIndicators" width="480" height="447" class="alignnone size-full wp-image-1619" /></p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">plusVMSum=Sum(plusVM,viDays,0)
minusVMSum=Sum(minusVM,viDays,0)
TRSum=Sum(TR,viDays,0)
plusVI=plusVMSum/TRSum
minusVI=minusVMSum/TRSum</pre></div></div>

<h3>Use in Trading Blox</h3>
<p>Adding the auxiliary block to any System will enable it to access the values of the vortex indicators.</p>
<p>Here is how it could be done for a simple reversal system switching from Short to Long when VI+ crosses with VI- (and vice-versa).</p>
<h4>Create an Entry Exit block</h4>
<p>The system will have the Vortex Indicator Auxiliary block and our new Entry Exit block.</p>
<h4>Add VI+ and VI- as IPV to the Entry Exit block</h4>
<p>This is just a declaration to indicate that the values of these indicators are calculated in another block (our Vortex Indicator Auxiliary block).</p>
<div id="attachment_1620" class="wp-caption alignnone" style="width: 470px"><img src="http://www.automated-trading-system.com/wp-content/uploads/2010/02/IPV_External.png" alt="The IPV is defined externally in another block (Vortex indicator)" title="IPV_External" width="460" height="241" class="size-full wp-image-1620" /><p class="wp-caption-text">The IPV is defined externally in another block (Vortex indicator)</p></div>
<p>The other parameters and indicators in this block are standard ATR Stop elements.</p>
<h4>Code up the entry formula</h4>
<p>Simple logic to enter long when VI+ is above VI- and no long position are in and opposite for short entry:</p>
<p><img src="http://www.automated-trading-system.com/wp-content/uploads/2010/02/Entry.png" alt="Entry" title="Entry" width="480" height="343" class="alignnone size-full wp-image-1621" /></p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">VARIABLES: pvi <span style="color: #000080;">TYPE</span>: Floating
pvi = plusVI
VARIABLES: nvi <span style="color: #000080;">TYPE</span>: Floating
nvi = minusVI	
VARIABLES: pos <span style="color: #000080;">TYPE</span>: <span style="color: #000080;">String</span>
pos = instrument.position
&nbsp;
<span style="color: #000080;">IF</span> 	plusVI &gt; minusVI <span style="color: #000080;">AND</span>
	instrument.position &lt;&gt; <span style="color: #000080;">LONG</span> <span style="color: #000080;">THEN</span>
&nbsp;
	<span style="color: #000080;">IF</span> useATRStops <span style="color: #000080;">THEN</span>
		broker.EnterLongOnOpen( instrument.<span style="color: #000080;">close</span> - averageTrueRange * atrStop )
	<span style="color: #000080;">ELSE</span>
		broker.EnterLongOnOpen
	ENDIF
&nbsp;
ENDIF
&nbsp;
<span style="color: #000080;">IF</span>	plusVI &lt; minusVI <span style="color: #000080;">AND</span>
	instrument.position &lt;&gt; SHORT <span style="color: #000080;">THEN</span>
&nbsp;
	<span style="color: #000080;">IF</span> useATRStops <span style="color: #000080;">THEN</span>
		broker.EnterShortOnOpen( instrument.<span style="color: #000080;">close</span> + averageTrueRange * atrStop )
	<span style="color: #000080;">ELSE</span>
		broker.EnterShortOnOpen
	ENDIF
&nbsp;
ENDIF</pre></div></div>

<h3>Trading Blox test</h3>
<p>Although I would like to do a more complete test to compare the Vortex Indicator to the DMI, all I have time left for today is a simple run of the system described above. I arbitrarily chose 39 for the VI period and here is the result:</p>
<table style="border:1px solid #c3c3c3; border-collapse:collapse;">
<tr>
<th style="background-color:#e5eecc; border:1px solid #c3c3c3; padding:5px;">
      CAGR
    </th>
<th style="background-color:#e5eecc; border:1px solid #c3c3c3; padding:5px;">
      Sharpe ratio
    </th>
<th style="background-color:#e5eecc; border:1px solid #c3c3c3; padding:5px;">
      Max DD
    </th>
</tr>
<tr>
<td style="background-color:#ffffff; border:1px solid #c3c3c3; padding:2px;">
5.80%
    </td>
<td style="background-color:#ffffff; border:1px solid #c3c3c3; padding:2px;" align = "right">
<div style="color:black">0.10</div>
</td>
<td style="background-color:#ffffff; border:1px solid #c3c3c3; padding:2px;" align = "right">
<div style="color:black">42.4%</div>
</td>
</tr>
</table>
<p>&nbsp;<br />
<div id="attachment_1627" class="wp-caption alignnone" style="width: 500px"><img src="http://www.automated-trading-system.com/wp-content/uploads/2010/02/LogarithmicEquityGraph_vortex11.png" alt="Logarithmic Equity curve from Vortex indicator system" title="LogarithmicEquityGraph_vortex1" width="490" height="295" class="size-full wp-image-1627" /><p class="wp-caption-text">Logarithmic Equity curve from Vortex indicator system</p></div></p>
<p>And as a side note of caution when dealing with backtest results, I&#8217;ll show you a quick trick that will allow me to nearly double the CAGR (Compounded Annual Growth Rate) by not touching the system at all:</p>
<table style="border:1px solid #c3c3c3; border-collapse:collapse;">
<tr>
<th style="background-color:#e5eecc; border:1px solid #c3c3c3; padding:5px;">
      CAGR
    </th>
<th style="background-color:#e5eecc; border:1px solid #c3c3c3; padding:5px;">
      Sharpe ratio
    </th>
<th style="background-color:#e5eecc; border:1px solid #c3c3c3; padding:5px;">
      Max DD
    </th>
</tr>
<tr>
<td style="background-color:#ffffff; border:1px solid #c3c3c3; padding:2px;">
10.93%
    </td>
<td style="background-color:#ffffff; border:1px solid #c3c3c3; padding:2px;" align = "right">
<div style="color:black">0.26</div>
</td>
<td style="background-color:#ffffff; border:1px solid #c3c3c3; padding:2px;" align = "right">
<div style="color:black">33.0%</div>
</td>
</tr>
</table>
<p>&nbsp;<br />
<div id="attachment_1628" class="wp-caption alignnone" style="width: 500px"><img src="http://www.automated-trading-system.com/wp-content/uploads/2010/02/LogarithmicEquityGraph_vortex2.png" alt="Logarithmic Equity curve from Vortex indicator system (truncated period)" title="LogarithmicEquityGraph_vortex2" width="490" height="295" class="size-full wp-image-1628" /><p class="wp-caption-text">Logarithmic Equity curve from Vortex indicator system (truncated period)</p></div></p>
<p>Notice what happened there: I just dropped years 1996 to 1999 from the backtests. Et voila! Surely a trick employed by more than one dubious trading systems salesmen&#8230;</p>
<h3>Conclusion</h3>
<p><del datetime="2010-02-17T00:25:39+00:00">The authors claim that the Vortex indicator improve on the DMI invented by Welles Wilder</del> Update: the authors have sent me an email to clarify that they have not made such claim (I was merely interpolating, given the ressemblance of the Vortex indicator with the DMI). It would be interesting to test this as the idea of mixing chaos/fluid mechanics concepts to price movements is appealing. Fixing the indicator flaws would be good too. More to come&#8230; (update: on the <a href="http://www.automated-trading-system.com/free-code-improved-vortex/">next post</a>, I also explain the authors response to my claim of the indicator having flaws).</p>
<h4>Code download</h4>
<p>Please find below the individual components (blocks) for download:<br />
<a href="http://www.automated-trading-system.com/wp-content/uploads/2010/02/Vortex-Indicator.tbx">link to Vortex indicator block file</a> (tbx)<br />
<a href="http://www.automated-trading-system.com/wp-content/uploads/2010/02/VI-Entry-Exit.tbx">link to VI sample Entry Exit block</a> (tbx)</p>
<img src="http://www.automated-trading-system.com/?ak_action=api_record_view&id=1600&type=feed" alt="" />

<p>Related posts:<ol><li><a href='http://www.automated-trading-system.com/free-code-improved-vortex/' rel='bookmark' title='Permanent Link: New: Free Code section &#8211; and improved Vortex'>New: Free Code section &#8211; and improved Vortex</a></li>
<li><a href='http://www.automated-trading-system.com/mmdi-portfolio-filter-trading-blox/' rel='bookmark' title='Permanent Link: MMDI Portfolio Filter in Trading Blox'>MMDI Portfolio Filter in Trading Blox</a></li>
<li><a href='http://www.automated-trading-system.com/e-ratio-tradersstudio-excel/' rel='bookmark' title='Permanent Link: e-ratio calculation in TradersStudio and Excel'>e-ratio calculation in TradersStudio and Excel</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.automated-trading-system.com/vortex-indicator/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Amibroker e-ratio code</title>
		<link>http://www.automated-trading-system.com/e-ratio-amibroker-code/</link>
		<comments>http://www.automated-trading-system.com/e-ratio-amibroker-code/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 12:30:53 +0000</pubDate>
		<dc:creator>Jez Liberty</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[afl]]></category>
		<category><![CDATA[amibroker]]></category>
		<category><![CDATA[e-ratio]]></category>
		<category><![CDATA[edge]]></category>
		<category><![CDATA[optimisation]]></category>
		<category><![CDATA[tradersstudio]]></category>

		<guid isPermaLink="false">http://www.automated-trading-system.com/?p=901</guid>
		<description><![CDATA[I recently posted about the e-ratio as a tool to measure parts of a trading system (the code files to compute the e-ratio in TradersStudio and Excel are also available). The e-ratio is supposed to be a quick tool to check how signals might add some edge to a trading system. However computing the e-ratio [...]


Related posts:<ol><li><a href='http://www.automated-trading-system.com/amibroker-tradersstudio-speed-comparison/' rel='bookmark' title='Permanent Link: Amibroker V. TradersStudio: Speed comparison Fight'>Amibroker V. TradersStudio: Speed comparison Fight</a></li>
<li><a href='http://www.automated-trading-system.com/amibroker-v-tradersstudio-comparison/' rel='bookmark' title='Permanent Link: Amibroker vs TradersStudio: comparison'>Amibroker vs TradersStudio: comparison</a></li>
<li><a href='http://www.automated-trading-system.com/e-ratio-tradersstudio-excel/' rel='bookmark' title='Permanent Link: e-ratio calculation in TradersStudio and Excel'>e-ratio calculation in TradersStudio and Excel</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I recently posted about the <a href="http://www.automated-trading-system.com/e-ratio-trading-edge/">e-ratio</a> as a tool to measure parts of a trading system (the <a href="http://www.automated-trading-system.com/e-ratio-tradersstudio-excel/">code files to compute the e-ratio in TradersStudio and Excel</a> are also available). The e-ratio is supposed to be a quick tool to check how signals might add some edge to a trading system. However computing the e-ratio in TradersStudio is slow (4+ hours for one signal over 100 different durations).</p>
<p>So I decided to give the &#8220;legendary fast&#8221; Amibroker a test to see if it could better TradersStudio&#8217;s performance. After some &#8220;playing and learning&#8221;, I have finalised the code to compute the e-ratio. My big thanks go to the <a href="http://theasxgorilla.blogspot.com/2007/07/how-to-compute-edge-ratio-in-amibroker.html" target="_blank" rel="nofollow">ASX gorilla</a> whose own version forms a large part of my code.<span id="more-901"></span></p>
<p>Below is the code explanation and downloadable <a href="http://www.automated-trading-system.com/wp-content/uploads/2009/11/e-ratio-gorilla.afl" target="_blank">afl file</a>.</p>
<p>Directly from the ASX Gorilla&#8217;s website as a prelude to the code:</p>
<blockquote><p>My implementation of the Edge Ratio involves two profound Amibroker fudges. The first is the use of the AddToComposite function to create a composite ticker symbol in which to hold the ATR array of a given stock for later retrieval within the Custom Back Tester via the Foreign function.</p></blockquote>
<blockquote><p>The second fudge is the use of the VarSet/VarGet function to create a quasi array. This was necessary to overcome the limitation where array elements cannot exceed in number the value of barcount-1.</p></blockquote>
<p>The first part is to actually code up your Buy signal (in our case a Donchian Channel Breakout). The Sell signals are tested separately:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">//BUY RULES: implemented with Buy Stop on Upper Donchian Channel(17)</span>
BuyStop <span style="color: #002200;">=</span> Ref<span style="color: #002200;">&#40;</span>HHV<span style="color: #002200;">&#40;</span>High, <span style="color: #2400d9;">17</span><span style="color: #002200;">&#41;</span>,<span style="color: #002200;">-</span><span style="color: #2400d9;">1</span><span style="color: #002200;">&#41;</span>;
Buy <span style="color: #002200;">=</span> Cross<span style="color: #002200;">&#40;</span> High, BuyStop <span style="color: #002200;">&#41;</span>;
BuyPrice <span style="color: #002200;">=</span> Max<span style="color: #002200;">&#40;</span> BuyStop, Low <span style="color: #002200;">&#41;</span>; <span style="color: #11740a; font-style: italic;">// make sure buy price &gt;= Low</span></pre></div></div>

<p>Exiting positions is done on a fixed duration basis:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">//Never Sell so that the position is stopped out after N bar instead</span>
Sell <span style="color: #002200;">=</span> <span style="color: #2400d9;">3</span> &gt; <span style="color: #2400d9;">5</span>;
<span style="color: #11740a; font-style: italic;">//Stop the positon and close it after N bars</span>
<span style="color: #11740a; font-style: italic;">//(eratio = N that we step from 1 to 100 in optimisation)</span>
ApplyStop<span style="color: #002200;">&#40;</span> stopTypeNBar, stopModeBars, eratio <span style="color: #002200;">&#41;</span>;</pre></div></div>

<p>The first fudge mentioned above to store the ATR:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">Normaliser <span style="color: #002200;">=</span> ATR<span style="color: #002200;">&#40;</span><span style="color: #2400d9;">17</span><span style="color: #002200;">&#41;</span>;
AddToComposite<span style="color: #002200;">&#40;</span>Normaliser, <span style="color: #bf1d1a;">&quot;~atr_&quot;</span><span style="color: #002200;">+</span>Name<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>, <span style="color: #bf1d1a;">&quot;C&quot;</span>, <span style="color: #2400d9;">1</span><span style="color: #002200;">+</span><span style="color: #2400d9;">2</span><span style="color: #002200;">+</span><span style="color: #2400d9;">8</span><span style="color: #002200;">&#41;</span>;</pre></div></div>

<p>And the &#8220;meat&#8221; of the code: the chunk that implements the custom back-testing to:</p>
<ol>
<li>Loop through the signals and store the Entry ATR value.</li>
<li>Loop through all trades and retrieve MFE, MAE and ATR.</li>
<li>Compute the e-ratio based on values from all trades.</li>
</ol>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;">SetCustomBacktestProc<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">&quot;&quot;</span><span style="color: #002200;">&#41;</span>; <span style="color: #11740a; font-style: italic;">//activate the custom backtester</span>
<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>Status<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">&quot;action&quot;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">==</span> actionPortfolio<span style="color: #002200;">&#41;</span> <span style="color: #11740a; font-style: italic;">//called when backtesting/optimising</span>
<span style="color: #002200;">&#123;</span>
	bo <span style="color: #002200;">=</span> GetBacktesterObject<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>;
	bo.PreProcess<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>; <span style="color: #11740a; font-style: italic;">// run default backtest procedure</span>
	TradeATR <span style="color: #002200;">=</span> NumTrades <span style="color: #002200;">=</span> ATRArr <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>; <span style="color: #11740a; font-style: italic;">//init variables</span>
	<span style="color: #a61390;">for</span><span style="color: #002200;">&#40;</span> bar<span style="color: #002200;">=</span><span style="color: #2400d9;">0</span>; bar &lt; BarCount<span style="color: #002200;">-</span><span style="color: #2400d9;">1</span>; bar<span style="color: #002200;">++</span><span style="color: #002200;">&#41;</span>
	<span style="color: #002200;">&#123;</span>
		bo.ProcessTradeSignals<span style="color: #002200;">&#40;</span>bar<span style="color: #002200;">&#41;</span>;
&nbsp;
		<span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span> sig<span style="color: #002200;">=</span>bo.GetFirstSignal<span style="color: #002200;">&#40;</span>bar<span style="color: #002200;">&#41;</span>; sig; sig<span style="color: #002200;">=</span>bo.GetNextSignal<span style="color: #002200;">&#40;</span>bar<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#41;</span>
		<span style="color: #002200;">&#123;</span>
			<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>sig.isEntry<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>
			<span style="color: #002200;">&#123;</span>
				NumTrades<span style="color: #002200;">++</span>;
				ATRArr <span style="color: #002200;">=</span> Foreign<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">&quot;~atr_&quot;</span><span style="color: #002200;">+</span>sig.Symbol, <span style="color: #bf1d1a;">&quot;C&quot;</span><span style="color: #002200;">&#41;</span>;
				VarSet<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">&quot;TradeATR&quot;</span> <span style="color: #002200;">+</span> NumTrades, ATRArr<span style="color: #002200;">&#91;</span>bar<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>;
&nbsp;
				_TRACE<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">&quot;Symbol &quot;</span> <span style="color: #002200;">+</span> sig.Symbol <span style="color: #002200;">+</span> <span style="color: #bf1d1a;">&quot; ATR: &quot;</span> <span style="color: #002200;">+</span> VarGet<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">&quot;TradeATR&quot;</span> <span style="color: #002200;">+</span> NumTrades<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>;
			<span style="color: #002200;">&#125;</span>
		<span style="color: #002200;">&#125;</span>
	<span style="color: #002200;">&#125;</span>
&nbsp;
	AvgMAE <span style="color: #002200;">=</span> AccumMAE <span style="color: #002200;">=</span> AvgMFE <span style="color: #002200;">=</span> AccumMFE <span style="color: #002200;">=</span> NumTrades <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>;
&nbsp;
	<span style="color: #11740a; font-style: italic;">// iterate through closed trades</span>
	<span style="color: #a61390;">for</span><span style="color: #002200;">&#40;</span> trade <span style="color: #002200;">=</span> bo.GetFirstTrade<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>; trade; trade <span style="color: #002200;">=</span> bo.GetNextTrade<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#41;</span>
	<span style="color: #002200;">&#123;</span>
		NumTrades<span style="color: #002200;">++</span>;
		EntryATR <span style="color: #002200;">=</span> VarGet <span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">&quot;TradeATR&quot;</span> <span style="color: #002200;">+</span> NumTrades<span style="color: #002200;">&#41;</span>;
		<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span> EntryATR <span style="color: #002200;">!=</span> <span style="color: #2400d9;">0</span> <span style="color: #002200;">&#41;</span>
		<span style="color: #002200;">&#123;</span>
			_TRACE<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">&quot;EntryATR: &quot;</span> <span style="color: #002200;">+</span> WriteVal<span style="color: #002200;">&#40;</span>EntryATR<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>;
			_TRACE<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">&quot;AccumMAE : &quot;</span> <span style="color: #002200;">+</span> WriteVal<span style="color: #002200;">&#40;</span>AccumMAE<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>;
			AccumMAE <span style="color: #002200;">=</span> AccumMAE <span style="color: #002200;">+</span> <span style="color: #002200;">&#40;</span>trade.GetMAE<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">*</span>trade.EntryPrice<span style="color: #002200;">/</span><span style="color: #002200;">&#40;</span><span style="color: #2400d9;">100</span><span style="color: #002200;">*</span>EntryATR<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>;
			AccumMFE <span style="color: #002200;">=</span> AccumMFE <span style="color: #002200;">+</span> <span style="color: #002200;">&#40;</span>trade.GetMFE<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">*</span>trade.EntryPrice<span style="color: #002200;">/</span><span style="color: #002200;">&#40;</span><span style="color: #2400d9;">100</span><span style="color: #002200;">*</span>EntryATR<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>;
		<span style="color: #002200;">&#125;</span>
&nbsp;
		trade.AddCustomMetric<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">&quot;My MAE&quot;</span>, trade.GetMAE<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">*</span>trade.EntryPrice<span style="color: #002200;">/</span><span style="color: #2400d9;">100</span><span style="color: #002200;">&#41;</span>;
		trade.AddCustomMetric<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">&quot;My MFE&quot;</span>, trade.GetMFE<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">*</span>trade.EntryPrice<span style="color: #002200;">/</span><span style="color: #2400d9;">100</span><span style="color: #002200;">&#41;</span>;
		trade.AddCustomMetric<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">&quot;Entry ATR&quot;</span>, EntryATR<span style="color: #002200;">*</span><span style="color: #2400d9;">10000</span><span style="color: #002200;">&#41;</span>;
	<span style="color: #002200;">&#125;</span>
&nbsp;
	AvgMAE <span style="color: #002200;">=</span> AccumMAE <span style="color: #002200;">/</span> NumTrades;
	AvgMFE <span style="color: #002200;">=</span> AccumMFE <span style="color: #002200;">/</span> NumTrades;
&nbsp;
	_TRACE<span style="color: #002200;">&#40;</span>WriteVal<span style="color: #002200;">&#40;</span>AccumMAE <span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>;
	_TRACE<span style="color: #002200;">&#40;</span>WriteVal<span style="color: #002200;">&#40;</span>NumTrades<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>;
	_TRACE<span style="color: #002200;">&#40;</span>WriteVal<span style="color: #002200;">&#40;</span>AvgMAE<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>;
&nbsp;
	Eratio <span style="color: #002200;">=</span> <span style="color: #a61390;">abs</span><span style="color: #002200;">&#40;</span>AvgMFE<span style="color: #002200;">/</span>AvgMAE<span style="color: #002200;">&#41;</span>;
&nbsp;
	_TRACE<span style="color: #002200;">&#40;</span>WriteVal<span style="color: #002200;">&#40;</span>Eratio<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>;
&nbsp;
	bo.AddCustomMetric<span style="color: #002200;">&#40;</span> <span style="color: #bf1d1a;">&quot;Avg MAE&quot;</span>, AvgMAE <span style="color: #002200;">&#41;</span>;
	bo.AddCustomMetric<span style="color: #002200;">&#40;</span> <span style="color: #bf1d1a;">&quot;Avg MFE&quot;</span>, AvgMFE <span style="color: #002200;">&#41;</span>;
	bo.AddCustomMetric<span style="color: #002200;">&#40;</span> <span style="color: #bf1d1a;">&quot;Eratio&quot;</span>, Eratio<span style="color: #002200;">&#41;</span>;
&nbsp;
	bo.PostProcess<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>;
<span style="color: #002200;">&#125;</span></pre></div></div>

<p>If you want to run this code, you can download the <a href="http://www.automated-trading-system.com/wp-content/uploads/2009/11/e-ratio-gorilla.afl" target="_blank">e-ratio &#8220;gorilla&#8221; afl file</a> and simply update the BUY signals to whatever you fancy testing.</p>
<p>The next post will be a direct speed comparison between TradersStudio and Amibroker for computing the e-ratio on the same underlying data and with the same signal. I expect Amibroker to <em>win the fight</em> hands-down as it appeared &#8220;way&#8221; faster!</p>
<img src="http://www.automated-trading-system.com/?ak_action=api_record_view&id=901&type=feed" alt="" />

<p>Related posts:<ol><li><a href='http://www.automated-trading-system.com/amibroker-tradersstudio-speed-comparison/' rel='bookmark' title='Permanent Link: Amibroker V. TradersStudio: Speed comparison Fight'>Amibroker V. TradersStudio: Speed comparison Fight</a></li>
<li><a href='http://www.automated-trading-system.com/amibroker-v-tradersstudio-comparison/' rel='bookmark' title='Permanent Link: Amibroker vs TradersStudio: comparison'>Amibroker vs TradersStudio: comparison</a></li>
<li><a href='http://www.automated-trading-system.com/e-ratio-tradersstudio-excel/' rel='bookmark' title='Permanent Link: e-ratio calculation in TradersStudio and Excel'>e-ratio calculation in TradersStudio and Excel</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.automated-trading-system.com/e-ratio-amibroker-code/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>e-ratio calculation in TradersStudio and Excel</title>
		<link>http://www.automated-trading-system.com/e-ratio-tradersstudio-excel/</link>
		<comments>http://www.automated-trading-system.com/e-ratio-tradersstudio-excel/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 10:31:48 +0000</pubDate>
		<dc:creator>Jez Liberty</dc:creator>
				<category><![CDATA[Backtest]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[e-ratio]]></category>
		<category><![CDATA[edge]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[tradersstudio]]></category>

		<guid isPermaLink="false">http://www.automated-trading-system.com/?p=810</guid>
		<description><![CDATA[Here is one method to implement an e-ratio calculation.
As we say in developerspeak, the following is a quick and dirty approach to calculating the e-ratio. But as far as I am concerned, it does the job! It can probably be programmed more elegantly in TradersStudio but I still have to climb some of that software [...]


Related posts:<ol><li><a href='http://www.automated-trading-system.com/e-ratio-amibroker-code/' rel='bookmark' title='Permanent Link: Amibroker e-ratio code'>Amibroker e-ratio code</a></li>
<li><a href='http://www.automated-trading-system.com/amibroker-tradersstudio-speed-comparison/' rel='bookmark' title='Permanent Link: Amibroker V. TradersStudio: Speed comparison Fight'>Amibroker V. TradersStudio: Speed comparison Fight</a></li>
<li><a href='http://www.automated-trading-system.com/e-ratio-trading-edge/' rel='bookmark' title='Permanent Link: e-ratio: How to measure your trading edge in 4 easy steps'>e-ratio: How to measure your trading edge in 4 easy steps</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Here is one method to implement an <a href="http://www.automated-trading-system.com/e-ratio-trading-edge/">e-ratio</a> calculation.<br />
As we say in <em>developerspeak</em>, the following is a <em>quick and dirty</em> approach to calculating the e-ratio. But as far as I am concerned, it does the job! It can probably be programmed more elegantly in TradersStudio but I still have to climb some of that software learning curve&#8230;</p>
<p>I will show you how I calculated the e-ratio for a 17-day Donchian Channel breakout coupled with <span id="more-810"></span>a 108-day moving average filter (the red curve on <a href="http://www.automated-trading-system.com/e-ratio-trading-edge#e-ratio-filter-chart">this chart</a>). All the code referenced is provided at the end of this post.</p>
<p>As we saw in the <a href="http://www.automated-trading-system.com/e-ratio-trading-edge/">last post about the e-ratio</a>, you need to run the same signal over multiple fixed trade durations and record trade data. For this the TradersStudio optimisation and custom reports functionalities fit the bill.</p>
<h3>System Code</h3>
<h4>Step 1: code up the system to test in TraderStudio</h4>
<p>As you can not have simultaneous open Buy and Sell positions, there are actually 2 systems (long-only and short-only). The below will be based on the Buy-only system.<br />
The entry signal is a breakout of the Donchian channel if the MA filter conditions are met (price > MA and MA rising).<br />
In TradersStudio this translates to:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">MA = ScriptAve(<span style="color: #000080;">Close</span>, MALength,0)
<span style="color: #000080;">If</span> MA &gt; MA[1] <span style="color: #000080;">And</span> <span style="color: #000080;">Close</span> &gt; MA <span style="color: #000080;">Then</span> 
    Buy(EntryName,1,donchianHigh+MinMove ,<span style="color: #000080;">Stop</span>,Day)
<span style="color: #000080;">End</span> <span style="color: #000080;">If</span></pre></div></div>

<p>The exit is simple: close the trade after <em>n</em> days (tradeLength):</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">If</span> BarsSinceEntry=tradeLength <span style="color: #000080;">And</span> MarketPosition=1 <span style="color: #000080;">Then</span> 
    ExitLong(<span style="color: #800000;">&quot;ExitLong&quot;</span>,EntryName,1,0,CloseExit,Day)
<span style="color: #000080;">End</span> <span style="color: #000080;">If</span></pre></div></div>

<h4>Step 2: retrieve trade data in custom report</h4>
<p>As discussed in the e-ratio post we need to get MAE, MFE and ATR for each trade. For this we use a TradersStudio custom report. The report code is executed at the end of the system test and retrieve trade info with the following command:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">GetInfoAboutTrades(Info, i + 1)</pre></div></div>

<p>we are interested in the MAE and MFE which can be derived off the Maximum Profit and Maximum Loss of each trade:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">SetCell(row, 13, 2, 10, Info[16]) <span style="color: #008000;">'Max Pos Profit
</span>SetCell(row, 14, 2, 10, Info[17]) 'Max Pos Loss</pre></div></div>

<p>For the ATR value, we need to use a little trick as it is not directly available. We record it as part of the entry name which can be output to the report.<br />
In the system code we have:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">EntryName = <span style="color: #800000;">&quot;DonchianBreakoutBuy&quot;</span> + <span style="color: #800000;">&quot;|&quot;</span> + indLength + <span style="color: #800000;">&quot;|&quot;</span> + tradeLength  + <span style="color: #800000;">&quot;|&quot;</span> + avgtruerange(indLength)</pre></div></div>

<p>which concatenates the entry name with the ATR value as well as the length of the indicator (Donchian Channel) and trade duration &#8211; this will come in handy when we do the e-ratio calculation.</p>
<h4>Step 3: run the system through the optimizer</h4>
<p>The system is called DonchianChanBrkoutFiltBuy and has 3 parameters:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Sub</span> DonchianChanBrkoutFiltBuy(indLength, tradeLength, MALength)</pre></div></div>

<p>In the optimization process, step through all values of trade duration required (e.g from 1 to 100 in increments of 1) &#8211; warning TradersStudio will take a few hours to do this (sic!).<br />
This will generate a custom trade report for all trades containing all the data required.</p>
<h4>Step 4: paste data in Excel</h4>
<p>Once you run the long-only and short-only systems, we are done with TradersStudio. We need to move the data over to Excel for analysis and the e-ratio computation.<br />
Copy the custom trade report from the short-only system run to one sheet and from the long-only run to another sheet (watch out for the number of rows: if you have more than 65,536 and a version of Excel earlier than 2007 you will need to do that in several chunks).</p>
<h4>Step 5: Run e-ratio macro</h4>
<p>Copy the macro code from the text file, create a new VBA module in Excel and paste the code in it.<br />
Go back to both sheets and run the macro. This should manipulate the data and create an aggregation pivot table on a separate sheet.</p>
<h4>Step 6: Compute the e-ratio</h4>
<p>On a brand new sheet, copy both pivot tables (I recommend a paste/special &#8211; values only) side by side so that each trade length values corespond with each other. Sum each Total value (column D and J) together for the same Buy and Sell parameters (in column N in example file). Divide each Sum of MFE by Sum of MAE: this gives you the e-ratio for the given trade length.</p>
<h3>THE CODE</h3>
<p>Please find below code files to support the example below (all txt files except the Excel workbook). This should be easily portable to any system (i.e. just change entry criteria in the system).<br />
<a href="http://www.automated-trading-system.com/wp-content/uploads/2009/10/e-ratio/DonchianChannel.txt" target="_blank">Donchian Channel Indicator</a><br />
<a href="http://www.automated-trading-system.com/wp-content/uploads/2009/10/e-ratio/MyCustomTBT.txt" target="_blank">Custom trade Report</a><br />
<a href="http://www.automated-trading-system.com/wp-content/uploads/2009/10/e-ratio/DonchianChanBrkoutFiltBuy.txt" target="_blank">Buy System</a><br />
<a href="http://www.automated-trading-system.com/wp-content/uploads/2009/10/e-ratio/DonchianChanBkoutFiltSell.txt" target="_blank">Sell System</a><br />
<a href="http://www.automated-trading-system.com/wp-content/uploads/2009/10/e-ratio/e-ratio XL macro.txt" target="_blank">Excel e-ratio macro (text file)</a><br />
<a href="http://www.automated-trading-system.com/wp-content/uploads/2009/10/e-ratio/Sample e-ratio calc.xls" target="_blank">Excel example workbook</a> (does not contain underlying raw data as it is 60MB!)</p>
<p>Or if you prefer a zipped version of all files &#8211; <a href="http://www.automated-trading-system.com/wp-content/uploads/2009/10/e-ratio/e-ratio.zip" target="_blank">here it is</a>.</p>
<p>Any questions, clarifications, etc. please let me know how I can help.</p>
<img src="http://www.automated-trading-system.com/?ak_action=api_record_view&id=810&type=feed" alt="" />

<p>Related posts:<ol><li><a href='http://www.automated-trading-system.com/e-ratio-amibroker-code/' rel='bookmark' title='Permanent Link: Amibroker e-ratio code'>Amibroker e-ratio code</a></li>
<li><a href='http://www.automated-trading-system.com/amibroker-tradersstudio-speed-comparison/' rel='bookmark' title='Permanent Link: Amibroker V. TradersStudio: Speed comparison Fight'>Amibroker V. TradersStudio: Speed comparison Fight</a></li>
<li><a href='http://www.automated-trading-system.com/e-ratio-trading-edge/' rel='bookmark' title='Permanent Link: e-ratio: How to measure your trading edge in 4 easy steps'>e-ratio: How to measure your trading edge in 4 easy steps</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.automated-trading-system.com/e-ratio-tradersstudio-excel/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Are you reading the essential books?</title>
		<link>http://www.automated-trading-system.com/essential-trading-books/</link>
		<comments>http://www.automated-trading-system.com/essential-trading-books/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 11:06:37 +0000</pubDate>
		<dc:creator>Jez Liberty</dc:creator>
				<category><![CDATA[Backtest]]></category>
		<category><![CDATA[Blog]]></category>
		<category><![CDATA[Books]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Data]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Money Management]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Strategies]]></category>
		<category><![CDATA[Trend Following]]></category>
		<category><![CDATA[library]]></category>

		<guid isPermaLink="false">http://www.automated-trading-system.com/?p=386</guid>
		<description><![CDATA[I am bit of a geek and this is especially true when it comes to books. I firmly believe in self-development and I think books are a great medium to learn many things. Ok, the internet is so great to learn about new things; but nothing beats a good in-depth book(s) to really learn a [...]


Related posts:<ol><li><a href='http://www.automated-trading-system.com/weekend-reading/' rel='bookmark' title='Permanent Link: Weekend reading'>Weekend reading</a></li>
<li><a href='http://www.automated-trading-system.com/practical-guide-to-etf-trading-systems-garner/' rel='bookmark' title='Permanent Link: A practical Guide to ETF Trading Systems'>A practical Guide to ETF Trading Systems</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I am bit of a geek and this is especially true when it comes to books. I firmly believe in self-development and I think books are a great medium to learn many things. Ok, the internet is so great to learn <em>about</em> new things; but nothing beats a good in-depth book(s) to really learn a subject by yourself.</p>
<p>This is the list of my real-life library dedicated to building automated trading systems. This is not the exhaustive list: I have more specialised books which I will add at a later stage (some I have not read yet&#8230;). But the collection below is a decent starting list:</p>
<p>Please feel free to suggest your book recommendations or any additional info using the comments section below.</p>
<p>Please find below the Library organised in several sections:</p>
<ul>
<li><a href="http://www.automated-trading-system.com/essential-trading-books/#TradingSystems" style="text-decoration:none; color:black;"><strong>TRADING SYSTEMS</strong></a></li>
<li><a href="http://www.automated-trading-system.com/essential-trading-books/#MoneyManagement" style="text-decoration:none; color:black;"><strong>MONEY MANAGEMENT</strong></a></li>
<li><a href="http://www.automated-trading-system.com/essential-trading-books/#TrendFollowing" style="text-decoration:none; color:black;"><strong>TREND FOLLOWING</strong></a></li>
<li><a href="http://www.automated-trading-system.com/essential-trading-books/#TradersInsights" style="text-decoration:none; color:black;"><strong>TRADERS INSIGHTS</strong></a></li>
<li><a href="http://www.automated-trading-system.com/essential-trading-books/#MarketsRiskChance" style="text-decoration:none; color:black;"><strong>MARKETS, RISK AND CHANCE</strong></a></li>
<li><a href="http://www.automated-trading-system.com/essential-trading-books/#Other" style="text-decoration:none; color:black;"><strong>OTHER</strong></a></li>
</ul>
<p><span id="more-386"></span></p>
<div style="line-height:125%;">
<table>
<tr>
<td colspan="2" style="padding-left:10px; padding-top:20px; padding-bottom:20px; font-size:1.4em;">
      <a name="TradingSystems" style="text-decoration:none; color:grey;"><strong>&#8211; TRADING SYSTEMS &#8211;</strong></a>
    </td>
</tr>
<tr>
<td valign="top" align="center">
      <img src="http://www.automated-trading-system.com/wp-content/uploads/library/images/book-covers/small/new-trading-systems-and-methods-kaufman_small.jpg">
    </td>
<td valign="top">
      <strong>New Trading Systems and Methods &#8211; Perry Kaufman</strong><br />
      <em>An encyclopedic (1,000+ pages) review of Systems Ideas and Methods</em><br />
      <span style="line-height:200%;">&#8211;No review/summary yet&#8211;<br /></span>Look up on Amazon <a href="http://www.amazon.com/exec/obidos/ASIN/047126847X/autotradblog-20" target="_blank" rel="nofollow">US</a> | <a href="http://www.amazon.ca/exec/obidos/ASIN/047126847X/autotradblo02-20" target="_blank" rel="nofollow">CA</a> | <a href="http://www.amazon.co.uk/exec/obidos/ASIN/047126847X/autotradblo01-21" target="_blank" rel="nofollow">UK</a>
    </td>
</tr>
<tr height="10">
<td colspan="2"></td>
</tr>
<tr>
<td valign="top" align="center">
      <img src="http://www.automated-trading-system.com/wp-content/uploads/library/images/book-covers/small/quality-money-management-vanvliet-kumiega_small.jpg">
    </td>
<td valign="top">
      <strong>Quality Money Management &#8211; Benjamin Van Vliet &#038; Andrew Kumiega</strong><br />
      <em>Best practices in Systematic Trading Technology. Build it with Quality!</em><br />
      <span style="line-height:200%;">&#8211;No review/summary yet&#8211;<br /></span>Look up on Amazon <a href="http://www.amazon.com/exec/obidos/ASIN/0123725496/autotradblog-20" target="_blank" rel="nofollow">US</a> | <a href="http://www.amazon.ca/exec/obidos/ASIN/0123725496/autotradblo02-20" target="_blank" rel="nofollow">CA</a> | <a href="http://www.amazon.co.uk/exec/obidos/ASIN/0123725496/autotradblo01-21" target="_blank" rel="nofollow">UK</a>
    </td>
</tr>
<tr height="10">
<td colspan="2"></td>
</tr>
<tr>
<td valign="top" align="center">
      <img src="http://www.automated-trading-system.com/wp-content/uploads/library/images/book-covers/small/Trading-Systems-Money-Management-Stridsman_small.jpg">
    </td>
<td valign="top">
      <strong>Trading Systems and Money Management &#8211; Thomas Stridsman</strong><br />
      <em>Presents a strong approach to developing Trading Systems integrating Money Management concepts</em><br />
      <span style="line-height:200%;">&#8211;No review/summary yet&#8211;<br /></span>Look up on Amazon <a href="http://www.amazon.com/exec/obidos/ASIN/0071400192/autotradblog-20" target="_blank" rel="nofollow">US</a> | <a href="http://www.amazon.com/exec/obidos/ASIN/0071400192/autotradblog-20" target="_blank" rel="nofollow">CA</a> | <a href="http://www.amazon.co.uk/exec/obidos/ASIN/0071400192/autotradblo01-21" target="_blank" rel="nofollow">UK</a>
    </td>
</tr>
<tr>
<td colspan="2" style="padding-left:10px; padding-top:20px; padding-bottom:20px; font-size:1.4em;">
      <a name="MoneyManagement" style="text-decoration:none; color:grey;"><strong>&#8211; MONEY MANAGEMENT &#8211;</strong></a>
    </td>
</tr>
<tr>
<td valign="top" align="center">
      <img src="http://www.automated-trading-system.com/wp-content/uploads/library/images/book-covers/small/balsara_small.jpg">
    </td>
<td valign="top">
      <strong>Money Management Strategies for Futures Traders &#8211; Nauzer Balsara</strong><br />
      <em>Complete introduction to the essential concept of Money Management.</em><br />
      <span style="line-height:200%;"><a href="http://www.automated-trading-system.com/balsara-money-management-strategies-for-futures-traders/">Check my review/summary</a><br /></span>Look up on Amazon <a href="http://www.amazon.com/exec/obidos/ASIN/0471522155/autotradblog-20" target="_blank" rel="nofollow">US</a> | <a href="http://www.amazon.ca/exec/obidos/ASIN/0471522155/autotradblo02-20" target="_blank" rel="nofollow">CA</a> | <a href="http://www.amazon.co.uk/exec/obidos/ASIN/0471522155/autotradblo01-21" target="_blank" rel="nofollow">UK</a>
    </td>
</tr>
<tr height="10">
<td colspan="2"></td>
</tr>
<tr>
<td valign="top" align="center">
      <img src="http://www.automated-trading-system.com/wp-content/uploads/library/images/book-covers/small/handbook-portfolio-mathematics-vince_small.jpg">
    </td>
<td valign="top">
      <strong>The Handbook of Portfolio Mathematics &#8211; Ralph Vince</strong><br />
      <em>Essential reading for Optimal Allocations and Leverage!</em><br />
      <span style="line-height:200%;">&#8211;No review/summary yet&#8211;<br /></span>Look up on Amazon <a href="http://www.amazon.com/exec/obidos/ASIN/0471757683/autotradblog-20" target="_blank" rel="nofollow">US</a> | <a href="http://www.amazon.ca/exec/obidos/ASIN/0471757683/autotradblo02-20" target="_blank" rel="nofollow">CA</a> | <a href="http://www.amazon.co.uk/exec/obidos/ASIN/0471757683/autotradblo01-21" target="_blank" rel="nofollow">UK</a>
    </td>
</tr>
<tr>
<td colspan="2" style="padding-left:10px; padding-top:20px; padding-bottom:20px; font-size:1.4em;">
      <a name="TrendFollowing" style="text-decoration:none; color:grey;"><strong>&#8211; TREND FOLLOWING &#8211;</strong></a>
    </td>
</tr>
<tr>
<td valign="top" align="center">
      <img src="http://www.automated-trading-system.com/wp-content/uploads/library/images/book-covers/small/trend-following-covel_small.jpg">
    </td>
<td valign="top">
      <strong>Trend Following &#8211; Michael Covel</strong><br />
      <em>See Why and How Trend Following works. Over a dozen of top CTAs covered.</em><br />
      <span style="line-height:200%;">&#8211;No review/summary yet&#8211;<br /></span>Look up on Amazon <a href="http://www.amazon.com/exec/obidos/ASIN/013702018X/autotradblog-20" target="_blank" rel="nofollow">US</a> | <a href="http://www.amazon.ca/exec/obidos/ASIN/013702018X/autotradblo02-20" target="_blank" rel="nofollow">CA</a> | <a href="http://www.amazon.co.uk/exec/obidos/ASIN/013702018X/autotradblo01-21" target="_blank" rel="nofollow">UK</a>
    </td>
</tr>
<tr height="10">
<td colspan="2"></td>
</tr>
<tr>
<td valign="top" align="center">
      <img src="http://www.automated-trading-system.com/wp-content/uploads/library/images/book-covers/small/The-Complete-Turtle-Trader-Covel_small.jpg">
    </td>
<td valign="top">
      <strong>The Complete Turtle Trader &#8211; Michael Covel</strong><br />
      <em>The Turtle story and their complete rules</em><br />
      <span style="line-height:200%;">&#8211;No review/summary yet&#8211;<br /></span>Look up on Amazon <a href="http://www.amazon.com/exec/obidos/ASIN/0061241717/autotradblog-20" target="_blank" rel="nofollow">US</a> | <a href="http://www.amazon.ca/exec/obidos/ASIN/0061241709/autotradblo02-20" target="_blank" rel="nofollow">CA</a> | <a href="http://www.amazon.co.uk/exec/obidos/ASIN/0061241709/autotradblo01-21" target="_blank" rel="nofollow">UK</a>
    </td>
</tr>
<tr height="10">
<td colspan="2"></td>
</tr>
<tr>
<td valign="top" align="center">
      <img src="http://www.automated-trading-system.com/wp-content/uploads/library/images/book-covers/small/Way-of-the-Turtle-Faith_small.jpg">
    </td>
<td valign="top">
      <strong>Way of the Turtle &#8211; Curtis Faith</strong><br />
      <em>The Turtle experiment from the inside &#8211; told by a Turtle!</em><br />
      <span style="line-height:200%;">&#8211;No review/summary yet&#8211;<br /></span>Look up on Amazon <a href="http://www.amazon.com/exec/obidos/ASIN/007148664X/autotradblog-20" target="_blank" rel="nofollow">US</a> | <a href="http://www.amazon.ca/exec/obidos/ASIN/007148664X/autotradblo02-20" target="_blank" rel="nofollow">CA</a> | <a href="http://www.amazon.co.uk/exec/obidos/ASIN/007148664X/autotradblo01-21" target="_blank" rel="nofollow">UK</a>
    </td>
</tr>
<tr>
<td colspan="2" style="padding-left:10px; padding-top:20px; padding-bottom:20px; font-size:1.4em;">
      <a name="TradersInsights" style="text-decoration:none; color:grey;"><strong>&#8211; TRADERS INSIGHTS &#8211;</strong></a>
    </td>
</tr>
<tr>
<td valign="top" align="center">
      <img src="http://www.automated-trading-system.com/wp-content/uploads/library/images/book-covers/small/Market-Wizards-Schwager_small.jpg">
    </td>
<td valign="top">
      <strong>Market Wizards &#8211; Jack Schwager</strong><br />
      <em>Legendary interviews of top traders. Inspirational and &#8220;motivation-kicker&#8221;!</em><br />
      <span style="line-height:200%;">&#8211;No review/summary yet&#8211;<br /></span>Look up on Amazon <a href="http://www.amazon.com/exec/obidos/ASIN/1592802974/autotradblog-20" target="_blank" rel="nofollow">US</a> | <a href="http://www.amazon.ca/exec/obidos/ASIN/1592802974/autotradblo02-20" target="_blank" rel="nofollow">CA</a> | <a href="http://www.amazon.co.uk/exec/obidos/ASIN/1592802974/autotradblo01-21" target="_blank" rel="nofollow">UK</a>
    </td>
</tr>
<tr height="10">
<td colspan="2"></td>
</tr>
<tr>
<td valign="top" align="center">
      <img src="http://www.automated-trading-system.com/wp-content/uploads/library/images/book-covers/small/New-Market-Wizards-Schwager_small.jpg">
    </td>
<td valign="top">
      <strong>The New Market Wizards &#8211; Jack Schwager</strong><br />
      <em>Schwager strikes back! You&#8217;ll re-read him often.</em><br />
      <span style="line-height:200%;">&#8211;No review/summary yet&#8211;<br /></span>Look up on Amazon <a href="http://www.amazon.com/exec/obidos/ASIN/1592803377/autotradblog-20" target="_blank" rel="nofollow">US</a> | <a href="http://www.amazon.ca/exec/obidos/ASIN/1592803377/autotradblo02-20" target="_blank" rel="nofollow">CA</a> | <a href="http://www.amazon.co.uk/exec/obidos/ASIN/0887306675/autotradblo01-21" target="_blank" rel="nofollow">UK</a>
    </td>
</tr>
<tr>
<td colspan="2" style="padding-left:10px; padding-top:20px; padding-bottom:20px; font-size:1.4em;">
      <a name="MarketsRiskChance" style="text-decoration:none; color:grey;"><strong>&#8211; MARKETS, RISK AND CHANCE &#8211;</strong></a>
    </td>
</tr>
<tr>
<td valign="top" align="center">
      <img src="http://www.automated-trading-system.com/wp-content/uploads/library/images/book-covers/small/(mis)behavior-of-markets-mandelbrot_small.jpg">
    </td>
<td valign="top">
      <strong>The (mis)behavior of Markets &#8211; Benoit Mandelbrot</strong><br />
      <em>A fractal view of Risk, Ruin and Reward</em><br />
      <span style="line-height:200%;">&#8211;No review/summary yet&#8211;<br /></span>Look up on Amazon <a href="http://www.amazon.com/exec/obidos/ASIN/0465043577/autotradblog-20" target="_blank" rel="nofollow">US</a> | <a href="http://www.amazon.ca/exec/obidos/ASIN/0465043577/autotradblo02-20" target="_blank" rel="nofollow">CA</a> | <a href="http://www.amazon.co.uk/exec/obidos/ASIN/0465043550/autotradblo01-21" target="_blank" rel="nofollow">UK</a>
    </td>
</tr>
<tr height="10">
<td colspan="2"></td>
</tr>
<tr>
<td valign="top" align="center">
      <img src="http://www.automated-trading-system.com/wp-content/uploads/library/images/book-covers/small/black-swan-taleb_small.jpg">
    </td>
<td valign="top">
      <strong>The Black Swan &#8211; Nasim Taleb</strong><br />
      <em>Taleb re-writes the rules of risk. An excellent perspective on conventionally accepted concepts</em><br />
      <span style="line-height:200%;">&#8211;No review/summary yet&#8211;<br /></span>Look up on Amazon <a href="http://www.amazon.com/exec/obidos/ASIN/1400063515/autotradblog-20" target="_blank" rel="nofollow">US</a> | <a href="http://www.amazon.ca/exec/obidos/ASIN/1400063515/autotradblo02-20" target="_blank" rel="nofollow">CA</a> | <a href="http://www.amazon.co.uk/exec/obidos/ASIN/0141034599/autotradblo01-21" target="_blank" rel="nofollow">UK</a>
    </td>
</tr>
<tr height="10">
<td colspan="2"></td>
</tr>
<tr>
<td valign="top" align="center">
      <img src="http://www.automated-trading-system.com/wp-content/uploads/library/images/book-covers/small/fooled-by-randomness-taleb_small.jpg">
    </td>
<td valign="top">
      <strong>Fooled by Randomness &#8211; Nasim Taleb</strong><br />
      <em>The hidden role of Chance in Life and the Markets</em><br />
      <span style="line-height:200%;">&#8211;No review/summary yet&#8211;<br /></span>Look up on Amazon <a href="http://www.amazon.com/exec/obidos/ASIN/1400067936/autotradblog-20" target="_blank" rel="nofollow">US</a> | <a href="http://www.amazon.ca/exec/obidos/ASIN/0812975219/autotradblo02-20" target="_blank" rel="nofollow">CA</a> | <a href="http://www.amazon.co.uk/exec/obidos/ASIN/0141031484/autotradblo01-21" target="_blank" rel="nofollow">UK</a>
    </td>
</tr>
<tr height="10">
<td colspan="2"></td>
</tr>
<tr>
<td valign="top" align="center">
      <img src="http://www.automated-trading-system.com/wp-content/uploads/library/images/book-covers/small/drunkards-walk-mlodinow_small.jpg">
    </td>
<td valign="top">
      <strong>The Drunkard&#8217;s Walk &#8211; Leonard Mlodinow</strong><br />
      <em>The hidden role of Chance in Life and the Markets</em><br />
      <span style="line-height:200%;">&#8211;No review/summary yet&#8211;<br /></span>Look up on Amazon <a href="http://www.amazon.com/exec/obidos/ASIN/0307275175/autotradblog-20" target="_blank" rel="nofollow">US</a> | <a href="http://www.amazon.ca/exec/obidos/ASIN/0307275175/autotradblo02-20" target="_blank" rel="nofollow">CA</a> | <a href="http://www.amazon.co.uk/exec/obidos/ASIN/0141026472/autotradblo01-21" target="_blank" rel="nofollow">UK</a>
    </td>
</tr>
<tr height="10">
<td colspan="2"></td>
</tr>
<tr>
<td valign="top" align="center">
      <img src="http://www.automated-trading-system.com/wp-content/uploads/library/images/book-covers/small/random-walk-down-wall-street-malkiel_small.jpg">
    </td>
<td valign="top">
      <strong>A Random Walk Down Wall Street &#8211; Burton Malkiel</strong><br />
      <em>The original classic claiming Efficiency in the Markets</em><br />
      <span style="line-height:200%;">&#8211;No review/summary yet&#8211;<br /></span>Look up on Amazon <a href="http://www.amazon.com/exec/obidos/ASIN/0393330338/autotradblog-20" target="_blank" rel="nofollow">US</a> | <a href="http://www.amazon.ca/exec/obidos/ASIN/0393330338/autotradblo02-20" target="_blank" rel="nofollow">CA</a> | <a href="http://www.amazon.co.uk/exec/obidos/ASIN/0393062457/autotradblo01-21" target="_blank" rel="nofollow">UK</a>
    </td>
</tr>
<tr height="10">
<td colspan="2"></td>
</tr>
<tr>
<td valign="top" align="center">
      <img src="http://www.automated-trading-system.com/wp-content/uploads/library/images/book-covers/small/non-random-walk-down-wall-street-lo-mackinlay_small.jpg">
    </td>
<td valign="top">
      <strong>A Non-Random Walk Down Wall Street &#8211;  Andrew lo &#038; Craig MacKinlay</strong><br />
      <em>Collection of academic papers on Efficiency Market Theory</em><br />
      <span style="line-height:200%;">&#8211;No review/summary yet&#8211;<br /></span>Look up on Amazon <a href="http://www.amazon.com/exec/obidos/ASIN/0691092567/autotradblog-20" target="_blank" rel="nofollow">US</a> | <a href="http://www.amazon.ca/exec/obidos/ASIN/0691092567/autotradblo02-20" target="_blank" rel="nofollow">CA</a> | <a href="http://www.amazon.co.uk/exec/obidos/ASIN/0691092567/autotradblo01-21" target="_blank" rel="nofollow">UK</a>
    </td>
</tr>
<tr height="10">
<td colspan="2"></td>
</tr>
<tr>
<td valign="top" align="center">
      <img src="http://www.automated-trading-system.com/wp-content/uploads/library/images/book-covers/small/when-genius-failed-lowenstein_small.jpg">
    </td>
<td valign="top">
      <strong>When Genius Failed &#8211; Roger Lowenstein</strong><br />
      <em>How mis-understanding of Risk and Money Management drove LTCM to their graves. Fascinating!</em><br />
      <span style="line-height:200%;">&#8211;No review/summary yet&#8211;<br /></span>Look up on Amazon <a href="http://www.amazon.com/exec/obidos/ASIN/0375758259/autotradblog-20" target="_blank" rel="nofollow">US</a> | <a href="http://www.amazon.ca/exec/obidos/ASIN/0375758259/autotradblo02-20" target="_blank" rel="nofollow">CA</a> | <a href="http://www.amazon.co.uk/exec/obidos/ASIN/1841155047/autotradblo01-21" target="_blank" rel="nofollow">UK</a>
    </td>
</tr>
<tr>
<td colspan="2" style="padding-left:10px; padding-top:20px; padding-bottom:20px; font-size:1.4em;">
      <a name="Other" style="text-decoration:none; color:grey;"><strong>&#8211; OTHER &#8211;</strong></a>
    </td>
</tr>
<tr>
<td valign="top" align="center">
      <img src="http://www.automated-trading-system.com/wp-content/uploads/library/images/book-covers/small/Schwager-on-Futures-Managed-Trading_small.jpg">
    </td>
<td valign="top">
      <strong>Schwager on Futures Managed Trading &#8211; Jack Schwager</strong><br />
      <em>In-depth investigation into the Managed Futures/CTA industry</em><br />
      <span style="line-height:200%;">&#8211;No review/summary yet&#8211;<br /></span>Look up on Amazon <a href="http://www.amazon.com/exec/obidos/ASIN/0471020575/autotradblog-20" target="_blank" rel="nofollow">US</a> | <a href="http://www.amazon.ca/exec/obidos/ASIN/0471020575/autotradblo02-20" target="_blank" rel="nofollow">CA</a> | <a href="http://www.amazon.co.uk/exec/obidos/ASIN/0471020575/autotradblo01-21" target="_blank" rel="nofollow">UK</a>
    </td>
</tr>
<tr height="10">
<td colspan="2"></td>
</tr>
<tr>
<td valign="top" align="center">
      <img src="http://www.automated-trading-system.com/wp-content/uploads/library/images/book-covers/small/starting-out-in-futures-trading-powers_small.jpg">
    </td>
<td valign="top">
      <strong>Starting Out in Futures Trading &#8211; Mark Powers</strong><br />
      <em>Learn the ropes of Futures Trading: a Beginner&#8217;s reference.</em><br />
      <span style="line-height:200%;">&#8211;No review/summary yet&#8211;<br /></span>Look up on Amazon <a href="http://www.amazon.com/exec/obidos/ASIN/0071363904/autotradblog-20" target="_blank" rel="nofollow">US</a> | <a href="http://www.amazon.ca/exec/obidos/ASIN/0071363904/autotradblo02-20" target="_blank" rel="nofollow">CA</a> | <a href="http://www.amazon.co.uk/exec/obidos/ASIN/0071363904/autotradblo01-21" target="_blank" rel="nofollow">UK</a>
    </td>
</tr>
<tr height="10">
<td colspan="2"></td>
</tr>
<tr>
<td valign="top" align="center">
      <img src="http://www.automated-trading-system.com/wp-content/uploads/library/images/book-covers/small/demark-indicators-perl_small.jpg">
    </td>
<td valign="top">
      <strong>DeMark Indicators Jason Perl</strong><br />
      <em>The clearest presentation of all TD indicators</em><br />
      <span style="line-height:200%;">&#8211;No review/summary yet&#8211;<br /></span>Look up on Amazon <a href="http://www.amazon.com/exec/obidos/ASIN/1576603148/autotradblog-20" target="_blank" rel="nofollow">US</a> | <a href="http://www.amazon.ca/exec/obidos/ASIN/1576603148/autotradblo02-20" target="_blank" rel="nofollow">CA</a> | <a href="http://www.amazon.co.uk/exec/obidos/ASIN/1576603148/autotradblo01-21" target="_blank" rel="nofollow">UK</a>
    </td>
</tr>
</table>
</div>
<img src="http://www.automated-trading-system.com/?ak_action=api_record_view&id=386&type=feed" alt="" />

<p>Related posts:<ol><li><a href='http://www.automated-trading-system.com/weekend-reading/' rel='bookmark' title='Permanent Link: Weekend reading'>Weekend reading</a></li>
<li><a href='http://www.automated-trading-system.com/practical-guide-to-etf-trading-systems-garner/' rel='bookmark' title='Permanent Link: A practical Guide to ETF Trading Systems'>A practical Guide to ETF Trading Systems</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.automated-trading-system.com/essential-trading-books/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Unfair Advantage API Code (C#): Extract Futures Continuous data</title>
		<link>http://www.automated-trading-system.com/unfair-advantage-api-code-c-extract-futures-continuous-data/</link>
		<comments>http://www.automated-trading-system.com/unfair-advantage-api-code-c-extract-futures-continuous-data/#comments</comments>
		<pubDate>Sun, 04 Oct 2009 15:37:09 +0000</pubDate>
		<dc:creator>Jez Liberty</dc:creator>
				<category><![CDATA[Backtest]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Data]]></category>
		<category><![CDATA[Futures]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[CSI]]></category>
		<category><![CDATA[rollover]]></category>
		<category><![CDATA[screenshots]]></category>
		<category><![CDATA[Unfair Advantage]]></category>

		<guid isPermaLink="false">http://www.automated-trading-system.com/?p=279</guid>
		<description><![CDATA[As mentioned in the previous post on retrieving Back-Adjusted Contracts using the RetrieveBackAdjustedContract2 function of the Unfair Advantage API, I have coded up this very simple project to read a list of Futures underlying instruments, retrieve a proportionally back-adjusted contract for each of the instruments and oputput it to a file.
Getting started with the API
Fire [...]


Related posts:<ol><li><a href='http://www.automated-trading-system.com/unfair-advantage-csi/' rel='bookmark' title='Permanent Link: I just got myself an Unfair Advantage&#8230;'>I just got myself an Unfair Advantage&#8230;</a></li>
<li><a href='http://www.automated-trading-system.com/continuous-contract-options/' rel='bookmark' title='Permanent Link: Continuous Contract options'>Continuous Contract options</a></li>
<li><a href='http://www.automated-trading-system.com/unfair-advantage-api-retrieve-back-adjusted-contracts-function/' rel='bookmark' title='Permanent Link: Unfair Advantage API: Retrieve Back-Adjusted Contracts function'>Unfair Advantage API: Retrieve Back-Adjusted Contracts function</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>As mentioned in the previous post on <a href="http://www.automated-trading-system.com/unfair-advantage-api-retrieve-back-adjusted-contracts-function/" target="_blank">retrieving Back-Adjusted Contracts using the RetrieveBackAdjustedContract2 function of the Unfair Advantage API</a>, I have coded up this very simple project to read a list of Futures underlying instruments, retrieve a proportionally back-adjusted contract for each of the instruments and oputput it to a file.</p>
<h3>Getting started with the API</h3>
<p>Fire up your favourite IDE/language that supports COM Interoperability (I am using Visual C# 2008 Express Edition), start Console Application project and add a reference to the Unfair Advantage API. For this you just need to &#8220;Add reference&#8221; and browse to the Unfair Advantage installation folder and select the main EXE (uad.exe). This gives access to the CSI UA API.</p>
<div id="attachment_288" class="wp-caption aligncenter" style="width: 606px"><img src="http://www.automated-trading-system.com/wp-content/uploads/2009/09/UA-C-reference1.jpg" alt="Add UA into your project and &quot;Bob&#039;s your Uncle!&quot;" title="UA-C#-reference" width="500" height="457" class="size-full wp-image-288" /><p class="wp-caption-text">Add UA into your project and &quot;Bob's your Uncle!&quot;</p></div>
<h3>Simple extraction code</h3>
<p>The rest is fairly simple as long as you<span id="more-279"></span> <a href="http://www.automated-trading-system.com/unfair-advantage-api-retrieve-back-adjusted-contracts-function/" target="_blank">understand the RetrieveBackAdjustedContract2 parameters</a>.<br />
The code below takes 2 parameters: an input file name containing the list of markets to extract and a folder name to extract each continuous contract to. It sets specific UA session parameters and calls the RetrieveBackAdjustedContract2 with specific variables to obtain the concatenation desired. Each continuous contract is output to a folder in a .txt file.<br />
The file containing the list of markets is of the following format (CSI number, Symbol, Market name):<br />
&#8230;<br />
8,CT,Cotton<br />
&#8230;</p>
<h3>The code</h3>
<p>Please find the code <a href="http://www.automated-trading-system.com/pages/csharp-uaapi-continuouscontract.html" target="_blank">there</a> (very nicely formatted thanks to <a href="http://www.manoli.net/csharpformat/" target="_blank" rel="nofollow">this great tool by manoli</a>). You can also download the Program.cs file:<br />
<a href='http://www.automated-trading-system.com/wp-content/uploads/2009/09/Program.cs'><img src="http://www.automated-trading-system.com/wp-content/uploads/2009/09/Program.cs.jpg" alt="Program.cs" title="Program.cs" width="162" height="58" class="aligncenter size-full wp-image-287" /></a></p>
<img src="http://www.automated-trading-system.com/?ak_action=api_record_view&id=279&type=feed" alt="" />

<p>Related posts:<ol><li><a href='http://www.automated-trading-system.com/unfair-advantage-csi/' rel='bookmark' title='Permanent Link: I just got myself an Unfair Advantage&#8230;'>I just got myself an Unfair Advantage&#8230;</a></li>
<li><a href='http://www.automated-trading-system.com/continuous-contract-options/' rel='bookmark' title='Permanent Link: Continuous Contract options'>Continuous Contract options</a></li>
<li><a href='http://www.automated-trading-system.com/unfair-advantage-api-retrieve-back-adjusted-contracts-function/' rel='bookmark' title='Permanent Link: Unfair Advantage API: Retrieve Back-Adjusted Contracts function'>Unfair Advantage API: Retrieve Back-Adjusted Contracts function</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.automated-trading-system.com/unfair-advantage-api-code-c-extract-futures-continuous-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
