<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Forex Software — Add TakeProfit in Percent in Portfolio?]]></title>
	<link rel="self" href="https://forexsb.com/forum/feed/atom/topic/7711/" />
	<updated>2019-01-25T22:21:54Z</updated>
	<generator>PunBB</generator>
	<id>https://forexsb.com/forum/topic/7711/add-takeprofit-in-percent-in-portfolio/</id>
		<entry>
			<title type="html"><![CDATA[Re: Add TakeProfit in Percent in Portfolio?]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/54156/#p54156" />
			<content type="html"><![CDATA[<p>Sure it will work, as long as you only reference the EAs that belong to it when closing positions.</p>]]></content>
			<author>
				<name><![CDATA[geektrader]]></name>
				<uri>https://forexsb.com/forum/user/1841/</uri>
			</author>
			<updated>2019-01-25T22:21:54Z</updated>
			<id>https://forexsb.com/forum/post/54156/#p54156</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Add TakeProfit in Percent in Portfolio?]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/54154/#p54154" />
			<content type="html"><![CDATA[<p>now its based on accountbalance. but what is when i use 5 different eas on one account? than this formula not working ?</p>]]></content>
			<author>
				<name><![CDATA[Roughey]]></name>
				<uri>https://forexsb.com/forum/user/10939/</uri>
			</author>
			<updated>2019-01-25T21:53:36Z</updated>
			<id>https://forexsb.com/forum/post/54154/#p54154</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Add TakeProfit in Percent in Portfolio?]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/54130/#p54130" />
			<content type="html"><![CDATA[<p>thanks i will try</p>]]></content>
			<author>
				<name><![CDATA[Roughey]]></name>
				<uri>https://forexsb.com/forum/user/10939/</uri>
			</author>
			<updated>2019-01-24T20:24:29Z</updated>
			<id>https://forexsb.com/forum/post/54130/#p54130</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Add TakeProfit in Percent in Portfolio?]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/54129/#p54129" />
			<content type="html"><![CDATA[<p>The code looks good so far, also great that you are doing &quot;+OrderSwap()+OrderCommission()&quot;, most programmers do &quot;-OrderSwap()-OrderCommission()&quot;, as they do not realize that the values are expressed negative by MT4 already. Good job :-)</p><p>As for your % based take profit, you somehow (before opening the next batch of trades) need to have a look at the AccountBalance() (<a href="https://docs.mql4.com/account/accountbalance">https://docs.mql4.com/account/accountbalance</a>), as you need to relate your percentage to the account balance in order to figure out when to close the trades. So your TakeProfitBasket would become something like this to express it in percent:</p><div class="codebox"><pre><code>TakeProfitBasket = AccountBalance() * 0.06;</code></pre></div><p>^ which then would make it take profit if the profit equals 6% of your current account balance. Of course you can make the % an input variable like this:</p><div class="codebox"><pre><code>input double TakeProfitPercent = 6.0;</code></pre></div><p>and then do:</p><div class="codebox"><pre><code>TakeProfitBasket = AccountBalance() * TakeProfitPercent / 100;</code></pre></div><p>Good luck!</p>]]></content>
			<author>
				<name><![CDATA[geektrader]]></name>
				<uri>https://forexsb.com/forum/user/1841/</uri>
			</author>
			<updated>2019-01-24T19:53:58Z</updated>
			<id>https://forexsb.com/forum/post/54129/#p54129</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Add TakeProfit in Percent in Portfolio?]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/54125/#p54125" />
			<content type="html"><![CDATA[<p>Hi,</p><p>i like to mod my Portfolio Ea with a special function. I want to Close all trades if % profit reached.</p><p>I tried this out with a input amount and it is working. But how i have to change this when i want to say if 5% profit reached close all trades?</p><p>THE INPUT:<br /></p><div class="codebox"><pre><code>input bool                 useTakeProfitBasket        = true;                 // USE TAKEPROFIT BASKET
input double               TakeProfitBasket           = 100;  </code></pre></div><br /><p>ON ON TICK I ADD THIS:<br /></p><div class="codebox"><pre><code>void OnTick()
  {
    if(useTakeProfitBasket &amp;&amp; (Open_Orders_Profit()&gt;=TakeProfitBasket))
   {
      CloseAllPositions();
      Print(&quot;Take Profit Basket Reached. All Trades CLOSED!&quot;);
      printf(&quot;Take Profit Basket Reached. All Trades CLOSED!&quot;);
      Alert(&quot;Take Profit Basket Reached. All Trades CLOSED!&quot;);
      Comment(&quot;Take Profit Basket Reached. All Trades CLOSED!&quot;);
   }</code></pre></div><br /><p>and i have this function added to get Profit of open orders.</p><div class="codebox"><pre><code>double Open_Orders_Profit()
{
   double openordersprofit = 0;
   RefreshRates();
   int Total=OrdersTotal();
   if(Total&gt;0)
   {
      for(int i=Total-1; i&gt;=0; i--)
      {
         if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==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)))
            {
               openordersprofit +=OrderProfit()+OrderSwap()+OrderCommission();
            }
         }
      }
   }
   return(openordersprofit);
}</code></pre></div><p>Can someone help me out to change this to have it in percent?</p>]]></content>
			<author>
				<name><![CDATA[Roughey]]></name>
				<uri>https://forexsb.com/forum/user/10939/</uri>
			</author>
			<updated>2019-01-24T17:01:10Z</updated>
			<id>https://forexsb.com/forum/post/54125/#p54125</id>
		</entry>
</feed>
