<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Forex Software — (Bug?) Slightly Different GetTrailingStopPrice() code between MT4/5]]></title>
		<link>https://forexsb.com/forum/topic/9071/bug-slightly-different-gettrailingstopprice-code-between-mt45/</link>
		<atom:link href="https://forexsb.com/forum/feed/rss/topic/9071/" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in (Bug?) Slightly Different GetTrailingStopPrice() code between MT4/5.]]></description>
		<lastBuildDate>Tue, 22 Mar 2022 23:03:30 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: (Bug?) Slightly Different GetTrailingStopPrice() code between MT4/5]]></title>
			<link>https://forexsb.com/forum/post/68407/#p68407</link>
			<description><![CDATA[<p>Thank you for fixing it.</p>]]></description>
			<author><![CDATA[null@example.com (geektrader)]]></author>
			<pubDate>Tue, 22 Mar 2022 23:03:30 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/68407/#p68407</guid>
		</item>
		<item>
			<title><![CDATA[Re: (Bug?) Slightly Different GetTrailingStopPrice() code between MT4/5]]></title>
			<link>https://forexsb.com/forum/post/68388/#p68388</link>
			<description><![CDATA[<p>The Experts code is updated.</p><p>Thank you again for the report!</p>]]></description>
			<author><![CDATA[null@example.com (Popov)]]></author>
			<pubDate>Mon, 21 Mar 2022 10:39:38 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/68388/#p68388</guid>
		</item>
		<item>
			<title><![CDATA[Re: (Bug?) Slightly Different GetTrailingStopPrice() code between MT4/5]]></title>
			<link>https://forexsb.com/forum/post/68253/#p68253</link>
			<description><![CDATA[<p>I see, smart idea. Then I will remove it. Many thanks.</p>]]></description>
			<author><![CDATA[null@example.com (geektrader)]]></author>
			<pubDate>Thu, 10 Mar 2022 06:26:27 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/68253/#p68253</guid>
		</item>
		<item>
			<title><![CDATA[Re: (Bug?) Slightly Different GetTrailingStopPrice() code between MT4/5]]></title>
			<link>https://forexsb.com/forum/post/68239/#p68239</link>
			<description><![CDATA[<p>Hello GeekTrader,</p><p>Thank you for the report.<br />Actually the <em>&quot;&amp;&amp; stopLossPrice &lt; bid&quot;</em> should be removed from MT4 code.</p><p>We do the check inside the <strong>if</strong>. <br />If &quot;<em>stopLossPrice &lt; bid</em>&quot; then we set SL. The SL is set to &quot;bid&quot; otherwise.<br />It works in the case of a big gap where the &quot;bid&quot; jumps over SL.</p>]]></description>
			<author><![CDATA[null@example.com (Popov)]]></author>
			<pubDate>Wed, 09 Mar 2022 11:06:11 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/68239/#p68239</guid>
		</item>
		<item>
			<title><![CDATA[(Bug?) Slightly Different GetTrailingStopPrice() code between MT4/5]]></title>
			<link>https://forexsb.com/forum/post/68229/#p68229</link>
			<description><![CDATA[<p>Hi Mr. Popov,</p><p>I´ve noticed that the GetTrailingStopPrice() function between MT4/5 is almost 100% identical, just one line (an extra check) is different. Shouldn´t this extra line from the MT4 function be added to the MT5 function as well?</p><p>MT4 function:</p><div class="codebox"><pre><code>double GetTrailingStopPrice()
  {
   double bid = Bid();
   double ask = Ask();
   double stopLevelPoints = _Point * stopLevel;
   double stopLossPoints  = pip * Stop_Loss;

   if (posType == OP_BUY)
     {
      double stopLossPrice = High[1] - stopLossPoints;
      if (posStopLoss &lt; stopLossPrice - pip &amp;&amp; stopLossPrice &lt; bid)
         return stopLossPrice &lt; bid
                 ? stopLossPrice &gt;= bid - stopLevelPoints
                    ? bid - stopLevelPoints
                    : stopLossPrice
                 : bid;
     }

   if (posType == OP_SELL)
     {
      double stopLossPrice = Low[1] + stopLossPoints;
      if (posStopLoss &gt; stopLossPrice + pip)
         return stopLossPrice &gt; ask
                 ? stopLossPrice &lt;= ask + stopLevelPoints
                    ? ask + stopLevelPoints
                    : stopLossPrice
                 : ask;
     }

   return posStopLoss;
  }</code></pre></div><p>MT5 function:</p><div class="codebox"><pre><code>double GetTrailingStopPrice()
  {
   double bid = Bid();
   double ask = Ask();
   double stopLevelPoints = _Point * stopLevel;
   double stopLossPoints  = pip * Stop_Loss;

   if (posType == OP_BUY)
     {
      double stopLossPrice = High(1) - stopLossPoints;
      if (posStopLoss &lt; stopLossPrice - pip)
         return stopLossPrice &lt; bid
                  ? stopLossPrice &gt;= bid - stopLevelPoints
                     ? bid - stopLevelPoints
                     : stopLossPrice
                  : bid;
     }

   if (posType == OP_SELL)
     {
      double stopLossPrice = Low(1) + stopLossPoints;
      if (posStopLoss &gt; stopLossPrice + pip)
         return stopLossPrice &gt; ask
                  ? stopLossPrice &lt;= ask + stopLevelPoints
                     ? ask + stopLevelPoints
                     : stopLossPrice
                  : ask;
     }

   return posStopLoss;
  }</code></pre></div><p>The difference is in this line (MT4) which is missing in MT5:</p><div class="codebox"><pre><code>      if (posStopLoss &lt; stopLossPrice - pip &amp;&amp; stopLossPrice &lt; bid)</code></pre></div><p>I think that extra check &quot;&amp;&amp; stopLossPrice &lt; bid&quot; should be added to the MT5 function as well?</p><p>Thank you :-)</p>]]></description>
			<author><![CDATA[null@example.com (geektrader)]]></author>
			<pubDate>Wed, 09 Mar 2022 00:37:37 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/68229/#p68229</guid>
		</item>
	</channel>
</rss>
