<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Forex Software — How to get Total History Profit from Portfolio ea?]]></title>
	<link rel="self" href="https://forexsb.com/forum/feed/atom/topic/7529/" />
	<updated>2018-10-01T15:02:15Z</updated>
	<generator>PunBB</generator>
	<id>https://forexsb.com/forum/topic/7529/how-to-get-total-history-profit-from-portfolio-ea/</id>
		<entry>
			<title type="html"><![CDATA[Re: How to get Total History Profit from Portfolio ea?]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/52418/#p52418" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Popov wrote:</cite><blockquote><p>Move&nbsp; &quot;const int magicNumber = OrderMagicNumber();&quot; within the &quot;if(OrderSelect(i,SELECT_BY_POS, MODE_HISTORY)==true)&quot;.</p><p>Like that:</p><div class="codebox"><pre><code>   for(int i=0;i&lt;total;i++)
     {
      if(OrderSelect(i,SELECT_BY_POS, MODE_HISTORY)==true)
        {
         const int magicNumber = OrderMagicNumber();
         if(OrderSymbol()==Symbol() &amp;&amp; (1000 * Base_Magic_Number &lt;= magicNumber &amp;&amp; magicNumber &lt; (1000 * Base_Magic_Number + 100)))</code></pre></div></blockquote></div><p>Yes nice it works. Thank you..</p>]]></content>
			<author>
				<name><![CDATA[deadlef]]></name>
				<uri>https://forexsb.com/forum/user/9894/</uri>
			</author>
			<updated>2018-10-01T15:02:15Z</updated>
			<id>https://forexsb.com/forum/post/52418/#p52418</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: How to get Total History Profit from Portfolio ea?]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/52413/#p52413" />
			<content type="html"><![CDATA[<p>Move&nbsp; &quot;const int magicNumber = OrderMagicNumber();&quot; within the &quot;if(OrderSelect(i,SELECT_BY_POS, MODE_HISTORY)==true)&quot;.</p><p>Like that:</p><div class="codebox"><pre><code>   for(int i=0;i&lt;total;i++)
     {
      if(OrderSelect(i,SELECT_BY_POS, MODE_HISTORY)==true)
        {
         const int magicNumber = OrderMagicNumber();
         if(OrderSymbol()==Symbol() &amp;&amp; (1000 * Base_Magic_Number &lt;= magicNumber &amp;&amp; magicNumber &lt; (1000 * Base_Magic_Number + 100)))</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Popov]]></name>
				<uri>https://forexsb.com/forum/user/2/</uri>
			</author>
			<updated>2018-10-01T11:21:50Z</updated>
			<id>https://forexsb.com/forum/post/52413/#p52413</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: How to get Total History Profit from Portfolio ea?]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/52411/#p52411" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Popov wrote:</cite><blockquote><p>You can check if a position magic number is from that portfolio expert by this way:</p><div class="codebox"><pre><code>const int magicNumber = OrderMagicNumber();
if (1000 * Base_Magic_Number &lt;= magicNumber &amp;&amp; magicNumber &lt; (1000 * Base_Magic_Number + 100))
 {
  // Do the things here
 }</code></pre></div></blockquote></div><br /><p>I tried it out put your example like this in code.<br /></p><div class="codebox"><pre><code>double Total_History_Profit()
  {
   const int magicNumber = OrderMagicNumber();
   double totalhistoryprofit=0;
   int total=OrdersHistoryTotal();
   for(int i=0;i&lt;total;i++)
     {
      if(OrderSelect(i,SELECT_BY_POS, MODE_HISTORY)==true)
        {
         if (1000 * Base_Magic_Number &lt;= magicNumber &amp;&amp; magicNumber &lt; (1000 * Base_Magic_Number + 100))
         if(OrderSymbol()==Symbol())
         if(OrderType()==OP_SELL || OrderType()==OP_BUY)
           {
            totalhistoryprofit+= OrderSwap()+OrderProfit();
           }
        }
     }
   return(totalhistoryprofit);
  }  </code></pre></div><p>also like this isnt working well.</p><div class="codebox"><pre><code>double Total_History_Profit()
  {
   const int magicNumber = OrderMagicNumber();
   double totalhistoryprofit=0;
   int total=OrdersHistoryTotal();
   for(int i=0;i&lt;total;i++)
     {
      if(OrderSelect(i,SELECT_BY_POS, MODE_HISTORY)==true)
        {
         if(OrderSymbol()==Symbol() &amp;&amp; (1000 * Base_Magic_Number &lt;= magicNumber &amp;&amp; magicNumber &lt; (1000 * Base_Magic_Number + 100)))
         if(OrderType()==OP_SELL || OrderType()==OP_BUY)
           {
            totalhistoryprofit+= OrderSwap()+OrderProfit();
           }
        }
     }
   return(totalhistoryprofit);
  }  </code></pre></div><p>But i get the complete history Total Profit not only from the magicnumbers. <br />What about when i use portfolio 4 times. One Basic Magicnumber 400...one 401..one 402.. So if the code runs on basic numver 402 and the code is</p><div class="codebox"><pre><code>(1000 * Base_Magic_Number &lt;= magicNumber &amp;&amp; magicNumber &lt; (1000 * Base_Magic_Number + 100)</code></pre></div><p>so when an has a smaller basenumber it will count all together.</p>]]></content>
			<author>
				<name><![CDATA[deadlef]]></name>
				<uri>https://forexsb.com/forum/user/9894/</uri>
			</author>
			<updated>2018-10-01T11:10:32Z</updated>
			<id>https://forexsb.com/forum/post/52411/#p52411</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: How to get Total History Profit from Portfolio ea?]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/52403/#p52403" />
			<content type="html"><![CDATA[<p>You can check if a position magic number is from that portfolio expert by this way:</p><div class="codebox"><pre><code>const int magicNumber = OrderMagicNumber();
if (1000 * Base_Magic_Number &lt;= magicNumber &amp;&amp; magicNumber &lt; (1000 * Base_Magic_Number + 100))
 {
  // Do the things here
 }</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Popov]]></name>
				<uri>https://forexsb.com/forum/user/2/</uri>
			</author>
			<updated>2018-10-01T05:59:30Z</updated>
			<id>https://forexsb.com/forum/post/52403/#p52403</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: How to get Total History Profit from Portfolio ea?]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/52397/#p52397" />
			<content type="html"><![CDATA[<p>hmm can nobody help out how i can get the calculated magicnumbers for that .. Cause when i change base magicnumber it also should be than in my Profit calculation.</p><p>i have tried that but dont work<br /></p><div class="codebox"><pre><code>         if(OrderSymbol()==Symbol()&amp;&amp; OrderMagicNumber()== GetMagicNumber());</code></pre></div>]]></content>
			<author>
				<name><![CDATA[deadlef]]></name>
				<uri>https://forexsb.com/forum/user/9894/</uri>
			</author>
			<updated>2018-09-30T18:08:50Z</updated>
			<id>https://forexsb.com/forum/post/52397/#p52397</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: How to get Total History Profit from Portfolio ea?]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/52390/#p52390" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Popov wrote:</cite><blockquote><p>A Portfolio Expert opens positions with different Magic numbers for each included strategy.</p><p>We are currently developing a tool in EA Studio that will be able to calculate the stats form a particular date. It will help you for that case.</p><p>On the other hand, if you need to calculate the profit in the expert, you have to take into account all used magic numbers.</p><p>The positions&#039; Magic Number calculation is:<br /></p><div class="codebox"><pre><code>int GetMagicNumber(int strategyIndex)
  {
   int magic=1000*Base_Magic_Number+strategyIndex;
   return (magic);
  }</code></pre></div><p>The <em>strategyIndex</em> is from 0 to the count of the strategies - 1.</p><p>..</p><p>Now I think that probably adding trading info in the Portfolio Expert is a good idea. It may be like in the FSB Pro&#039;s experts and to plot on the chart something like:<br />Total strategies: 32<br />Long&nbsp; positions count: 11, lots: 0.11, profit: 333 <br />Short positions count: 03, lots: 0.03, profit: -24</p></blockquote></div><p> yes i saw that this calculation. but when i try to implement it in my functions it gives me errors..<br />something lik GetMagicNumber() dont work on my process</p><p>we have to put the calculated magicnumber as global variable than it might be work.. but i dont know how to solve this..</p>]]></content>
			<author>
				<name><![CDATA[deadlef]]></name>
				<uri>https://forexsb.com/forum/user/9894/</uri>
			</author>
			<updated>2018-09-28T18:24:34Z</updated>
			<id>https://forexsb.com/forum/post/52390/#p52390</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: How to get Total History Profit from Portfolio ea?]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/52389/#p52389" />
			<content type="html"><![CDATA[<p>A Portfolio Expert opens positions with different Magic numbers for each included strategy.</p><p>We are currently developing a tool in EA Studio that will be able to calculate the stats form a particular date. It will help you for that case.</p><p>On the other hand, if you need to calculate the profit in the expert, you have to take into account all used magic numbers.</p><p>The positions&#039; Magic Number calculation is:<br /></p><div class="codebox"><pre><code>int GetMagicNumber(int strategyIndex)
  {
   int magic=1000*Base_Magic_Number+strategyIndex;
   return (magic);
  }</code></pre></div><p>The <em>strategyIndex</em> is from 0 to the count of the strategies - 1.</p><p>..</p><p>Now I think that probably adding trading info in the Portfolio Expert is a good idea. It may be like in the FSB Pro&#039;s experts and to plot on the chart something like:<br />Total strategies: 32<br />Long&nbsp; positions count: 11, lots: 0.11, profit: 333 <br />Short positions count: 03, lots: 0.03, profit: -24</p>]]></content>
			<author>
				<name><![CDATA[Popov]]></name>
				<uri>https://forexsb.com/forum/user/2/</uri>
			</author>
			<updated>2018-09-28T17:40:14Z</updated>
			<id>https://forexsb.com/forum/post/52389/#p52389</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[How to get Total History Profit from Portfolio ea?]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/52388/#p52388" />
			<content type="html"><![CDATA[<p>Hi,</p><p>how can i get the total Profit of an Portfolio EA?</p><p>On normal Eas this kind of code is working well.<br /></p><div class="codebox"><pre><code>double Total_History_Profit()
  {
   double totalhistoryprofit=0;
   int total=OrdersHistoryTotal();
   for(int i=0;i&lt;total;i++)
     {
      if(OrderSelect(i,SELECT_BY_POS, MODE_HISTORY)==true)
        {
         if(OrderSymbol()==Symbol()&amp;&amp; OrderMagicNumber()==Magic_Number)
         if(OrderType()==OP_SELL || OrderType()==OP_BUY)
           {
            totalhistoryprofit+= OrderSwap()+OrderProfit();
           }
        }
     }
   return(totalhistoryprofit);
  }  </code></pre></div><p>But cause Portfolio have different magicnumbers.. What did i have to put in this line instead of Magic_Number?</p><div class="codebox"><pre><code>         if(OrderSymbol()==Symbol()&amp;&amp; OrderMagicNumber()==Magic_Number)</code></pre></div>]]></content>
			<author>
				<name><![CDATA[deadlef]]></name>
				<uri>https://forexsb.com/forum/user/9894/</uri>
			</author>
			<updated>2018-09-28T14:47:27Z</updated>
			<id>https://forexsb.com/forum/post/52388/#p52388</id>
		</entry>
</feed>
