<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Forex Software — Array out of range in 'Portfolio Expert EURUSD H1.mq4' (592,16)]]></title>
		<link>https://forexsb.com/forum/topic/8189/array-out-of-range-in-portfolio-expert-eurusd-h1mq4-59216/</link>
		<atom:link href="https://forexsb.com/forum/feed/rss/topic/8189" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Array out of range in 'Portfolio Expert EURUSD H1.mq4' (592,16).]]></description>
		<lastBuildDate>Thu, 18 Mar 2021 12:03:50 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Array out of range in 'Portfolio Expert EURUSD H1.mq4' (592,16)]]></title>
			<link>https://forexsb.com/forum/post/64378/#p64378</link>
			<description><![CDATA[<p>all right</p>]]></description>
			<author><![CDATA[null@example.com (bobstar)]]></author>
			<pubDate>Thu, 18 Mar 2021 12:03:50 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/64378/#p64378</guid>
		</item>
		<item>
			<title><![CDATA[Re: Array out of range in 'Portfolio Expert EURUSD H1.mq4' (592,16)]]></title>
			<link>https://forexsb.com/forum/post/64377/#p64377</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (Popov)]]></author>
			<pubDate>Thu, 18 Mar 2021 11:46:49 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/64377/#p64377</guid>
		</item>
		<item>
			<title><![CDATA[Re: Array out of range in 'Portfolio Expert EURUSD H1.mq4' (592,16)]]></title>
			<link>https://forexsb.com/forum/post/64375/#p64375</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (bobstar)]]></author>
			<pubDate>Thu, 18 Mar 2021 11:07:34 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/64375/#p64375</guid>
		</item>
		<item>
			<title><![CDATA[Re: Array out of range in 'Portfolio Expert EURUSD H1.mq4' (592,16)]]></title>
			<link>https://forexsb.com/forum/post/64368/#p64368</link>
			<description><![CDATA[<p>Done.</p><p>Please reload EA Studio with Ctrl + F5 and try.</p>]]></description>
			<author><![CDATA[null@example.com (Popov)]]></author>
			<pubDate>Wed, 17 Mar 2021 23:16:37 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/64368/#p64368</guid>
		</item>
		<item>
			<title><![CDATA[Re: Array out of range in 'Portfolio Expert EURUSD H1.mq4' (592,16)]]></title>
			<link>https://forexsb.com/forum/post/64367/#p64367</link>
			<description><![CDATA[<p>yes, it&#039;s a solution</p>]]></description>
			<author><![CDATA[null@example.com (bobstar)]]></author>
			<pubDate>Wed, 17 Mar 2021 22:33:38 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/64367/#p64367</guid>
		</item>
		<item>
			<title><![CDATA[Re: Array out of range in 'Portfolio Expert EURUSD H1.mq4' (592,16)]]></title>
			<link>https://forexsb.com/forum/post/64366/#p64366</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (Popov)]]></author>
			<pubDate>Wed, 17 Mar 2021 22:05:17 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/64366/#p64366</guid>
		</item>
		<item>
			<title><![CDATA[Re: Array out of range in 'Portfolio Expert EURUSD H1.mq4' (592,16)]]></title>
			<link>https://forexsb.com/forum/post/64365/#p64365</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (bobstar)]]></author>
			<pubDate>Wed, 17 Mar 2021 21:13:40 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/64365/#p64365</guid>
		</item>
		<item>
			<title><![CDATA[Re: Array out of range in 'Portfolio Expert EURUSD H1.mq4' (592,16)]]></title>
			<link>https://forexsb.com/forum/post/64364/#p64364</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (Popov)]]></author>
			<pubDate>Wed, 17 Mar 2021 20:20:00 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/64364/#p64364</guid>
		</item>
		<item>
			<title><![CDATA[Re: Array out of range in 'Portfolio Expert EURUSD H1.mq4' (592,16)]]></title>
			<link>https://forexsb.com/forum/post/64361/#p64361</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (bobstar)]]></author>
			<pubDate>Wed, 17 Mar 2021 17:19:56 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/64361/#p64361</guid>
		</item>
		<item>
			<title><![CDATA[Re: Array out of range in 'Portfolio Expert EURUSD H1.mq4' (592,16)]]></title>
			<link>https://forexsb.com/forum/post/64358/#p64358</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (Popov)]]></author>
			<pubDate>Wed, 17 Mar 2021 16:55:02 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/64358/#p64358</guid>
		</item>
		<item>
			<title><![CDATA[Re: Array out of range in 'Portfolio Expert EURUSD H1.mq4' (592,16)]]></title>
			<link>https://forexsb.com/forum/post/64356/#p64356</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (bobstar)]]></author>
			<pubDate>Wed, 17 Mar 2021 16:41:28 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/64356/#p64356</guid>
		</item>
		<item>
			<title><![CDATA[Re: Array out of range in 'Portfolio Expert EURUSD H1.mq4' (592,16)]]></title>
			<link>https://forexsb.com/forum/post/59600/#p59600</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (Popov)]]></author>
			<pubDate>Thu, 05 Mar 2020 15:29:48 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/59600/#p59600</guid>
		</item>
		<item>
			<title><![CDATA[Re: Array out of range in 'Portfolio Expert EURUSD H1.mq4' (592,16)]]></title>
			<link>https://forexsb.com/forum/post/59501/#p59501</link>
			<description><![CDATA[<p>any idea about that?</p>]]></description>
			<author><![CDATA[null@example.com (Roughey)]]></author>
			<pubDate>Thu, 27 Feb 2020 17:32:07 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/59501/#p59501</guid>
		</item>
		<item>
			<title><![CDATA[Re: Array out of range in 'Portfolio Expert EURUSD H1.mq4' (592,16)]]></title>
			<link>https://forexsb.com/forum/post/59289/#p59289</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (Roughey)]]></author>
			<pubDate>Sun, 16 Feb 2020 15:54:28 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/59289/#p59289</guid>
		</item>
		<item>
			<title><![CDATA[Re: Array out of range in 'Portfolio Expert EURUSD H1.mq4' (592,16)]]></title>
			<link>https://forexsb.com/forum/post/59055/#p59055</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (Popov)]]></author>
			<pubDate>Fri, 31 Jan 2020 05:44:55 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/59055/#p59055</guid>
		</item>
	</channel>
</rss>
