<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Forex Software — Auto Lot Size Calculation]]></title>
		<link>https://forexsb.com/forum/topic/6251/auto-lot-size-calculation/</link>
		<atom:link href="https://forexsb.com/forum/feed/rss/topic/6251" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Auto Lot Size Calculation.]]></description>
		<lastBuildDate>Sat, 27 Nov 2021 12:11:58 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Auto Lot Size Calculation]]></title>
			<link>https://forexsb.com/forum/post/67026/#p67026</link>
			<description><![CDATA[<p>i struggling to let run a perfecct function for the entry percent..maybe popov can you make it for the new mt5 porttfolio?</p>]]></description>
			<author><![CDATA[null@example.com (Roughey)]]></author>
			<pubDate>Sat, 27 Nov 2021 12:11:58 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/67026/#p67026</guid>
		</item>
		<item>
			<title><![CDATA[Re: Auto Lot Size Calculation]]></title>
			<link>https://forexsb.com/forum/post/65090/#p65090</link>
			<description><![CDATA[<p>Dear Popov,</p><p>can you please make an update for this old topic? I compared the code from a fresh new strategy with the old one from the EA updated here and it seems to me that the coding is different. </p><p>I am very interested (as you know <img src="https://forexsb.com/forum/img/smilies/smile.png" width="15" height="15" alt="smile" /> ) in using percentages instead of lots and I haven&#039;t found a solution yet.</p><p>I tried to use FSB because of the percentage, but still I have more other problems there. With Expert Advisor I miss only this function, otherwise it is PERFECT !</p><p><img src="https://forexsb.com/forum/img/smilies/smile.png" width="15" height="15" alt="smile" /></p><p>thanks<br />Sebastian</p>]]></description>
			<author><![CDATA[null@example.com (mentosan)]]></author>
			<pubDate>Tue, 18 May 2021 10:39:51 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/65090/#p65090</guid>
		</item>
		<item>
			<title><![CDATA[Re: Auto Lot Size Calculation]]></title>
			<link>https://forexsb.com/forum/post/52241/#p52241</link>
			<description><![CDATA[<div class="quotebox"><cite>Popov wrote:</cite><blockquote><p>Yes, it is possible. You can use the follow function (taken from the FSB Pro scripts):</p><div class="codebox"><pre><code>double NormalizeEntrySize(double size)
{
    double minlot  = MarketInfo(_Symbol, MODE_MINLOT);
    double lotstep = MarketInfo(_Symbol, MODE_LOTSTEP);

    if (size &lt;= minlot)
        return (minlot);

    int steps = (int) MathRound((size - minlot) / lotstep);
    size = minlot + steps * lotstep;

    if (size &gt;= Maximum_Lots)
        size = Maximum_Lots;

    size = NormalizeDouble(size, digits);

    return (size);
}</code></pre></div><p>Put this function somewhere in the file and use it like that:</p><div class="codebox"><pre><code>Entry_Amount = NormalizeEntrySize(Entry_Amount);</code></pre></div></blockquote></div><p>Is it posible to make the EA detect minimum alllowed lot size and maximum lotsize automatically?<br />I think the code check the minlot size but what to do if the lotsize reached the maxium allowed from broker?<br />Is this code correct?<br /></p><div class="codebox"><pre><code>double NormalizeEntrySize(double size) {
   double minlot  = MarketInfo(_Symbol, MODE_MINLOT);
   double maxlot  = MarketInfo(_Symbol, MODE_MAXLOT);
   double lotstep = MarketInfo(_Symbol, MODE_LOTSTEP);

   if (size &lt;= minlot)
       return (minlot);

   int steps = (int) MathRound((size - minlot) / lotstep);
   size = minlot + steps * lotstep;

   if (size &gt;= maxlot || size &gt;=Maximum_Lots)
       size = maxlot;
       
   size = NormalizeDouble(size, digits);   

   return (size);
}   </code></pre></div>]]></description>
			<author><![CDATA[null@example.com (deadlef)]]></author>
			<pubDate>Sun, 16 Sep 2018 17:36:31 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/52241/#p52241</guid>
		</item>
		<item>
			<title><![CDATA[Re: Auto Lot Size Calculation]]></title>
			<link>https://forexsb.com/forum/post/49615/#p49615</link>
			<description><![CDATA[<p>if i want to have both. Entry amount fix and entry amount with percent. If Lot size percent true...how will be the code for ea studi portfolio or generall normal strats`?</p>]]></description>
			<author><![CDATA[null@example.com (deadlef)]]></author>
			<pubDate>Sat, 17 Mar 2018 22:26:38 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/49615/#p49615</guid>
		</item>
		<item>
			<title><![CDATA[Re: Auto Lot Size Calculation]]></title>
			<link>https://forexsb.com/forum/post/43751/#p43751</link>
			<description><![CDATA[<div class="quotebox"><cite>Blaiserboy wrote:</cite><blockquote><p><strong>yonkuro</strong></p><p>Thanks for asking these features and developing solutions...</p><p>These are most helpful... I had been asking a couple of them and now see in this thread that you are months ahead of me..</p><p>Thank you again!</p></blockquote></div><p>No problem Sir... <img src="https://forexsb.com/forum/img/smilies/wink.png" width="15" height="15" alt="wink" /></p>]]></description>
			<author><![CDATA[null@example.com (yonkuro)]]></author>
			<pubDate>Sat, 20 May 2017 12:47:29 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/43751/#p43751</guid>
		</item>
		<item>
			<title><![CDATA[Re: Auto Lot Size Calculation]]></title>
			<link>https://forexsb.com/forum/post/43748/#p43748</link>
			<description><![CDATA[<p><strong>yonkuro</strong></p><p>Thanks for asking these features and developing solutions...</p><p>These are most helpful... I had been asking a couple of them and now see in this thread that you are months ahead of me..</p><p>Thank you again!</p>]]></description>
			<author><![CDATA[null@example.com (Blaiserboy)]]></author>
			<pubDate>Sat, 20 May 2017 08:55:40 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/43748/#p43748</guid>
		</item>
		<item>
			<title><![CDATA[Re: Auto Lot Size Calculation]]></title>
			<link>https://forexsb.com/forum/post/38836/#p38836</link>
			<description><![CDATA[<p>Thank you so much, it works perfectly <img src="https://forexsb.com/forum/img/smilies/wink.png" width="15" height="15" alt="wink" /></p>]]></description>
			<author><![CDATA[null@example.com (yonkuro)]]></author>
			<pubDate>Wed, 28 Sep 2016 05:52:15 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/38836/#p38836</guid>
		</item>
		<item>
			<title><![CDATA[Re: Auto Lot Size Calculation]]></title>
			<link>https://forexsb.com/forum/post/38833/#p38833</link>
			<description><![CDATA[<p>This error is because the NormalizeEntrySize is inside the OpenPosition function. MQL doesn&#039;t allow nesting functions. The solution is very simple - move NormalizeEntrySize before OpenPosition function.</p>]]></description>
			<author><![CDATA[null@example.com (Popov)]]></author>
			<pubDate>Wed, 28 Sep 2016 04:30:08 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/38833/#p38833</guid>
		</item>
		<item>
			<title><![CDATA[Re: Auto Lot Size Calculation]]></title>
			<link>https://forexsb.com/forum/post/38832/#p38832</link>
			<description><![CDATA[<p>Hi Popov, I got this error when applying that code, I don&#039;t know, may be I applied it incorrectly<br /><a href="https://postimg.org/image/6ub45v5z9/"><span class="postimg"><img src="https://s18.postimg.org/6ub45v5z9/SS_FSB_28092016.jpg" alt="https://s18.postimg.org/6ub45v5z9/SS_FSB_28092016.jpg" /></span></a></p><p>The EA is attached.</p>]]></description>
			<author><![CDATA[null@example.com (yonkuro)]]></author>
			<pubDate>Wed, 28 Sep 2016 02:49:00 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/38832/#p38832</guid>
		</item>
		<item>
			<title><![CDATA[Re: Auto Lot Size Calculation]]></title>
			<link>https://forexsb.com/forum/post/38822/#p38822</link>
			<description><![CDATA[<p>Yes, it is possible. You can use the follow function (taken from the FSB Pro scripts):</p><div class="codebox"><pre><code>double NormalizeEntrySize(double size)
{
    double minlot  = MarketInfo(_Symbol, MODE_MINLOT);
    double lotstep = MarketInfo(_Symbol, MODE_LOTSTEP);

    if (size &lt;= minlot)
        return (minlot);

    int steps = (int) MathRound((size - minlot) / lotstep);
    size = minlot + steps * lotstep;

    if (size &gt;= Maximum_Lots)
        size = Maximum_Lots;

    size = NormalizeDouble(size, digits);

    return (size);
}</code></pre></div><p>Put this function somewhere in the file and use it like that:</p><div class="codebox"><pre><code>Entry_Amount = NormalizeEntrySize(Entry_Amount);</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Popov)]]></author>
			<pubDate>Tue, 27 Sep 2016 13:21:43 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/38822/#p38822</guid>
		</item>
		<item>
			<title><![CDATA[Re: Auto Lot Size Calculation]]></title>
			<link>https://forexsb.com/forum/post/38809/#p38809</link>
			<description><![CDATA[<p>Thanks, but is it posible to make the EA detect minimum alllowed lot size automatically?</p>]]></description>
			<author><![CDATA[null@example.com (yonkuro)]]></author>
			<pubDate>Tue, 27 Sep 2016 08:12:50 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/38809/#p38809</guid>
		</item>
		<item>
			<title><![CDATA[Re: Auto Lot Size Calculation]]></title>
			<link>https://forexsb.com/forum/post/38807/#p38807</link>
			<description><![CDATA[<p>You are correct. You have to make the following changes:</p><div class="codebox"><pre><code>    Entry_Amount=MathMax(Entry_Amount,0.1);
    Entry_Amount=NormalizeDouble(Entry_Amount,1);</code></pre></div><p>This must work. You don&#039;t need to set additional increment value because it is most probably 0.1 and when the <em>NormalizeDouble(Entry_Amount,1)</em> function round it to the first decimal digit, it will work fine.</p>]]></description>
			<author><![CDATA[null@example.com (Popov)]]></author>
			<pubDate>Tue, 27 Sep 2016 07:48:37 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/38807/#p38807</guid>
		</item>
		<item>
			<title><![CDATA[Re: Auto Lot Size Calculation]]></title>
			<link>https://forexsb.com/forum/post/38805/#p38805</link>
			<description><![CDATA[<p>Ah I got it I should change NormalizeDouble(Entry_Amount,2); to NormalizeDouble(Entry_Amount,1);. </p><p>But how do I make the EA to detect the minimum allowed increment automatically?</p>]]></description>
			<author><![CDATA[null@example.com (yonkuro)]]></author>
			<pubDate>Tue, 27 Sep 2016 07:25:11 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/38805/#p38805</guid>
		</item>
		<item>
			<title><![CDATA[Re: Auto Lot Size Calculation]]></title>
			<link>https://forexsb.com/forum/post/38804/#p38804</link>
			<description><![CDATA[<p>Hi Popov, if the broker only allows mini lot (0.1) step/increment, which code should I change?</p><p>The backtest show this error : OrderSend error 131, after I searched in Google, it&#039;s said the error is due to broker doesn&#039;t allow micro lot increment.</p><p>I test it using fixed lot version with 0.11 lot and it give the same error, but when I change the lot size to round number such as 0.1 or 0.2, it works well. So I&#039;m sure the problem is the allowed increment</p>]]></description>
			<author><![CDATA[null@example.com (yonkuro)]]></author>
			<pubDate>Tue, 27 Sep 2016 07:10:16 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/38804/#p38804</guid>
		</item>
		<item>
			<title><![CDATA[Re: Auto Lot Size Calculation]]></title>
			<link>https://forexsb.com/forum/post/38106/#p38106</link>
			<description><![CDATA[<p>Thanks a lot, it works and unexpectedly fun <img src="https://forexsb.com/forum/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[null@example.com (yonkuro)]]></author>
			<pubDate>Thu, 11 Aug 2016 13:17:40 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/38106/#p38106</guid>
		</item>
	</channel>
</rss>
