<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Forex Software — Array out of range in 'Portfolio Expert EURUSD H1.mq4' (592,16)]]></title>
	<link rel="self" href="https://forexsb.com/forum/feed/atom/topic/8189" />
	<updated>2021-03-18T12:03:50Z</updated>
	<generator>PunBB</generator>
	<id>https://forexsb.com/forum/topic/8189/array-out-of-range-in-portfolio-expert-eurusd-h1mq4-59216/</id>
		<entry>
			<title type="html"><![CDATA[Re: Array out of range in 'Portfolio Expert EURUSD H1.mq4' (592,16)]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/64378/#p64378" />
			<content type="html"><![CDATA[<p>all right</p>]]></content>
			<author>
				<name><![CDATA[bobstar]]></name>
				<uri>https://forexsb.com/forum/user/12160/</uri>
			</author>
			<updated>2021-03-18T12:03:50Z</updated>
			<id>https://forexsb.com/forum/post/64378/#p64378</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Array out of range in 'Portfolio Expert EURUSD H1.mq4' (592,16)]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/64377/#p64377" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p>Please reload EA Studio with Ctrl + F5 and try.</p></blockquote></div><p>But you are right. There are many users that don&#039;t reload EA Studio for weeks. So I changed the MQL to have requiredBars = 100 by default.</p>]]></content>
			<author>
				<name><![CDATA[Popov]]></name>
				<uri>https://forexsb.com/forum/user/2/</uri>
			</author>
			<updated>2021-03-18T11:46:49Z</updated>
			<id>https://forexsb.com/forum/post/64377/#p64377</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Array out of range in 'Portfolio Expert EURUSD H1.mq4' (592,16)]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/64375/#p64375" />
			<content type="html"><![CDATA[<p>@Popov, you forgot to define the macro REQUIRED_BARS, in fact it doesn&#039;t compile because of this error (both on MQL for single EA and Portfolio)</p>]]></content>
			<author>
				<name><![CDATA[bobstar]]></name>
				<uri>https://forexsb.com/forum/user/12160/</uri>
			</author>
			<updated>2021-03-18T11:07:34Z</updated>
			<id>https://forexsb.com/forum/post/64375/#p64375</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Array out of range in 'Portfolio Expert EURUSD H1.mq4' (592,16)]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/64368/#p64368" />
			<content type="html"><![CDATA[<p>Done.</p><p>Please reload EA Studio with Ctrl + F5 and try.</p>]]></content>
			<author>
				<name><![CDATA[Popov]]></name>
				<uri>https://forexsb.com/forum/user/2/</uri>
			</author>
			<updated>2021-03-17T23:16:37Z</updated>
			<id>https://forexsb.com/forum/post/64368/#p64368</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Array out of range in 'Portfolio Expert EURUSD H1.mq4' (592,16)]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/64367/#p64367" />
			<content type="html"><![CDATA[<p>yes, it&#039;s a solution</p>]]></content>
			<author>
				<name><![CDATA[bobstar]]></name>
				<uri>https://forexsb.com/forum/user/12160/</uri>
			</author>
			<updated>2021-03-17T22:33:38Z</updated>
			<id>https://forexsb.com/forum/post/64367/#p64367</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Array out of range in 'Portfolio Expert EURUSD H1.mq4' (592,16)]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/64366/#p64366" />
			<content type="html"><![CDATA[<p>A better solution would be to skip all the calculations until we have enough bars.</p><p>Something like:</p><div class="codebox"><pre><code>const int requiredBars = 100;

void OnTick()
{
    if ( ArraySize(Time) &lt; requiredBars ) return;

    ...
}</code></pre></div><p>requiredBars can be set from EA Studio on export depending on the strategy.</p>]]></content>
			<author>
				<name><![CDATA[Popov]]></name>
				<uri>https://forexsb.com/forum/user/2/</uri>
			</author>
			<updated>2021-03-17T22:05:17Z</updated>
			<id>https://forexsb.com/forum/post/64366/#p64366</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Array out of range in 'Portfolio Expert EURUSD H1.mq4' (592,16)]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/64365/#p64365" />
			<content type="html"><![CDATA[<p>The purpose of importing data into MT4 is to make high quality backtests from tick by tick data; MT4 by default uses the global history data that are not good for tick by tick backtests, instead Tickstory or Tickdata Suite are optimal choices for professional backtest and these data are taken from Dukascopy database (@Popov the same provider that you are using for Premium Data on EA Studio).</p><p>It&#039;s possible to overcome these &quot;Array out of range&quot; problems by starting the backtest 1 or 2 days later, but @Popov you know that &quot;Array out of range&quot; is not a problem from a backtest but from a source code and needs to be managed properly.</p><p>Like I told you, a possible solution is to put a simple condition before accessing to the actual array, like that:</p><p>datetime Time(int bar){<br />&nbsp; &nbsp; if(bar &gt;= ArraySize(Time)) return 0;<br />&nbsp; &nbsp; return Time[bar];<br />}</p><p>instead of</p><p>datetime Time(int bar){<br />&nbsp; &nbsp; return Time[bar];<br />}</p><p>Think about that, maybe for the next release.<br />Thank you @Popov</p>]]></content>
			<author>
				<name><![CDATA[bobstar]]></name>
				<uri>https://forexsb.com/forum/user/12160/</uri>
			</author>
			<updated>2021-03-17T21:13:40Z</updated>
			<id>https://forexsb.com/forum/post/64365/#p64365</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Array out of range in 'Portfolio Expert EURUSD H1.mq4' (592,16)]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/64364/#p64364" />
			<content type="html"><![CDATA[<p>In that case, the better solution is to set a starting date of the backtest. Let&#039;s say 2020-01-03.</p><p>What is the purpose of importing data in MetaTrader?</p><p>The backtest on third party data may not correspond to the following real trading.</p>]]></content>
			<author>
				<name><![CDATA[Popov]]></name>
				<uri>https://forexsb.com/forum/user/2/</uri>
			</author>
			<updated>2021-03-17T20:20:00Z</updated>
			<id>https://forexsb.com/forum/post/64364/#p64364</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Array out of range in 'Portfolio Expert EURUSD H1.mq4' (592,16)]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/64361/#p64361" />
			<content type="html"><![CDATA[<p>Yes, it&#039;s possible to start the backtest from the first bar (when you download data from Tickstory for example or other third-party providers), in this case when the backtest starts at the beginning of downloaded datas, it doesn&#039;t show any previous bar and therefore the size of these standard arrays (Time[], Open[], etc...) are limited to the actual bars.<br />With some strategies, that uses these values, this can happen.</p><p>@Popov here a screenshot where I made a Print of the value of the ArraySize of Time and it shows also the number of Bars on the chart (that of course are equal to ArraySize(Time).</p><p><span class="postimg"><img src="https://forexsb.com/forum/misc.php?action=pun_attachment&amp;item=4468" alt="PunBB bbcode test" /></span></p>]]></content>
			<author>
				<name><![CDATA[bobstar]]></name>
				<uri>https://forexsb.com/forum/user/12160/</uri>
			</author>
			<updated>2021-03-17T17:19:56Z</updated>
			<id>https://forexsb.com/forum/post/64361/#p64361</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Array out of range in 'Portfolio Expert EURUSD H1.mq4' (592,16)]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/64358/#p64358" />
			<content type="html"><![CDATA[<p>How you can start the backtest from the first bar?<br />Usually, MetaTrader starts from bar number 100.</p><p>Please check if you have any data. Print the size of the data arrays.<br />Is it possible to require more bars than you have?</p>]]></content>
			<author>
				<name><![CDATA[Popov]]></name>
				<uri>https://forexsb.com/forum/user/2/</uri>
			</author>
			<updated>2021-03-17T16:55:02Z</updated>
			<id>https://forexsb.com/forum/post/64358/#p64358</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Array out of range in 'Portfolio Expert EURUSD H1.mq4' (592,16)]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/64356/#p64356" />
			<content type="html"><![CDATA[<p>This bug can happen when you start the backtest at the exact beginning of a historical data, and for some strategies requires an index that go outside the array size (for these Time[], Open[], High[], Low[], Close[]).<br />I solved and fixed this bug by modyfing the code like that:</p><p>datetime Time(int bar){ if(bar &gt;= ArraySize(Time)) return 0; return Time[bar];}<br />double Open(int bar){&nbsp; &nbsp;if(bar &gt;= ArraySize(Open)) return 0; return Open[bar];}<br />double High(int bar){&nbsp; &nbsp; if(bar &gt;= ArraySize(High))&nbsp; return 0; return High[bar];}<br />double Low(int bar){&nbsp; &nbsp; &nbsp;if(bar &gt;= ArraySize(Low))&nbsp; &nbsp;return 0; return Low[bar];}<br />double Close(int bar){&nbsp; &nbsp;if(bar &gt;= ArraySize(Close)) return 0; return Close[bar];}</p><p>@Popov I thinnk you can modify this code in the current MQL template, in order to fix this bug with that solution.</p>]]></content>
			<author>
				<name><![CDATA[bobstar]]></name>
				<uri>https://forexsb.com/forum/user/12160/</uri>
			</author>
			<updated>2021-03-17T16:41:28Z</updated>
			<id>https://forexsb.com/forum/post/64356/#p64356</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Array out of range in 'Portfolio Expert EURUSD H1.mq4' (592,16)]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/59600/#p59600" />
			<content type="html"><![CDATA[<p>I tested the attached Portfolio Expert on &quot;every tick&quot; and found it working fine.</p><p><a href="https://image-holder.forexsb.com/store/portfolio-ea-tick-testing-found-ok.png"><span class="postimg"><img src="https://image-holder.forexsb.com/store/portfolio-ea-tick-testing-found-ok-thumb.png" alt="https://image-holder.forexsb.com/store/portfolio-ea-tick-testing-found-ok-thumb.png" /></span></a></p><p>It must be something of how MT generates the ticks. Generally, you don&#039;t need to use &quot;every tick&quot; in MT with EA Studio experts. Please check if you have similar results when you use the &quot;bar open&quot; or the &quot;control points&quot; methods with EA Studio.</p>]]></content>
			<author>
				<name><![CDATA[Popov]]></name>
				<uri>https://forexsb.com/forum/user/2/</uri>
			</author>
			<updated>2020-03-05T15:29:48Z</updated>
			<id>https://forexsb.com/forum/post/59600/#p59600</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Array out of range in 'Portfolio Expert EURUSD H1.mq4' (592,16)]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/59501/#p59501" />
			<content type="html"><![CDATA[<p>any idea about that?</p>]]></content>
			<author>
				<name><![CDATA[Roughey]]></name>
				<uri>https://forexsb.com/forum/user/10939/</uri>
			</author>
			<updated>2020-02-27T17:32:07Z</updated>
			<id>https://forexsb.com/forum/post/59501/#p59501</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Array out of range in 'Portfolio Expert EURUSD H1.mq4' (592,16)]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/59289/#p59289" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Popov wrote:</cite><blockquote><p>I tested an expert with Candle Color and it works fine. </p><p>Please upload your expert for further analysis. It can be another reason and we must find and fix it.</p></blockquote></div><p>Hi,</p><p>i have now checked a little. It must be something with Open Prices Only test and Tick data test.</p><p>When i use Tickdata test than i get the out of range error when i use open prices only it is working.</p><p>But why it is ? Can you check . Here the Ea.&nbsp; Use date from 02.01.2015 - 31.01.2020</p>]]></content>
			<author>
				<name><![CDATA[Roughey]]></name>
				<uri>https://forexsb.com/forum/user/10939/</uri>
			</author>
			<updated>2020-02-16T15:54:28Z</updated>
			<id>https://forexsb.com/forum/post/59289/#p59289</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Array out of range in 'Portfolio Expert EURUSD H1.mq4' (592,16)]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/59055/#p59055" />
			<content type="html"><![CDATA[<p>I tested an expert with Candle Color and it works fine. </p><p>Please upload your expert for further analysis. It can be another reason and we must find and fix it.</p>]]></content>
			<author>
				<name><![CDATA[Popov]]></name>
				<uri>https://forexsb.com/forum/user/2/</uri>
			</author>
			<updated>2020-01-31T05:44:55Z</updated>
			<id>https://forexsb.com/forum/post/59055/#p59055</id>
		</entry>
</feed>
