<?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>Financial Blog &#187; multicharts</title>
	<atom:link href="https://fx1.net/blog/tag/multicharts/feed/" rel="self" type="application/rss+xml" />
	<link>https://fx1.net/blog</link>
	<description>Forex, Futures, Programming</description>
	<lastBuildDate>Fri, 06 Mar 2015 16:13:23 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.1</generator>
	<item>
		<title>Tradestation´s slow FileAppend</title>
		<link>https://fx1.net/blog/tradestations-slow-fileappend/</link>
		<comments>https://fx1.net/blog/tradestations-slow-fileappend/#comments</comments>
		<pubDate>Fri, 02 Jan 2015 15:41:06 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[Easylanguage]]></category>
		<category><![CDATA[append]]></category>
		<category><![CDATA[easylanguage]]></category>
		<category><![CDATA[fileappend]]></category>
		<category><![CDATA[multicharts]]></category>
		<category><![CDATA[tradestation]]></category>

		<guid isPermaLink="false">https://fx1.net/blog/?p=2009</guid>
		<description><![CDATA[Tradestation and Multicharts Fileappend command is too slow for many operations. Here i would like to introduce a solution Compatibility This library is not dedicated for Tradestation. It will work [&#8230;]]]></description>
				<content:encoded><![CDATA[<h3>Tradestation and Multicharts Fileappend command is too slow for many operations. Here i would like to introduce a solution</h3>
<h2  id=underline>Compatibility</h2>
<p>This library is not dedicated for Tradestation. It will work with every other platform such as Multicharts, Ninjatrader, C#. Our demonstration here is just for demo.</p>
<h2  id=underline>Details</h2>
<p>Lets imagine you want to export OHLC Data as CSV to be able to analyse from an external tool. The problem is that <a href='http://help.tradestation.com/08_08/elword/word/fileappend_reserved_word_.htm'>Fileappend</a> will be very slow operating, this is probably because Tradestation has only single command (its easy to handle) to Append and it probably does open and close by every single line and this requires time.</p>
<p>If we wanted export all Bar OHLC Data as external .csv file we need a code like seen:</p>
<pre class="brush: php; title: ; notranslate">
// code snipplet
OHLC=&quot;ohlc=O=&quot;+Numtostr(o,6)+&quot;;&quot;
		+&quot;H=&quot;+Numtostr(h,6)+&quot;;&quot;
		+&quot;L=&quot;+Numtostr(l,6)+&quot;;&quot;
		+&quot;C=&quot;+Numtostr(c,6)+&quot;;&quot;
		+&quot;DATE=&quot;+Numtostr(Date,0)+&quot;;&quot;
		+&quot;TIME=&quot;+Numtostr(TIME,0)+&quot;;&quot;		
		+&quot;VOLUME=&quot;+Numtostr(Volume,1)+&quot;;&quot;+Newline;

Fileappend(FN,OHLC);
</pre>
</p>
<p>
Exporting 1 Year of M1 Data contains around 726000 Bars in Tradestation (EURUSD), to export all these bars <a href='http://help.tradestation.com/08_08/elword/word/fileappend_reserved_word_.htm'>Fileappend()</a> needs 65 seconds to complete the operation (at least on my very fast computer with Flash/SSD Harddisk). If you need to export 10 years of data it would require over 12 minutes to complete, not very efficient.
</p>
<h2  id=underline>Solution Approach</h2>
<p>I have developed a library called <a href='/blog/files/fast_appender.dll'>fast_appender.dll</a>, this library is allowed to accept lines to append, it does not open, close by every single append operation. It opens the file and keeps appending until you say to close.</p>
<p>
The import is like seen:</p>
<pre class="brush: php; title: ; notranslate">
external: &quot;fast_appender.dll&quot;, string, &quot;faVersionA&quot;;  
external: &quot;fast_appender.dll&quot;, int, &quot;faInitA&quot;,LPSTR,int; 
external: &quot;fast_appender.dll&quot;, int, &quot;faAppendA&quot;,int,LPSTR; 
external: &quot;fast_appender.dll&quot;, int, &quot;faClose&quot;,int;
</pre>
</p>
<p>
I have made tests for both variants to append, with fileAppend native command of Easylanguage and FastAppender Library:<br />
<a href="https://fx1.net/blog/wp-content/uploads/2015/01/si.png"><img src="https://fx1.net/blog/wp-content/uploads/2015/01/si-1024x388.png" alt="si" width="1024" height="388" class="alignnone size-large wp-image-2045" /></a></p>
<p>
As you see FastAppender is over 5 times faster in appending to text files. 5 times speed improvement is not something you should underestimate, there is huge difference between 5 seconds and 25 seconds per chart and symbol and exported file.
</p>
<h2  id=underline>FastAppender</h2>
<h4>int faInitA(string Filename,bool Append)</h4>
<p>This is first function you need to call and call it only once (once begin&#8230;.end block) at start. First parameter is name of file, second parameter accepts either 0 (false) or 1 (true), if you call it with 1, it will Append to existing file, if you call it with 0, it will Overwrite file and start Appending from first byte. This function returns a handle as int, you need to remember this handle, it will be reused in other commands</p>
<h4>int faAppendA(int Handle,string LineToAppend)</h4>
<p>This function will append LineToAppend to previously opened File, the Handle is taken from faInitA.</p>
<h4>int faClose(int Handle)</h4>
<p>This closes the handle, you will not need this function in Multicharts / Tradestation, you can need this function if you need to call from other platforms. Once you close the handle, you also close the file and you cannot Append anymore. If you are sure you will not append anymore, then you can close it.</p>
<h4>string faVersionA()</h4>
<p>Returns Version information of library.</p>
<h2  id=underline>Demonstration</h2>
<p>This example exports OHLC Data of all bars as .csv file</p>
<pre class="brush: php; title: ; notranslate">
Inputs: ExportDirectory(&quot;c:\DATA1\&quot;);
Vars: OHLC(&quot;&quot;),intrabarpersist FN(&quot;&quot;),BInterval(0),intrabarpersist fa(0);

// Import fast_appender
external: &quot;fast_appender.dll&quot;, string, &quot;faVersionA&quot;;  
external: &quot;fast_appender.dll&quot;, int, &quot;faInitA&quot;,LPSTR,int; 
external: &quot;fast_appender.dll&quot;, int, &quot;faAppendA&quot;,int,LPSTR; 
external: &quot;fast_appender.dll&quot;, int, &quot;faClose&quot;,int;

Once Begin
	if BarType=1 then BInterval=BarInterVal;
	if BarType=2 then BInterval=24*60; 
	if BarType=3 then BInterval=24*60*7;
	if BarType=4 then BInterval=24*60*30;
	If BarType=12 then BInterval=(Range/1 Point);	
	FN=ExportDirectory+getsymbolname+&quot;-&quot;+Numtostr(BInterval,0)+&quot;.csv&quot;;	
	// open File Handle and remember Handle in fa variable
	fa=faInitA(FN,1);  
end;

OHLC=&quot;ohlc=O=&quot;+Numtostr(o,6)+&quot;;&quot;
		+&quot;H=&quot;+Numtostr(h,6)+&quot;;&quot;
		+&quot;L=&quot;+Numtostr(l,6)+&quot;;&quot;
		+&quot;C=&quot;+Numtostr(c,6)+&quot;;&quot;
		+&quot;DATE=&quot;+Numtostr(Date,0)+&quot;;&quot;
		+&quot;TIME=&quot;+Numtostr(TIME,0)+&quot;;&quot;		
		+&quot;VOLUME=&quot;+Numtostr(Volume,1)+&quot;;&quot;+Newline;
 
if (fa&gt;0) then faAppendA(fa,OHLC);
</pre>
<h2>Download</h2>
<p>You can download it <a href='/blog/files/fast_appender.dll'>here</a></p>
<h2 id=underline>Final Words</h2>
<p>FastAppender library is working with threads, you submit the data which needs to be appended and it will do the actual work in background to ensure speed. This library is over 5x faster than native command. It replaces native Fileappend command completely, you can use it for all your Append, Export operations.Have fun using it</p>
]]></content:encoded>
			<wfw:commentRss>https://fx1.net/blog/tradestations-slow-fileappend/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
