<?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>Programming &#8211; The Financial Hacker</title>
	<atom:link href="https://financial-hacker.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>https://financial-hacker.com</link>
	<description>A new view on algorithmic trading</description>
	<lastBuildDate>Mon, 13 Jan 2025 09:53:32 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://financial-hacker.com/wp-content/uploads/2017/07/cropped-mask-32x32.jpg</url>
	<title>Programming &#8211; The Financial Hacker</title>
	<link>https://financial-hacker.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Pimp your performance with key figures</title>
		<link>https://financial-hacker.com/pimp-your-performance-with-key-figures/</link>
					<comments>https://financial-hacker.com/pimp-your-performance-with-key-figures/#comments</comments>
		
		<dc:creator><![CDATA[jcl]]></dc:creator>
		<pubDate>Wed, 08 Jan 2025 13:34:40 +0000</pubDate>
				<category><![CDATA[No Math]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Money]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Zorro]]></category>
		<guid isPermaLink="false">https://financial-hacker.com/?p=4782</guid>

					<description><![CDATA[Not all scripts we’re hired to write are trading strategies. Some are for data analysis or event prediction – for instance: Write me a script that calculates the likeliness of a stock market crash tomorrow. Some time ago a client ordered a script for improving the performance of their company. This remarkable script was very &#8230; <a href="https://financial-hacker.com/pimp-your-performance-with-key-figures/" class="more-link">Continue reading<span class="screen-reader-text"> "Pimp your performance with key figures"</span></a>]]></description>
										<content:encoded><![CDATA[
<p>Not all scripts we’re hired to write are trading strategies. Some are for data analysis or event prediction – for instance: <em>Write me a script that calculates the likeliness of a stock market crash tomorrow</em>. Some time ago a client ordered a script for improving the performance of their company. This remarkable script was very different to a trading system. Its algorithm can in fact improve companies, but also your personal performance. How does this work?<span id="more-4782"></span></p>



<p>Just like the performance of a stock, the performance of a company is measured by numerical indicators. They are named <strong>key figures</strong>. Key figures play a major role in quality management, such as the <strong>ISO 9000</strong> standards. An ISO 9000 key figure is a detail indicator, such as the number of faults in a production line, the number of bugs found in a beta test, the number of new clients acquired per day, the total of positive minus negative online reviews, an so on. Aside from being essential for an ISO 9000 certification, these key figures have two purposes:</p>


<ul class="wp-block-list">
	<li>They give <strong>detailed insight</strong> and expose strengths and weaknesses.</li>


	<li>And they give a <strong>strong motivation</strong> for reaching a certain goal.</li>
</ul>


<p>The script below opens a user interface for entering various sorts of key figures. It calculates an <strong>overall score</strong> that reflects the current performance of a company &#8211; or of a person &#8211; and displays it in a chart. If you use it not for a company, but for yourself, it helps improving your personal life. And from the short script you can see how to create a relatively complex software with relatively few lines of code.</p>


<p>Hackers like the concept of key figures. They are plain numbers that you can work with. Anyone can define key figures for herself. If you’re a writer, an important key figure is the number of words you&#8217;ve written today; if you&#8217;re an alcolohic, it&#8217;s the number of drinks you had today. Many self-improvement books tell you precisely what you need to do for living a healthier, wealthier, happier life &#8211; but they all suffer from the same problem: <strong>long-term motivation</strong>. If you lack the iron will to keep your daily exercises, reduce smoking, stay away from fast food, and so on &#8211; all good resolutions will eventually fall into oblivion. If you had <strong>resolutions for 2025</strong>, you&#8217;ll soon know what I mean.</p>


<p>Failure is less likely when you can observe your progress any day and see its immediately effect on your overall performance score. This score is a direct measure of your success in live. Whether you’re a company or a person, you want to keep this core rising. This feedback produces a strong motivation, every day again.</p>


<figure class="wp-block-image"><img fetchpriority="high" decoding="async" width="701" height="405" class="wp-image-4783" src="https://financial-hacker.com/wp-content/uploads/2025/01/word-image-4782-1.png" alt="" srcset="https://financial-hacker.com/wp-content/uploads/2025/01/word-image-4782-1.png 701w, https://financial-hacker.com/wp-content/uploads/2025/01/word-image-4782-1-300x173.png 300w" sizes="(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px" /></figure>



<p><br />
The above performance chart is plotted by the key figure management script in C for the Zorro platform. The red line is the overall score, derived from all key figures in a way explained below. The blue line is the key figure for which you just entered a new value (in the example it&#8217;s the number of large or small features implemented in the last 6 months in the Zorro platform). The X axis is the date in YYMMDD format.</p>


<p>Of course, key figures can be very different. Some may have a daily goal, some not, some shall sum up over time, others (like your bank account value) are just taken as they are. The idea is that your overall score rises when you exceed the daily goals, and goes down otherwise. All key figures and their parameters can be freely defined in a CSV file, which can be edited with a text editor or with Excel. It looks like this:</p>


<div class="wp-block-group"><div class="wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained">
<div class="wp-block-group"><div class="wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained">
<p><code>Name, Decimals, Unit, Offset, Growth, Sum<br />
Appr,1,0.1,0,0,0<br />
Praise,0,10,0,-30,1<br />
Weight,1,-0.1,-250,0.033,0<br />
Duck,1,0.5,0,-0.5,1<br />
Worth,0,1,-6000,0,0</code></p>
</div></div>
</div></div>


<p>In the first column you can assign a name. The second column is the number of decimals in the display, the third is their unit in the overall score, the fourth is an offset in the score, the fifth is the daily goal, and the last tells if the figures shall sum up over time (1) or not (0).</p>


<p>Example. Suppose you’re a president of a large country and want to pimp up your personal performance. What’s your key figures? First, of course, approval rate. Any tenth percent adds one point to your score. So the first entry is simple:</p>


<p><code>Name, Decimals, Unit, Offset, Growth, Sum </code><br />
<code>Appr, 1, 0.1, 0, 0, 0</code></p>


<p>Next, fame. Key figure is the daily number of praises on Fox News, OneAmerica, and Newsmax. You’ve ordered a White House department to count the praises; of course you’re personally counting them too, just in case. Less than 30 praises per day would be bad and reduce your score, more will improve it. So 30 praises are daily subtracted from your score. Any 10 further praises add one point. This is an accumulative key figure:</p>


<p><code>Praise, 0, 10, 0, -30, 1</code></p>


<p>Next, health. Key figure is weight. Your enemies spread rumors that you&#8217;re unfit and obese. Your doctors urge you to shed weight. So you want to lose one pound every month, which (you have your mathematicians for calculating difficult things) is about 0.033 per day. Any lost 0.1 pound adds one point to your score. The numbers are negative since you want your weight to go down, not up. The offset is your current weight.</p>


<p><code>Weight, 1, -0.1, -250, 0.033, 0</code></p>


<p>Next, literacy. Your enemies spread rumors you&#8217;re illiterate. To prove them wrong, you&#8217;ve decided to read at least half a page per day in a real book (you’ve chosen <a href="https://www.amazon.de/-/en/Doreen-Cronin/dp/0689863772">Duck for President</a> to begin with). Any further half page adds one point to your score. This is also an accumulative figure.</p>


<p><code>Duck, 1, 0.5, 0, -0.5, 1</code></p>


<p>Finally, net worth. You’ve meanwhile learned to better avoid business attempts. Let your net worth grow due to the value increase of your inherited real estate, which is currently at 6 billion. Any million further growth adds one point to your score (numbers given in millions):</p>


<p><code>Worth, 0, 1, -6000, 0, 0</code></p>


<p>For improving your personal performance, download the script from the 2025 repository. Copy the files <strong>KeyFigures.csv</strong> and <strong>KeyFigures.c</strong> in your Strategy folder. Edit <strong>KeyFigures.csv</strong> for entering your personal key figures, as in the above example (you can later add or remove key figures and use Excel to add or remove the new columns to the data file). This is the script:</p>
<pre class="prettyprint">// Pimp Your Performance with Key Figures //////////////////////

string Rules = "Strategy\\KeyFigures.csv";
string Data = "Data\\KeyData.csv"; // key figures history
string Format = "0%d.%m.%Y,f1,f,f,f,f,f,f,f,f,f,f,f,f,f,f";
int Records,Fields;

var value(int Record,int Field,int Raw)
{
	var Units = dataVar(1,Field,2);
	var Offset = dataVar(1,Field,3);
	var Growth = dataVar(1,Field,4);
	var Value = 0;
	int i;
	for(i=0; i&lt;=Record; i++) {
		if(dataVar(2,i,Field+1) &lt; 0.) continue; // ignore negative entries
		Value += Growth;
		if(i == Record || (dataInt(1,Field,5)&amp;1)) // Sum up? 
			Value += dataVar(2,i,Field+1)+Offset;
	}
	if(Raw) return Value-Offset;
	else return Value/Units;
}

var score(int Record)
{
	int i,Score = 0;
	for(i=0; i&lt;Fields; i++) 
		Score += value(Record,i,0);
	panelSet(Record+1,Fields+1,sftoa(Score,0),YELLOW,16,4);
	return Score;
}


void click(int Row,int Col)
{
	dataSet(2,Row-1,Col,atof(panelGet(Row,Col)));
	score(Row-1);
	if(dataSaveCSV(2,Format,Data)) sound("Click.wav");
	int i;
	for(i=0; i&lt;Records; i++) {
		var X = ymd(dataVar(2,i,0)) - 20000000;
		plotBar("Score",i,X,score(i),LINE,RED);
		plotBar(dataStr(1,Col-1,0),i,NIL,value(i,Col-1,1),AXIS2,BLUE);
	}
	if(Records &gt;= 2) plotChart("");
}

void main()
{
	int i = 0, j = 0;
	printf("Today is %s",strdate("%A, %d.%m.%Y",NOW));
	ignore(62);
	PlotLabels = 5;
// File 1: Rules
	Fields = dataParse(1,"ssss,f1,f,f,f,i",Rules);
// File 2: Content
	Records = dataParse(2,Format,Data);
	int LastDate = dataVar(2,Records-1,0);
	int Today = wdate(NOW);
	if(LastDate &lt; Today) { // no file or add new line
		dataAppendRow(2,16);
		for(i=1; i&lt;=Fields; i++)
			if(!(dataInt(1,i-1,5)&amp;1))
				dataSet(2,Records,i,dataVar(2,Records-1,i));
		Records++;
	}
	dataSet(2,Records-1,0,(var)Today);

// display in panel
	panel(Records+1,Fields+2,GREY,-58);
	panelFix(1,0);
	print(TO_PANEL,"Key Figures");
	for(i=0; i&lt;Fields; i++)
		panelSet(0,i+1,dataStr(1,i,0),ColorPanel[0],16,1);
	panelSet(0,i+1,"Score",ColorPanel[0],16,1);
	panelSet(0,0,"Date",ColorPanel[0],16,1);
	for(j=0; j&lt;Records; j++) {
		panelSet(j+1,0,strdate("%d.%m.%y",dataVar(2,j,0)),ColorPanel[0],0,1);
		score(j);
		for(i=0; i&lt;Fields; i++) 
			panelSet(j+1,i+1,sftoa(dataVar(2,j,i+1),-dataVar(1,i,1)),ColorPanel[2],0,2);
	}
	panelSet(-1,0,"Rules",0,0,0);
}</pre>
<p>The file locations and the CSV format of the key figures history are defined at the begin. The <strong>value</strong> function calculates the contribution of a particular key figure to the overall score. The <strong>score</strong> function updates the overall score. The <strong>click</strong> function, which is called when you enter a new value, calculates the score of that day, updates the spreadsheet, and prints the chart. The <strong>main</strong> function imports the data and key figures from their CSV files into datasets, prints the current day and displays a spreadsheet of your key figures and score history, like this:</p>


<figure class="wp-block-image"><img decoding="async" width="484" height="163" class="wp-image-4784" src="https://financial-hacker.com/wp-content/uploads/2025/01/ein-bild-das-text-screenshot-schrift-zahl-enth.png" alt="Ein Bild, das Text, Screenshot, Schrift, Zahl enthält.

Automatisch generierte Beschreibung" srcset="https://financial-hacker.com/wp-content/uploads/2025/01/ein-bild-das-text-screenshot-schrift-zahl-enth.png 484w, https://financial-hacker.com/wp-content/uploads/2025/01/ein-bild-das-text-screenshot-schrift-zahl-enth-300x101.png 300w" sizes="(max-width: 484px) 85vw, 484px" /> </figure>



<p> <br />
You will need <a href="https://zorro-project.com/download.php" target="_blank" rel="noopener">Zorro S</a> because the spreadsheet function is not available in the free version. Start the script any morning. It will open the spreadsheet, where you can click in any of the white fields and enter a new key figure value for today. You can anytime enter new figures for today or for past days. At any entry, the score is calculated and &#8211; if the history spans more than 2 days – a chart is plotted as in the above example.</p>


<p>Normally, personal performance depends on about 5-10 key figures (maximum is 15). For instance, miles you’ve jogged today, steps walked, exercises done, pages read, words written, words learned in a new language, value of your bank account, value of your stock portfolio, burgers eaten, cigarettes smoked, enemies killed, or number of old ladies you helped crossing the street. If you’re a president, consider the script a free present (we hope for generous tax exceptions in exchange). If you’re an ISO 9000 certified company and want to use the script for your quality management, please contact oP group to pay your fee. For personal use, the script is free. Pimp your performance and make the world a better place!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://financial-hacker.com/pimp-your-performance-with-key-figures/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>Trading with REST</title>
		<link>https://financial-hacker.com/crypto-trading-with-rest-part-1/</link>
					<comments>https://financial-hacker.com/crypto-trading-with-rest-part-1/#comments</comments>
		
		<dc:creator><![CDATA[jcl]]></dc:creator>
		<pubDate>Mon, 17 Oct 2022 11:16:41 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Bittrex]]></category>
		<category><![CDATA[Broker]]></category>
		<category><![CDATA[Hacking]]></category>
		<guid isPermaLink="false">https://financial-hacker.com/?p=4517</guid>

					<description><![CDATA[Many brokers and exchanges can nowadays be accessed online with a REST API that communicates with plain-text HTTP requests. The days of awkward proprietary broker APIs are coming to an end. This article is a step by step instruction of implementating a REST API interface in C for connecting a trading system to the Bittrex &#8230; <a href="https://financial-hacker.com/crypto-trading-with-rest-part-1/" class="more-link">Continue reading<span class="screen-reader-text"> "Trading with REST"</span></a>]]></description>
										<content:encoded><![CDATA[
<p>Many brokers and exchanges can nowadays be accessed online with a REST API that communicates with plain-text HTTP requests. The days of <a href="https://financial-hacker.com/dear-brokers/" target="_blank" rel="noopener">awkward proprietary broker APIs</a> are coming to an end. This article is a step by step instruction of implementating a REST API interface in C for connecting a trading system to the <a href="https://global.bittrex.com/" target="_blank" rel="noopener">Bittrex cryptocurrency exchange.</a> It&#8217;s for the <a href="https://zorro-project.com" target="_blank" rel="noopener">Zorro platform</a>, but the principles are also valid for other exchanges and platforms. The C code for a basic REST API implementation is relatively short and straightforward. <span id="more-4517"></span></p>
<p> For connecting the Zorro platform to a particular broker API, a DLL must be dropped in its Plugin folder. The DLL is then automatically recognized and appears in Zorro&#8217;s Broker selection box. For trading with the broker, the DLL exports functions for getting prices and sending orders. These functions are standardized and described in the <a href="https://zorro-project.com/manual/en/brokerplugin.htm" target="_blank" rel="noopener">Zorro manual</a>. They are the same for all brokers. The following 4 functions are the most important:</p>
<p><strong>BrokerOpen</strong> &#8211; identify the DLL.<br /><strong>BrokerLogin</strong> &#8211; initialize and store login credentials.<br /><strong>BrokerAsset</strong> &#8211; retrieve price and other parameters of an asset.<br /><strong>BrokerBuy2</strong> &#8211; send a buy or sell order.</p>
<p>These four are sufficient for running most trading strategies. The DLL can export additional functions that are useful, but not mandatory, since Zorro works around them when they are not implemented:</p>
<p><strong>BrokerAccount</strong> -get the account state.<br /><strong>BrokerTrade</strong> &#8211; get the trade or order state.<br /><strong>BrokerHistory2</strong> -get price history.<br /><strong>BrokerCommand</strong> &#8211; set special modes, get order book, etc.</p>
<p>Zorro users have written DLLs for several broker APIs, but the code is often redundant and invents the wheel many times again. I&#8217;ll give here an example of a relatively lean broker DLL that can be used as template for individual REST API implementations. Bittrex is a US based digital currency exchange that supports several hundred crypto currencies and provides free API access. We&#8217;re first going to implement the 4 mandatory functions, following the API description on the Bittrex website:</p>
<p><a href="https://bittrex.github.io/api/v3" target="_blank" rel="noopener">https://bittrex.github.io/api/v3</a></p>
<p>We will use the free Visual C++ Community Edition from Microsoft. Aside from the exported functions, we need some internal functions to print messages, send HTTP requests, parse a JSON response, and generate a digital signature. For all this there&#8217;s ready code available on the Internet, but there are also ready functions in Zorro&#8217;s library. To make life easier, we simply import the <a href="https://zorro-project.com/manual/en/funclist.htm" target="_blank" rel="noopener">Zorro function library</a> to the DLL. The VC++ setup for generating such a DLL is described here:</p>
<p><a href="https://zorro-project.com/manual/en/dlls.htm#project" target="_blank" rel="noopener">https://zorro-project.com/manual/en/dlls.htm</a></p>
<p>The setup is for a C++ trading strategy, but works as well for a broker API DLL. First we&#8217;re going to implement the adminstrative stuff, the <strong>BrokerOpen</strong> and <strong>BrokerLogin</strong> functions:</p>
<pre class="prettyprint">#define PLUGIN_TYPE 2<br />#define PLUGIN_NAME "Bittrex V3"<br />#define DLLFUNC extern "C" __declspec(dllexport)<br /><br />int (__cdecl *BrokerMessage)(const char *Text);<br />int (__cdecl *BrokerProgress)(const int Progress);<br />...<br /><br />DLLFUNC int BrokerOpen(char* Name,FARPROC fpMessage,FARPROC fpProgress)<br />{<br />  strcpy_s(Name,32,PLUGIN_NAME);<br />  (FARPROC&amp;)BrokerMessage = fpMessage;<br />  (FARPROC&amp;)BrokerProgress = fpProgress;<br />  return PLUGIN_TYPE;<br />}</pre>
<p>The <strong>BrokerOpen</strong> function is Zorro specific. It sets up two function pointers for printing message and sending heartbeats to Zorro. It&#8217;s needed for recognizing the DLL in the <strong>Plugin</strong> folder and letting the plugin name, &#8220;Bittrex V3&#8221;, appear in the broker scrollbox. </p>
<p>Next we need the login function that&#8217;s called at the begin and the end of any algo trading session</p>
<pre class="prettyprint">struct GLOBAL {<br />  int PriceType,VolType,OrderType;<br />  double Unit; // smallest trade unit<br />  char Path[256]; // send path buffer<br />  char Key[256],Secret[256]; // credentials<br />  char Symbol[64],Uuid[256]; // last trade symbol and UUID<br />  char AccountId[16]; // account currency<br />} G; // parameter singleton<br />...<br /><br />DLLFUNC int BrokerLogin(char* User,char* Pwd,char* Type,char* Accounts)<br />{<br />  if(User) { // login<br />    memset(&amp;G,0,sizeof(G));<br />    strcpy_s(G.Key,User);<br />    strcpy_s(G.Secret,Pwd);<br />    return 1;<br />  } else  // logout<br />    return 0;<br />}</pre>
<p>This function only sets up the <strong>G</strong> struct, a singleton that holds all global variables of the DLL. The <strong>User</strong> and <strong>Pwd</strong> arguments contain the Bittrex key and secret. They are taken from the Zorro login fields or from the account list. <strong>Type</strong> is the account type, ignored here because Bittrex has no demo accounts.  <strong>Account</strong> is the account identifier and also ignored since we&#8217;re not using sub-accounts.</p>
<p>Next comes the function to retrieve prices and other parameters of a particular cryptocurrency. It&#8217;s a bit more complex and requires a HTTP request to the API. Some requests require authentication, some not. For all this we first implement a <strong>send()</strong> function in the DLL that uses Zorro&#8217;s functions for sending <a href="https://zorro-project.com/manual/en/http.htm" target="_blank" rel="noopener">http requests</a> and generating a <a href="https://zorro-project.com/manual/en/hmac.htm" target="_blank" rel="noopener">HMAC signature</a>. The authentication method by the Bittrex REST API V3 is a bit complex:</p>
<p><em>To properly sign an authenticated request for the Bittrex v3 API, the following headers must be included: Api-Key, Api-Timestamp, Api-Content-Hash, Api-Signature. <span style="font-size: revert;">Api-Timestamp is </span>the current time as a UNIX timestamp in epoch-millisecond format. <span style="font-size: revert;">Api-Content-Hash </span>is a SHA512 hash of the request body, Hex-encoded (with no request body, a SHA512 hash of an empty string). For creating the Api-Signature, first generate a string by concatenating the following items: Contents of the Api-Timestamp header; the full URI used to make the request, including query string; the HTTP method of the request, in all caps (GET, POST, DELETE, etc.); Contents of the Api-Content-Hash header. Sign this string via HmacSHA512, using the API secret as the signing secret. Hex-encode the result and populate the Api-Signature header with it.</em></p>
<p>This is the implementation:</p>
<pre class="prettyprint">#define RHEADER "https://api.bittrex.com/v3/"<br />...<br /><br />int sleep(int ms)<br />{<br />  Sleep(ms); <br />  return BrokerProgress(0);<br />}<br /><br />char* send(const char* Url,<br />  int Mode = 0,<br />  const char* Method = NULL,<br />  const char* Body = NULL)
{
  static char Url[1024], Header[2048], Signature[1024],
    Buffer1[1024*1024], Buffer2[2048];
  *Signature = *Header = 0;
  sprintf_s(Url,"%s%s",RHEADER,Url);
  if (Mode &amp; 1) { // Authentication required
    strcpy_s(Header, "Content-Type:application/json");
    strcat_s(Header, "\nAccept:application/json");
    strcat_s(Header, "\nApi-Key: ");
    strcat_s(Header,G.Key);
    strcat_s(Header, "\nApi-Timestamp: ");
    __time64_t Time; _time64(&amp;Time);
    static __time64_t Offset = 0;
    char* TimeStamp = i64toa(Time*1000 + Offset++); 
    strcat_s(Header, TimeStamp);
    strcat_s(Header, "\nApi-Content-Hash: ");
    char* Hash = hmac(Body, 0, 0, 512);
    strcat_s(Header,Hash);
    strcpy_s(Signature, TimeStamp);
    strcat_s(Signature, Url);
    if(Method &amp;&amp; *Method)
      strcat_s(Signature, Method);
    else if(!Body)
      strcat_s(Signature,"GET");
    else
      strcat_s(Signature,"POST");
    strcat_s(Signature, Hash);
    strcat_s(Header, "\nApi-Signature: ");
    strcat_s(Header, hmac(Signature, 0, G.Secret, 512));
  }

  char* Response = Mode &amp; 2? Buffer2 : Buffer1;<br />  int MaxSize = Mode &amp; 2? sizeof(Buffer2) : sizeof(Buffer1);<br />  int Id = http_request(Url,Body,Header,Method);
  if(!Id) goto send_error;
// wait 30 seconds for the server to reply
  int Size = 0, Wait = 3000;  
  while (!(Size = http_status(Id)) &amp;&amp; --Wait &gt; 0)
    if(!sleep(10)) goto send_error;
  if (!Size) goto send_error;
  if(!http_result(Id,Response,MaxSize)) goto send_error;
  Response[MaxSize-1] = 0; // prevent buffer overrun
  http_free(Id);
  return Response;
<br />// transfer unsuccessful?
send_error:
  if(Id) http_free(Id);
  return NULL;
}
</pre>
<p>The above code adds an authentication header with signature when <strong>Mode</strong> == 1. <strong>Mode == 2</strong> selects a second, smaller response buffer and thus allows to evaluate two API responses at the same time. The <strong>sleep</strong> function generates a delay with a heartbeat to keep the Zorro window responsive during long requests. If it returns <strong>0</strong>, someone has hit Zorro&#8217;s [Stop] key and all operations should be aborted. The Windows <strong>_time64</strong> function has only 1-second resolution, so we add an incremented <strong>Offset</strong> for generating unique timestamps.</p>
<p>We&#8217;re now prepared to implement the <strong>BrokerAsset</strong> function:</p>
<pre class="prettyprint">double fixAmount(double Value)<br />{<br />  int Exp = log10(Value);<br />  if (Exp &gt;= 0) Exp++;<br />  return pow(10,Exp);<br />}<br /><br />DLLFUNC int BrokerAsset(char* Symbol,double* pPrice,double* pSpread,<br />double *pVolume, double *pPip, double *pPipCost, double *pMinAmount,<br />double *pMargin, double *pRollLong, double *pRollShort, double *pCommission)<br />{<br />  sprintf_s(G.Url,"markets/%s/ticker",fixSymbol(Symbol));<br />  char* Response = send(G.Url,2);<br />  if(!Response) return 0;<br />  double Bid = strvar(Response, "bidRate", 0.),<br />    Ask = strvar(Response,"askRate",0.);<br />  if (Ask &gt; 0. Bid &gt; 0. &amp;&amp; pSpread) <br />    *pSpread = Ask - Bid;<br />  double Last = strvar(Response, "lastTradeRate", 0.);<br />  if(Ask == 0. || G.PriceType == 2) <br />    Ask = Last;<br />  if (Ask == 0.) return 0; // symbol does not exist<br />  if(pPrice) *pPrice = Ask;<br />  if(pVolume) {<br />    sprintf_s(G.Url,"markets/%s/summary",fixSymbol(Symbol));<br />    Response = send(G.Url,2);<br />    if (Response) {<br />      if (G.VolType == 4)<br />        *pVolume = strvar(Response, "volume", 0);<br />    else<br />        *pVolume = strvar(Response, "quoteVolume", 0);<br />    }<br />  }<br />  if (pMinAmount) { // get lot amount<br />    sprintf_s(G.Url,"markets/%s",fixSymbol(Symbol));<br />    Response = send(G.Url,2);<br />    if (Response) {<br />      *pMinAmount = fixAmount(strvar(Response,"minTradeSize",0.000001));<br />      if (pPip) {<br />        int Exp = strvar(Response,"precision",8);<br />        *pPip = pow(10,-Exp); <br />        while (*pPip * *pMinAmount &lt; 0.000000001)<br />         *pPip *= 10; // avoid too small pip cost<br />        if (pPipCost)<br />          *pPipCost = *pPip * *pMinAmount;<br />      }<br />    }<br />  }<br />  if (pMargin) <br />    *pMargin = -100; // no leverage<br />  return 1;<br />} </pre>
<p>This function is supposed to return current price, current ask-bid spread, and current volume. It can also optionally request other asset specific parameters when available from the API. Otherwise Zorro will replace them with parameter values from the asset list. Broker APIs rarely provide all requested parameters. Make sure to only calculate and fill a parameter when its pointer passed to the function is nonzero. Most of the pointers are NULL most of the time.</p>
<p>The <strong>send</strong> function uses the second buffer because we&#8217;ll need price requests internally for calculating the account state. For getting lot amount, pip size, and pip cost, two more API requests are needed. The values from the response string are parsed with Zorro&#8217;s <strong>strvar</strong> function. The <strong>fixAmount</strong> function converts a value to its next-higher power of 10 &#8211; for instance, 7 is converted to 10 and 0.07 to 0.1. We&#8217;re doing this because we don&#8217;t want a strange number for the lot amount. The pip size is calculated from the precision, but we prevent it from going too small. Bittrex has no leverage, so the margin cost is always 100%.    </p>
<p>The next and final function sends an order to the API:</p>
<pre class="prettyprint">DLLFUNC int BrokerBuy2(char* Symbol,int Volume,double StopDist,double Limit,double *pPrice,int *pFill)<br />{<br />  if(!isConnected() || !Volume) return 0;<br /><br />// compose the body<br />  char Body[256] = "{\n";<br />  strcat_s(Body,"\"marketsymbol\": \"");<br />  strcat_s(Body,fixSymbol(Symbol));<br />  strcat_s(Body,"\",\n\"direction\": \"");<br />  strcat_s(Body,Volume &gt; 0? "BUY" : "SELL");<br />  strcat_s(Body,"\",\n\"type\": \"");<br />  strcat_s(Body,Limit &gt; 0. ? "LIMIT" : "MARKET");<br />  strcat_s(Body,"\",\n\"quantity\": \"");<br />  double Size = labs(Volume);<br />  if(G.Amount &lt; 1.) Size *= G.Amount;<br />  strcat_s(Body,ftoa(Size));<br />  if (Limit &gt; 0.) {<br />    strcat_s(Body,"\",\n\"limit\": \"");<br />    strcat_s(Body,ftoa(Limit));<br />  }<br />  strcat_s(Body,"\",\n\"timeInForce\": \"");<br />  if ((G.OrderType&amp;2) &amp;&amp; Limit &gt; 0.) <br />    strcat_s(Body,"GOOD_TIL_CANCELLED"); // limit orders only<br />  else if (G.OrderType&amp;1) <br />    strcat_s(Body,"FILL_OR_KILL"); // fill all or nothing<br />  else <br />    strcat_s(Body,"IMMEDIATE_OR_CANCEL");<br />  strcat_s(Body,"\"\n}");<br /><br />  char* Response = send("orders",1,0,Body);<br />  if(!Response) return 0;<br /><br />  char* Uuid = strtext(Response,"id","");<br />  if(!*Uuid) return 0; // failed<br />  strcpy(G.Uuid,Uuid);<br />  double Filled = strvar(Response,"fillQuantity",0);<br />  if(Filled == 0. &amp;&amp; !(G.OrderType&amp;2))<br />    return 0; // unfilled FOK/IOC order<br />  double Price = strvar(Response,"proceeds",0);<br />  if (Filled &gt; 0. &amp;&amp; Price &gt; 0. &amp;&amp; pPrice)<br />    *pPrice = Price/Filled;<br />  if (*pFill) *pFill = Filled/min(1.,G.Unit);<br />  return -1; <br />}</pre>
<p>The function first composes a message body in this JSON format (example):</p>
<pre>{<br /><span class="hljs-attr">  "marketSymbol"</span>: <span class="hljs-string">"ETH/BTC"</span>,<br /><span class="hljs-attr">  "direction"</span>: <span class="hljs-string">"BUY"</span>,<br /><span class="hljs-attr">  "type"</span>: <span class="hljs-string">"LIMIT"</span>,<br /><span class="hljs-attr">  "quantity"</span>: <span class="hljs-string">"0.1"</span>,<br /><span class="hljs-attr">  "limit"</span>: "0.008<span class="hljs-string">"</span>,<br /><span class="hljs-attr">  "timeInForce"</span>: "IMMEDIATE_OR_CANCEL<span class="hljs-string">"</span><br />}</pre>
<p>If the order is accepted, the response has this JSON format:</p>
<pre>{<br />  "id": "12345-6789-007-4711",<br />  "marketSymbol": "ETH/BTC",<br />  "direction": "BUY",<br />  "type": "LIMIT",<br />  "quantity": "0.1",<br />  "limit": "0.008",<br />  "timeInForce": "IMMEDIATE_OR_CANCEL",<br />  "fillQuantity": "0.05",<br />  "commission": "0.000002",<br />  "proceeds": "0.00001",<br />  "status": "<span class="json-property-enum" title="Possible values"><span class="json-property-enum-item">CLOSED</span></span>"<br />}</pre>
<p>The relevant fields, especially the id, the fill amount, and the fill price, are parsed from the response and returned. The return value <strong>-1</strong> indicates to Zorro that the order generated no identifer number, but an UUID. It was stored and can be retrieved with a subsequent command. <strong>G.Unit </strong>is the lot amount that was generated with the previous <strong>BrokerAsset</strong> call. </p>
<p>The remaining functions not described here &#8211; <strong>BrokerTrade</strong>, <strong>BrokerAccount</strong>, <strong>BrokerHistory2</strong>, and <strong>BrokerCommand</strong> &#8211;  are implemented in a similar way. You can find them in the full source code in the <strong>Source</strong> folder of the latest Zorro version. </p>
<p><strong>Update, November 2023:</strong> Bittrex recently announced that they will terminate their operation. So the Bittrex API plugin described herein lost its purpose, but you can still use the code as a template for connecting Zorro to any other broker or crypto exchange APIs &#8211; at least as long as they remain operational.  </p>
]]></content:encoded>
					
					<wfw:commentRss>https://financial-hacker.com/crypto-trading-with-rest-part-1/feed/</wfw:commentRss>
			<slash:comments>12</slash:comments>
		
		
			</item>
		<item>
		<title>The COVID survival calculator</title>
		<link>https://financial-hacker.com/the-covid-survival-calculator/</link>
		
		<dc:creator><![CDATA[jcl]]></dc:creator>
		<pubDate>Sun, 12 Dec 2021 15:08:16 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Covid]]></category>
		<guid isPermaLink="false">https://financial-hacker.com/?p=4224</guid>

					<description><![CDATA[Trading is obviously affected by global pandemics. Not only because markets tank whenever a new virus variant emerges. It&#8217;s also personal. After all, if you know that you have only a few months before you likely die, you might be motivated to trade a little more risky. To help you with this decision, I&#8217;m publishing &#8230; <a href="https://financial-hacker.com/the-covid-survival-calculator/" class="more-link">Continue reading<span class="screen-reader-text"> "The COVID survival calculator"</span></a>]]></description>
										<content:encoded><![CDATA[<p>Trading is obviously affected by global pandemics. Not only because markets tank whenever a new virus variant emerges. It&#8217;s also personal. After all, if you know that you have only a few months before you likely die, you might be motivated to trade a little more risky. To help you with this decision, I&#8217;m publishing here a Zorro script that calculates your average survival time depending on the COVID incidence in your country and on your vaccination status.<span id="more-4224"></span></p>
<p>The algorithm is plain math, based on three variables: The <strong>vaccination percentage</strong> of your country, the vaccination percentage among cases, and the <strong>7-day incidence</strong>, i.e. the number of cases per week and per 100,000 people.&nbsp; &#8216;Case&#8217; can be infection, hospitalization, or death, dependent on what result you want to calculate. Those 3 variables are often available from health organizations in most countries, or can be derived from publicly available statistics. The script calculates the vaccinated and unvaccinated incidences and the average survival time in weeks before a vaccinated or unvaccinated person is infected, hospitalized, or dead. It makes no assumptions about the effectivity of vaccinations.</p>
<p>First, incidence calculation. Let&#8217;s assume that your country has a total 7-day incidence of 400, and that 70% of people, and 35% of the infected are vaccinated. The incidence of the vaccinated is then:</p>
<p><em>I<sub>vac</sub> = 400 * 35/70 = 200</em></p>
<p>The incidence of the unvaccinated:</p>
<p><em>I<sub>unv</sub> = 400 * (100-35)/(100-70) = 867</em></p>
<p>Thus, in that hypothetical case you&#8217;re four times more likely to catch the virus when you&#8217;re unvaccinated &#8211; despite the relatively high 35% vaccinated infection rate. But what does this mean for your survival time?</p>
<p>The probability <em>P</em> to survive a week without becoming a &#8216;case&#8217; depends on incidence <em>I</em>:</p>
<p><em>P = 1-I/100000</em></p>
<p>The chance to survive <em>N</em> weeks is thus</p>
<p><em>(1-I/100000)<sup>N</sup></em></p>
<p>The half life &#8211; the time <em>T</em> in weeks until 50% of people are infected &#8211; is given by</p>
<p><em>T = ln(0.5)/ln(P)</em></p>
<p>When we enter the above figures, first for the vaccinated:</p>
<p><em>T = ln(0.5)/ln(1-200/100000) = 346 weeks</em></p>
<p>Then for the unvaccinated:</p>
<p><em>T = ln(0.5)/ln(1-867/100000) = 80 weeks</em></p>
<p>Thus, in the given scenario most of the unvaccinated will be either dead or recovered within two years. Of course under the assumption that the incidence does not change during that time. We know that this is not the case: due to the exponential spread, pandemics tend to come and go in waves, as in the above image. Therefore, in the case of COVID, use not the current incidence, but the&nbsp; average incidence from top to valley of the most recent wave for estimating your average survival time.</p>
<p>The script in C for Zorro:</p>
<pre class="prettyprint">// Covid Vaxxed vs Unvaxxed survival calculator ///////////////////////////

void click(int Row,int Col)
{
	if(Row != -1) return; // [Result] clicked?
	sound("click.wav");
	printf("\nTotal: Vaxx %.0f%% Unvaxx %.0f%%",
		slider(1),100-slider(1));
	printf("\nCases: Vaxx %.0f%% Unvaxx %.0f%%",
		slider(2),100-slider(2));
	var Vaxx = slider(3)*slider(2)/slider(1);
	var Unvaxx = slider(3)*(100-slider(2))/(100-slider(1));
	printf("\nIncidence: Vaxx %.0f Unvaxx %.0f",
		Vaxx,Unvaxx);
	printf("\nRisk/week: Vaxx %.2f%% Unvaxx %.2f%%",
		Vaxx/1000,Unvaxx/1000);
	printf("\nSurvival/weeks: Vaxx %.0f Unvaxx %.0f",
		log(0.5)/log(1.-Vaxx/100000),
		log(0.5)/log(1.-Unvaxx/100000));
	printf("\n");
}

void main()
{
	slider(1,70,1,99,"Total %","Vaccinated in population");
	slider(2,30,1,99,"Cases %","Vaccinated cases");
	slider(3,1000,1,2000,"Incidence","Weekly cases per 100,000"); 
	while(wait(100)); // keep script alive
}</pre>


<p>Start the script and set up the 3 sliders to:</p>
<ul style="list-style-type: square;">
<li>the total vaccination percentage in the population,</li>
<li>the vaccination percentage of cases,</li>
<li>the 7-day per 100,000 case incidence.</li>
</ul>
<p>Then click on [Result]. The printout should look like this:</p>
<pre>Total: Vaxx 70% Unvaxx 30%
Cases: Vaxx 35% Unvaxx 65%
Incidence: Vaxx 200 Unvaxx 867
Risk/week: Vaxx 0.20% Unvaxx 0.87%
Survival/weeks: Vaxx 346 Unvaxx 80</pre>
<p>The script can be downloaded from the 2021 repository. Zorro can be downloaded from <a href="https://zorro-project.com/download.php" target="_blank" rel="noopener">zorro-project.com</a>.&nbsp;</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Petra on Programming: Short-Term Candle Patterns</title>
		<link>https://financial-hacker.com/petra-on-programming-short-term-candle-patterns/</link>
					<comments>https://financial-hacker.com/petra-on-programming-short-term-candle-patterns/#comments</comments>
		
		<dc:creator><![CDATA[Petra Volkova]]></dc:creator>
		<pubDate>Wed, 23 Dec 2020 13:33:08 +0000</pubDate>
				<category><![CDATA[Indicators]]></category>
		<category><![CDATA[No Math]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Candle Pattern]]></category>
		<category><![CDATA[Indicator]]></category>
		<guid isPermaLink="false">https://financial-hacker.com/?p=3764</guid>

					<description><![CDATA[Japanese rice merchants invented candle patterns in the eighteenth century. Some traders believe that those patterns are still valid today. But alas, it seems no one yet got rich with them. Still, trading book authors are all the time praising patterns and inventing new ones, in hope to find one pattern that is really superior &#8230; <a href="https://financial-hacker.com/petra-on-programming-short-term-candle-patterns/" class="more-link">Continue reading<span class="screen-reader-text"> "Petra on Programming: Short-Term Candle Patterns"</span></a>]]></description>
										<content:encoded><![CDATA[<p><em>Japanese rice merchants invented candle patterns in the eighteenth century. Some traders believe that those patterns are still valid today. But alas, it seems no one yet got rich with them. Still, trading book authors are all the time praising patterns and inventing new ones, in hope to find one pattern that is really superior to randomly entering positions. In the Stocks &amp; Commodities January 2021 issue, <strong>Perry Kaufman</strong> presented several new candle patterns. Let&#8217;s repeat his pattern tests with major US stocks and indices, and with or without an additional trend filter.</em><span id="more-3764"></span></p>
<p>Kaufman&#8217;s 6 patterns were named Key Reversal, Island Reversal, Outside Days, Wide Ranging days, 3-Day Compression, and Gap opening. All are calculated from the previous 3 or 4 candles or price ranges. All but one are symmetric, meaning they deliver bullish and bearish signals. And because I&#8217;m a bit on the evil side, I added a 7th pattern that I just invented: TotalRandom.</p>
<p>Here&#8217;s how the patterns look as indicators in C:</p>
<pre class="prettyprint">// a higher high followed by a lower close. 
var cdlKeyReversal()
{
  if(priceHigh(0) &gt; priceHigh(1) &amp;&amp; priceLow(0) &lt; priceLow(1)) {
    if(priceClose(0) &lt; priceLow(1)) return -100; // sell
    if(priceClose(0) &gt; priceHigh(1)) return 100; // buy
  } 
  return 0;
}


// recent 3 days each have a true range smaller than the 4th previous day.
var cdl3DayCompression()
{
  vars TRs = series(TrueRange(),4);
  if(TRs[0] &lt; TRs[3] &amp;&amp; TRs[1] &lt; TRs[3] &amp;&amp; TRs[2] &lt; TRs[3])
    return 100;
  else
    return 0;
}

// a gap higher followed by a lower close, but not filling the gap. 
var cdlIslandReversal()
{
  if(priceLow(0) &gt; priceHigh(1) &amp;&amp; priceClose(0) &lt; priceOpen(0)) 
    return -100; // sell
  if(priceLow(1) &gt; priceHigh(0) &amp;&amp; priceClose(0) &gt; priceOpen(0)) 
    return 100; // buy
  else return 0;
}

// a higher high and a lower low, close in upper or lower 25% of the range.
var cdlOutsideDay()
{
  if(priceHigh(0) &gt; priceHigh(1) &amp;&amp; priceLow(0) &lt; priceLow(1)) {
    if(priceClose(0) &lt; 0.75*priceLow(0) + 0.25*priceHigh(0)) 
      return -100; // sell
    if(priceClose(0) &gt; 0.25*priceLow(0) + 0.75*priceHigh(0)) 
      return 100; // buy
  } 
  return 0; 
}

// same as outside days, but true range must exceed 1.5 × 20-day ATR
var cdlWideRangeDays()
{
  if(TrueRange() &gt; 1.5*ATR(20))
    return cdlOutsideDay();
  else
    return 0;
}

// gap must be larger than 0.5 × 20-day ATR.
var cdlGapOpening()
{
  var Ratio = (priceOpen(0) - priceClose(1))/ATR(20);
  if(Ratio &gt;= 0.5) return 100;
  if(Ratio &lt;= -0.5) return -100;
  return 0; 
}

// just enter a trade when you feel lucky
var cdlTotalRandom()
{
  int Pattern = random(100);
  if(Pattern &gt; 90) return 100;
  if(Pattern &lt; 10) return -100;
  return 0;
}</pre>
<p>Following the convention of the classic candle pattern indicators from the TA library, the pattern functions return +100 for a bullish pattern, -100 for a bearish pattern, and 0 for no pattern.</p>
<p>We&#8217;re now putting them to the  test. We want to trade the patterns with IWM, AAPL, AMZN, GE, WMT, and TSLA stocks, with SPY and QQQ index ETFs, and with and without an additional trend filter. For any detected pattern, we&#8217;re entering a long or short position depending on if it&#8217;s bullish or bearish. We always invest the same amount, regardless of the price of the stock. The position is closed after 1, 2, 3, 4, or 5 days. For any asset and any exit type we&#8217;ll export the number of trades and the total win and loss to a table in HTML format. That is convenient for me because I can paste it directly in this blog article.</p>
<p>The test script:</p>
<pre class="prettyprint">var pattern();

function run()
{
  pattern = cdlKeyReversal;
  bool WithTrend = 0;
  string Name = "KeyRev";

  BarPeriod = 1440;
  StartDate = 20100101; // TSLA went public in 2010
  EndDate = 2020; // test until 2020
  var Investment = 10000;
  TradesPerBar = 40; // 8 assets * 5 algos

  char File[100];
  if(is(EXITRUN)) {
    sprintf(File,"Log\\%s.htm",strf("%s%s",
      Name,ifelse(WithTrend,"WithTrend","NoTrend")));
    printf("\nStoring results in %s",File);
    file_write(File,strf("&lt;p&gt;%s:&lt;/p&gt;\n&lt;table&gt;&lt;tr&gt;",File),0);
// write the table header
    file_append(File,"&lt;td&gt;Asset&lt;/td&gt;",0);
    file_append(File,"&lt;td&gt;Long/Short&lt;/td&gt;",0);
    file_append(File,"&lt;td&gt;Day 1&lt;/td&gt;",0);
    file_append(File,"&lt;td&gt;Day 2&lt;/td&gt;",0);
    file_append(File,"&lt;td&gt;Day 3&lt;/td&gt;",0);
    file_append(File,"&lt;td&gt;Day 4&lt;/td&gt;",0);
    file_append(File,"&lt;td&gt;Day 5&lt;/td&gt;&lt;/tr&gt;",0);
  }

  assetAdd("SPY","STOOQ:*.US"); // load price history from Stooq
  assetAdd("QQQ","STOOQ:*.US");
  assetAdd("IWM","STOOQ:*.US");
  assetAdd("AAPL","STOOQ:*.US");
  assetAdd("AMZN","STOOQ:*.US");
  assetAdd("GE","STOOQ:*.US");
  assetAdd("WMT","STOOQ:*.US");
  assetAdd("TSLA","STOOQ:*.US");

  while(asset(loop("SPY","QQQ","IWM","AAPL","AMZN","GE","WMT","TSLA"))) {
  vars Trend = series(SMA(seriesC(),80));
  while(algo(loop("Day1","Day2","Day3","Day4","Day5"))) {

  Lots = Investment/priceClose();
  LifeTime = Itor2+1; // life time in days
  int Signal = pattern();
  if(Signal &gt; 0 &amp;&amp; (!WithTrend || rising(Trend)))
    enterLong();
  else if(Signal &lt; 0 &amp;&amp; (!WithTrend || falling(Trend)))
    enterShort();
  if(is(EXITRUN)) {
    if(Algo == "Day1") // first loop run
      file_append(File,strf("\n&lt;tr&gt;&lt;td&gt;%s&lt;/td&gt;&lt;td&gt;%i/%i&lt;/td&gt;",
        Asset,NumWinLong+NumLossLong,NumWinShort+NumLossShort),0);
    string Color = ifelse(WinLong-LossLong+WinShort-LossShort &gt; 0,
      "bgcolor=\"lime\"","bgcolor=\"red\"");
    file_append(File,strf("&lt;td %s&gt;%.0f/%.0f&lt;/td&gt;",
      Color,WinLong-LossLong,WinShort-LossShort),0);
    if(Algo == "Day5")
      file_append(File,"&lt;/tr&gt;",0);
  }

  }} // loops
  if(is(EXITRUN)) {
    file_append(File,"&lt;/table&gt;",0);
    file_append(File,strf("&lt;p&gt;Total Profit: %.0f (%.0f%%)&lt;/p&gt;",
      WinTotal-LossTotal,100*(WinTotal-LossTotal)/Investment),0);
  }
}
</pre>
<p>Some explanations about the code. At the begin of the <strong>run()</strong> function the pattern and the trend mode are set up. For convenience we&#8217;re using a function pointer that is set to the pattern function to be tested. Afterwards, when it&#8217;s the last run, the table header is written into the HTM file. A char array (<strong>File</strong>) and the <strong>sprintf()</strong> function is used for the file name instead of the more convenient <strong>strf()</strong>, because we need to keep the file name for later writing into the table.</p>
<p>The test uses two nested loops, first for selecting the stocks, second for selecting the trade life time to get the results from a 1-day trade up to a 5-days trade. The predefined <strong>Itor2</strong> variable is the iterator of the second loop and runs from 0 to 4, so we just use it to set the LifeTime variable for the subsequent trade. The results are printed in the EXITRUN at the last day of the simulation.</p>
<p>The numbers in the tables are the results from long/short trades. A winning pattern is displayed in green, a losing pattern in red. Transaction costs are considered.</p>
<div data-tadv-p="keep">
<p><span style="font-family: 'andale mono', monospace; font-size: 8pt;">KeyRev, No Trend:</span></p>
<table>
<tbody>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Asset</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Long/Short</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 1</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 2</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 3</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 4</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 5</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">SPY</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">54/73</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">379/-74</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">787/-1126</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1276/-1753</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1203/-2587</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">986/-3444</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">QQQ</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">66/80</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1028/-2222</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1842/-1958</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">2042/-2242</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">2008/-2681</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1179/-4133</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">IWM</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">63/84</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">19/-300</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">756/-488</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1298/-502</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1386/-900</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">2063/-2429</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">AAPL</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">59/61</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-1346/-7827</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-947/-9158</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-559/-13563</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-1237/-11751</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">356/-11040</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">AMZN</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">69/58</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">142/-1259</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">2013/-2446</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1252/-2293</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">2208/-4940</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">3134/-7322</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">GE</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">66/61</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-4510/-2948</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-7995/-6381</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-8232/-6583</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-7267/-8451</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-7646/-10219</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">WMT</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">62/69</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-337/-177</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">228/-100</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1709/-821</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1612/-128</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1472/-983</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">TSLA</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">65/52</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">5480/2377</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">11321/814</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">11299/-206</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">9784/-1291</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">5640/-5471</span></td>
</tr>
</tbody>
</table>
<p><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Total Profit: -103182 (-1032%)</span></p>
<p><span style="font-family: 'andale mono', monospace; font-size: 8pt;">KeyRev, With Trend:</span></p>
<table>
<tbody>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Asset</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Long/Short</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 1</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 2</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 3</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 4</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 5</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">SPY</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">44/13</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">208/472</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">276/260</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">744/198</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">96/-236</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">345/-855</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">QQQ</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">53/12</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">448/-490</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1350/-427</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1763/-488</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1806/-1524</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">985/-1860</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">IWM</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">43/22</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">563/557</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">831/-150</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">81/-773</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">225/-1174</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-55/-2342</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">AAPL</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">46/10</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-842/-475</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">55/-926</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">955/-1562</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-149/-1882</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">603/-2556</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">AMZN</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">58/16</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">314/-661</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1254/-897</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-727/-566</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-680/-1734</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-27/-1628</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">GE</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">36/29</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-1967/-645</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-2990/-2871</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-1527/-3644</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-262/-4542</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-1106/-6970</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">WMT</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">42/26</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-438/215</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-379/676</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">610/-9</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">312/706</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1050/-76</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">TSLA</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">41/17</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">5530/-1068</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">11484/-1301</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">10308/-3273</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">10240/-3127</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">7723/-3471</span></td>
</tr>
</tbody>
</table>
<p><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Total Profit: -2109 (-21%)</span></p>
<p><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Compression, No Trend:</span></p>
<table>
<tbody>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Asset</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Long/Short</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 1</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 2</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 3</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 4</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 5</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">SPY</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">699/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">6795/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">11511/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">17027/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">18998/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">23941/0</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">QQQ</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">694/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">13941/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">22562/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">28398/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">33369/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">35845/0</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">IWM</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">719/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">9964/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">15613/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">19472/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">22317/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">22088/0</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">AAPL</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">740/0</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-32636/0</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-19330/0</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-12002/0</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-2776/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">2230/0</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">AMZN</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">733/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">25188/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">37365/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">49592/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">52783/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">62537/0</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">GE</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">728/0</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-48784/0</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-45754/0</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-40932/0</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-41726/0</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-44097/0</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">WMT</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">743/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">4060/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">9378/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">19676/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">19954/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">19714/0</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">TSLA</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">701/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">34085/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">39053/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">50163/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">74096/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">93178/0</span></td>
</tr>
</tbody>
</table>
<p><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Total Profit: 606857 (6069%)</span></p>
<p><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Compression With Trend:</span></p>
<table>
<tbody>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Asset</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Long/Short</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 1</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 2</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 3</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 4</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 5</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">SPY</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">561/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">5212/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">8658/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">9792/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">10530/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">12164/0</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">QQQ</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">571/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">10895/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">18052/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">20473/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">24411/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">26917/0</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">IWM</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">525/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">6363/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">9300/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">9143/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">14086/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">15742/0</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">AAPL</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">547/0</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-20085/0</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-4174/0</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-1241/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">5801/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">5899/0</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">AMZN</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">557/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">19877/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">28991/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">34042/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">32737/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">38519/0</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">GE</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">385/0</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-24387/0</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-22127/0</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-16754/0</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-16487/0</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-19714/0</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">WMT</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">501/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">4228/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">9813/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">18114/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">21492/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">20353/0</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">TSLA</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">443/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">29320/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">34921/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">42957/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">58827/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">66305/0</span></td>
</tr>
</tbody>
</table>
<p><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Total Profit: 548966 (5490%)</span></p>
<p><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Island, No Trend:</span></p>
<table>
<tbody>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Asset</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Long/Short</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 1</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 2</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 3</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 4</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 5</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">SPY</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">19/32</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">547/696</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">540/314</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-262/1357</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-282/1186</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-517/133</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">QQQ</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">24/26</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">300/-283</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-684/-452</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-1190/360</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-2194/-65</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-1274/-920</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">IWM</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">10/27</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">921/-15</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1587/-112</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1610/1583</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1936/918</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1698/924</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">AAPL</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">30/33</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-2304/-1850</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-2055/-2128</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-3958/-2921</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-4046/-3311</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-5085/-3696</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">AMZN</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">20/25</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">498/-1995</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">454/-1575</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-28/-1469</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-150/-2013</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-214/-2048</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">GE</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">20/28</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">24/-1885</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-1181/-221</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-719/1343</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">2468/106</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">682/-1594</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">WMT</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">23/17</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1099/972</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">2056/605</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">2508/697</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">3300/1188</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">3094/782</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">TSLA</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">25/28</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1029/-5539</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1732/-7774</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">3167/-5777</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1278/-6200</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-2787/-10091</span></td>
</tr>
</tbody>
</table>
<p><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Total Profit: -47171 (-472%)</span></p>
<p><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Island With Trend:</span></p>
<table>
<tbody>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Asset</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Long/Short</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 1</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 2</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 3</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 4</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 5</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">SPY</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">11/5</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">348/391</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-19/444</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">104/841</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-69/910</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">133/411</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">QQQ</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">15/4</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-43/376</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-274/407</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-1069/948</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-1588/1139</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-1544/557</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">IWM</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">5/7</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">47/173</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">461/234</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">562/1312</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">539/1506</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">643/1364</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">AAPL</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">24/4</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-1095/-337</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-1625/104</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-3931/26</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-4541/175</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-5013/115</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">AMZN</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">12/3</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">90/-377</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-1049/-311</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-1364/-3</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-2070/214</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-1720/-32</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">GE</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">10/15</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-407/-829</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-2018/34</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-2323/1562</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-1673/767</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-2358/-155</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">WMT</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">13/3</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">813/58</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1138/-257</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1269/185</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1484/365</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1389/-15</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">TSLA</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">13/8</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-12/-1216</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1134/-1731</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1574/-1913</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-41/-2357</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-5443/-2904</span></td>
</tr>
</tbody>
</table>
<p><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Total Profit: -27380 (-274%)</span></p>
<p><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Outside, No Trend:</span></p>
<table>
<tbody>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Asset</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Long/Short</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 1</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 2</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 3</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 4</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 5</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">SPY</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">77/77</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">888/-1105</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1410/-1913</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">2295/-2788</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1849/-3487</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1555/-3798</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">QQQ</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">86/86</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">919/-1641</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1510/-2001</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1638/-1562</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">2132/-2919</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1198/-3920</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">IWM</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">89/83</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-17/-740</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">205/216</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">15/155</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">885/-739</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">419/-1453</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">AAPL</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">65/65</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">2441/-3824</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">3324/-5405</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">4000/-7484</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">4439/-7002</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">6148/-7471</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">AMZN</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">85/68</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">489/-561</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">2895/-1176</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">2629/-2024</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">2498/-3505</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">4767/-6733</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">GE</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">74/73</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-239/-4137</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-2582/-6322</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-3096/-7272</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-3567/-8987</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-3550/-11511</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">WMT</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">72/84</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-491/1036</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">461/361</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1678/-514</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1991/-700</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">879/-2724</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">TSLA</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">74/59</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">6927/1382</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">11200/0</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">12701/-1546</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">11173/-5879</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">6769/-6498</span></td>
</tr>
</tbody>
</table>
<p><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Total Profit: -35405 (-354%)</span></p>
<p><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Outside With Trend:</span></p>
<table>
<tbody>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Asset</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Long/Short</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 1</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 2</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 3</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 4</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 5</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">SPY</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">63/13</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">664/123</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">977/-243</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1430/-396</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">596/-887</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">830/-1168</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">QQQ</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">69/11</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">214/-123</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">371/-70</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">481/-8</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">919/-998</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-43/-1275</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">IWM</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">59/23</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">918/-59</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1629/-481</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1346/-1381</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1447/-2182</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1339/-2496</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">AAPL</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">51/11</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">2210/-377</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">3673/-635</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">4927/-799</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">5244/-1175</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">6062/-2042</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">AMZN</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">67/14</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">979/-563</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1886/-906</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">89/-377</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">316/-1515</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1795/-1141</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">GE</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">42/34</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">677/-2682</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-353/-4345</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1801/-5183</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1663/-6603</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-732/-10460</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">WMT</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">49/31</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-746/1081</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-482/1016</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1165/267</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">644/244</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1183/-976</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">TSLA</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">49/23</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">6834/-1174</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">11638/333</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">10403/-871</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">10899/-1795</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">8143/-2696</span></td>
</tr>
</tbody>
</table>
<p><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Total Profit: 38018 (380%)</span></p>
<p><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Range, NoTrend:</span></p>
<table>
<tbody>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Asset</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Long/Short</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 1</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 2</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 3</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 4</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 5</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">SPY</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">18/27</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">205/-520</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">206/-1392</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">179/-1244</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-10/-1337</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-254/-2635</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">QQQ</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">18/30</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-64/-214</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">274/-741</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">412/161</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">839/72</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">558/-1528</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">IWM</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">19/25</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-392/-382</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-873/-88</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-711/1284</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-1083/1207</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-886/456</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">AAPL</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">9/13</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">404/-293</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">318/-951</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1193/-420</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1187/-576</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">980/-1500</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">AMZN</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">13/17</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1100/-1315</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1785/-843</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">938/612</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1702/526</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">2577/-667</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">GE</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">17/23</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-1281/-181</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-1833/-2128</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-3415/-2288</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-4833/-1910</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-5257/-3787</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">WMT</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">12/14</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-142/399</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-433/915</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-1078/801</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-1232/998</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-1746/697</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">TSLA</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">21/17</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">849/33</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">3714/-1998</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">3761/-3474</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">2735/-7781</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">386/-7093</span></td>
</tr>
</tbody>
</table>
<p><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Total Profit: -38348 (-383%)</span></p>
<p><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Range With Trend:</span></p>
<table>
<tbody>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Asset</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Long/Short</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 1</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 2</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 3</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 4</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 5</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">SPY</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">15/4</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-245/51</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-193/283</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">11/413</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-409/105</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-522/-507</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">QQQ</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">13/5</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-585/-99</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-374/151</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-293/514</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-138/86</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-539/-216</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">IWM</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">11/5</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">393/-230</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">304/-222</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">212/-246</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-74/-9</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">77/-157</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">AAPL</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">8/2</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">517/295</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">254/21</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1049/448</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1092/335</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">840/103</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">AMZN</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">11/4</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-34/-1248</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">252/-1603</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-759/-364</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-603/-1203</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-141/-1438</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">GE</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">9/10</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">906/319</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">496/-1302</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">389/-1897</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-343/-1786</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-1874/-3716</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">WMT</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">6/4</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-262/154</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-545/604</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-328/404</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-704/424</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-558/61</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">TSLA</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">13/3</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">386/-191</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">4201/309</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1815/-35</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1290/-206</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1/-597</span></td>
</tr>
</tbody>
</table>
<p><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Total Profit: -7235 (-72%)</span></p>
<p><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Gap, No Trend:</span></p>
<table>
<tbody>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Asset</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Long/Short</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 1</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 2</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 3</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 4</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 5</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">SPY</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">349/281</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1843/-2647</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">5590/-3626</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">7139/-5568</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">8563/-8215</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">9461/-9622</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">QQQ</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">307/249</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-436/-2679</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">947/-5712</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">3275/-8531</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">7805/-12092</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">9842/-13431</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">IWM</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">234/209</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">2551/-84</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">3639/-418</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">5118/-2119</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">6055/-3499</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">9321/-5574</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">AAPL</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">270/192</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">6959/-1638</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">7870/-5676</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">9847/-7260</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">13533/-5428</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">16900/-8041</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">AMZN</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">195/135</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1427/-2939</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">2777/-4051</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">4995/-4568</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">8998/-6259</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">13534/-6271</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">GE</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">241/195</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">112/371</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-4831/5254</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-3762/3531</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-1410/5945</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1695/4319</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">WMT</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">125/180</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-1507/-7044</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">329/-7500</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">448/-6792</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">24/-6722</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">876/-7916</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">TSLA</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">197/154</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">21127/-6332</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">36571/-12591</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">46932/-11143</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">58537/-9760</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">71862/-9286</span></td>
</tr>
</tbody>
</table>
<p><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Total Profit: 192941 (1929%)</span></p>
<p><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Gap With Trend:</span></p>
<table>
<tbody>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Asset</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Long/Short</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 1</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 2</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 3</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 4</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 5</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">SPY</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">282/82</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">2592/-488</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">5160/166</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">7869/-2794</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">8352/-3565</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">8935/-5882</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">QQQ</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">249/68</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-718/-2463</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-1388/-5109</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">91/-9515</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">4466/-11318</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">5774/-12975</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">IWM</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">163/82</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">2456/617</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">3057/2235</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">5188/917</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">6955/2870</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">8950/2094</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">AAPL</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">219/60</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">3901/-978</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1837/-2601</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">2008/-5555</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">6634/-5316</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">10460/-6654</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">AMZN</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">169/34</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-1685/-2236</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-1130/-5903</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-397/-6310</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">3148/-7550</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">6830/-6188</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">GE</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">138/91</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">969/1315</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-1600/6072</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-679/5257</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">748/5819</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">3337/2798</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">WMT</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">90/79</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-465/-1144</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">174/-456</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-93/-1071</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-760/-1130</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">135/-2431</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">TSLA</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">151/62</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">16146/-4006</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">30939/-3936</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">42024/-3501</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">54105/-1597</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">70309/-915</span></td>
</tr>
</tbody>
</table>
<p><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Total Profit: 221201 (2212%)</span></p>
<p><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Random, NoTrend:</span></p>
<table>
<tbody>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Asset</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Long/Short</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 1</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 2</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 3</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 4</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 5</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">SPY</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">264/245</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">2161/-2628</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">3479/-4002</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">4118/-3867</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">8184/-5686</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">3223/-7478</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">QQQ</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">274/256</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">6391/-6434</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">4669/-3082</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">6549/-7386</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">4095/-2891</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">11244/-6941</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">IWM</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">247/227</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">4546/-2869</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">7429/114</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">4610/1211</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">10551/1705</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">8259/-6920</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">AAPL</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">265/248</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">2130/-9670</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">2688/-4795</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">12171/-6907</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">17141/-9278</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">12451/-25170</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">AMZN</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">239/215</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">2970/-4240</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">3796/-6628</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">4579/-8738</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">7889/-6822</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">10022/-11536</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">GE</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">254/259</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1016/-4440</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-1860/-3617</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">3682/-2421</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">10588/552</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-8794/-12820</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">WMT</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">258/260</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">670/-2260</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">2830/-459</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-55/-2294</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-3118/-5824</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">4529/-3994</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">TSLA</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">209/250</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">8366/-9571</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-4906/-32877</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">17063/-33473</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">19937/-13389</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">8788/-53044</span></td>
</tr>
</tbody>
</table>
<p><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Total Profit: -115840 (-1158%)</span></p>
<p><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Random With Trend:</span></p>
<table>
<tbody>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Asset</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Long/Short</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 1</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 2</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 3</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 4</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Day 5</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">SPY</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">189/55</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">2273/-386</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">597/-600</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">2753/-747</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1864/883</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-1143/-3324</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">QQQ</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">194/53</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">2461/-2976</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">3675/-947</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1360/-3750</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">7607/-7892</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">12958/-2974</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">IWM</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">182/85</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">3478/2507</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">4262/-969</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">3827/-2263</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">902/-3130</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">8135/-4938</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">AAPL</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">183/70</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">7704/-2776</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">9537/-3962</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">8168/-759</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">13781/-5973</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">13117/-2048</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">AMZN</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">174/70</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1795/-4108</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-362/-2203</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">3809/-5626</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">9710/-8699</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">16006/-8834</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">GE</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">125/109</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1187/3311</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-3939/-1684</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">264/2732</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-3265/4335</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">425/-8270</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">WMT</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">174/91</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1962/132</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">2008/-1731</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">-946/-285</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1927/1556</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">1790/-5483</span></td>
</tr>
<tr>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">TSLA</span></td>
<td><span style="font-family: 'andale mono', monospace; font-size: 8pt;">148/92</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">13794/-7286</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">13013/-3592</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">15655/-6054</span></td>
<td bgcolor="lime"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">15511/-10460</span></td>
<td bgcolor="red"><span style="font-family: 'andale mono', monospace; font-size: 8pt;">15264/-18641</span></td>
</tr>
</tbody>
</table>
<p><span style="font-family: 'andale mono', monospace; font-size: 8pt;">Total Profit: 85014 (850%)</span></p>
<p>We can see that the trend filter always improves the results, which indicates some momentum in the stock markets. Aside from that, patterns show no real advantage over random trading. But wait, there&#8217;s an exception: the Compression pattern looks extraordinarily successful. Have we finally found the one pattern that beats randomness?</p>
<p>Unfortunately, a closer look reveals the real reason. The compression pattern opens only long positions, and since most stocks are bullish in the long term, a positive result is to be expected. If you modify the random pattern function so that it only opens long positions, you&#8217;ll get the same effect. Randomly opening long positions beats hands down all symmetric candle patterns. So it seems that trading with candle patterns, no matter old or new, still requires strong faith &#8211; and some disposable money.</p>
<p>The pattern functions and the test script can be downloaded from the 2020 script repository.</p>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://financial-hacker.com/petra-on-programming-short-term-candle-patterns/feed/</wfw:commentRss>
			<slash:comments>14</slash:comments>
		
		
			</item>
		<item>
		<title>Petra on Programming: Get Rid of Noise</title>
		<link>https://financial-hacker.com/petra-on-programming-get-rid-of-noise/</link>
					<comments>https://financial-hacker.com/petra-on-programming-get-rid-of-noise/#comments</comments>
		
		<dc:creator><![CDATA[Petra Volkova]]></dc:creator>
		<pubDate>Fri, 27 Nov 2020 14:54:48 +0000</pubDate>
				<category><![CDATA[Indicators]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ehlers]]></category>
		<category><![CDATA[RSI]]></category>
		<category><![CDATA[SPY]]></category>
		<guid isPermaLink="false">https://financial-hacker.com/?p=3742</guid>

					<description><![CDATA[A major problem of indicator-based strategies is that most indicators produce more or less noisy output, resulting in false signals. The faster the indicator reacts on market situations, the noisier is it usually. In the S&#38;C December issue, John Ehlers proposed a de-noising technology based on correlation. Compared with a lowpass filter, this method does &#8230; <a href="https://financial-hacker.com/petra-on-programming-get-rid-of-noise/" class="more-link">Continue reading<span class="screen-reader-text"> "Petra on Programming: Get Rid of Noise"</span></a>]]></description>
										<content:encoded><![CDATA[<p><em>A major problem of indicator-based strategies is that most indicators produce more or less noisy output, resulting in false signals. The faster the indicator reacts on market situations, the noisier is it usually. In the S&amp;C December issue, <strong>John Ehlers</strong> proposed a de-noising technology based on correlation. Compared with a lowpass filter, this method does not delay the signal. As an example, we will apply the noise elimination to Ehlers&#8217; <strong>MyRSI</strong> indicator, a RSI variant that he presented in an earlier article.</em><span id="more-3742"></span></p>
<p>The MyRSI indicator sums up positive and negative changes in a data series, and returns their normalized difference. The C version for Zorro:</p>
<pre class="prettyprint">var MyRSI(vars Data,int Period)<br />{<br /> var CU = SumUp(Data,Period+1);<br /> var CD = -SumDn(Data,Period+1);<br /> return ifelse(CU+CD != 0,(CU-CD)/(CU+CD),0);<br />}<span style="color: #2e74b5"><br /></span></pre>
<p>For eliminating noise, the function below (<strong>NET</strong> = <strong>N</strong>oise <strong>E</strong>limination <strong>T</strong>echnology) calculates the <strong>Kendall Correlation</strong> of a data series with a rising slope. This is supposed to remove all components that are not following the main trend of the indicator output. The code:</p>
<pre class="prettyprint">var NET(vars Data,int Period)<br />{<br /> int i,k;<br /> var Num = 0;<br /> for(i=1; i&lt;Period; i++)<br />   for(k=0; k&lt;i; k++)<br />     Num -= sign(Data[i]-Data[k]);<br /> var Denom = .5*Period*(Period-1);<br /> return Num/Denom;<br />}</pre>
<p>For making the effect of the denoising visible, we produce a SPY chart from 2019-2020. The red line is the original MyRSI, the blue line the de-noised version:</p>
<p><img decoding="async" src="https://financial-hacker.com/wp-content/uploads/2020/11/112720_1424_PetraonProg1.png" alt="" /></p>
<p>The technology appears to work well in this example for removing the noise. But the NET function is not meant as a replacement of a lowpass or smoothing filter: its output is always in the -1 .. +1 range, so it can be used for de-noising oscillators, but not, for instance, to generate a smoothed version of the price curve.</p>
<p>One might be tempted to use the blue line in the above chart for trade signals. RSI-based signals usually trigger a long trade when the indicator crosses below a lower threshold, and a short trade when it crosses above an upper threshold. But alas, neither is strategy development this easy nor is the de-noised MyRSI the holy grail of indicators. I tested several methods to use it for generating SPY trade signals, but neither was a strong improvement over a simple lowpass filter strategy or even to buy-and-hold. Maybe a reader can find a more convincing solution?</p>
<p>The MyRSI and NET functions and the script for generating the chart can be downloaded from the 2020 script repository. You need Zorro 2.33 or above.</p>

]]></content:encoded>
					
					<wfw:commentRss>https://financial-hacker.com/petra-on-programming-get-rid-of-noise/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Petra on Programming: The Gann Hi-Lo Activator</title>
		<link>https://financial-hacker.com/petra-on-programming-the-gann-hi-lo-activator/</link>
					<comments>https://financial-hacker.com/petra-on-programming-the-gann-hi-lo-activator/#comments</comments>
		
		<dc:creator><![CDATA[Petra Volkova]]></dc:creator>
		<pubDate>Fri, 25 Sep 2020 13:26:23 +0000</pubDate>
				<category><![CDATA[Indicators]]></category>
		<category><![CDATA[No Math]]></category>
		<category><![CDATA[Programming]]></category>
		<guid isPermaLink="false">https://financial-hacker.com/?p=3636</guid>

					<description><![CDATA[Fortunately I could write this article without putting my witch hat on. Despite its name, the &#8216;Gann Hi-Lo Activator&#8217; was not invented by the famous esotericist, but by Robert Krausz in a 1998 article in the Stocks&#38;Commodities magazine. In a recent article, Barbara Star combined it with other indicators for a swing trading system. Will &#8230; <a href="https://financial-hacker.com/petra-on-programming-the-gann-hi-lo-activator/" class="more-link">Continue reading<span class="screen-reader-text"> "Petra on Programming: The Gann Hi-Lo Activator"</span></a>]]></description>
										<content:encoded><![CDATA[<p><em>Fortunately I could write this article without putting my witch hat on. Despite its name, the &#8216;Gann Hi-Lo Activator&#8217; was not invented by the famous esotericist, but by Robert Krausz in a 1998 article in the Stocks&amp;Commodities magazine. In a recent article, Barbara Star combined it with other indicators for a swing trading system. Will an indicator with the name &#8216;Gann&#8217; work outside the realm of the supernatural? </em><span id="more-3636"></span></p>
<p><span style="font-size: inherit;">&#8216;Activator&#8217; is an indicator synonym that I didn&#8217;t know before. However the Gann Hi-Lo Activator (<strong>GHLA</strong>) does not activate something, but compares the current price with the SMAs of the highs and lows of a price series. Depending on the comparison, it returns one of the two SMAs. It is said to indicate a bullish market when the current price is above the Activator, and a bearish market when it is below. The comparison sign is also stored in a &#8216;Color&#8217; variable which we must later use for the swing trading system. The C code:</span></p>
<pre class="prettyprint">var ColorGHLA;
var GHLA(int HPeriod,int LPeriod)
{
 vars H = series(priceHigh());
 vars L = series(priceLow());
 vars MaH = series(SMA(H,HPeriod),2);
 vars MaL = series(SMA(L,LPeriod),2);
 vars State = series(0,2);
 if(priceClose() &gt; MaH[1]) State[0] = 1;
 else if(priceClose() &lt; MaL[1]) State[0] = -1;
 else State[0] = State[1]; // return the previous state
 ColorGHLA = State[0];
 return ifelse(State[0] &lt; 0,MaH[0],MaL[0]);
}</pre>
<p>We store the sign in the series <strong>State</strong> of length 2 because the indicator inventor required to return the previous sign when the price was between the two SMAs. If you wonder why I did not just use a static variable to store the previous sign: That would work for one asset, but not for a portfolio, if someone ever wants to trade one with this indicator.</p>
<p>Two other indicators are used in the author&#8217;s swing trading system: the difference of Welles Wilder&#8217;s plus and minus directional indicators, named <strong>DMI</strong>, and a variant by William Blau of the Stochastic indicator, named &#8216;Stochastic Momentum Index&#8217; (<strong>SMI</strong>). The code:</p>
<pre class="prettyprint">var DMI(int Period)
{
 return PlusDI(Period) - MinusDI(Period);
}

var SMI(int DLength,int KLength)
{
 var Hi = HH(KLength), Lo = LL(KLength);
 var Diff = Hi-Lo;
 var RelDiff = priceClose()-(Hi+Lo)/2;
 var AvgRel = EMA(EMA(RelDiff,DLength),DLength);
 var AvgDiff = EMA(EMA(Diff,DLength),DLength);
 return ifelse(AvgDiff!=0,AvgRel/AvgDiff*200,0);
}</pre>
<p>All 3 together on a chart gives already an impressive show of colorful lines. Here&#8217;s the script for replicating the author&#8217;s chart with the indicators on an NVDA price curve:</p>
<pre class="prettyprint">function run()
{
 BarPeriod = 1440;
 StartDate = 20200201;
 EndDate = 20200410;
 assetAdd("NVDA","STOOQ:NVDA.US");
 asset("NVDA");

 var Ghla = GHLA(3,3);
 var Smi = SMI(3,8);
 var Dmi = DMI(10);
 plot("GHLA",Ghla,LINE,BLUE);
 plot("DMI",Dmi,NEW|BARS,BLUE);
 plot("SMI",Smi,NEW|LINE,BLUE);
 plot("Zero",0,0,BLACK);
}</pre>
<p>The resulting chart (sorry, blue colors only):</p>
<p><img decoding="async" src="https://financial-hacker.com/wp-content/uploads/2020/09/092520_0925_PetraonProg1.png" alt="" /></p>
<p>For trading this indicator soup, the author recommends opening a position when all 3 indicators are in sync, meaning they have the same sign. That&#8217;s why we needed the &#8216;color&#8217; of the GHLA. So we will now open a long position when all signs are positive, and reverse to a short one when they are all negative. We can just use the charting script with this additional code:</p>
<pre class="prettyprint">MaxLong = MaxShort = 1;
if(ColorGHLA &gt; 0 &amp;&amp; Dmi &gt; 0 &amp;&amp; Smi &gt; 0)
 enterLong();
if(ColorGHLA &lt; 0 &amp;&amp; Dmi &lt; 0 &amp;&amp; Smi &lt; 0)
 enterShort();
</pre>
<p>Sure enough, this system shows stellar performance in the author&#8217;s example chart of Spring 2020. 3 out of 4 trades are winners. But what happens when we trade it for a longer period, for example 5 years? Set the <strong>StartDate</strong> variable to a 2015 date and repeat the test.</p>
<p>The sad result:</p>
<p><img decoding="async" src="https://financial-hacker.com/wp-content/uploads/2020/09/092520_0925_PetraonProg2.png" alt="" /></p>
<p>We can see that the system can do anything: win, lose, and stay flat over long periods. The end result is zero. Apparently,  successful swing trading needs other methods. Or maybe better indicators? Of course, this quick test does not mean much. It&#8217;s possible that the GHLA works when removing the other indicators and using other entry conditions, such as entering positions only on a peak. Or maybe the indicator periods were ill chosen and had to be adapted to the market by an optimization process. But at least we got now three more indicators for our collection.</p>
<p>The SMI, DMI, and GHLA indicators, as well as the code for the chart and the trading system can be downloaded from the 2020 script repository.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://financial-hacker.com/petra-on-programming-the-gann-hi-lo-activator/feed/</wfw:commentRss>
			<slash:comments>7</slash:comments>
		
		
			</item>
		<item>
		<title>Petra on Programming: Four Dimensions of Strength</title>
		<link>https://financial-hacker.com/petra-on-programming-4-dimensions-of-strength/</link>
					<comments>https://financial-hacker.com/petra-on-programming-4-dimensions-of-strength/#comments</comments>
		
		<dc:creator><![CDATA[Petra Volkova]]></dc:creator>
		<pubDate>Thu, 20 Aug 2020 10:37:07 +0000</pubDate>
				<category><![CDATA[Indicators]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Portfolio rotation]]></category>
		<category><![CDATA[RS4R]]></category>
		<guid isPermaLink="false">https://financial-hacker.com/?p=3585</guid>

					<description><![CDATA[In the S&#38;C September 2020 article &#8220;Tracking Relative Strength In Four Dimensions&#8221;, James Garofallou presents a metric for evaluating a security&#8217;s strength relative to 11 major market sectors and over several time periods. All this information is squeezed into a single value. Maybe at cost of losing other important information? In this article we&#8217;ll look &#8230; <a href="https://financial-hacker.com/petra-on-programming-4-dimensions-of-strength/" class="more-link">Continue reading<span class="screen-reader-text"> "Petra on Programming: Four Dimensions of Strength"</span></a>]]></description>
										<content:encoded><![CDATA[<p><em>In the S&amp;C September 2020 article &#8220;Tracking Relative Strength In Four Dimensions&#8221;, James Garofallou presents a metric for evaluating a security&#8217;s strength relative to 11 major market sectors and over several time periods. All this information is squeezed into a single value. Maybe at cost of losing other important information? In this article we&#8217;ll look into how to program such a beast, and how it fares when we use it for rebalancing a stock portfolio.</em><span id="more-3585"></span></p>
<p>For getting the 4-dimensional relative strength we start with two dimensions. The <strong>RS2</strong> indicator divides a securities&#8217; price by a market index, then calculates four moving averages of the result and encodes their relations in a number that is then returned. Here&#8217;s the RS2 code:</p>
<pre class="prettyprint">var RS2(var Close, string Index)
{
   assetAdd(strf("IDX%i",NumIndex),strf("YAHOO:%s",Index)); 
   if(!asset(Asset)) return quit("Index not found!");
   var RS2 = Close/priceClose(0);
   var Fast = EMA(series(RS2),10*PERIOD);
   var Med = SMA(series(Fast),7*PERIOD);
   var Slow = SMA(series(Fast),15*PERIOD);
   var VSlow = SMA(series(Slow),30*PERIOD);
   if(Fast &gt;= Med &amp;&amp; Med &gt;= Slow &amp;&amp; Slow &gt;= VSlow)
      return 10;
   else if(Fast &gt;= Med &amp;&amp; Med &gt;= Slow &amp;&amp; Slow &lt; VSlow)
      return 9;
   else if(Fast &lt; Med &amp;&amp; Med &gt;= Slow &amp;&amp; Slow &gt;= VSlow)
      return 9;
   else if(Fast &lt; Med &amp;&amp; Med &gt;= Slow &amp;&amp; Slow &lt; VSlow)
      return 5;
   else
      return 0;
}
</pre>
<p>The code above takes the Close of the security and the name of the index for the division. It gets the index price from Yahoo, then determines 4 moving averages as prescribed by the author, and returns either 10, 9, 5, or 0 depending on how fast the price quotient is rising. Note that I had to multiply all MA periods with a predefined PERIOD factor. That&#8217;s because I could at first not reproduce the author&#8217;s charts, until I found out that his MA periods are apparently not days, but candle width units of his chart. He used 3-day candles for some reason. So I had to multiply all MA periods with a PERIOD of 3. Without this correction, the resulting charts would be very different.</p>
<p>The next step is the RS4, which combines the RS2 values of 11 major market indexes. I used the same Fidelity indexes as the author. The C code of the RS4 indicator:</p>
<pre class="prettyprint">var RS4(var Close)
{
  var RS3 = RS2(Close,"FXAIX") // SPX 500
    + RS2(Close,"FNCMX") // Nasdaq
    + RS2(Close,"FSMDX") // Mid Cap
    + RS2(Close,"FSSNX") // Small Cap
    + RS2(Close,"FSPGX") // Large Growth
    + RS2(Close,"FLCOX") // Large Val
    + RS2(Close,"FPADX") // Emerging Market
    + RS2(Close,"FSRNX") // Real Estate
    + RS2(Close,"FSAGX") // Gold
    + RS2(Close,"FSUTX") // Utilities
    + RS2(Close,"FTBFX"); // Total Bond
  return 10*RS3/11;
}</pre>
<p>The returned value is multiplied with 10 and normalized by the number of indexes. Now we got all 4 dimensions together, the 4th one apparently being the normalization. We can now reproduce the author&#8217;s chart with a smoothed RS4 – named &#8220;RS4osc&#8221; – and a further smoothed signal line. For the security we&#8217;re using Fidelity Gold, FSAGX. The code:</p>
<pre class="prettyprint">voidrun()
{
  BarPeriod = 1440;
  StartDate = 20181201;
  EndDate = 20200415;
  LookBack = 200;
  assetAdd("Gold","YAHOO:FSAGX");
  asset("Gold");
  var RS4Osc = SMA(series(RS4(priceClose(0))),3*PERIOD);
  var Mv = SMA(series(RS4Osc),5*PERIOD);
  plot("RS4Osc",RS4Osc,NEW|LINE,BLUE);
  plot("Mv",Mv,LINE,RED);
}</pre>
<p>The resulting chart:</p>
<p><img decoding="async" src="https://financial-hacker.com/wp-content/uploads/2020/08/082020_1037_PetraonProg1-1.png" alt="" /></p>
<p>Before you even try: No, the red and blue line crossings in the chart do not indicate profitable trade entries. Not even the author claims that. So what do we do with this indicator? Since it represents strength, let&#8217;s try it in a basic portfolio rotation system. Of a universe of 10 major stocks, it shall select the 4 strongest stocks and invest in them according to their strength. The portfolio is rebalanced at any month. First, we use a simple momentum based strength. The code:</p>
<pre class="prettyprint">void run() 
{
  BarPeriod = 1440;
  LookBack = 200;
  StartDate = 2012;
  EndDate = 2020;
  Capital = 10000;
  var Weights[10],Strengths[10];
  string Stock,Stocks[10];
  assetList("assetsIB");
  while(Stock = loop("AAPL","MSFT","XOM","AMZN","JNJ","FB","GE","TSLA","JPM","PG"))
  {
    if(Init) assetHistory(Stock,FROM_STOOQ);
    asset(Stock);
    Stocks[Itor1] = Stock;
    Strengths[Itor1] = RET(30*PERIOD);
  }
  if(month(0) != month(1)) // at any month
  {
    distribute(Weights,Strengths,10,4,0);
    int i;
    for(i = 0; i&lt;10; i++) {
      asset(Stocks[i]);
      int NewShares = Weights[i]*Balance/priceClose(0) - LotsPool;
      if(NewShares &gt; 0)
        enterLong(NewShares);
      else if(NewShares &lt; 0)
        exitLong("",-NewShares);
    }
  } 
}</pre>
<p>I&#8217;ve used the 10 top stocks from the S&amp;P 500. The strength is simply defined as the stock return over 30*3 days, which is the same as the &#8220;very long&#8221; MA period of the RS2. The <a href="https://manual.zorro-project.com/distribute.htm">distribute</a> function in the code is a special Zorro function that sorts the stocks according to their strength, and assigns weights among the 4 strongest stocks. The remaining 6 weaker stocks get weight 0. The weights are then converted to positions and rebalanced at the first workday of any month by buying or selling stocks.</p>
<p>The resulting equity curve (mind the Covid-19 drop):</p>
<p><img decoding="async" src="https://financial-hacker.com/wp-content/uploads/2020/08/082020_1037_PetraonProg2-1.png" alt="" /></p>
<p>In the backtest from 2012-2020, this system achieves 47% CAGR, mostly due to the strong volatility at the end. It&#8217;s not an optimal system and you would probably not want to trade it live. Now what happens when we replace the 90-day return with the RS4? For this we only need to change the line where the strength is calculated:</p>
<pre class="prettyprint">Strengths[Itor1] = RS4(priceClose(0));</pre>
<p>The equity curve of the RS4-based portfolio rotation system:</p>
<p><img decoding="async" src="https://financial-hacker.com/wp-content/uploads/2020/08/082020_1037_PetraonProg3-1.png" alt="" /></p>
<p>The CAGR has dropped to 35%. The Covid-19 drop is not as significant, but the the recovery afterwards isn&#8217;t either. Although the equity curve looks less volatile, the Sharpe Ratio is in fact lower, 1.01 compared to 1.11 with the previous return-based system.</p>
<p>Does this mean that the RS4 is inferior to a simple 90-day return? No, because I just tried it with the first and simplest stock rotation system that came in mind. For really judging the RS4, a lot more tests with a lot more systems and with walk forward analysis had to be done.</p>
<p>The RS2 and RS4 indicators, as well as the code for the portfolio rotation system can be downloaded from the 2020 script repository.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://financial-hacker.com/petra-on-programming-4-dimensions-of-strength/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Petra on Programming: The Compare Price Momentum Oscillator</title>
		<link>https://financial-hacker.com/petra-on-programming-the-compare-price-momentum-oscillator/</link>
					<comments>https://financial-hacker.com/petra-on-programming-the-compare-price-momentum-oscillator/#comments</comments>
		
		<dc:creator><![CDATA[Petra Volkova]]></dc:creator>
		<pubDate>Fri, 24 Jul 2020 13:36:09 +0000</pubDate>
				<category><![CDATA[Indicators]]></category>
		<category><![CDATA[No Math]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[CPMO]]></category>
		<category><![CDATA[PMO]]></category>
		<guid isPermaLink="false">https://financial-hacker.com/?p=3530</guid>

					<description><![CDATA[Vitali Apirine, inventor of the OBVM indicator, presented another new tool for believers in technical analysis. His new Compare Price Momentum Oscillator (CPMO), described in the Stocks &#38; Commodities August 2020 issue, is based on the Price Momentum Oscillator (PMO) by Carl Swenlin. Yet another indicator with an impressive name. But has it any use? &#8230; <a href="https://financial-hacker.com/petra-on-programming-the-compare-price-momentum-oscillator/" class="more-link">Continue reading<span class="screen-reader-text"> "Petra on Programming: The Compare Price Momentum Oscillator"</span></a>]]></description>
										<content:encoded><![CDATA[<p><em>Vitali Apirine, inventor of the <a href="https://financial-hacker.com/petra-on-programming-the-smoothed-obv/">OBVM indicator</a>, presented another new tool for believers in technical analysis. His new Compare Price Momentum Oscillator (<strong>CPMO</strong><span style="font-size: inherit;">), described in the Stocks &amp; Commodities August 2020 issue, is based on the Price Momentum Oscillator (<strong>PMO</strong>) by Carl Swenlin. Yet another indicator with an impressive name. But has it any use?</span></em><span id="more-3530"></span></p>
<p><span style="font-size: inherit;">The PMO is the EMA of the EMA of the 1-day rate-of-change (ROC) of a stock or index price, multiplied with 10. Since his inventor Swenlin used a nonstandard EMA formula, the two EMA periods, supposed to be 35 and 20, are in fact 34 and 19. I also am not sure why he multiplied the result with 10 &#8211; but who am I to doubt? Once an indicator is established, we must stick with its formula, no matter if it resulted from a typo, from not knowing the EMA formula, or from whatever else. </span></p>
<p>The PMO code in C:</p>
<pre class="prettyprint">var PMO(vars Data) { return 10*EMA(EMA(ROC(Data,1),34),19); }</pre>
<p>(If you know Zorro indicators and wonder why it&#8217;s not <code>EMA(series(EMA(series(ROC(...</code> &#8211; both is possible, but since Zorro 2.28 the EMA function also accepts single values instead of series.)</p>
<p>Apirine&#8217;s CPMO is no new indicator, but a comparison of two index PMOs in hope of deriving useful information from their divergences or crossing points. The author gave several examples in his magazine article. We&#8217;re replicating one of them, the PMOs of the Consumer Discretionary Select Sector (IXY) and the Consumer Staples Select Sector (IXR) compared with the trend of the S&amp;P 500 index (SPX). Below is the code. It retrieves the historical data from Stooq and Yahoo:</p>
<pre class="prettyprint">function run()
{
  BarPeriod = 1440;
  assetAdd("SPX","STOOQ:^SPX");
  asset("SPX");
  assetAdd("IXY","YAHOO:IXY");
  asset("IXY");
  vars PricesIXY = series(priceClose());
  assetAdd("IXR","YAHOO:IXR");
  asset("IXR");
  vars PricesIXR = series(priceClose());

  plot("IXY",PMO(PricesIXY),NEW|LINE,GREEN);
  plot("IXR",PMO(PricesIXR),LINE,RED);
}</pre>
<p>The script produces this chart:</p>
<p><img decoding="async" src="https://financial-hacker.com/wp-content/uploads/2020/07/072420_1223_PetraonProg1.png" alt="" /></p>
<p>According to the author, the IXR-IXY PMO crossings identify changes in investor sentiment and therefore indicate upcoming SPX trend. Indeed they do in the selected chart, although with some delay and only three out of five times. So it&#8217;s hard to judge the CPMO&#8217;s usefulness in that context. But as the author says: <em>CPMO […] should be used in conjunction with other indicators like moving averages, chart patterns, or other forms of technical analysis.</em></p>
<p>Add enough other indicators, and you will succeed. Maybe. For your own experiments, the PMO indicator and script can be downloaded from the 2020 script repository.</p>

]]></content:encoded>
					
					<wfw:commentRss>https://financial-hacker.com/petra-on-programming-the-compare-price-momentum-oscillator/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Petra on Programming: Truncated Indicators</title>
		<link>https://financial-hacker.com/petra-on-programming-truncated-indicators/</link>
					<comments>https://financial-hacker.com/petra-on-programming-truncated-indicators/#comments</comments>
		
		<dc:creator><![CDATA[Petra Volkova]]></dc:creator>
		<pubDate>Sun, 21 Jun 2020 10:09:11 +0000</pubDate>
				<category><![CDATA[Indicators]]></category>
		<category><![CDATA[No Math]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Bandpass filter]]></category>
		<category><![CDATA[Ehlers]]></category>
		<guid isPermaLink="false">https://financial-hacker.com/?p=3503</guid>

					<description><![CDATA[Cumulative indicators, such as the EMA or the MACD, are affected by a theoretically infinite history of candles. In finite backtests, these indicators return slightly different results depending on the test period. This effect is often assumed negligible. But John Ehlers demonstrated in his July S&#38;C article that it is not so. At least not &#8230; <a href="https://financial-hacker.com/petra-on-programming-truncated-indicators/" class="more-link">Continue reading<span class="screen-reader-text"> "Petra on Programming: Truncated Indicators"</span></a>]]></description>
										<content:encoded><![CDATA[<p><em>Cumulative indicators, such as the EMA or the MACD, are affected by a theoretically infinite history of candles. In finite backtests, these indicators return slightly different results depending on the test period. This effect is often assumed negligible. But <strong>John Ehlers</strong> demonstrated in his July S&amp;C article that it is not so. At least not for some indicators, such as a narrow bandpass filter. We have to truncate the indicator&#8217;s &#8216;internal history&#8217; for getting consistent results. How do we do that in C?</em><span id="more-3503"></span></p>
<p>Bandpass filters are normally used for detecting cycles in price curves. But they do not work well with steep edges in the curve. Sudden price jumps cause a narrow-band filter to &#8216;ring like a bell&#8217; and generate artificial cycles that can cause false triggers. As a solution, Ehlers proposed to truncate the candle history of the filter. Limiting the history to 10 bars effectively dampened the filter output and produced a better representation of the cycles in the price curve.</p>
<p>For limiting the history of a cumulative indicator, we&#8217;re not using Ehler&#8217;s code here, but write a general &#8216;truncate&#8217; function that works for any indicator:</p>
<pre class="prettyprint">var indicator(vars Data,int Period,var Param);

var truncate(function Indicator,vars Data,int Period,var Param)
{
 indicator = Indicator;
 var *Trunc = zalloc(UnstablePeriod*sizeof(var));
 var Ret;
 int i;
 for(i = UnstablePeriod-1; i &gt;= 0; i--) {
   SeriesBuffer = Trunc;
   Ret = indicator(Data+i,Period,Param);
   shift(Trunc,0,UnstablePeriod);
 }
 return Ret;
}
</pre>
<p>This function accesses the internal data series of the cumulative indicator which is passed as the first argument. The <strong>SeriesBuffer</strong> variable replaces that series with an external array that&#8217;s temporarily allocated on the C heap with the <strong>zalloc</strong> function. <strong>UnstablePeriod</strong> is a global variable already used by Zorro for limiting the history range of traditional indicators, such as EMA or MACD. The <strong>truncate</strong> function returns the value of the truncated indicator.</p>
<p>The following code shows how the <strong>truncate</strong> function is used with our narrow bandpass filter:</p>
<pre class="prettyprint">function run()
{
 BarPeriod = 1440;
 StartDate = 20181101;
 assetAdd("SPY","STOOQ:SPY.US"); // load price history from Stooq
 asset("SPY");
 UnstablePeriod = 10;
 vars Prices = series(priceClose());
 var PB = BandPass(Prices, 20, 0.1);
 var Trunc = truncate(BandPass, Prices, 20, 0.1);
 plot("Bandpass",BP,NEW|LINE,RED);
 plot("Truncated",Trunc,LINE,BLUE);
}
</pre>
<p>Applied to SPY:</p>
<p><img decoding="async" src="https://financial-hacker.com/wp-content/uploads/2020/06/062120_0923_PetraonProg1.png" alt="" /></p>
<p>The chart confirms Ehler&#8217;s observation that the truncated narrow bandpass (blue line) represents cycles better than the original bandpass (red line). For comparison I&#8217;ve added a medium-wide bandpass filter as it&#8217;s normally used in trading systems (green line). This filter doesn&#8217;t &#8216;ring&#8217; either, truncated or not. This makes me wonder: What is the better choice for detecting cycles, a truncated narrow bandpass or simply a non-truncated wide bandpass?</p>
<p>For finding out, we feed the three bandpass variants with a sine chirp and compare their responses. The resulting charts:</p>
<p><img decoding="async" src="https://financial-hacker.com/wp-content/uploads/2020/06/062120_0923_PetraonProg2.png" alt="" /></p>
<p>The top chart is the chirp, a sine wave with a period rising from 5 to 60 cycles. The charts below show the chirp responses of the original narrow bandpass, the truncated narrow bandpass, and the wide bandpass. And here we can see that truncation produced strange artifacts: the bandpass got a wider bandwidth, some wiggles at the low cycles, and a shifted center frequency. A nontruncated filter with an already wider bandwidth seems here the clearly better solution.</p>
<p>I think you should not truncate a filter to just 10 bars. The <strong>ta-lib</strong> used by Zorro truncates indicators to 40 bars by default, and affects only classical indicators such as EMA. The advantage of proper truncating is that the indicator output does not depend on the previous history and lookback period of the trading system. A disadvantage is speed: truncating makes indicators much slower because they run in a loop. Not very relevant for normal trading systems, but for HFT systems.</p>
<p>The <strong>truncate</strong> function and the test scripts can be downloaded from the 2020 script repository. Zorro 2.28 or above is required.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://financial-hacker.com/petra-on-programming-truncated-indicators/feed/</wfw:commentRss>
			<slash:comments>9</slash:comments>
		
		
			</item>
		<item>
		<title>Petra on Programming: The Correlation Cycle Indicator</title>
		<link>https://financial-hacker.com/petra-on-programming-the-correlation-cycle-indicator/</link>
					<comments>https://financial-hacker.com/petra-on-programming-the-correlation-cycle-indicator/#comments</comments>
		
		<dc:creator><![CDATA[Petra Volkova]]></dc:creator>
		<pubDate>Tue, 02 Jun 2020 12:32:32 +0000</pubDate>
				<category><![CDATA[Indicators]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Corona drop]]></category>
		<category><![CDATA[Correlation cycle]]></category>
		<guid isPermaLink="false">https://financial-hacker.com/?p=3447</guid>

					<description><![CDATA[The previous article dealt with indicators based on correlation with a trend line. This time we&#8217;ll look into another correlation-based indicator by John Ehlers. The new Correlation Cycle indicator (CCY) measures the price curve correlation with a sine wave. This works surprisingly well &#8211; not for generating trade signals, but for a different purpose. Ehlers &#8230; <a href="https://financial-hacker.com/petra-on-programming-the-correlation-cycle-indicator/" class="more-link">Continue reading<span class="screen-reader-text"> "Petra on Programming: The Correlation Cycle Indicator"</span></a>]]></description>
										<content:encoded><![CDATA[
<p><em>The previous article dealt with indicators based on correlation with a trend line. This time we&#8217;ll look into another correlation-based indicator by <strong>John Ehlers</strong>. The new Correlation Cycle indicator (CCY) measures the price curve correlation with a sine wave. This works surprisingly well &#8211; not for generating trade signals, but for a different purpose.</em></p>
<p><span id="more-3447"></span></p>
<p>Ehlers published the indicator together with TradeStation code in the recent S&amp;C magazine. Since the C language supports function pointers, we can code it in a shorter and more elegant way:</p>
<pre class="prettyprint">var correlY(var Phase); // function pointer
var cosFunc(var Phase) { return cos(2*PI*Phase); }
var sinFunc(var Phase) { return -sin(2*PI*Phase); }

var correl(vars Data, int Length, function Func)
{
   correlY = Func; 
   var Sx = 0, Sy = 0, Sxx = 0, Sxy = 0, Syy = 0;
   int count;
   for(count = 0; count &lt; Length; count++) {
      var X = Data[count];
      var Y = correlY((var)count/Length);
      Sx += X; Sy += Y;
      Sxx += X*X; Sxy += X*Y; Syy += Y*Y;
   }
   if(Length*Sxx-Sx*Sx &gt; 0 &amp;&amp; Length*Syy-Sy*Sy &gt; 0)
      return (Length*Sxy-Sx*Sy)/sqrt((Length*Sxx-Sx*Sx)*(Length*Syy-Sy*Sy));
   else return 0;
}

var CCY(vars Data, int Length) { return correl(Data,Length,cosFunc); }<br />var CCYROC(vars Data, int Length) { return correl(Data,Length,sinFunc); }</pre>
<p>The <strong>correl</strong> function measures the correlation of the Data series with an arbitrary curve given by the <strong>Func</strong> function. This allows us to create all sorts of correlation indicators by just using a different <strong>Func</strong>. For example, it reduces Ehlers&#8217; <a href="https://financial-hacker.com/petra-on-programming-a-unique-trend-indicator/">Correlation Trend Indicator</a> from the previous article to 2 lines:</p>
<pre class="prettyprint">var trendFunc(var Phase) { return -Phase; }

var CTI(vars Data,int Length) { return correl(Data,Length,trendFunc); }
 </pre>
<p>The empty <strong>correlY</strong> function pointer in the code above serves as a template for <strong>Func</strong>, and is used for calling it inside the <strong>correl</strong> function. For the CTI it&#8217;s simply a rising slope (negative because series are in reverse order), for the CCY it&#8217;s the standard cosine function.</p>
<p>At first let&#8217;s see how the CCY indicator behaves when applied to a sine wave. We&#8217;re using Zorro&#8217;s wave generator to produce a sine chirp with a rising cycle length from 15 up to 30 bars, which is 25% below and 50% above the used CCY period of 20 bars. The code:</p>
<pre class="prettyprint">function run()<br />{<br />   MaxBars = 300;<br />   LookBack = 40;<br />   asset(""); // dummy asset<br />   ColorUp = ColorDn = 0; // don't plot a price curve<br />   <br />   vars Chirp = series(genSine(15,30));<br />   plot("Chirp",2*Chirp[0]-1,LINE,BLUE);<br />   plot("CCY",CCY(Chirp,20),LINE,RED);<br />}
 </pre>
<p>And the result:</p>
<p><a href="https://financial-hacker.com/wp-content/uploads/2020/06/CCY_Chirp.png"><img decoding="async" class="alignnone size-full wp-image-3467" src="https://financial-hacker.com/wp-content/uploads/2020/06/CCY_Chirp.png" alt="" width="701" height="362" srcset="https://financial-hacker.com/wp-content/uploads/2020/06/CCY_Chirp.png 701w, https://financial-hacker.com/wp-content/uploads/2020/06/CCY_Chirp-300x155.png 300w" sizes="(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px" /></a>This confirms Ehlers&#8217; stress test. A shorter period results in a phase lag, a longer period in a phase lead. We&#8217;re now going to apply the indicator to real-world price curves. This code displays the CCY and its rate of change (CCYROC) in a SPY chart:</p>
<pre class="prettyprint">function run()<br />{<br />   BarPeriod = 1440;
   LookBack = 40;
   StartDate = 20190101;

   assetAdd("SPY","STOOQ:SPY.US"); // load price history from Stooq
   asset("SPY");

   vars Prices = series(priceClose());
   plot("CCY(14)",CCY(Prices,14),NEW|LINE,RED);
   plot("ROC(14)",CCYROC(Prices,14),LINE,GREEN);
 }</pre>
<p><a href="https://financial-hacker.com/wp-content/uploads/2020/06/CCY_ROC.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-3468" src="https://financial-hacker.com/wp-content/uploads/2020/06/CCY_ROC.png" alt="" width="701" height="365" srcset="https://financial-hacker.com/wp-content/uploads/2020/06/CCY_ROC.png 701w, https://financial-hacker.com/wp-content/uploads/2020/06/CCY_ROC-300x156.png 300w" sizes="auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px" /></a></p>
<p>What&#8217;s the use of the Correlation Cycle indicator in a trading system? The chart might hint that its peaks or valleys could be used for trade signals, but you can save the time of testing it: I did already. The CCY is no good for trade signals. But Ehlers had another idea. The phase angle of the CCY and CCYROC reflects the market state. It returns 1 for a rising trend, -1 for a falling trend, and 0 for cycle regime. Here&#8217;s the code of Ehlers CCY market state indicator:</p>
<pre class="prettyprint">var CCYState(vars Data,int Length,var Threshold)<br />{<br />   vars Angles = series(0,2);<br />   var Real = correl(Data,Length,cosFunc);<br />   var Imag = correl(Data,Length,sinFunc);<br />// compute the angle as an arctangent function and resolve ambiguity<br />   if(Imag != 0) Angles[0] = 90 + 180/PI*atan(Real/Imag);<br />   if(Imag &gt; 0) Angles[0] -= 180;<br />// do not allow the rate change of angle to go negative<br />   if(Angles[1]-Angles[0] &lt; 270 &amp;&amp; Angles[0] &lt; Angles[1])<br />      Angles[0] = Angles[1];<br />   //return Angles[0];<br />// compute market state<br />   if(abs(Angles[0]-Angles[1]) &lt; Threshold)<br />      return ifelse(Angles[0] &lt; 0,-1,1);<br />   else return 0;<br />}</pre>
<p>Applied to SPY:</p>
<p><a href="https://financial-hacker.com/wp-content/uploads/2020/06/CCY_State.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-3469" src="https://financial-hacker.com/wp-content/uploads/2020/06/CCY_State.png" alt="" width="701" height="365" srcset="https://financial-hacker.com/wp-content/uploads/2020/06/CCY_State.png 701w, https://financial-hacker.com/wp-content/uploads/2020/06/CCY_State-300x156.png 300w" sizes="auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px" /></a></p>
<p>At first glance, trends and cycles seem to be rather well and timely detected. But how useful is the indicator in a real trading system?</p>
<p>For finding out, we&#8217;ll compare the performance with and without market state detection of a simple trend follower, as in the first Zorro workshop. It uses a lowpass filter for detecting trend reversals. The only parameter is the cutoff period of the low pass filter. This parameter is walk forward optimized, so the system does depend on any choosen parameter value. The trend follower without market state detection:</p>
<pre class="prettyprint">function run() 
{
   set(PARAMETERS);
   BarPeriod = 1440;
   LookBack = 40;
   NumYears = 8;

   assetAdd("SPY","STOOQ:SPY.US"); // load price history from Stooq
   asset("SPY");
   
   NumWFOCycles = 4;
   int Cutoff = optimize(10,5,30,5);

   vars Prices = series(priceClose());
   vars Signals = series(LowPass(Prices,Cutoff));
   if(valley(Signals))
      enterLong();
   else if(peak(Signals))
      enterShort();
}</pre>
<p>The system enters a long position on any valley of the lowpass filtered price curve, and a short position on any peak. The resulting equity curve:</p>
<p><a href="https://financial-hacker.com/wp-content/uploads/2020/06/CCY_TradeWithout.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-3470" src="https://financial-hacker.com/wp-content/uploads/2020/06/CCY_TradeWithout.png" alt="" width="701" height="362" srcset="https://financial-hacker.com/wp-content/uploads/2020/06/CCY_TradeWithout.png 701w, https://financial-hacker.com/wp-content/uploads/2020/06/CCY_TradeWithout-300x155.png 300w" sizes="auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px" /></a></p>
<p>We can see that the simple SPY trend follower is not very good. Yes, it&#8217;s profitable, but the main profit came from some lucky trades at the corona drop. In the years before the system had long flat periods. Let&#8217;s see if the CCYState indicator can help. Its two parameters, period and threshold, are also walk forward optimized. The new script:</p>
<pre class="prettyprint">function run() 
{
   set(PARAMETERS);
   BarPeriod = 1440;
   LookBack = 40;
   NumYears = 8;

   assetAdd("SPY","STOOQ:SPY.US"); // load price history from Stooq
   asset("SPY");
   
   NumWFOCycles = 4;
   int Cutoff = optimize(10,5,30,5);
   int Period = optimize(14,10,25,1);
   var Threshold = optimize(9,5,15,1);

   vars Prices = series(priceClose());
   var State = CCYState(Prices,Period,Threshold);
   plot("State",State*0.9,NEW|LINE,BLUE);
   vars Signals = series(LowPass(Prices,Cutoff));
   
   if(State != 0) {
      if(valley(Signals))
         enterLong();
      else if(peak(Signals))
         enterShort();
   }
   else {
      exitLong(); 
      exitShort();
   }
}</pre>
<p>The new system trades only when the market state is 1 or -1, indicating trend regime. It goes out of the market when the market state is 0. We can see that this improves the equity curve remarkably:</p>
<p><a href="https://financial-hacker.com/wp-content/uploads/2020/06/CCY_TradeWith.png"><img loading="lazy" decoding="async" class="alignnone size-full wp-image-3471" src="https://financial-hacker.com/wp-content/uploads/2020/06/CCY_TradeWith.png" alt="" width="701" height="365" srcset="https://financial-hacker.com/wp-content/uploads/2020/06/CCY_TradeWith.png 701w, https://financial-hacker.com/wp-content/uploads/2020/06/CCY_TradeWith-300x156.png 300w" sizes="auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px" /></a></p>
<p>I think most people would prefer this system to the previous one, even though it stayed out of the market at the corona drop. Ehlers&#8217; market state indicator did a good job.</p>
<h3>Reference</h3>
<p>John Ehlers, Correlation Cycle Indicator, Stocks&amp;Commodities 6/2020</p>
<p>The indicators and trade systems are available in the Scripts 2020 repository.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://financial-hacker.com/petra-on-programming-the-correlation-cycle-indicator/feed/</wfw:commentRss>
			<slash:comments>25</slash:comments>
		
		
			</item>
	</channel>
</rss>
