<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Forex Software — Averaging improved modification]]></title>
		<link>https://forexsb.com/forum/topic/1157/averaging-improved-modification/</link>
		<atom:link href="https://forexsb.com/forum/feed/rss/topic/1157/" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Averaging improved modification.]]></description>
		<lastBuildDate>Mon, 04 Jan 2010 22:19:58 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Averaging improved modification]]></title>
			<link>https://forexsb.com/forum/post/4110/#p4110</link>
			<description><![CDATA[<p>I&#039;m closing this thread since a proper averaging is included in the distributed expert.</p>]]></description>
			<author><![CDATA[null@example.com (Popov)]]></author>
			<pubDate>Mon, 04 Jan 2010 22:19:58 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/4110/#p4110</guid>
		</item>
		<item>
			<title><![CDATA[Re: Averaging improved modification]]></title>
			<link>https://forexsb.com/forum/post/3654/#p3654</link>
			<description><![CDATA[<p>Hi Miroslav, </p><p>thanks a lot for your explanation, it really helps a lot. I will go through everything in detail and try to come up with an implementation on what you suggested. </p><p>For me, the possibility of having the EA close and reopen the trades is not an option as the spread cost is way too much for my taste, so for sure it has to be a solution based on the virtual position and partial close/open of orders. </p><p>One thing I observed on my currrent mod 4 is as you said, the time it takes to handle 20 orders is quite a lot, and some of them close several minutes appart for some reason. So some work needs to be done in that front too, I checked my code and I believe there is some redundant code that might be causing the extra delay. I will post here any progress I make.</p><p>Thanks.</p>]]></description>
			<author><![CDATA[null@example.com (Nick)]]></author>
			<pubDate>Fri, 27 Nov 2009 00:15:24 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/3654/#p3654</guid>
		</item>
		<item>
			<title><![CDATA[Re: Averaging improved modification]]></title>
			<link>https://forexsb.com/forum/post/3640/#p3640</link>
			<description><![CDATA[<p>Probably we can workaround SL/TP modifications. It&#039;s possible SL / TP to be saved in the&nbsp; global posAvrgStopLoss and posAvrgTakeProfit at every signal from FST. At the same time to send&nbsp; OrderSend without SL and TP. After that a function CheckSLandTP(symbol) to be called at every tick.</p><p>prototype:<br /></p><div class="codebox"><pre><code>int CheckStopLossAndTakeProfit(symbol)
{
   if (posAvrgType == Long)
   {
      if(posAvrgStopLoss  &gt; 0)
         if(MarketInfo(symbol, MODE_BID) &lt; posAvrgStopLoss + Point / 2)
            CloseAll();
      if(posAvrgTakeProfit &gt; 0)
         if(MarketInfo(symbol, MODE_BID) &gt; posAvrgTakeProfit - Point / 2)
            CloseAll();
   }
   
   if (posAvrgType == Short)
   {
      if(posAvrgStopLoss  &gt; 0)
         if(MarketInfo(symbol, MODE_ASK) &gt; posAvrgStopLoss - Point / 2)
            CloseAll();
      if(posAvrgTakeProfit &gt; 0)
         if(MarketInfo(symbol, MODE_ASK) &lt;  posAvrgTakeProfit + Point / 2)
            CloseAll();
   }
}</code></pre></div><p>Pros:<br />&nbsp; - it is not necessary to modify SL and TP at every adding or reducing</p><p>Cons:<br />&nbsp; - The orders haven&#039;t got SL and TP. That is dangerous because of possible failure of the net connection or software.</p>]]></description>
			<author><![CDATA[null@example.com (Popov)]]></author>
			<pubDate>Thu, 26 Nov 2009 14:06:58 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/3640/#p3640</guid>
		</item>
		<item>
			<title><![CDATA[Re: Averaging improved modification]]></title>
			<link>https://forexsb.com/forum/post/3637/#p3637</link>
			<description><![CDATA[<p>Let me show you in a live account how the orders are taken. I am usin a fixed 100 pips stop and a fixed 176 TP. I am usind add as the Same direction signal. As I was saying the FST is setting these TP and PL at each order independently. It does not keep the TP and SL set by the fisrt order. I truly hope that FSB is acting in the same way. Else I will have to rethink the strategy. Thank you. <br /><a href="http://www.postimage.org/"><span class="postimg"><img src="http://s3.postimage.org/1qAdiA.jpg" alt="http://s3.postimage.org/1qAdiA.jpg" /></span></a></p>]]></description>
			<author><![CDATA[null@example.com (majorusa)]]></author>
			<pubDate>Thu, 26 Nov 2009 11:57:41 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/3637/#p3637</guid>
		</item>
		<item>
			<title><![CDATA[Re: Averaging improved modification]]></title>
			<link>https://forexsb.com/forum/post/3634/#p3634</link>
			<description><![CDATA[<p>Years ago when I&#039;ve started FSB development I was in front of the dilemma how to treat SL and TP. <br />Finally I decided that the SL and TP have to be readjusted at every adding or reducing. My logic was:</p><p>The strategy must be objective and to analyze the market at the exact moment of entry. That decision includes the entry direction, the entry price (or time), trading size, SL and TP. The strategy should look at the market only when rises a signal. But several situations are possible depending on what our position was just before the signal.</p><p>Let say we have a buy signal and the present position was:</p><p>- Square: We open new long position;<br />- Long: We add to the current position;<br />- Short: (Depending on the lots) - Reducing, Closing or Reversing.</p><p>The user can decide how the strategy to react on these situations by changing the same/ opposite signal options but the important is that the logic behind these signals is the same. So the SL and TP have to be readjusted at every execution. That&#039;s why I requested the SL and TP to be changed for the previously opened positions in the Nick&#039;s code. SL and TP have to be equal for all positions and have to be readjusted after adding, reducing, trailing stop move or manual SL/TP modification from FST.</p><p>Please note that FST doesn&#039;t modify SL / TP during automatic trade. SL/TP are set at entry only. An exception is Trailing Stop but it&#039;s code is in the expert.</p><p>Actually FSB deals with SL/TP in different way. It sends OCO stop and limit pending orders to every open position and OCO stop and limit IF orders to the pending orders. (You can see these orders in the FSB&#039;s journal). On the other hand FST uses SL/TP features of MetaTrader. The end result is the same. The only problem is the unavailability of MT to add to a position.</p><p>FSB averages the price of a position after adding and sets new SL and TP. The current Nick&#039;s code leaves the SL/TP of the previously opened position unchanged. That may result in closing of these positions at their SL / TP which will be a reduction of the virtual averaged position. That reduction will not be because of an opposite&nbsp; entry signal like in FSB.</p><p>I&#039;m not sure how MT will deal with multiple OrderModify() and OrderClose() in case of 10-20 positions. Probably it will be OK. We&#039;ll see it soon.</p>]]></description>
			<author><![CDATA[null@example.com (Popov)]]></author>
			<pubDate>Thu, 26 Nov 2009 10:07:39 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/3634/#p3634</guid>
		</item>
		<item>
			<title><![CDATA[Re: Averaging improved modification]]></title>
			<link>https://forexsb.com/forum/post/3632/#p3632</link>
			<description><![CDATA[<p>Yes you are right, the SL handling is not quite there yet in my mod, and it is a problem if the strategy uses them. For now I just design my strategies without SL and TP, I never liked them anyway. At some point I hope to look into more detail about how the backtester treats the combined SL/TP and modify the mod accordingly, unless someone else does it before me <img src="https://forexsb.com/forum/img/smilies/smile.png" width="15" height="15" alt="smile" /></p><p>Mr Popov is already looking into multiple pairs, I believe will be possible soon. There is another topic for that <img src="https://forexsb.com/forum/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[null@example.com (Nick)]]></author>
			<pubDate>Thu, 26 Nov 2009 09:02:44 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/3632/#p3632</guid>
		</item>
		<item>
			<title><![CDATA[Re: Averaging improved modification]]></title>
			<link>https://forexsb.com/forum/post/3631/#p3631</link>
			<description><![CDATA[<p>One simple thought. If you change the EA to act differently than it acts currently meaning - each position is open by closing the previous one with its own SL and TP then the FSB should be changed accordingly. Else you will end up with a strategy tested in a way by the FSB and traded differently by the FST. It is a recipe for disaster. I am using FST in live and works ok. My main issue is the imposibillity to trade multiple pairs. I am trading two pairs now and I am using two computers for it. That is why I salute your magic number initiative. But how can I run on the same PC two instances of the FST? I thik Mr. Popov will be the only one to help with this. </p><p>Anyhow , great work so far!</p>]]></description>
			<author><![CDATA[null@example.com (majorusa)]]></author>
			<pubDate>Thu, 26 Nov 2009 08:55:05 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/3631/#p3631</guid>
		</item>
		<item>
			<title><![CDATA[Re: Averaging improved modification]]></title>
			<link>https://forexsb.com/forum/post/3611/#p3611</link>
			<description><![CDATA[<p>Mod 4.</p><p>I made modifications to fix the problem with the partial orders close in position reduction mode, fix the problem of single order management, and allow the user to limit the EA to its own orders only (with extern parameter).</p><p>I think the position reverse needs looking into as well, not sure it will work as it is.</p><p>This is an untested version.</p>]]></description>
			<author><![CDATA[null@example.com (Nick)]]></author>
			<pubDate>Wed, 25 Nov 2009 04:09:59 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/3611/#p3611</guid>
		</item>
		<item>
			<title><![CDATA[Re: Averaging improved modification]]></title>
			<link>https://forexsb.com/forum/post/3610/#p3610</link>
			<description><![CDATA[<div class="quotebox"><cite>Popov wrote:</cite><blockquote><p>- When adds to a position(s) the expert must change the SL and TP of all the previous opened positions. All positions must be with equal SL and TP and that has to be reported to FST.</p></blockquote></div><p>So for example, if we buy 1 lot at 1.5100 with SL 10 pips lets say SL will be 1.5090 (lets ignore spread for now). </p><p>Then if the price goes to 1.5200 and we want to add 1 more lot, the 2nd position SL (for 10 pips SL) will be 1.5190.</p><p>At this moment, the EA will report back 1 virtual position of price the average of the 2 entries = 1.5150, and virtual SL the average of the 2 SL = 1.5140. So the FST sees 1 virtual order.</p><p>So what is the problem with this? because I can&#039;t understand why we need to change the previous order SL <img src="https://forexsb.com/forum/img/smilies/smile.png" width="15" height="15" alt="smile" /></p><p>Or maybe it&#039;s wrong to report back the average of the 2 as entry price, and we should report the first order entry only as order entry price, just with increased lot size = the total lot size? How is this best to match the engine of FSB? (I mean to make the real execution as close to the backtest as possible). I dont know how FSB handles an order when we have added to it. Which is the combined order open price and SL/TP?</p><p>Thanks</p>]]></description>
			<author><![CDATA[null@example.com (Nick)]]></author>
			<pubDate>Wed, 25 Nov 2009 00:55:17 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/3610/#p3610</guid>
		</item>
		<item>
			<title><![CDATA[Re: Averaging improved modification]]></title>
			<link>https://forexsb.com/forum/post/3608/#p3608</link>
			<description><![CDATA[<p>sounds good. I think we can add an option to the EA, if user wants the EA to specify magic then it will handle it&#039;s own trades, otherwise it will be like now, all trades on the symbol.</p><p>Thanks!</p>]]></description>
			<author><![CDATA[null@example.com (Nick)]]></author>
			<pubDate>Tue, 24 Nov 2009 23:40:55 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/3608/#p3608</guid>
		</item>
		<item>
			<title><![CDATA[Re: Averaging improved modification]]></title>
			<link>https://forexsb.com/forum/post/3607/#p3607</link>
			<description><![CDATA[<div class="quotebox"><blockquote><p>1. Added function MagicFromSymbol() to auto calculate a magic number depending on the current symbol. I wanted to include this in order send, but then I realised that FST sends an argument with magic number information, so for the moment my MagicNumber is not being used. I would like to know your opinion about this. The idea was to include checking based on magic on each order before modify or close, to make sure it belongs to the EA (in case we are also trading other EA or manually on the same account and symbol).</p></blockquote></div><p>FST doesn&#039;t use the magic number. It only copies and resends it. My idea was one to be able to trade manually together with FST. Manual and automated trade at the same as a collaboration. FST is stateless and adopts the trading according to the current environment. It loads account, market and positions info at every tick/ping. So a trader can execute an entry manually (from FST or from MT) and FST to close it according to the strategy. Or&nbsp; a trader can close the automatically opened position without problems.&nbsp; Thinking in that direction FST should know about all the opened positions for the symbol. But if you want you can make exceptions (special magics) that makes a position(s) invisible for the program.</p>]]></description>
			<author><![CDATA[null@example.com (Popov)]]></author>
			<pubDate>Tue, 24 Nov 2009 23:17:15 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/3607/#p3607</guid>
		</item>
		<item>
			<title><![CDATA[Re: Averaging improved modification]]></title>
			<link>https://forexsb.com/forum/post/3606/#p3606</link>
			<description><![CDATA[<p>thanks Miroslav, </p><p>nice observations. I will look into these issues and let you know.</p><p>Edit: I updated the file in the post above with what I think fixes the single order error. Can&#039;t test it right now, but will test later and will try to implement the other suggestions.</p><p>Thanks</p>]]></description>
			<author><![CDATA[null@example.com (Nick)]]></author>
			<pubDate>Tue, 24 Nov 2009 22:58:18 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/3606/#p3606</guid>
		</item>
		<item>
			<title><![CDATA[Re: Averaging improved modification]]></title>
			<link>https://forexsb.com/forum/post/3605/#p3605</link>
			<description><![CDATA[<p>I didn&#039;t check your code thoroughly yet but it looks promising at first glance.</p><p>Some issues:<br />- when you attach expert on a chart with one open position the expert doesn&#039;t reports properly to FST (the &quot;start execution&quot; button changes to grey). The same is when you open your very first trade on FSB. </p><p>- When adds to a position(s) the expert must change the SL and TP of all the previous opened positions. All positions must be with equal SL and TP and that has to be reported to FST.</p><p>- When you reduce a position the expert closes all opened positions instead only one with the same lots. If there is no position with the same lots, the expert must close some other and to open a new with lots = oldLots - reducingLots.</p><br /><p>Edit:</p><p>Check all the operations with different lots, SL and TP manually. If they work manually, the will work automatically also. The only problem I see is the necessary time for managing multiple orders.</p><p>PS</p><p>It&#039;s nice you have added some error checks and a cycle for order execution.</p>]]></description>
			<author><![CDATA[null@example.com (Popov)]]></author>
			<pubDate>Tue, 24 Nov 2009 22:53:08 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/3605/#p3605</guid>
		</item>
		<item>
			<title><![CDATA[Re: Averaging improved modification]]></title>
			<link>https://forexsb.com/forum/post/3604/#p3604</link>
			<description><![CDATA[<p>First thank you for the detailed change log. </p><p>I downloaded successfully your expert and I&#039;m going to test it.</p>]]></description>
			<author><![CDATA[null@example.com (Popov)]]></author>
			<pubDate>Tue, 24 Nov 2009 22:16:40 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/3604/#p3604</guid>
		</item>
		<item>
			<title><![CDATA[Re: Averaging improved modification]]></title>
			<link>https://forexsb.com/forum/post/3602/#p3602</link>
			<description><![CDATA[<p>I have added virtual order reporting (used weighting according to lots relative to total lot size). I checked with some print statements that the position type is reported correctly and&nbsp; that the rest positions are averaged correctly (I have already some sell trades open and the EA identifies them as virtual type 1)</p><p>I hope this helps.</p><p>PS: the forum time is off by 1 hour (shows 1 hour more than it should be).</p><p>Edit: hopefully fixed the single order error</p>]]></description>
			<author><![CDATA[null@example.com (Nick)]]></author>
			<pubDate>Tue, 24 Nov 2009 21:49:59 +0000</pubDate>
			<guid>https://forexsb.com/forum/post/3602/#p3602</guid>
		</item>
	</channel>
</rss>
