 <?xml-stylesheet type="text/css" href="http://wealth-lab.net/Data/style/rss1.css" ?> <?xml-stylesheet type="text/xsl" href="http://wealth-lab.net/Data/style/rss1.xsl" ?>
<rss version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd">
  <channel>
    <title>How to</title>
    <link>http://wealth-lab.net/home.aspx</link>
    <description />
    <docs>http://www.rssboard.org/rss-specification</docs>
    <generator>mojoPortal Blog Module</generator>
    <ttl>120</ttl>
    <itunes:owner />
    <itunes:explicit>no</itunes:explicit>
    <itunes:category text="Extensions" />
    <itunes:category text="iTunes" />
    <item>
      <title>Открывать позиции в WLD с защитой стопом</title>
      <description><![CDATA[<script type="text/javascript" src="http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js"></script><script type="text/javascript" src="http://alexgorbatchev.com/pub/sh/current/scripts/shAutoloader.js"></script><script type="text/javascript" src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCSharp.js"></script>
<link href="http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css" rel="stylesheet" type="text/css" />
<p>
	В примерах стратегий часто можно видеть такие конструкции:</p>
<pre class="brush: csharp">
Position p = BuyAtLimit(bar + 1, Close[bar]);
if (p != null)
{
 SellAtLimit(bar + 1, p, p.EntryPrice + DEVIATION1);
 SellAtStop(bar + 1, p, p.EntryPrice - DEVIATION2);
}
</pre>
<script type="text/javascript">SyntaxHighlighter.all()</script>
<p>
	Такой код работает на истории, правда есть нюанс - что если цена внутри бара меняется в другом порядке, сначала реализуется цена для выхода, а потом для входа? Но этот пост о другом, как реализовать этот код в стратегии для реальной торговли?</p>
<p>
	В квике есть заявки типа с условием «по исполнению».</p>
<blockquote>
	<p>
		<strong><em>Заявки «по исполнению»</em></strong> представляют собой условные заявки, условием активации (начала проверки их стоп-цены сервером QUIK) которых является исполнение определенной активной заявки (далее называемой «заявкой-условием»). Такие заявки могут применяться, например, для закрытия позиции по инструменту, открываемой данной активной заявкой.</p>
	<p>
		Исполнение одной активной заявки может вызывать активацию нескольких заявок «по исполнению» разных типов.</p>
</blockquote>
<p>
	Как выставить такие заявки в Квик при торговле через наш адаптер можно прочитать в разделе <a href="http://www.wealth-lab.net/OnExecution-order.aspx">Community</a>.</p>
<br /><a href='http://wealth-lab.net/open-position-wld-with-stop-limit.aspx'>Admin</a>&nbsp;&nbsp;<a href='http://wealth-lab.net/open-position-wld-with-stop-limit.aspx'>...</a><a class='tweetthislink' title='Tweet This' href='http://twitter.com/home?status=%d0%9e%d1%82%d0%ba%d1%80%d1%8b%d0%b2%d0%b0%d1%82%d1%8c+%d0%bf%d0%be%d0%b7%d0%b8%d1%86%d0%b8%d0%b8+%d0%b2+WLD+%d1%81+%d0%b7%d0%b0%d1%89%d0%b8%d1%82%d0%be%d0%b9+%d1%81%d1%82%d0%be%d0%bf%d0%be%d0%bc+http%3a%2f%2fwealth-lab.net%2fopen-position-wld-with-stop-limit.aspx'><img src='http://wealth-lab.net/Data/SiteImages/tweetthis3.png' alt='Tweet This' /></a><div class='fblikebutton'><iframe src='http://www.facebook.com/plugins/like.php?href=http%3a%2f%2fwealth-lab.net%2fopen-position-wld-with-stop-limit.aspx&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;height=35&amp;action=like&amp;colorscheme=light' scrolling='no' frameborder='0' allowTransparency='true' style='border:none; overflow:hidden;width:450px; height:35px;'></iframe></div>]]></description>
      <link>http://wealth-lab.net/open-position-wld-with-stop-limit.aspx</link>
      <comments>http://wealth-lab.net/open-position-wld-with-stop-limit.aspx</comments>
      <guid isPermaLink="true">http://wealth-lab.net/open-position-wld-with-stop-limit.aspx</guid>
      <pubDate>Tue, 21 Aug 2012 12:30:00 GMT</pubDate>
    </item>
    <item>
      <title>Настройка параметров стратегии</title>
      <description><![CDATA[<script type="text/javascript" src="http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js"></script><script type="text/javascript" src="http://alexgorbatchev.com/pub/sh/current/scripts/shAutoloader.js"></script><script type="text/javascript" src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCSharp.js"></script>
	<link href="http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css" rel="stylesheet" type="text/css" />
<p>
	При созданиии стратегии вы можете создать несколько параметров стратегии, на основании которых, например, будут считаться различные индикаторы. Для этого вам нужно сделать следующие:</p>
<pre class="brush: csharp">
class MyStrategy : WealthScript 
{ 
 //Create parameters 
   private StrategyParameter param1; 
   private StrategyParameter param2; 
   public MyStrategy ()
   {
    param1= CreateParameter("Param1", 20, 1, 100, 1); 
    param2= CreateParameter("P", 50, 20, 300, 5);
   }
   protected override void Execute() 
   {
    //Do something 
   }
}
</pre>
<p>
	При этом в левом нижнем углу появится ползунок, с помощью которого можно плавно изменять значения параметров:</p>
<p>
	<img alt="" src="http://wealth-lab.net/Data/Sites/1/SharedFiles/doc/ans.jpg" style="width: 550px; height: 343px;" /> <script type="text/javascript">SyntaxHighlighter.all()</script></p>
<br /><a href='http://wealth-lab.net/tuning-strategy-parameters.aspx'>Alex</a>&nbsp;&nbsp;<a href='http://wealth-lab.net/tuning-strategy-parameters.aspx'>...</a><a class='tweetthislink' title='Tweet This' href='http://twitter.com/home?status=%d0%9d%d0%b0%d1%81%d1%82%d1%80%d0%be%d0%b9%d0%ba%d0%b0+%d0%bf%d0%b0%d1%80%d0%b0%d0%bc%d0%b5%d1%82%d1%80%d0%be%d0%b2+%d1%81%d1%82%d1%80%d0%b0%d1%82%d0%b5%d0%b3%d0%b8%d0%b8+http%3a%2f%2fwealth-lab.net%2ftuning-strategy-parameters.aspx'><img src='http://wealth-lab.net/Data/SiteImages/tweetthis3.png' alt='Tweet This' /></a><div class='fblikebutton'><iframe src='http://www.facebook.com/plugins/like.php?href=http%3a%2f%2fwealth-lab.net%2ftuning-strategy-parameters.aspx&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;height=35&amp;action=like&amp;colorscheme=light' scrolling='no' frameborder='0' allowTransparency='true' style='border:none; overflow:hidden;width:450px; height:35px;'></iframe></div>]]></description>
      <link>http://wealth-lab.net/tuning-strategy-parameters.aspx</link>
      <comments>http://wealth-lab.net/tuning-strategy-parameters.aspx</comments>
      <guid isPermaLink="true">http://wealth-lab.net/tuning-strategy-parameters.aspx</guid>
      <pubDate>Wed, 15 Aug 2012 06:52:00 GMT</pubDate>
    </item>
    <item>
      <title>Набор стратегий с разными параметрами</title>
      <description><![CDATA[<p>
	Как организовать&nbsp;несколько стратегий с одинаковой логикой,&nbsp;которые различаются набором параметров?</p>
<p>
	Предлагаем в таких случаях создать отдельную библиотеку, в которой&nbsp;поместить&nbsp;базовый класс. В базовом классе определить конструктор,&nbsp;который принимает&nbsp;на вход&nbsp;и инициализирует&nbsp;все&nbsp;параметры. Кроме этого, в базовом классе может&nbsp;быть определена&nbsp;вся торговая логика.</p>
<p>
	В классе-наследнике&nbsp;определяем конструктор по&nbsp;умолчанию, который передает&nbsp;конкретные&nbsp;параметры в базовый. Вся торговая&nbsp;логика уже реализована.&nbsp;Пример:</p>
<pre style="background: rgb(246, 248, 255); color: rgb(0, 0, 32);">
<code>
<span style="color: rgb(32, 0, 128); font-weight: bold;">namespace</span> WLRT<span style="color: rgb(48, 128, 128);">.</span>Strategyes
<span style="color: rgb(64, 96, 128);">{</span>
    <span style="color: rgb(32, 0, 128); font-weight: bold;">public</span> <span style="color: rgb(32, 0, 128); font-weight: bold;">abstract</span> <span style="color: rgb(32, 0, 128); font-weight: bold;">class</span> MyBaseStrategy <span style="color: rgb(48, 128, 128);">:</span> WealthLab<span style="color: rgb(48, 128, 128);">.</span>WealthScript
    <span style="color: rgb(64, 96, 128);">{</span>
        <span style="color: rgb(32, 0, 128); font-weight: bold;">private</span> <span style="color: rgb(32, 0, 128); font-weight: bold;">readonly</span> <span style="color: rgb(32, 0, 128); font-weight: bold;">double</span> _koeff<span style="color: rgb(64, 96, 128);">;</span>

        <span style="color: rgb(32, 0, 128); font-weight: bold;">protected</span> MyBaseStrategy<span style="color: rgb(48, 128, 128);">(</span><span style="color: rgb(32, 0, 128); font-weight: bold;">double</span> k<span style="color: rgb(48, 128, 128);">)</span>
        <span style="color: rgb(64, 96, 128);">{</span>
            _koeff <span style="color: rgb(48, 128, 128);">=</span> k<span style="color: rgb(64, 96, 128);">;</span>
        <span style="color: rgb(64, 96, 128);">}</span>

        <span style="color: rgb(32, 0, 128); font-weight: bold;">protected</span> <span style="color: rgb(32, 0, 128); font-weight: bold;">override</span> <span style="color: rgb(32, 0, 128); font-weight: bold;">sealed</span> Execute<span style="color: rgb(48, 128, 128);">(</span><span style="color: rgb(48, 128, 128);">)</span>
        <span style="color: rgb(64, 96, 128);">{</span>
            <span style="color: rgb(32, 0, 128); font-weight: bold;">if</span><span style="color: rgb(48, 128, 128);">(</span>_koeff<span style="color: rgb(48, 128, 128);">=</span><span style="color: rgb(48, 128, 128);">=</span><span style="color: rgb(0, 140, 0);">0</span><span style="color: rgb(48, 128, 128);">)</span> DoSmth<span style="color: rgb(48, 128, 128);">(</span><span style="color: rgb(48, 128, 128);">)</span><span style="color: rgb(64, 96, 128);">;</span>
            <span style="color: rgb(32, 0, 128); font-weight: bold;">else</span> DoSmthElse<span style="color: rgb(48, 128, 128);">(</span><span style="color: rgb(48, 128, 128);">)</span><span style="color: rgb(64, 96, 128);">;</span>
        <span style="color: rgb(64, 96, 128);">}</span>
    <span style="color: rgb(64, 96, 128);">}</span>

    <span style="color: rgb(32, 0, 128); font-weight: bold;">public</span> <span style="color: rgb(32, 0, 128); font-weight: bold;">sealed</span> <span style="color: rgb(32, 0, 128); font-weight: bold;">class</span> MyStrategy1 <span style="color: rgb(48, 128, 128);">:</span> MyBaseStrategy
    <span style="color: rgb(64, 96, 128);">{</span>
        <span style="color: rgb(32, 0, 128); font-weight: bold;">public</span> MyStrategy1<span style="color: rgb(48, 128, 128);">(</span><span style="color: rgb(48, 128, 128);">)</span> <span style="color: rgb(48, 128, 128);">:</span> <span style="color: rgb(32, 0, 128); font-weight: bold;">base</span><span style="color: rgb(48, 128, 128);">(</span><span style="color: rgb(0, 140, 0);">1</span><span style="color: rgb(48, 128, 128);">)</span>
        <span style="color: rgb(64, 96, 128);">{</span>
        <span style="color: rgb(64, 96, 128);">}</span>
    <span style="color: rgb(64, 96, 128);">}</span>
<span style="color: rgb(64, 96, 128);">}</span>
</code></pre>
<p>
	&nbsp;</p>
<br /><a href='http://wealth-lab.net/набор-стратегий-с-разными-параметрами.aspx'>Admin</a>&nbsp;&nbsp;<a href='http://wealth-lab.net/набор-стратегий-с-разными-параметрами.aspx'>...</a><a class='tweetthislink' title='Tweet This' href='http://twitter.com/home?status=%d0%9d%d0%b0%d0%b1%d0%be%d1%80+%d1%81%d1%82%d1%80%d0%b0%d1%82%d0%b5%d0%b3%d0%b8%d0%b9+%d1%81+%d1%80%d0%b0%d0%b7%d0%bd%d1%8b%d0%bc%d0%b8+%d0%bf%d0%b0%d1%80%d0%b0%d0%bc%d0%b5%d1%82%d1%80%d0%b0%d0%bc%d0%b8+http%3a%2f%2fwealth-lab.net%2f%d0%bd%d0%b0%d0%b1%d0%be%d1%80-%d1%81%d1%82%d1%80%d0%b0%d1%82%d0%b5%d0%b3%d0%b8%d0%b9-%d1%81-%d1%80%d0%b0%d0%b7%d0%bd%d1%8b%d0%bc%d0%b8-%d0%bf%d0%b0%d1%80%d0%b0%d0%bc%d0%b5%d1%82%d1%80%d0%b0%d0%bc%d0%b8.aspx'><img src='http://wealth-lab.net/Data/SiteImages/tweetthis3.png' alt='Tweet This' /></a><div class='fblikebutton'><iframe src='http://www.facebook.com/plugins/like.php?href=http%3a%2f%2fwealth-lab.net%2f%d0%bd%d0%b0%d0%b1%d0%be%d1%80-%d1%81%d1%82%d1%80%d0%b0%d1%82%d0%b5%d0%b3%d0%b8%d0%b9-%d1%81-%d1%80%d0%b0%d0%b7%d0%bd%d1%8b%d0%bc%d0%b8-%d0%bf%d0%b0%d1%80%d0%b0%d0%bc%d0%b5%d1%82%d1%80%d0%b0%d0%bc%d0%b8.aspx&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;height=35&amp;action=like&amp;colorscheme=light' scrolling='no' frameborder='0' allowTransparency='true' style='border:none; overflow:hidden;width:450px; height:35px;'></iframe></div>]]></description>
      <link>http://wealth-lab.net/набор-стратегий-с-разными-параметрами.aspx</link>
      <comments>http://wealth-lab.net/набор-стратегий-с-разными-параметрами.aspx</comments>
      <guid isPermaLink="true">http://wealth-lab.net/набор-стратегий-с-разными-параметрами.aspx</guid>
      <pubDate>Thu, 17 May 2012 09:43:00 GMT</pubDate>
    </item>
  </channel>
</rss>