<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Forex Software — Bar Closing and Bar Opening]]></title>
	<link rel="self" href="https://forexsb.com/forum/feed/atom/topic/5418/" />
	<updated>2015-07-01T05:45:37Z</updated>
	<generator>PunBB</generator>
	<id>https://forexsb.com/forum/topic/5418/bar-closing-and-bar-opening/</id>
		<entry>
			<title type="html"><![CDATA[Re: Bar Closing and Bar Opening]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/30357/#p30357" />
			<content type="html"><![CDATA[<p>Miroslav could you leave free to change the default value of advanced time inside FSB?<br />It does not keep new value in MT4 or MT5 expert, when I change it.</p><p>In FSB is 3 and and in expert is 15.</p><p>(You can leave 3 the default value).</p><p>Thanks</p>]]></content>
			<author>
				<name><![CDATA[GD]]></name>
				<uri>https://forexsb.com/forum/user/8542/</uri>
			</author>
			<updated>2015-07-01T05:45:37Z</updated>
			<id>https://forexsb.com/forum/post/30357/#p30357</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Bar Closing and Bar Opening]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/30356/#p30356" />
			<content type="html"><![CDATA[<p>Because what happens in the backtest in MT can happen in the real trade. MT brokers use &quot;plugins&quot; that manipulate the market for the traders and everything is possible. </p><p>Another reason is that any fail reflects on me. It is easier for the users to think that the problems are in FSB or in the experts than accepting the fact that MT fails.</p>]]></content>
			<author>
				<name><![CDATA[Popov]]></name>
				<uri>https://forexsb.com/forum/user/2/</uri>
			</author>
			<updated>2015-07-01T05:00:22Z</updated>
			<id>https://forexsb.com/forum/post/30356/#p30356</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Bar Closing and Bar Opening]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/30355/#p30355" />
			<content type="html"><![CDATA[<p>I think the reason is because the way data are saved as OHLC.</p><p><strong>Relative to advance time</strong></p><p>I think Miroslav makes a trick in case something went wrong during his first approach of Closing bar and make it sure to be corrected the time of Opening a new bar.&nbsp; He had to do that in order to be more compatible with MT4 Tester. By doing that also he gives better opportunities for testing and compare fast FSB results in MT4. It will definitely make happy many users. </p><p>Except of that there is a much better way but Miroslav will have to do it in a further step later. I cannot write it here.</p><p>The advantage of FSB is the fast manipulation of files and many other things which by time can be improved.</p>]]></content>
			<author>
				<name><![CDATA[GD]]></name>
				<uri>https://forexsb.com/forum/user/8542/</uri>
			</author>
			<updated>2015-07-01T02:49:02Z</updated>
			<id>https://forexsb.com/forum/post/30355/#p30355</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Bar Closing and Bar Opening]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/30354/#p30354" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Popov wrote:</cite><blockquote><div class="quotebox"><blockquote><p>do I get you right you are going to &quot;fix&quot; backtesting issues in MT?</p></blockquote></div><p>I cannot entirely fix it, but I can workaround it to make the backtest acceptable.<br />Actually, I&#039;m ready and testing now the new script.</p><p>The idea is simple.<br />1. Normally the Bar Closing sends the close signal at the first tick XXX seconds before the theoretical end of a bar, where XXX is the number of seconds you set on EA Input form on startup.<br />2. When a new bar starts, the EA checks if the strategy uses Bar Closing (Day Closing, ....) and if there is an open position. If it is true, the EA proceeds with the closing procedure in the same way as if it was the last tick. We may think for it as sending the close order at Bar Open, if it was not executed on Bar Closing.<br />3. If a missed close order was executed at Bar Open, the expert checks if the strategy opens a position at Bar Open. If it is true, the EA checks if the position entry rules are satisfied and send the entry order at the same tick.</p><p>As a result of that changes, the EA sends a missed closing order at the Bar Open without missing the next entry. Other benefit is that we can reduce the closing time advance to 5-6 seconds for fast markets in order to improve the closing precision.</p><p>Now I&#039;m testing it with closing time 1 sec on a demo and on backtest and it works fine.</p><p>It is possible to have a Gap between the Open and the Close price. However, if there were no ticks in the last seconds and the closing was not activated, it means that the market is very slow and an eventual gap will be minimal.</p></blockquote></div><p>Seems like a waste of resource, why focus on MT backtest when FSB offers all we need?</p>]]></content>
			<author>
				<name><![CDATA[footon]]></name>
				<uri>https://forexsb.com/forum/user/1242/</uri>
			</author>
			<updated>2015-06-30T23:49:52Z</updated>
			<id>https://forexsb.com/forum/post/30354/#p30354</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Bar Closing and Bar Opening]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/30350/#p30350" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p>do I get you right you are going to &quot;fix&quot; backtesting issues in MT?</p></blockquote></div><p>I cannot entirely fix it, but I can workaround it to make the backtest acceptable.<br />Actually, I&#039;m ready and testing now the new script.</p><p>The idea is simple.<br />1. Normally the Bar Closing sends the close signal at the first tick XXX seconds before the theoretical end of a bar, where XXX is the number of seconds you set on EA Input form on startup.<br />2. When a new bar starts, the EA checks if the strategy uses Bar Closing (Day Closing, ....) and if there is an open position. If it is true, the EA proceeds with the closing procedure in the same way as if it was the last tick. We may think for it as sending the close order at Bar Open, if it was not executed on Bar Closing.<br />3. If a missed close order was executed at Bar Open, the expert checks if the strategy opens a position at Bar Open. If it is true, the EA checks if the position entry rules are satisfied and send the entry order at the same tick.</p><p>As a result of that changes, the EA sends a missed closing order at the Bar Open without missing the next entry. Other benefit is that we can reduce the closing time advance to 5-6 seconds for fast markets in order to improve the closing precision.</p><p>Now I&#039;m testing it with closing time 1 sec on a demo and on backtest and it works fine.</p><p>It is possible to have a Gap between the Open and the Close price. However, if there were no ticks in the last seconds and the closing was not activated, it means that the market is very slow and an eventual gap will be minimal.</p>]]></content>
			<author>
				<name><![CDATA[Popov]]></name>
				<uri>https://forexsb.com/forum/user/2/</uri>
			</author>
			<updated>2015-06-30T18:54:37Z</updated>
			<id>https://forexsb.com/forum/post/30350/#p30350</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Bar Closing and Bar Opening]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/30349/#p30349" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Popov wrote:</cite><blockquote><p>By mean time, I&#039;m not going to wait for their response and think to workaround the issue by myself.<br />You can expect a new version of our expert code in 2-3 days.</p></blockquote></div><p>Even though I&#039;m in fever, do I get you right you are going to &quot;fix&quot; backtesting issues in MT?</p>]]></content>
			<author>
				<name><![CDATA[footon]]></name>
				<uri>https://forexsb.com/forum/user/1242/</uri>
			</author>
			<updated>2015-06-30T17:55:58Z</updated>
			<id>https://forexsb.com/forum/post/30349/#p30349</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Bar Closing and Bar Opening]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/30340/#p30340" />
			<content type="html"><![CDATA[<p>That is why I had problems with Advanced Time in some cases.<br />MT5 worked better but MT4 was a problem<br />I had to use big time to see same results, which of course was not normal.</p><p>I could not believe what I saw and finally you came to discover a big problem in MT4.</p><p>I hope to find time to think on it.</p><p><a href="http://postimg.org/image/sl9xz938p/"><span class="postimg"><img src="http://s28.postimg.org/sl9xz938p/2015_06_30.jpg" alt="http://s28.postimg.org/sl9xz938p/2015_06_30.jpg" /></span></a></p><p>Real events look to be like that.</p><p>If we want to apply classic analysis then we have to use our own definition of bars.</p><p>MT4 and MT5 cannot make that...</p><p>The other way is to find a sophisticated approximation.</p>]]></content>
			<author>
				<name><![CDATA[GD]]></name>
				<uri>https://forexsb.com/forum/user/8542/</uri>
			</author>
			<updated>2015-06-30T04:52:42Z</updated>
			<id>https://forexsb.com/forum/post/30340/#p30340</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Bar Closing and Bar Opening]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/30337/#p30337" />
			<content type="html"><![CDATA[<p>Case development:</p><p><strong>Alain Verleyen</strong> - a MQL5 moderator with 19000 post said:</p><div class="quotebox"><blockquote><p>Which pitfalls are you talking about ? MT4 or MT5 ? They are NOT the same. Please don&#039;t mix MT4 and MT5</p></blockquote></div><p>Hmm. Of course they are not the same, but we expect both MT4 and MT5 to work, trade and test <strong>at the exactly same way</strong>.&nbsp; I assume he has an internal info to the subject. Well, we have been warned.</p><div class="quotebox"><blockquote><p>The Strategy Tester will NEVER by accurate, no matter which algorithm is used.</p></blockquote></div><p>He stressed on the world never. I&#039;m sure he doesn&#039;t understand the backtesting theory well enough or he knows something more for the MT backtester.</p><p>Of course, there are cases where a backtester is not correct. That&#039;s why FSB shows ambiguous bars. However, there are many cases where a backtester should work fine. It depends on the backtesting algo and the strategy structure. A a backtester should never show an overestimated result.</p><p>It seams I have to make a series of seminars or videos on the bakctesting theory and the best way to apply it in the practice. </p><p> Mr. Verleyen stated also that:<br /></p><div class="quotebox"><blockquote><p>If you use TimeCurrent(), that will give you the time of the tick.</p></blockquote></div><p>Unfortunately, it doesn&#039;t work.</p><p>I finally wrote directly to the MT development team. I hope they will fix the issue or at least they will comment the case. </p><p>By mean time, I&#039;m not going to wait for their response and think to workaround the issue by myself.<br />You can expect a new version of our expert code in 2-3 days.</p>]]></content>
			<author>
				<name><![CDATA[Popov]]></name>
				<uri>https://forexsb.com/forum/user/2/</uri>
			</author>
			<updated>2015-06-29T22:16:30Z</updated>
			<id>https://forexsb.com/forum/post/30337/#p30337</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Bar Closing and Bar Opening]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/30325/#p30325" />
			<content type="html"><![CDATA[<p>In MT5 the things work better but in MT4, inside one bar trading gave me hard time</p><p>I will test it and answer you soon cause today things go wrong...</p>]]></content>
			<author>
				<name><![CDATA[GD]]></name>
				<uri>https://forexsb.com/forum/user/8542/</uri>
			</author>
			<updated>2015-06-29T09:31:09Z</updated>
			<id>https://forexsb.com/forum/post/30325/#p30325</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Bar Closing and Bar Opening]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/30322/#p30322" />
			<content type="html"><![CDATA[<p>It is good that the topic in the MT forum is not deleted. I hope MetaQuotes will comment.</p><p>..</p><p>Please test your terminal with the attached expert. It prints the time of the previous bar last tick.</p><div class="codebox"><pre><code>string previousRecord = &quot;&quot;;

void OnTick()
  {
   string time = TimeToString(TimeCurrent(), TIME_DATE|TIME_MINUTES|TIME_SECONDS);
   string bid = DoubleToString(Bid,_Digits);
   string ask = DoubleToString(Ask,_Digits);
   if(Volume[0] == 1)
      Print(previousRecord);
   previousRecord = &quot;TimeCurrent: &quot; + time + &quot;, Bid: &quot; + bid + &quot;, Ask: &quot; + ask;
  }</code></pre></div><p>On my ActiveTrades terminal the last ticks are either at xx:35 or at xx:25 +- 1 second for EURUSD M5 and M15.</p><p><a href="http://postimg.org/image/rqtbjub49/"><span class="postimg"><img src="http://s28.postimg.org/rqtbjub49/screenshot_1027.jpg" alt="http://s28.postimg.org/rqtbjub49/screenshot_1027.jpg" /></span></a></p>]]></content>
			<author>
				<name><![CDATA[Popov]]></name>
				<uri>https://forexsb.com/forum/user/2/</uri>
			</author>
			<updated>2015-06-29T08:26:53Z</updated>
			<id>https://forexsb.com/forum/post/30322/#p30322</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Bar Closing and Bar Opening]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/30320/#p30320" />
			<content type="html"><![CDATA[<p>I opened a ticked in the MT5 community for that case. <a href="https://www.mql5.com/en/forum/60765">MT4 Strategy Tester doesn&#039;t generate ticks near to the end of M5 bars</a></p><p>There is no solution so far.</p>]]></content>
			<author>
				<name><![CDATA[Popov]]></name>
				<uri>https://forexsb.com/forum/user/2/</uri>
			</author>
			<updated>2015-06-29T07:59:38Z</updated>
			<id>https://forexsb.com/forum/post/30320/#p30320</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Bar Closing and Bar Opening]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/30295/#p30295" />
			<content type="html"><![CDATA[<p>I experienced this issue on the MT4 backtester. I added a printing status code in the expert to see what is happening and the full beauty of the MT backester shined as a bright sun.</p><p><a href="http://postimg.org/image/8ghpmnzrd/"><span class="postimg"><img src="http://s28.postimg.org/8ghpmnzrd/screenshot_1021.jpg" alt="http://s28.postimg.org/8ghpmnzrd/screenshot_1021.jpg" /></span></a></p><p>My Bar closing advance parameter is the default 15 seconds, but the problem is other. The shiny MT backtester normally fabricates ticks every 2-3 seconds, but not for the whole bar. There are 37 seconds missing from the end of that bar. And from the next ... and from the next ...</p>]]></content>
			<author>
				<name><![CDATA[Popov]]></name>
				<uri>https://forexsb.com/forum/user/2/</uri>
			</author>
			<updated>2015-06-27T15:31:44Z</updated>
			<id>https://forexsb.com/forum/post/30295/#p30295</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Bar Closing and Bar Opening]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/30198/#p30198" />
			<content type="html"><![CDATA[<p>With the above results we have agreement.</p><p>And I just verified them to MT5 also.</p><p>The problem can be in the writing of some of the indicators.</p>]]></content>
			<author>
				<name><![CDATA[GD]]></name>
				<uri>https://forexsb.com/forum/user/8542/</uri>
			</author>
			<updated>2015-06-24T12:11:20Z</updated>
			<id>https://forexsb.com/forum/post/30198/#p30198</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Bar Closing and Bar Opening]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/30197/#p30197" />
			<content type="html"><![CDATA[<p>MT4 backtest with default settings.</p><p><a href="http://postimg.org/image/p2uoi03bd/"><span class="postimg"><img src="http://s28.postimg.org/p2uoi03bd/screenshot_1009.jpg" alt="http://s28.postimg.org/p2uoi03bd/screenshot_1009.jpg" /></span></a></p><p>Another one with MT4 and closing at Bar Closing at every bar.</p><br /><p><a href="http://postimg.org/image/h2d90ppev/"><span class="postimg"><img src="http://s23.postimg.org/h2d90ppev/FSB_Expert_Stress_Test.jpg" alt="http://s23.postimg.org/h2d90ppev/FSB_Expert_Stress_Test.jpg" /></span></a>.</p>]]></content>
			<author>
				<name><![CDATA[Popov]]></name>
				<uri>https://forexsb.com/forum/user/2/</uri>
			</author>
			<updated>2015-06-24T11:59:39Z</updated>
			<id>https://forexsb.com/forum/post/30197/#p30197</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Bar Closing and Bar Opening]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/30196/#p30196" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Popov wrote:</cite><blockquote><div class="quotebox"><blockquote><p>Now relative to strategy testers what parameter value to use in order to find same results like FSB</p></blockquote></div><p>The FSB backtester closes the positions at the exact Close price. On the other hand, MT backtester fabricates ticks and times on it&#039;s own algorithm. 15 seconds must work well but you can test with other values.</p><div class="quotebox"><blockquote><p>I use numbers like 999 etc. Do I have some problem Or it is normal?</p></blockquote></div><p>You are the one that do not want limits, so you can try it.<br />But I definitely would not set anything higher than 30 or 60 (for H1 charts and upper).</p><p>Read this carefully: <a href="http://forexsb.com/forum/post/30191/#p30191">http://forexsb.com/forum/post/30191/#p30191</a></p></blockquote></div><p>The behavior depends a lot on this parameter in back testing. The other thing could happened is some problems on some indicators. Not all but some of them.</p>]]></content>
			<author>
				<name><![CDATA[GD]]></name>
				<uri>https://forexsb.com/forum/user/8542/</uri>
			</author>
			<updated>2015-06-24T11:53:39Z</updated>
			<id>https://forexsb.com/forum/post/30196/#p30196</id>
		</entry>
</feed>
