<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Forex Software — Entry Size Relative to SL-Account Balance for Porfolio Experts]]></title>
		<link>https://forexsb.com/forum/topic/7805/entry-size-relative-to-slaccount-balance-for-porfolio-experts/</link>
		<atom:link href="https://forexsb.com/forum/feed/rss/topic/7805/" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Entry Size Relative to SL-Account Balance for Porfolio Experts.]]></description>
		<lastBuildDate>Mon, 22 Apr 2019 06:23:49 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Entry Size Relative to SL-Account Balance for Porfolio Experts]]></title>
			<link>https://forexsb.com/forum/post/55239/#p55239</link>
			<description><![CDATA[<p>Hye guys,</p><p>So with the help of other users I got my strategies working with a entry size relative to account balance and stop loss ie risk 1% of account balance by calculating the $ amount of the SL</p><p>Replace EntryAmount with:</p><div class="codebox"><pre><code>double Entry_Amount;
input double MaxRiskPerTrade = 1;
input int Maximum_Lots = 5; 
input double Minimum_Lots = 0.01;</code></pre></div><p>Replace void OnTick() with:</p><div class="codebox"><pre><code>void OnTick()
  {
  int margin=(int) MarketInfo(_Symbol,MODE_MARGINREQUIRED);
      Entry_Amount=(AccountBalance()*MaxRiskPerTrade/1000)/(Stop_Loss);
      Entry_Amount = NormalizeEntrySize(Entry_Amount);
   if(Time[0]&gt;barTime)
     {
      barTime=Time[0];
      OnBar();
     }
  }
  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)
        size = minlot;
    if   (size &lt;=Minimum_Lots)
        size = Minimum_Lots;

  

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

   return (size);
}  </code></pre></div><br /><br /><br /><p>Now the next probelm im hoping someone can help me with is intergrating this code with a portfolio expert.<br />I can get it to work with a using the same StopLoss amount for all strategies however that isnt very practical. I feel the code is almost there however I just need to somehow call up the StopLoss of each strategy and insert it in the calculation for Entry_Amount. I am very new to coding so Im finding it quite difficult</p>]]></description>
			<author><![CDATA[null@example.com (Michael1)]]></author>
			<pubDate>Mon, 22 Apr 2019 06:23:49 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/55239/#p55239</guid>
		</item>
	</channel>
</rss>
