<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Forex Software — Manual StopLoss and TakeProfit]]></title>
		<link>https://forexsb.com/forum/topic/8960/manual-stoploss-and-takeprofit/</link>
		<atom:link href="https://forexsb.com/forum/feed/rss/topic/8960/" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Manual StopLoss and TakeProfit.]]></description>
		<lastBuildDate>Thu, 11 Nov 2021 09:22:40 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Manual StopLoss and TakeProfit]]></title>
			<link>https://forexsb.com/forum/post/66861/#p66861</link>
			<description><![CDATA[<div class="quotebox"><cite>Popov wrote:</cite><blockquote><p>Each strategy of the Portfolio Expert forms its entry and exit signals with two functions:<br /> `CreateExitSignal` and `CreateEntrySignal` correspondingly.<br />The SL and TP values are hard-coded in the 3rd end 2nd params from the end.</p><p>Signal signal = CreateExitSignal(2, ind3long, ind3short, 61, 44, false);</p><p>Here StopLoss is 61&nbsp; pips and TakeProfit is 44 pips.</p><p>The easiest way to make a common SL and TP is within these two functions. They are very similar, so I&#039;ll show the modification in `CreateEntrySignal` only.</p><div class="codebox"><pre><code>Signal CreateEntrySignal(...) // AND CreateExitSignal (...)
{
   ...

   signal.StopLossPips   = stopLossPips;
   signal.TakeProfitPips = takeProfitPips;
   signal.IsTrailingStop = isTrailingStop;
   
   // The new code for overriding SL and TP
   if (useCommonSLTP) {
       signal.StopLossPips   = myStopLossPips;
       signal.TakeProfitPips = myTakeProfitPips;
   }

   return (signal);
}</code></pre></div></blockquote></div><br /><p>thank you.</p>]]></description>
			<author><![CDATA[null@example.com (Roughey)]]></author>
			<pubDate>Thu, 11 Nov 2021 09:22:40 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/66861/#p66861</guid>
		</item>
		<item>
			<title><![CDATA[Re: Manual StopLoss and TakeProfit]]></title>
			<link>https://forexsb.com/forum/post/66860/#p66860</link>
			<description><![CDATA[<p>Each strategy of the Portfolio Expert forms its entry and exit signals with two functions:<br /> `CreateExitSignal` and `CreateEntrySignal` correspondingly.<br />The SL and TP values are hard-coded in the 3rd end 2nd params from the end.</p><p>Signal signal = CreateExitSignal(2, ind3long, ind3short, 61, 44, false);</p><p>Here StopLoss is 61&nbsp; pips and TakeProfit is 44 pips.</p><p>The easiest way to make a common SL and TP is within these two functions. They are very similar, so I&#039;ll show the modification in `CreateEntrySignal` only.</p><div class="codebox"><pre><code>Signal CreateEntrySignal(...) // AND CreateExitSignal (...)
{
   ...

   signal.StopLossPips   = stopLossPips;
   signal.TakeProfitPips = takeProfitPips;
   signal.IsTrailingStop = isTrailingStop;
   
   // The new code for overriding SL and TP
   if (useCommonSLTP) {
       signal.StopLossPips   = myStopLossPips;
       signal.TakeProfitPips = myTakeProfitPips;
   }

   return (signal);
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Popov)]]></author>
			<pubDate>Thu, 11 Nov 2021 09:08:12 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/66860/#p66860</guid>
		</item>
		<item>
			<title><![CDATA[Manual StopLoss and TakeProfit]]></title>
			<link>https://forexsb.com/forum/post/66859/#p66859</link>
			<description><![CDATA[<p>Hi,</p><p>i am struggling to get in run in Portfolio.</p><p>Each strategy has its own TP SL by code.</p><p>If i decide to have a stopLoss and takeProfit which i want for all strategies to use, can some coder help.</p><p>This my new input param:<br /></p><div class="codebox"><pre><code>input bool choose = true;
input double Stopl = 100;
input double Takep = 100;</code></pre></div><p>Here i have made changes in OpenPosition<br /></p><div class="codebox"><pre><code>//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OpenPosition(Signal &amp;signal)
  {
   for(int attempt=0; attempt&lt;TRADE_RETRY_COUNT; attempt++)
     {
      int    ticket     = 0;
      int    lastError  = 0;
      bool   modified   = false;
      int    command    = OrderDirectionToCommand(signal.Direction);
      double amount     = Entry_Amount;
      double stopLoss   = signal.StopLossPips&gt;0 ? GetStopLoss(command, signal.StopLossPips) : 0;
      double takeProfit = signal.TakeProfitPips&gt;0 ? GetTakeProfit(command, signal.TakeProfitPips) : 0;
      string comment    = IntegerToString(signal.MagicNumber);
      color  arrowColor = command==OP_BUY ? clrGreen : clrRed;
      double stopl = Stopl;
      double takep = Takep;

      if(IsTradeContextFree())
        {
         double price=MarketInfo(_Symbol,command==OP_BUY ? MODE_ASK : MODE_BID);
         if(setProtectionSeparately)
           {
            ticket=OrderSend(_Symbol,command,amount,price,10,0,0,comment,signal.MagicNumber,0,arrowColor);
            if(ticket&gt;0 &amp;&amp; (signal.StopLossPips&gt;0 || signal.TakeProfitPips&gt;0))
               modified=OrderModify(ticket,0,stopLoss,takeProfit,0,clrBlue);
           }
         else
           {
          [b] if(choose)
           {
            ticket=OrderSend(_Symbol,command,amount,price,10,stopl,takep,comment,signal.MagicNumber,0,arrowColor);
            lastError=GetLastError();
            if(ticket&lt;=0 &amp;&amp; lastError==130)
              {
               ticket=OrderSend(_Symbol,command,amount,price,10,0,0,comment,signal.MagicNumber,0,arrowColor);
               if(ticket&gt;0 &amp;&amp; (stopl&gt;0 || stopl&gt;0))
                  modified=OrderModify(ticket,0,stopl,takep,0,clrBlue);
               if(ticket&gt;0 &amp;&amp; modified)
                 {
                  setProtectionSeparately=true;
                  Print(&quot;Detected ECN type position protection.&quot;);
                 }
              }
            }
            else
           {
            ticket=OrderSend(_Symbol,command,amount,price,10,stopLoss,takeProfit,comment,signal.MagicNumber,0,arrowColor);
            lastError=GetLastError();
            if(ticket&lt;=0 &amp;&amp; lastError==130)
              {
               ticket=OrderSend(_Symbol,command,amount,price,10,0,0,comment,signal.MagicNumber,0,arrowColor);
               if(ticket&gt;0 &amp;&amp; (signal.StopLossPips&gt;0 || signal.TakeProfitPips&gt;0))
                  modified=OrderModify(ticket,0,stopLoss,takeProfit,0,clrBlue);
               if(ticket&gt;0 &amp;&amp; modified)
                 {
                  setProtectionSeparately=true;
                  Print(&quot;Detected ECN type position protection.&quot;);
                 }
              }
            }            [/b]
          
           }
        }

      if(ticket&gt;0) break;

      lastError=GetLastError();

      if(lastError!=135 &amp;&amp; lastError!=136 &amp;&amp; lastError!=137 &amp;&amp; lastError!=138) break;

      Sleep(TRADE_RETRY_WAIT);
      Print(&quot;Open Position retry no: &quot;+IntegerToString(attempt+2));
     }
  }</code></pre></div><br /><p>So i have made an if.</p><p>if choose true than it use anoother OrderSend with my stopLoss and tp from input.<br />But not working</p><p>any idea how to get it run easily.</p>]]></description>
			<author><![CDATA[null@example.com (Roughey)]]></author>
			<pubDate>Thu, 11 Nov 2021 06:28:33 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/66859/#p66859</guid>
		</item>
	</channel>
</rss>
