<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Forex Software — Forex backtesting and value comparison]]></title>
	<link rel="self" href="https://forexsb.com/forum/feed/atom/topic/290/" />
	<updated>2008-03-16T20:45:32Z</updated>
	<generator>PunBB</generator>
	<id>https://forexsb.com/forum/topic/290/forex-backtesting-and-value-comparison/</id>
		<entry>
			<title type="html"><![CDATA[Re: Forex backtesting and value comparison]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/966/#p966" />
			<content type="html"><![CDATA[<p>Thank you, I have taken note of your explanations <br />Regards <br />Orlando</p>]]></content>
			<author>
				<name><![CDATA[lordorly]]></name>
				<uri>https://forexsb.com/forum/user/288/</uri>
			</author>
			<updated>2008-03-16T20:45:32Z</updated>
			<id>https://forexsb.com/forum/post/966/#p966</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Forex backtesting and value comparison]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/964/#p964" />
			<content type="html"><![CDATA[<p>Dear users,</p><p>I received an interesting letter from Orlando Cornudella yesterday.</p><div class="quotebox"><blockquote><p>Buenos dias, first of all to thank you for the wonderful tool that they share with us. <br />Secondly say that my English is painful and I used an automatic translator. <br />Thirdly send a strategy developed FSB 2.6.01, the results are quite good, however checking periods of time have confirmed that there are &quot;bar&quot; where the logic does not work or that I think my. <br />For example: <br />07/03 on the day between 9:15 and 11:15 should enter into short, however, the strategy has not worked, or so I think to me, what is more secure you made some incorrect definition, how can it help?. <br />There are other times that supposedly should have entered the strategy, but I give that example. Thanks <br />Regards <br />Orlando </p><p>I am Spanish</p></blockquote></div><p>The strategy:</p><p><strong>Forex Strategy Builder v2.6.0.1</strong><br />Strategy name: <strong>Momo5min.</strong><br />Exported on: 16.3.2008 ?. 10:47:29</p><p>Market: EURUSD 5 Minutes<br />Spread: 4 pips<br />Swap Long: 1 pip<br />Swap Short: -1 pips<br />Slippage: 0 pips</p><p>Intrabar scanning: Not accomplished<br />Interpolation method: Pessimistic scenario<br />Ambiguous bars: 0<br />Tested bars: 19959<br />Balance: <strong>764</strong> pips<br />Minimum account: 0 pips<br />Maximum drawdown: 209 pips<br />Time in position: 61 %</p><p><strong>A same direction signal</strong> - <em>Does nothing</em><br /><strong>An opposite direction signal</strong> - <em>Does nothing</em><br /><strong>Permanent Stop Loss</strong> - <em>-23</em></p><p><strong>[Opening point of the position]</strong><br /><strong><span style="color:blue">Bar Opening</span></strong><br />&nbsp; &nbsp; &nbsp;<strong><span style="color:teal">Enter the market at the beginning of the bar</span></strong><br />&nbsp; &nbsp; &nbsp;<strong>Base price</strong>&nbsp; -&nbsp; <em>Open</em></p><p><strong>[Opening logic condition]</strong><br /><strong><span style="color:blue">MACD Histogram</span></strong><br />&nbsp; &nbsp; &nbsp;<strong><span style="color:teal">The MACD histogram crosses the Level line upward</span></strong><br />&nbsp; &nbsp; &nbsp;<strong>Smoothing method</strong>&nbsp; -&nbsp; <em>Exponential</em><br />&nbsp; &nbsp; &nbsp;<strong>Base price</strong>&nbsp; -&nbsp; <em>Close</em><br />&nbsp; &nbsp; &nbsp;<strong>Signal line method</strong>&nbsp; -&nbsp; <em>Exponential</em><br />&nbsp; &nbsp; &nbsp;<strong>Slow MA period</strong>&nbsp; -&nbsp; <em>29</em><br />&nbsp; &nbsp; &nbsp;<strong>Fast MA period</strong>&nbsp; -&nbsp; <em>10</em><br />&nbsp; &nbsp; &nbsp;<strong>Signal line period</strong>&nbsp; -&nbsp; <em>8</em><br />&nbsp; &nbsp; &nbsp;<strong>Level</strong>&nbsp; -&nbsp; <em>0,0001</em><br />&nbsp; &nbsp; &nbsp;<strong>Use previous bar value</strong>&nbsp; -&nbsp; <em>Yes</em></p><p><strong>[Opening logic condition]</strong><br /><strong><span style="color:blue">Moving Average</span></strong><br />&nbsp; &nbsp; &nbsp;<strong><span style="color:teal">The bar opens above the MA value</span></strong><br />&nbsp; &nbsp; &nbsp;<strong>Smoothing method</strong>&nbsp; -&nbsp; <em>Exponential</em><br />&nbsp; &nbsp; &nbsp;<strong>Base price</strong>&nbsp; -&nbsp; <em>Close</em><br />&nbsp; &nbsp; &nbsp;<strong>Period</strong>&nbsp; -&nbsp; <em>24</em><br />&nbsp; &nbsp; &nbsp;<strong>Shift</strong>&nbsp; -&nbsp; <em>0</em><br />&nbsp; &nbsp; &nbsp;<strong>Use previous bar value</strong>&nbsp; -&nbsp; <em>Yes</em></p><p><strong>[Closing point of the position]</strong><br /><strong><span style="color:blue">Take Profit</span></strong><br />&nbsp; &nbsp; &nbsp;<strong><span style="color:teal">Exit at the Take Profit level</span></strong><br />&nbsp; &nbsp; &nbsp;<strong>Take Profit</strong>&nbsp; -&nbsp; <em>55</em></p><br /><p>Thanks Orlando for the good question. I hope the answer will clear some of the FSB backtester logic.</p><p><span class="postimg"><img src="http://forexsb.com/img1/comparison.png" alt="http://forexsb.com/img1/comparison.png" /></span></p><br /><p>I suppose, the misunderstanding comes from the &quot;The MACD histogram crosses the Level line upward&quot; logic implementation.<br />In that example the Level = 0.0001. (Dashed line on the chart.)</p><p>At first sight the logic - &quot;? crosses the Level upward&quot; should be implemented by the formula:</p><p>Long logic condition: Value (t-1) &lt; Level and Value (t) &gt; Level<br />Short logic condition: Value (t-1) &gt; Level and Value (t) &lt; Level</p><p>Looking the above chart, the signal should be at bar <strong>b</strong>: <strong>a</strong> &lt; 0.0001 and <strong>b</strong> &gt; 0.0001<br />Off course we have &quot;Use previous bar value&quot; that moves the signal one bar ahead to bar <strong>c</strong>.</p><p>But, Forex Strategy Builder does not use that logic.</p><p>The problem comes from the manner the computers represent the float numbers.<br />If you define Value = 0.0001, at the next moment the computer can show that Value = 0.0001000003 or Value = 0.000099999998.<br />So, the logic Value &gt; 0.0001 simply does not work well.</p><p>The values should be compared like this:</p><p>Value &gt; 0.0001 + delta<br />where delta is the acceptable error.</p><p>FSB uses delta = Point / 2<br />where Point = 0.0001 for EURUSD and 0.01 for USDJPY</p><p>That means:</p><p>Long logic condition: Value (t-1) &lt; Level - delta and Value (t) &gt; Level + delta<br />Short logic condition: Value (t-1) &gt; Level + delta and Value (t) &lt; Level - delta</p><p>But the programming can be insidious some time. (That is I like it)<br />Let see the following values for three consecutive bars:<br />&nbsp; &nbsp; Value1 = 0.0000<br />&nbsp; &nbsp; Value2 = 0.0001<br />&nbsp; &nbsp; Value3 = 0.0002</p><p>Ops, the above logic does not work. We have crossing of the Level 0.0001 here, but there is no any signal.</p><p>In that situation neither:<br />Value1 &lt; Level and Value2 &gt; Level<br />nor:<br />Value1 &lt; Level - delta and Value2 &gt; Level + delta<br />work.</p><p>The problem is that Value2 = Level</p><p>And even worse, we can meet:<br />&nbsp; &nbsp; Value1 = 0.0000<br />&nbsp; &nbsp; Value3 = 0.0001<br />&nbsp; &nbsp; Value4 = 0.0001<br />&nbsp; &nbsp; Value5 = 0.0001<br />&nbsp; &nbsp; Value6 = 0.0002<br />&nbsp; &nbsp;<br />For that reason Forex Strategy Builder uses a little bit complicated approach:</p><div class="codebox"><pre><code>Case IndicatorLogic.The_indicator_crosses_the_level_line_upward:
  float fMicron = Point / 2;
  for (int iBar = iFirstBar; iBar &lt; Bars; iBar++)
  {
     int iBaseBar = iBar - iPrvs - 1;
     while (Math.Abs(afIndValue[iBaseBar] - fLevelLong) &lt; fMicron &amp;&amp; iBaseBar &gt; iFirstBar)
     {
        iBaseBar--;
     }

      indCompLong.Value [iBar] = (afIndValue[iBaseBar]     &lt; fLevelLong  - fMicron &amp;&amp;
                                  afIndValue[iBar - iPrvs] &gt; fLevelLong  + fMicron) ? 1 : 0;

      indCompShort.Value[iBar] = (afIndValue[iBaseBar]     &gt; fLevelShort + fMicron &amp;&amp;
                                  afIndValue[iBar - iPrvs] &lt; fLevelShort - fMicron) ? 1 : 0;
  }
  break;</code></pre></div><p>(The source is published in the Library section.)</p><p>It ignores the bars which are in the range of the Level line (+- fMicron)</p><p>For that reason, looking at the chart, the bars that crosses the Level is the bar <strong>d</strong> (d &gt; 0.00015) and FSB raises the signal at bar <strong>e</strong>, because of the &quot;Use previous bar value&quot; logic.</p>]]></content>
			<author>
				<name><![CDATA[Popov]]></name>
				<uri>https://forexsb.com/forum/user/2/</uri>
			</author>
			<updated>2008-03-16T18:53:47Z</updated>
			<id>https://forexsb.com/forum/post/964/#p964</id>
		</entry>
</feed>
