<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Forex Software — Limit the number of open positions.]]></title>
	<link rel="self" href="https://forexsb.com/forum/feed/atom/topic/8968" />
	<updated>2023-12-07T00:19:28Z</updated>
	<generator>PunBB</generator>
	<id>https://forexsb.com/forum/topic/8968/limit-the-number-of-open-positions/</id>
		<entry>
			<title type="html"><![CDATA[Re: Limit the number of open positions.]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/77858/#p77858" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>cristyangeo wrote:</cite><blockquote><p>Hello<br />I have created an expert with studio and the &quot;max open position&quot; option doesn&#039;t limit the positions open simultaneously even I set it to max 1 open position the expert opens 2 positions<br />Can you help me where I should modify in the code the max open position to only 1 ?<br />Thanks</p></blockquote></div><p> Use o criador web ele funciona perfeitamente e os doados são melhores e as ias mais precisas</p>]]></content>
			<author>
				<name><![CDATA[gabdecsters]]></name>
				<uri>https://forexsb.com/forum/user/14801/</uri>
			</author>
			<updated>2023-12-07T00:19:28Z</updated>
			<id>https://forexsb.com/forum/post/77858/#p77858</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Limit the number of open positions.]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/77820/#p77820" />
			<content type="html"><![CDATA[<p>Hello<br />I have created an expert with studio and the &quot;max open position&quot; option doesn&#039;t limit the positions open simultaneously even I set it to max 1 open position the expert opens 2 positions<br />Can you help me where I should modify in the code the max open position to only 1 ?<br />Thanks</p>]]></content>
			<author>
				<name><![CDATA[cristyangeo]]></name>
				<uri>https://forexsb.com/forum/user/14667/</uri>
			</author>
			<updated>2023-12-05T06:59:46Z</updated>
			<id>https://forexsb.com/forum/post/77820/#p77820</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Limit the number of open positions.]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/67033/#p67033" />
			<content type="html"><![CDATA[<p>Each strategy can open one position at a time. Since we have 100 strategies at max, it means that 100 is the absolute maximum for the particular Base_Magic range (for the particular symbol).</p><p>&gt; or is this open trades per bar?</p><p>The limit means total simultaneously open positions not matter if they are open this or om a previous bar.</p><p>It is not count of orders but actually open positions.</p>]]></content>
			<author>
				<name><![CDATA[Popov]]></name>
				<uri>https://forexsb.com/forum/user/2/</uri>
			</author>
			<updated>2021-11-27T20:34:23Z</updated>
			<id>https://forexsb.com/forum/post/67033/#p67033</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Limit the number of open positions.]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/67030/#p67030" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Popov wrote:</cite><blockquote><p>Added a &quot;Max Open Positions&quot; option in the Portfolio Experts for MT4 and MT5.<br />The new option works both in tester and in a live trading.<br />Please report any issues.</p></blockquote></div><br /><p>nice...is this now when 100 deals are open ea will not open a new trade?</p><p>or is this open trades per bar? ea can open 100 trades at new bar?</p>]]></content>
			<author>
				<name><![CDATA[Roughey]]></name>
				<uri>https://forexsb.com/forum/user/10939/</uri>
			</author>
			<updated>2021-11-27T18:30:42Z</updated>
			<id>https://forexsb.com/forum/post/67030/#p67030</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Limit the number of open positions.]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/67029/#p67029" />
			<content type="html"><![CDATA[<p>Added a &quot;Max Open Positions&quot; option in the Portfolio Experts for MT4 and MT5.<br />The new option works both in tester and in a live trading.</p><br /><p><span class="postimg"><img src="https://image-holder.forexsb.com/store/portfolio-expert-max-open-positons.png" alt="https://image-holder.forexsb.com/store/portfolio-expert-max-open-positons.png" /></span></p><p>Please report any issues.</p>]]></content>
			<author>
				<name><![CDATA[Popov]]></name>
				<uri>https://forexsb.com/forum/user/2/</uri>
			</author>
			<updated>2021-11-27T16:39:36Z</updated>
			<id>https://forexsb.com/forum/post/67029/#p67029</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Limit the number of open positions.]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/67028/#p67028" />
			<content type="html"><![CDATA[<p>It can be easier limit the number of open positions. However, I&#039;m afraid it will break the trading logic of the suspended strategies.</p><p>With the new Portfolio Experts it will be easier to add additional features.<br />I&#039;ll open a new topic to discuss the possibilities.</p><p>I&#039;ll post a solution for the current request.</p>]]></content>
			<author>
				<name><![CDATA[Popov]]></name>
				<uri>https://forexsb.com/forum/user/2/</uri>
			</author>
			<updated>2021-11-27T16:00:41Z</updated>
			<id>https://forexsb.com/forum/post/67028/#p67028</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Limit the number of open positions.]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/67027/#p67027" />
			<content type="html"><![CDATA[<p>Hi,</p><p>i am using counting deals on portfolio ea on mql4 this code<br /></p><div class="codebox"><pre><code>void OpenOrdersResults()
  {
//------------------------------------------------------
   SumOrders=0;
   BuyOrders=0;
   SellOrders=0;
   TypeLastOrder=-1;
   PipsBuyOrders=0;
   PipsSellOrders=0;
   PipsLastBuyOrders=0;
   PipsLastSellOrders=0;
   ProfitBuyOrders=0;
   ProfitSellOrders=0;
   SumFloating=0;
//---
   for(int i=0; i&lt;OrdersTotal(); i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
        {
         const int magicNumber = OrderMagicNumber();
         if(OrderSymbol()==Symbol() &amp;&amp; (magicsize * Magic &lt;= magicNumber &amp;&amp; magicNumber &lt; (magicsize * Magic + strategiesCount)))
           {
            TypeLastOrder=OrderType();
            if(OrderType()==OP_BUY)
              {
               //               PipsLastBuyOrders=(Bid-OrderOpenPrice())/pip;
               //               PipsBuyOrders+=(Bid-OrderOpenPrice())/pip;
               //               ProfitBuyOrders+=OrderProfit()+OrderCommission()+OrderSwap();
               BuyOrders++;
              }
            if(OrderType()==OP_SELL)
              {
               //               PipsLastSellOrders=(OrderOpenPrice()-Ask)/pip;
               //               PipsSellOrders+=(OrderOpenPrice()-Ask)/pip;
               //               ProfitSellOrders+=OrderProfit()+OrderCommission()+OrderSwap();
               SellOrders++;
              }
            SumOrders++;
            SumFloating+=OrderProfit()+OrderCommission()+OrderSwap();
           }
        }
     }

  }</code></pre></div><p>now i am struggling to get this code in mql5 for new portfolio ea..<br />i need this cause i am managing the open orders..</p><p>EnableMaxPositionsPerBar&nbsp; &nbsp;= false;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />MaxPositionsPerBar&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= 2;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Set Max Open Position per Bar<br />EnableMaxBuyPositions&nbsp; &nbsp; &nbsp; = false;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />MaxBuyPositions&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = 6;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Set Max Open Long Positions<br />EnableMaxSellPositions&nbsp; &nbsp; &nbsp;= false;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />MaxSellPositions&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= 7;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Set Max Open Short Positions<br /> EnableTotalPositions&nbsp; &nbsp; &nbsp; &nbsp;= false;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />TotalPositions&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= 10;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Set Max Open Positions</p><p>so i need it so i can change during running the ea that he not open more thax x posi at same time or only open longs or open short and at on bar ea porfolio can open x positions per bar..sometimes if portfolio is big ea opens 20-30 positions at once.</p>]]></content>
			<author>
				<name><![CDATA[Roughey]]></name>
				<uri>https://forexsb.com/forum/user/10939/</uri>
			</author>
			<updated>2021-11-27T12:28:59Z</updated>
			<id>https://forexsb.com/forum/post/67027/#p67027</id>
		</entry>
</feed>
