<?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>Cubesteak Central &#187; MT4 Includes</title>
	<atom:link href="http://www.cubesteak.net/category/mt4/mt4-library-function/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cubesteak.net</link>
	<description>Forex Trading with MetaTrader 4</description>
	<lastBuildDate>Thu, 16 Nov 2006 12:23:36 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>3 Fold Trading Hours Filter for EA</title>
		<link>http://www.cubesteak.net/2006/08/3-fold-trading-hours-filter-for-ea/</link>
		<comments>http://www.cubesteak.net/2006/08/3-fold-trading-hours-filter-for-ea/#comments</comments>
		<pubDate>Sat, 26 Aug 2006 04:46:31 +0000</pubDate>
		<dc:creator>cubesteak</dc:creator>
				<category><![CDATA[MT4 Includes]]></category>

		<guid isPermaLink="false">http://www.cubesteak.net/2006/08/3-fold-trading-hours-filter-for-ea/</guid>
		<description><![CDATA[In a previous post, I made available a small indicator that simply mentioned if you should be trading or not based on three different configurable timeframes.
In the process of changing the logic for use in an EA, I also improved on the previous indicator.  You can now use hours and minutes, not just hours [...]]]></description>
			<content:encoded><![CDATA[<p>In a <a title="3 Fold Trading Hours Indicator" href="http://www.cubesteak.net/2006/08/3-fold-trading-hours/">previous post</a>, I made available a small indicator that simply mentioned if you should be trading or not based on three different configurable timeframes.</p>
<p>In the process of changing the logic for use in an EA, I also improved on the previous indicator.  You can now use hours and minutes, not just hours for the configured time frames.</p>
<p>The file below is not a new indicator, but is intended to be included in an EA.  Its is the 3 Fold Trading Hours logic turned into a boolean function.  Simply wrap all your EA logic in the call to HourlyFilter();  It returns true when the time is within your specified hours, and false when it&#8217;s not.</p>
<p>Pseudo code for placement in the Start() function is:</p>
<p><code>if HourlyFilter()<br />
{<br />
PerformEALogic();<br />
}<br />
else return (0);</code></p>
<p>UPDATE: There was an error in the source, which has now been fixed.  Filter 3 was being checked twice, and Filter 2 was being ignored.  Sorry for any inconvenience.</p>
<p><img border="0" align="left" alt="MetaQuotes 4 Language File" title="MetaQuotes 4 Language File" src="http://www.cubesteak.net/images/MQ4.gif" /><a title="3FoldTradingFilterforEA.mq4" href="http://www.cubesteak.net/downloads/3FoldTradingFilterforEA.mq4"> 3FoldTradingFilterforEA.mq4</a><br />
<a title="3FoldTradingFilterforEA.zip" href="http://www.cubesteak.net/downloads/3FoldTradingFilterforEA.zip">3FoldTradingFilterforEA.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.cubesteak.net/2006/08/3-fold-trading-hours-filter-for-ea/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>More Array Functions for MT4</title>
		<link>http://www.cubesteak.net/2006/08/more-array-functions-for-mt4/</link>
		<comments>http://www.cubesteak.net/2006/08/more-array-functions-for-mt4/#comments</comments>
		<pubDate>Wed, 23 Aug 2006 08:59:43 +0000</pubDate>
		<dc:creator>cubesteak</dc:creator>
				<category><![CDATA[MT4 Includes]]></category>

		<guid isPermaLink="false">http://www.cubesteak.net/2006/08/more-array-functions-for-mt4/</guid>
		<description><![CDATA[One of the things that has bugged me, is the inability to search a multi-dimensional array in MT4.
So, I made a function to do so. In this case, we really want the function to give us two things:

If the value exists in the array&#8217;s second dimension
If it does exist, the actual coordinates of where

Ideally, you [...]]]></description>
			<content:encoded><![CDATA[<p>One of the things that has bugged me, is the inability to search a multi-dimensional array in MT4.</p>
<p>So, I made a function to do so. In this case, we really want the function to give us two things:</p>
<ol>
<li>If the value exists in the array&#8217;s second dimension</li>
<li>If it does exist, the actual coordinates of where</li>
</ol>
<p>Ideally, you could do this with as little &#8220;usage hassle&#8221; as possible. So, the function that I&#8217;ve written does the following:</p>
<ol>
<li>It uses a 2 bucket single-dimension array to hold the coordinates of our search value. This array should be declared prior to calling the search function. The search function updates the value of the array because the array is &#8220;passed by reference&#8221;.</li>
<li>The function itself of a boolean type, so a return of &#8220;true&#8221; means it was found, and &#8220;false&#8221; means it wasn&#8217;t.</li>
</ol>
<p>Here is the function spec:</p>
<p><code>SearchSecondDim (ReturnArray, ArrayToSearch, ValueToSearch, SearchDirection)</code></p>
<p><strong>Return Values</strong>:</p>
<p><em><strong>True or False</strong></em><br />
<em>With ReturnArray passed by reference so that after function is run:<br />
ReturnArray [0] = ArrayToSearch first dimension location<br />
ReturnArray [1] = ArrayToSearch second dimension location<br />
if ReturnArray [0] or ReturnArray [1] = -1 value was not found.</em></p>
<p>NOTE: ReturnArray[2] need to be declared prior to using this function!</p>
<p><strong>Example 1: </strong></p>
<p><code>double MySearchArray[10][5];<br />
ArrayInitialize(MySearchArray,0);<br />
MySearchArray [7][5] = 7;<br />
double foo[2];<br />
bool FoundIt = SearchSeconDim (foo,MySearchArray,7,MODE_ASCEND);</code></p>
<p>This will set foo[0]==7 and foo[1]==5. Also, FoundIt will be &#8220;true&#8221;.</p>
<p><strong>Example 2</strong>:</p>
<p><code>double MySearchArray[10][5];<br />
ArrayInitialize(MySearchArray,0);<br />
MySearchArray [7][5] = 7;<br />
double foo[2];<br />
bool FoundIt = SearchSeconDim (foo,MySearchArray,10,MODE_ASCEND);</code></p>
<p>This will set foo[0]==-1 and foo[1]==-1 since the value isn&#8217;t anywhere in the array&#8217;s second dimension. Also, FoundIt will be &#8220;false&#8221;.</p>
<p><strong><font size="+1">Some Extra Goodies</font></strong>!</p>
<p>Also included in this file, is the single dimension array <a title="SearchArray" href="http://www.cubesteak.net/2006/08/a-better-way-to-search-arrays-in-mt4/">search function</a> that I posted earlier (see that post for more details) and 2 simple array &#8220;printing&#8221; functions. These printing functions output to the &#8220;Experts&#8221; tab of MT4&#8217;s terminal window.</p>
<p><strong>Printing a 1 dimensional array:</strong></p>
<p><code>PrintSingleArray(double ArrayToPrint[])</code></p>
<p><strong>Return Values:</strong></p>
<p><em><strong>None / Void. </strong></em><br />
A single comma separated line is printed to the Experts output window.</p>
<p><strong>Printing a 2 dimensional array:</strong></p>
<p><code>PrintDblArray(double ArrayToPrint[][])</code></p>
<p><strong>Return Values:</strong></p>
<p><em><strong>None / Void. </strong></em><br />
Each comma separated &#8220;row&#8221; is printed on a new line in the Experts output window.</p>
<p>ENJOY!</p>
<p><img title="MetaQuotes 4 Language File" alt="MetaQuotes 4 Language File" src="http://www.cubesteak.net/images/MQ4.gif" align="left" border="0" /><a title="CSArrayFunctions.mq4" href="http://www.cubesteak.net/downloads/CSArrayFunctions.mq4"> CSArrayFunctions.mq4</a><br />
<a title="CSArrayFunctions.zip" href="http://www.cubesteak.net/downloads/CSArrayFunctions.zip">CSArrayFunctions.zip</a><a /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.cubesteak.net/2006/08/more-array-functions-for-mt4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A &#8220;Better&#8221; Way to Search Arrays in MT4</title>
		<link>http://www.cubesteak.net/2006/08/a-better-way-to-search-arrays-in-mt4/</link>
		<comments>http://www.cubesteak.net/2006/08/a-better-way-to-search-arrays-in-mt4/#comments</comments>
		<pubDate>Tue, 22 Aug 2006 00:00:02 +0000</pubDate>
		<dc:creator>cubesteak</dc:creator>
				<category><![CDATA[MT4 Includes]]></category>

		<guid isPermaLink="false">http://www.cubesteak.net/2006/08/a-better-way-to-search-arrays-in-mt4/</guid>
		<description><![CDATA[MT4 provides the function ArrayBSearch to search arrays. It seems a bit &#8220;non-standard&#8221; to me, in that according to the documentation, it &#8220;returns the index of the first occurrence of a value in the first dimension of array if possible, or the nearest one, if the occurrence is not found.&#8221;
It wasn&#8217;t readily apparent to me [...]]]></description>
			<content:encoded><![CDATA[<p>MT4 provides the function <a target="_blank" title="ArrayBSearch at MQL4.com" href="http://docs.mql4.com/array/ArrayBsearch">ArrayBSearch</a> to search arrays. It seems a bit &#8220;non-standard&#8221; to me, in that according to the documentation, it &#8220;returns the index of the first occurrence of a value in the first dimension of array if possible, or the nearest one, if the occurrence is not found.&#8221;</p>
<p>It wasn&#8217;t readily apparent to me what the heck that meant, so I did a little experimenting. I did the following:</p>
<p><code>double foo[10] = {1,2,3,4,5,6,7,8,9,10};<br />
ArraySort(foo);<br />
int index = ArrayBsearch(foo,4);<br />
Print ("found: "+index);<br />
index = ArrayBsearch(foo,11);<br />
Print ("not found: "+index);</code></p>
<p>And got:</p>
<p><code>found: 3<br />
not found: 9</code></p>
<p>And then did this:</p>
<p><code>double foo[10] = {1,2,3,4,5,6,7,8,9,10};<br />
ArraySort(foo);<br />
int index = ArrayBsearch(foo,4);<br />
Print ("found: "+index);<br />
index = ArrayBsearch(foo,-1);<br />
Print ("not found: "+index);</code></p>
<p>And got:</p>
<p><code>found: 3<br />
not found: 0</code></p>
<p>So, it seems that this means that ArrayBsearch returns either the first or the last index position if your number isn&#8217;t found in the array. To me, that&#8217;s kind of dumb, as it means you still have no idea if the first or last index position actually contains the item you are searching for! It could mean it found your value, or it could mean it DIDN&#8217;T find your value. Not really the sort of information I&#8217;m looking for in a &#8220;search&#8221; function.</p>
<p>If you do a Google search for &#8220;array bsearch&#8221;, you&#8217;ll find several examples of these kinds of searches. They pretty much boil down to the following:</p>
<blockquote><p>bsearch returns a pointer to an occurrence of key in the array pointed to by base. If key is not found, the function returns NULL.</p></blockquote>
<p>So, I created this little function as a more &#8220;sane&#8221; array search for MT4. Since we don&#8217;t have access to pointers, I just used a &#8220;-1&#8243; return instead. I hope you like it!</p>
<p><img border="0" align="left" alt="MetaQuotes 4 Language File" title="MetaQuotes 4 Language File" src="http://www.cubesteak.net/images/MQ4.gif" /><a title="ArraySearch.mq4" href="http://www.cubesteak.net/downloads/ArraySearch.mq4"> ArraySearch.mq4</a><br />
<a title="ArraySearch.zip" href="http://www.cubesteak.net/downloads/ArraySearch.zip">ArraySearch.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.cubesteak.net/2006/08/a-better-way-to-search-arrays-in-mt4/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
