<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Forex Software — Use Trailing stop without settings of strategy]]></title>
	<link rel="self" href="https://forexsb.com/forum/feed/atom/topic/9898/" />
	<updated>2025-01-24T17:40:08Z</updated>
	<generator>PunBB</generator>
	<id>https://forexsb.com/forum/topic/9898/use-trailing-stop-without-settings-of-strategy/</id>
		<entry>
			<title type="html"><![CDATA[Re: Use Trailing stop without settings of strategy]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/82446/#p82446" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Popov wrote:</cite><blockquote><p>You can make a &quot;MQL script&quot; that loops over all the open positions and modify the SL as needed.<br />You can make a separate script for each case. </p><p>Here is how we loop over the positions:<br /></p><div class="codebox"><pre><code>   for(int i = PositionsTotal() - 1; i &gt;= 0; i -= 1)
     {
      const ulong ticket = PositionGetTicket(i);
      if(ticket == 0 || !PositionSelectByTicket(ticket))
         continue;

      const string posSymbol = PositionGetString (POSITION_SYMBOL);
      const long   posMagic  = PositionGetInteger(POSITION_MAGIC);

      // ...
     }</code></pre></div><p>Take a look at these two functions:<br /> - <strong>GetTrailingStopPrice</strong> - it calculates the new value of Traling SL according to the current price and a given Stop Loss</p><p> - <strong>ManageTrailingStop</strong> - it either closes a position or modifies it if the SL needs trailing</p><p>- <strong>ModifyPosition</strong> - does the actual SL modification (Trailing)</p><p>Look for these function in a Portfolio Expert or in a single Expert file</p></blockquote></div><p>ok thanks i will try</p>]]></content>
			<author>
				<name><![CDATA[Roughey]]></name>
				<uri>https://forexsb.com/forum/user/10939/</uri>
			</author>
			<updated>2025-01-24T17:40:08Z</updated>
			<id>https://forexsb.com/forum/post/82446/#p82446</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Use Trailing stop without settings of strategy]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/82404/#p82404" />
			<content type="html"><![CDATA[<p>You can make a &quot;MQL script&quot; that loops over all the open positions and modify the SL as needed.<br />You can make a separate script for each case. </p><p>Here is how we loop over the positions:<br /></p><div class="codebox"><pre><code>   for(int i = PositionsTotal() - 1; i &gt;= 0; i -= 1)
     {
      const ulong ticket = PositionGetTicket(i);
      if(ticket == 0 || !PositionSelectByTicket(ticket))
         continue;

      const string posSymbol = PositionGetString (POSITION_SYMBOL);
      const long   posMagic  = PositionGetInteger(POSITION_MAGIC);

      // ...
     }</code></pre></div><p>Take a look at these two functions:<br /> - <strong>GetTrailingStopPrice</strong> - it calculates the new value of Traling SL according to the current price and a given Stop Loss</p><p> - <strong>ManageTrailingStop</strong> - it either closes a position or modifies it if the SL needs trailing</p><p>- <strong>ModifyPosition</strong> - does the actual SL modification (Trailing)</p><p>Look for these function in a Portfolio Expert or in a single Expert file</p>]]></content>
			<author>
				<name><![CDATA[Popov]]></name>
				<uri>https://forexsb.com/forum/user/2/</uri>
			</author>
			<updated>2025-01-18T20:45:47Z</updated>
			<id>https://forexsb.com/forum/post/82404/#p82404</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Use Trailing stop without settings of strategy]]></title>
			<link rel="alternate" href="https://forexsb.com/forum/post/82401/#p82401" />
			<content type="html"><![CDATA[<p>Hi,</p><p>we have now a trailing stop integrated in the code. But it uses the trailing from the strategy each. Now i think about how can we change the code so i use a trailing stop for all strategys with same global settings. So the trailing not depends on the strategy but for all on the magicnumber. Maybe @Popov can help.</p>]]></content>
			<author>
				<name><![CDATA[Roughey]]></name>
				<uri>https://forexsb.com/forum/user/10939/</uri>
			</author>
			<updated>2025-01-18T08:55:55Z</updated>
			<id>https://forexsb.com/forum/post/82401/#p82401</id>
		</entry>
</feed>
