robot. StockSharphttps://stocksharp.com/handlers/atom.ashx?category=tag&id=robot&type=communityCopyright @ StockSharp Platform LLC 2010 - 20242024-03-28T08:52:55Zhttps://stocksharp.com/images/logo.pnghttps://stocksharp.com/topic/15389/Share your projects with us! And make it visible for the world!2021-03-04T12:51:20Z2021-03-04T12:51:20ZILYAhttps://stocksharp.com/users/127794/info@stocksharp.com<a href='https://stocksharp.com/file/120478/stocksharp-software-development_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/120478/stocksharp-software-development_png/?size=500x500" alt="stocksharp-software-development.png" title="stocksharp-software-development.png" /></a><br /><br />Dear friends!<br /><br />Many of you have been using our platform for quite a long time and the programs built on it. With the help of <a href="https://stocksharp.com/products/api/" title="https://stocksharp.com/products/api/">S#.API</a> library many of you <b>created own applications, built connectors and utility which helping to solve your problems.</b> But what if your application may help other users? Perhaps you want to share some of your pre-built projects with other members to contribute in a community?<br /><br />Send us detailed description about your projects to <a href="mailto:info@stocksharp.com">info@stocksharp.com</a>:<br />- Describe your application you willing to share with others<br />- Will you charge for your application or is it completely free?<br />- Explain about all essentials functions and features you consider important.<br /><br /><span style="color:red"><span style="font-size:140%">On the grounds of this, we will make the most interesting applications available to a wide range of users through</span></span> <a href="https://stocksharp.com/articles/12374/Assign-install-and-work-with-SInstaller/" title="https://stocksharp.com/articles/12374/Assign-install-and-work-with-SInstaller/">S#.Installer</a>. And of course, we will indicate that you are the author of the product! We are waiting for you! [happy]<br /><br />In conclusion, the most interesting and advanced projects <span style="color:red"><span style="font-size:140%">will be available through Installer for a broad audience</span></span>. And of course, the author of the application will be shown and all rights will be reserved.https://stocksharp.com/topic/14714/StockSharp online store!2020-11-19T12:47:28Z2020-11-19T16:23:10ZILYAhttps://stocksharp.com/users/127794/info@stocksharp.com<h2><span style="color:red">Good news everyone!</span></h2><br /><br /><a href='https://stocksharp.com/file/116904/algo-trading-online-store_jpg/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/116904/algo-trading-online-store_jpg/?size=500x500" alt="algo-trading-online-store.jpg" title="algo-trading-online-store.jpg" /></a><br /><br />Welcome to our new online store! We've just opened a new online store which located in trading <a href="https://stocksharp.com/robot/" title="https://stocksharp.com/robot/">robot section</a> and warmly welcome you!<br /><br /><h2><b>From now on every of you can order any of our products and moreover you can publish and sell your products through our website, dear client! </b></h2><br /><br />Contact to our email <a href="mailto:info@stocksharp.com">info@stocksharp.com</a>, we will reply your questions and will provide assistant with your products.<br />https://stocksharp.com/topic/14627/Our new tech support service S#.Freelance!2020-10-29T14:42:45Z2020-10-29T14:42:45ZILYAhttps://stocksharp.com/users/127794/info@stocksharp.comDear friends,<br /><br /><b><em><h2>The great news is coming!</h2></em></b><br /><br /><a href='https://stocksharp.com/file/116649/algo-trading-news_jpg/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/116649/algo-trading-news_jpg/?size=500x500" alt="algo-trading-news.jpg" title="algo-trading-news.jpg" /></a> <br /><br />We are very pleased to announce that after months of hard work and dedication we launch <b><em>a new service</em></b> <a href="https://stocksharp.com/support/" title="https://stocksharp.com/support/">S#.Freelance</a>. <br /><br />By organically growing a strong trading <a href="https://stocksharp.com/community/" title="https://stocksharp.com/community/">community</a>, we receive more and more questions about our <a href="https://stocksharp.com/products/" title="https://stocksharp.com/products/">products</a>, <a href="https://stocksharp.com/support/" title="https://stocksharp.com/support/">S#.Freelance</a> <b><h2>is developed to make your life as a trader easier to find all necessary solutions and solve required tasks!</h2></b><br /><span style="color:red"><span style="font-size:140%">You can either be a freelancer to helping others or hire someone to get your projects done.</span></span><br /><br />The <b><em><u>S#</u></em></b> still constantly in touch with our community members on all critical issues and guarantees you a full transparency in receiving required services and making payments. <br /><br />We wish you a pleasant experience!<br />https://stocksharp.com/topic/12489/Principles for trading cryptocurrencies part 42020-09-22T13:21:42Z2020-09-22T13:21:42ZILYAhttps://stocksharp.com/users/127794/info@stocksharp.comIn today’s article we will review the significant part of trading analysis – <b>trading volume</b>.[happy]<br /><br />Let’s explain what trading volume is – <b><em>the whole amount of cryptocurrency units which trade on crypto exchanges that are traded on base of executed orders within considered period</em></b>. Obtaining this volume is important that’s why there’re many charts of trading volume. For example <b><u>the program software for downloading market data</u></b> <a href="https://stocksharp.com/products/hydra/" title="https://stocksharp.com/products/hydra/"><b><em><u>S#.Data(Hydra)</u></em></b></a> easily can build trading charts and trading volume charts, giving the trader to see and compare them in one work space flow. Definitely it will give you a wide picture for further analysis. [wink]<br /><br />For the analysis itself it’s crucial to know the volume indicator that occurs by reaching some fixed price level. Given information is a signal to start a trade or the opposite – to wait. <b><u>Volume chart can be vertical or horizontal, however the first one is more used by traders, </u></b>[nerd]<br />By building the graphs based on download market data in <a href="https://stocksharp.com/products/hydra/" title="https://stocksharp.com/products/hydra/"><b><u><em>Hydra</em></u></b></a> it has the same time period as for <b><em>candlestick chart and displays in the form of bars</em></b>.<br /><br /><a href='https://stocksharp.com/file/116286/download-market-data_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/116286/download-market-data_png/?size=500x500" alt="download-market-data.png" title="download-market-data.png" /></a><br /><br /><a href='https://stocksharp.com/file/116287/tradnig-volume_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/116287/tradnig-volume_png/?size=500x500" alt="tradnig-volume.png" title="tradnig-volume.png" /></a><br /><br /><br />In short words, if a trader builds a graph by trading volumes over the past 30 minutes then the bar value will indicate the whole cumulative volume of 30 minutes.[ninja]<br />By fact, one of the options using charts is to find the end of correction movement in a trend. <b><em>Thus, if the volume increased dramatically by the price which the direction is opposite to the trend therefore it might indicate the end of the trade itself.</em></b> This moment might be benefits for trade in the direction of a trend and often used for trading robots, particularly in <b><u>a constructor of trading robots</u></b> - <a href="https://stocksharp.com/products/designer/" title="https://stocksharp.com/products/designer/"><b><u><u>S#.Designer</u></u></b></a>. [love]<br />Also, you should keep in mind that a big trading volume of cryptocurrency not always indicates for beneficial price movement the cause of might be set aggressive orders.<br />In any case, if a trader gets an opportunity to use such financial instruments for analysis it will lead to reducing risk and gaining profits! <br />https://stocksharp.com/topic/12027/Crucial solutions in creating trading robots2020-08-11T13:48:03Z2020-08-11T13:48:03ZILYAhttps://stocksharp.com/users/127794/info@stocksharp.comTraders may face a problem if they want to create trading robots and one of the issues is the lack of programming knowledge. Not every trader can be a <em>programmer</em>. A <b>trader</b> may simulate a good trading system but have zero coding knowledge. Even if you know of the programming languages very well, you might need to learn another one but if you have 0 knowledge of programming then it can be very challenging. Of course, you can buy trading robot but always keep in mind that it’s not perfect and may have some bugs or problems which lead to difficulties in modifying <b>trading robot</b>. [nerd]<br /><br /><a href='https://stocksharp.com/file/115588/trading-robot_jpg/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/115588/trading-robot_jpg/?size=500x500" alt="trading-robot.jpg" title="trading-robot.jpg" /></a><br /><br />No worries here, there’s a solution. For example, our trading software - <a href="https://stocksharp.com/products/designer/" title="https://stocksharp.com/products/designer/">S#.Designer</a>. <b><em><u>It has the functions to create trading robots even with 0 knowledge of programming</u></em></b> with help of cubic system which represent an individual elements of trading strategies. And at the same time such strategy won't be having less functionality or reliability. <a href="https://stocksharp.com/products/designer/" title="https://stocksharp.com/products/designer/">S#.Designer</a> can combine and use the blocks (cubic) of code making strategies more flexible by your wish.[happy]<br /><br />Another disadvantage of trading robot is considered the lack of analyzing the current market conditions and trends. For sure, a <b><em>trading robot</em></b> is not an artificial intelligence and mostly depends human knowledge, however the knowledge of market with its technical analyse may minimize the problem. Using market data or other trading tools such as indicators or indexes which consist in <a href="https://stocksharp.com/products/designer/" title="https://stocksharp.com/products/designer/">S#.Designer</a> in a large amount, you will be able to create a robot more loyal to the market, expand the conditions, functionality and possibilities to react to a particular trading situation. [wink]<br /><br /><b><em><u>Automated trading systems</u></em></b> can participants of the exchange market huge opportunities for a trade, provide some benefits over those manual traders. In any market, a trading robot always perform its embedded algorithm. However, you must know, that a <b>trading robot </b><br />only a tool and you have to know monitor its work in order to correct some problems showed up. A <b>trader</b> should understand that <a href="https://stocksharp.com/products/designer/" title="https://stocksharp.com/products/designer/">S#.Designer</a> is not just create a robot, but also fill it with intelligence and logic, adding additional features and conditions. It also takes a step forward in creating more interactive and complex logic trading strategy that makes decision based on inputs which increases its profitability. [love]<br /><br /><a href='https://stocksharp.com/file/115589/algotrading_jpg/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/115589/algotrading_jpg/?size=500x500" alt="algotrading.jpg" title="algotrading.jpg" /></a><br />https://stocksharp.com/topic/12017/The benefits of using a trading robot2020-08-04T13:16:01Z2020-08-04T13:16:01ZILYAhttps://stocksharp.com/users/127794/info@stocksharp.comThe use of <b>trading robots</b> nowadays is essential part of trading and its process. In today’s article we will explain all advantages and benefits along with successful approaches of using <b>trading robots</b>.<br /><br /><a href='https://stocksharp.com/file/115426/algo-trading-robots_jpg/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/115426/algo-trading-robots_jpg/?size=500x500" alt="algo-trading-robots.jpg" title="algo-trading-robots.jpg" /></a><br /><br />1) The trading robot itself can’t make a mistake but only if a trader made this mistake by creating this robot. For example by creating a <b>trading robot </b>with <a href="https://stocksharp.com/products/api/" title="https://stocksharp.com/products/api/">S#.API</a> program, the user using tested and debugged libraries what makes the whole process of developing a <b>trading robot </b>way easier and the strategy itself is more stable. By placing an order, a correctly built a trading robot doesn't make any technical or syntactic errors, thus we don't face any failures and losses, as for example if the order has been placed manually. <br /><br />2) A<b> trading robot</b> has a technical ability to track hundreds of quotes at once instantly react at market changes, make necessary calculations by operating with a large number of conditions and a big amount of information making the right decision correlating to the base algorithm. The <b><em><u>API library</u></em></b> allows you to create a robot whose speed of data processing makes it possible immediately take into account the trends and conditions of the market. Traders which don't use trading robots are forced to reduce the amount of trading tools, increase the use of time intervals (timeframes) and leave the idea of perspective but complex trading systems.<br /><br />3) A <b>trading robot</b> doesn't have any <b>psychological effect</b> or influence, it works based on algorithm written in the code what makes it reliable and stable tool for placing orders and the whole trading process.<br /><br />4) Once you developed a trading robot then you don't have to spend days around the monitor rather let your advisor to handle all the work and monitor 24/7 the whole trading process and put orders. Only what you need to do is manage conditions and strategy behavior by using a library.<br /><br /><a href='https://stocksharp.com/file/115427/stock-market_jpg/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/115427/stock-market_jpg/?size=500x500" alt="stock-market.jpg" title="stock-market.jpg" /></a><br /><br />5) Ease and simplicity of a program for creating <b>robots</b> - <a href="https://stocksharp.com/products/shell/" title="https://stocksharp.com/products/shell/">S#.Shell</a> and stable libraries <a href="https://stocksharp.com/products/api/" title="https://stocksharp.com/products/api/">S#.API</a> allows you to fill your trading strategy with additional features setting and installing new tools such as <em><u>SMS notifications and remote control of trading systems</u></em>.<br /><br />We's explained some positive aspects of trading robots and in a next article we will analyse some disadvantages and try to reduce its impact on your trading strategy.<br />https://stocksharp.com/topic/12010/ Algo trading: What it means for Stock market? Part 22020-07-29T13:57:19Z2020-07-29T13:57:19ZILYAhttps://stocksharp.com/users/127794/info@stocksharp.comIn previous time we’ve reviewed and analysed trading software for <b>algorithmic trading</b>. Let’s continue our analysis of trading systems.<br /><br /><a href='https://stocksharp.com/file/115409/tradingsystems_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/115409/tradingsystems_png/?size=500x500" alt="tradingsystems.png" title="tradingsystems.png" /></a><br /><br /><br />- The next system will make <b>volume analysis</b>s of orders by tool and will determine the largest one. This system we call - <b>Front running</b>. A robot makes a decision where the largest order holds the price and force traders to trade in opposite direction.<br /><br />- Another popular trading system is <b>arbitrage algo robot</b>. By trading with this robot the trade continues by the tools where correlation of is almost equal to 1. By tool we meant stocks and futures. Shares of the same issuer in different <b>markets</b> are also used. The robot monitoring price flow of financial instruments and make mirror trades, sells one out and buys another to balance the price. One of such robots is <a href="https://stocksharp.com/robot/18/edward-scissorhands/" title="https://stocksharp.com/robot/18/edward-scissorhands/">"Edward - scissor hands"</a> which is a product of StockSharp company and able to do arbitrage trading and make a profit for traders.<br /><br />- One of the most complex in terms of knowledge and technical base is <b>volatility trading</b>. The original principle based on buying options of different types, taking that a potential growth of volatility of a securities with expectation that the volatility of a certain securities will growth.<br /><br /><a href='https://stocksharp.com/file/115410/trading_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/115410/trading_png/?size=500x500" alt="trading.png" title="trading.png" /></a><br /><br /> All represented types of algo trading have a myriad of trading systems. Our company developed such programs as <a href="https://stocksharp.com/products/designer/" title="https://stocksharp.com/products/designer/">S#.Designer</a> which allows traders to trade in any direction. The trader have an opportunity to build a robot with help of constructor and sets any parameters for strategy.<br /><br />More about S#.Designer you can find on our <a href="https://stocksharp.com/products/designer/" title="https://stocksharp.com/products/designer/">website</a>. <br />https://stocksharp.com/topic/11998/Algo trading: What it means for Stock market?2020-07-22T13:29:32Z2020-07-22T13:29:32ZILYAhttps://stocksharp.com/users/127794/info@stocksharp.com<em>Algo Trading's gained a big popularity in both Stock and Derivatives markets. These markets let you implement all features of algotrading.</em><br /><br />It's very common nowadays to use <b>automated trading software</b> and <b>trading advisors</b> by both big corporate and private companies. In both cases the competent use of the capabilities of <b>robots</b> is a vital tool which can reduce the risk that the level of profits forecasted might not be achieved along with all possible losses. The most active <b>market maker</b> is typically a large bank or institution, some of them are HFT divisions of Deutsche Bank, Goldman Sachs, Morgan Stanley and so on.<br /><br /><a href='https://stocksharp.com/file/115195/algotrading_jpg/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/115195/algotrading_jpg/?size=500x500" alt="algotrading.jpg" title="algotrading.jpg" /></a><br /><br />Let's review some types of <b>algotrading</b> which are widely used in Stock market:<br /><br /><b>- Trading systems which use technical indicators which can help to predict market performance and behaviour.<br /><br />- Trading robots that use a ratio on several tools, which have a relatively large percentage of correlation while it is not equal to 1. Tracking the deviations of these tools, the robot is selling and buying making a profit.<br /><br />- Broadly, a market maker is a trader that provides liquidity to both buy and sell products. Without market makers, there would likely be little liquidity and the system works because of market liquidity. The market maker get benefits and rewards from the trading platforms regardless the profit or loss.</b><br /><br /><a href='https://stocksharp.com/file/115196/marketmaker_jpg/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/115196/marketmaker_jpg/?size=500x500" alt="marketmaker.jpg" title="marketmaker.jpg" /></a><br /><br />With our programs, such as <a href="https://stocksharp.com/products/shell/" title="https://stocksharp.com/products/shell/">S#.Shell</a> и <a href="https://stocksharp.com/products/api/" title="https://stocksharp.com/products/api/">S#.API</a> you can create any types of trading robot. The software let your ability to create your own graphic interface to work with, and the API library can create a whole trading system. More detailed information you can find on our <a href="https://stocksharp.com/products/" title="https://stocksharp.com/products/">website</a>.<br />https://stocksharp.com/topic/10131/S#.UI - StockSharp Graphic Framework2018-11-15T16:25:45Z2018-11-26T22:13:12ZЮрий Басанговhttps://stocksharp.com/users/7/info@stocksharp.com<a href='https://stocksharp.com/file/108007/image3979_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108007/image3979_png/?size=500x500" alt="image3979.png" title="image3979.png" /></a><br /><br />In this paper, I will show how to use graphic components included in S#.API, in order to create a fully-featured application of the <a href="https://stocksharp.com/products/shell/" title="https://stocksharp.com/products/shell/">S#.Shell</a>:<br /><br />You will learn how to make a professional-level program with connection settings, output of securities, prices, and charts (and all this is saved and loaded upon restart). And the complexity of creating such an application is not a few months, but just a few hours (it is no joke! read to the end). This is the main advantage of the graphic framework, which I called by analogy S#.UI (this name is unofficial, I think it up myself).<br />I will not use complex constructs and design patterns that are understandable only to professional programmers. On the contrary, the paper's purpose is to show that the learning curve on creating your trading applications using S#.API is very short.<br />You will also be interested if you work in a company and make your own unique software (for example, you work in proprietary trading or a brokerage company). In this paper, you will be able to learn the practice of creating such systems (especially if you have just taken up your duties).<br /><br /><h2>What You Need</h2><br />1) Visual Studio 2017 (Community, free version), in which we will program.<br />2) Free connection to test exchange trading, I will use QUIK.<br /><br /><h2>Creating Project</h2><br />We create a new WPF application in Visual Studio.<br /><a href='https://stocksharp.com/file/108008/image5545_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108008/image5545_png/?size=500x500" alt="image5545.png" title="image5545.png" /></a><br />After that we need to add the S#.API libraries, and how to do this is described <a href="http://doc.stocksharp.com/html/b9f672db-e0c9-4208-9759-179e5de17fd8.htm" title="http://doc.stocksharp.com/html/b9f672db-e0c9-4208-9759-179e5de17fd8.htm">here</a>. I prefer installing with Nuget.<br />Since all S#.API graphic elements are based on DevExpress, and DevExpress libraries are included in S#.API, it would be foolish not to use them. All information about DevExpress graphic elements can be found in Google.<br />Let's go to the MainWindow.xaml window editor.<br /><a href='https://stocksharp.com/file/108009/image4259_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108009/image4259_png/?size=500x500" alt="image4259.png" title="image4259.png" /></a><br />We replace Window with DXWindow, we will need it to use different color schemes. <br /><a href='https://stocksharp.com/file/108010/image4329_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108010/image4329_png/?size=500x500" alt="image4329.png" title="image4329.png" /></a><br />Visual Studio will prompt us to add the necessary libraries.<br />We split the window into three parts, there will be a bar with buttons of connection setting and connection at the top. The window with logs will be below. All other panels are in the middle. The easiest way is to split the window in this way using LayoutControl from DevExpress.<br />We will add the elements we need to the resulting three parts.<br /><a href='https://stocksharp.com/file/108011/image2275_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108011/image2275_png/?size=500x500" alt="image2275.png" title="image2275.png" /></a><br /><br /><h2>Configuring Connection to Connector</h2><br />We add two buttons, one button to configure connection and the second button to connect. To do this, we use the SimpleButton button from DevExpress. The buttons will be located at the top of application. We will place pictures familiar with Terminal and Designer on each button.<br /><a href='https://stocksharp.com/file/108012/image9977_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108012/image9977_png/?size=500x500" alt="image9977.png" title="image9977.png" /></a><br />We will see such an image in the upper right corner of the screen form.<br /><a href='https://stocksharp.com/file/108013/image1157_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108013/image1157_png/?size=500x500" alt="image1157.png" title="image1157.png" /></a><br />We double-click each button to create button click event handlers.<br />In MainWindow code it is necessary to declare the connector, as well as the file location and name where the connector settings will be stored.<br /><a href='https://stocksharp.com/file/108014/image836_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108014/image836_png/?size=500x500" alt="image836.png" title="image836.png" /></a><br />We will open the connector configuration window in the connector settings button click event handler and save it to a file.<br /><a href='https://stocksharp.com/file/108015/image1289_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108015/image1289_png/?size=500x500" alt="image1289.png" title="image1289.png" /></a><br />We will check in the constructor whether there is a directory and a file with the connector settings and, if there is one, we will load it into the connector.<br /><a href='https://stocksharp.com/file/108016/image3497_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108016/image3497_png/?size=500x500" alt="image3497.png" title="image3497.png" /></a><br />Most S#.API objects have Save and Load methods, with which it is possible to save and load this object from an XML file.<br />We connect the connector in the connection button click event handler method.<br /><a href='https://stocksharp.com/file/108017/image6463_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108017/image6463_png/?size=500x500" alt="image6463.png" title="image6463.png" /></a><br />Now we can run the program and test it.<br /><br /><h2>Setting Dark Theme</h2><br />I prefer a dark theme. Therefore, we make the program theme dark at once. To do this in the App.xaml file <br /><a href='https://stocksharp.com/file/108018/image1012_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108018/image1012_png/?size=500x500" alt="image1012.png" title="image1012.png" /></a><br />We replace Application with charting:ExtendedBaseApplication. Visual Studio will prompt us to add the necessary libraries. And in the file App.xaml.cs delete ": Application". The code will be the following.<br /><a href='https://stocksharp.com/file/108019/image4777_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108019/image4777_png/?size=500x500" alt="image4777.png" title="image4777.png" /></a><br /><a href='https://stocksharp.com/file/108020/image9701_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108020/image9701_png/?size=500x500" alt="image9701.png" title="image9701.png" /></a><br />We write ApplicationThemeHelper.ApplicationThemeName = Theme.VS2017DarkName in the MainWindow constructor;<br />Full code at the moment:<br /><a href='https://stocksharp.com/file/108021/image8484_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108021/image8484_png/?size=500x500" alt="image8484.png" title="image8484.png" /></a><br />Run to check the dark theme.<br /><a href='https://stocksharp.com/file/108022/image1199_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108022/image1199_png/?size=500x500" alt="image1199.png" title="image1199.png" /></a><br /><br /><h2>Creating Security Panel</h2><br />We add the XAML folder where we will store all the created controls.<br />We add our first UserControll to the folder, let's call it SecurityGridControl.<br /><a href='https://stocksharp.com/file/108023/image5159_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108023/image5159_png/?size=500x500" alt="image5159.png" title="image5159.png" /></a><br />We add one SecurityPicker element to it. In which the available securities will be displayed. Similar to the main window, we will use LayoutControl from DevExpress.<br /><a href='https://stocksharp.com/file/108024/image2385_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108024/image2385_png/?size=500x500" alt="image2385.png" title="image2385.png" /></a><br />We go to the main window constructor and change the central part to the tab view. We place created control with SecurityPicker in one of the tabs.<br /><a href='https://stocksharp.com/file/108025/image5375_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108025/image5375_png/?size=500x500" alt="image5375.png" title="image5375.png" /></a><br />Now we have the security panel, we need to set it a data source, in our case it is a connector. It was possible to write SecurityPanel.SecPicker.SecurityProvider = Connector in MainWindow constructor.<br />But we will not place code in the MainWindow that is not related to it. Therefore, I will create the Instance static variable, and assign it the MainWindow value in the MainWindow constructor.<br /><a href='https://stocksharp.com/file/108026/image1508_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108026/image1508_png/?size=500x500" alt="image1508.png" title="image1508.png" /></a><br />Now we can call the MainWindow properties anywhere in our program using MainWindow.Instance.XXX code.<br />In the SecurityGridControl constructor, we specify Connector as a data source.<br /><a href='https://stocksharp.com/file/108027/image6003_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108027/image6003_png/?size=500x500" alt="image6003.png" title="image6003.png" /></a><br />We run the program to check.<br /><a href='https://stocksharp.com/file/108028/image8483_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108028/image8483_png/?size=500x500" alt="image8483.png" title="image8483.png" /></a><br /><br /><h2>Adding Logging</h2><br />The operation of the program, connector or robot must be monitored. For this purpose, S#.API has a special LogManager class. This class receives messages from sources and sends them to listeners. In our case, the sources will be Connector, strategies, etc., and listeners will be a file and log panel.<br />In the MainWindow code, we declare the LogManager object and the location where it will be stored.<br /><a href='https://stocksharp.com/file/108029/image3414_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108029/image3414_png/?size=500x500" alt="image3414.png" title="image3414.png" /></a><br />In the MainWindow constructor, we create LogManager, set in it Connector as the source, and a file as the listener.<br /><a href='https://stocksharp.com/file/108030/image5931_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108030/image5931_png/?size=500x500" alt="image5931.png" title="image5931.png" /></a><br />Similar to the security panel, we create a log panel, add another UserControl to the XAML folder. We call it MonitorControl. We add the Monitor element to it.<br /><a href='https://stocksharp.com/file/108031/image4717_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108031/image4717_png/?size=500x500" alt="image4717.png" title="image4717.png" /></a><br />In the MonitorControl constructor, we set Monitor as a listener in LogManager.<br /><a href='https://stocksharp.com/file/108032/image8141_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108032/image8141_png/?size=500x500" alt="image8141.png" title="image8141.png" /></a><br />We add the created MonitorControl to the bottom of MainWindow.<br /><a href='https://stocksharp.com/file/108033/image5572_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108033/image5572_png/?size=500x500" alt="image5572.png" title="image5572.png" /></a><br />We run the program to check.<br /><a href='https://stocksharp.com/file/108034/image6299_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108034/image6299_png/?size=500x500" alt="image6299.png" title="image6299.png" /></a><br /><br /><h2>Creating Portfolio Panel</h2><br />Similar to the security panel, we create a log panel, add another UserControl to the XAML folder. We call it PortfolioGridControl. We add the PortfolioGrid element to it.<br /><a href='https://stocksharp.com/file/108035/image68_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108035/image68_png/?size=500x500" alt="image68.png" title="image68.png" /></a><br />In PortfolioGridControl constructor, we need to subscribe to new portfolio appearance events and event of new position appearance at Connector.<br /><a href='https://stocksharp.com/file/108036/image1333_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108036/image1333_png/?size=500x500" alt="image1333.png" title="image1333.png" /></a><br />Thus, when a new portfolio appears, it will be displayed in the portfolio panel, and when a new position appears in the portfolio panel, the portfolio will update the position.<br />We add the created PortfolioGridControl panel to the central part of MainWindow.<br /><a href='https://stocksharp.com/file/108037/image127_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108037/image127_png/?size=500x500" alt="image127.png" title="image127.png" /></a><br />We run the program to check.<br /><a href='https://stocksharp.com/file/108038/image3862_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108038/image3862_png/?size=500x500" alt="image3862.png" title="image3862.png" /></a><br />We have a tab with portfolios.<br /><br /><h2>Creating Order Panel</h2><br />The order panel in S#.API has the ability to register orders, cancel orders and reregister them.<br />Similar to the security panel, we create an order panel, add another UserControl to the XAML folder. We call it OrderGridControl. We add the OrderGrid element to it.<br /><a href='https://stocksharp.com/file/108039/image4502_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108039/image4502_png/?size=500x500" alt="image4502.png" title="image4502.png" /></a><br />OrderGrid has the OrderRegistering event, the OrderReRegistering event, and the OrderCanceling event.<br />Let's create their handlers.<br /><a href='https://stocksharp.com/file/108040/image6128_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108040/image6128_png/?size=500x500" alt="image6128.png" title="image6128.png" /></a><br />In the order registration event handler, we create an OrderWindow window where we need to specify data sources for securities, portfolios, and market data. For all cases, this will be the Connector.<br />After that, we call OrderWindow using ShowModal method, if the OK button was clicked in this window, we register the order via the connector using the RegisterOrder method.<br /><a href='https://stocksharp.com/file/108041/image4848_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108041/image4848_png/?size=500x500" alt="image4848.png" title="image4848.png" /></a><br />We do the same in the order reregistration event handler. Only in this case the event receives the Order object - this is the order that needs to be reregistered. Therefore, in OrderWindow, we specify Order = order.ReRegisterClone(newVolume: order.Balance) to fill in the fields of the OrderWindow window.<br />After that, we call OrderWindow using ShowModal method, if the OK button was clicked in this window, we will reregister the order via connector using the ReRegisterClone method. We pass to it old order, which should be cancelled, and the new one, which should be registered.<br /><a href='https://stocksharp.com/file/108042/image1314_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108042/image1314_png/?size=500x500" alt="image1314.png" title="image1314.png" /></a><br />In the order canceling event handler, it is enough to call the CancelOrder method and pass to it the order that need to be canceled.<br /><a href='https://stocksharp.com/file/108043/image2355_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108043/image2355_png/?size=500x500" alt="image2355.png" title="image2355.png" /></a><br />In order for Orders to be displayed in the OrderGrid, it is necessary in the OrderGridControl constructor to subscribe to new order appearance events and to a registration error event and pass these events to the OrderGrid.<br /><a href='https://stocksharp.com/file/108044/image9790_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108044/image9790_png/?size=500x500" alt="image9790.png" title="image9790.png" /></a><br />We add the created OrderGridControl panel to the central part of MainWindow.<br /><a href='https://stocksharp.com/file/108045/image4806_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108045/image4806_png/?size=500x500" alt="image4806.png" title="image4806.png" /></a><br />We run the program to check.<br /><a href='https://stocksharp.com/file/108046/image7488_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108046/image7488_png/?size=500x500" alt="image7488.png" title="image7488.png" /></a><br /><br /><h2>Creating Panel of Own Trades</h2><br />Similar to the security panel, we create a panel of own trades, add another UserControl to the XAML folder. We call it MyTradeGridControl. We add the MyTradeGrid element to it.<br /><a href='https://stocksharp.com/file/108047/image3653_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108047/image3653_png/?size=500x500" alt="image3653.png" title="image3653.png" /></a><br />In the MyTradeGridControl constructor, we need to subscribe to the new own trade appearance events and pass it to MyTradeGrid. <br /><a href='https://stocksharp.com/file/108048/image7227_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108048/image7227_png/?size=500x500" alt="image7227.png" title="image7227.png" /></a><br />We add the created OrderGridControl panel to the central part of MainWindow.<br /><a href='https://stocksharp.com/file/108049/image3738_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108049/image3738_png/?size=500x500" alt="image3738.png" title="image3738.png" /></a><br />We run the program to check.<br /><a href='https://stocksharp.com/file/108050/image514_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108050/image514_png/?size=500x500" alt="image514.png" title="image514.png" /></a><br /><br /><h2>Creating Order Book Panel</h2><br />Similar to the previous panels, we create an order book panel, add another UserControl to the XAML folder. We call it MarketDepthControl. <br />In MainWindow we have already used LayoutControl, in this control we will also use LayoutControl. We split the panel into two parts horizontally.<br /><a href='https://stocksharp.com/file/108051/image1678_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108051/image1678_png/?size=500x500" alt="image1678.png" title="image1678.png" /></a><br />We add SecurityPicker to the left side, we use it when we created the security panel.<br /><a href='https://stocksharp.com/file/108052/image7627_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108052/image7627_png/?size=500x500" alt="image7627.png" title="image7627.png" /></a><br />Let's split the right part into vertical parts. There will be an order book on the top right.<br /><a href='https://stocksharp.com/file/108053/image1159_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108053/image1159_png/?size=500x500" alt="image1159.png" title="image1159.png" /></a><br />In MarketDepthControl, we need to set some MaxHeight value, otherwise the application will not start.<br />Below the order book we will place the elements of specifying a portfolio, price, and order volume.<br /><a href='https://stocksharp.com/file/108054/image8282_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108054/image8282_png/?size=500x500" alt="image8282.png" title="image8282.png" /></a><br />Here it is worth noting the Label property of LayoutItem, it allows to set the text over the element. And also the SpinEdit element from DevExpress, in which it is convenient to set numerical values. These elements look like this.<br /><a href='https://stocksharp.com/file/108055/image4967_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108055/image4967_png/?size=500x500" alt="image4967.png" title="image4967.png" /></a><br />Even below, we will place the buttons to buy, sell.<br /><a href='https://stocksharp.com/file/108056/image62_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108056/image62_png/?size=500x500" alt="image62.png" title="image62.png" /></a><br />Full code.<br /><a href='https://stocksharp.com/file/108057/image9810_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108057/image9810_png/?size=500x500" alt="image9810.png" title="image9810.png" /></a><br />In the MarketDepthControl constructor, we set the security source for SecurityPicker and the portfolio source for PortfolioComboBox, in our case it will be Connector.<br /><a href='https://stocksharp.com/file/108058/image651_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108058/image651_png/?size=500x500" alt="image651.png" title="image651.png" /></a><br />We create a security selection event handler in SecurityPicker. We check in it whether the selected security is not equal to zero. If it is not equal to zero, we save the received security to a local variable, we will need it when updating the order book. After that, we clear and register the received security in Connector to receive an order book using the RegisterMarketDepth method. Using the GetMarketDepth method, we get the current order book on security to update the MarketDepthControl.<br /><a href='https://stocksharp.com/file/108059/image3667_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108059/image3667_png/?size=500x500" alt="image3667.png" title="image3667.png" /></a><br />To keep the order book updated in the MarketDepthControl constructor, we will subscribe to the MarketDepthChanged order book change event at the connector. In the handler of this event, we will check which security the received order book belongs to, and if it belongs to the security selected in SecurityPicker, we update MarketDepthControl with it.<br /><a href='https://stocksharp.com/file/108060/image4084_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108060/image4084_png/?size=500x500" alt="image4084.png" title="image4084.png" /></a><br />We add the created MarketDepthControl panel to the central part of MainWindow.<br /><a href='https://stocksharp.com/file/108061/image7347_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108061/image7347_png/?size=500x500" alt="image7347.png" title="image7347.png" /></a><br />At this stage, we can run the program and check the order book update operation.<br />We create a buy and sell buttons click event handler. In each handler we create an Order, in which we specify the security selected in SecurityPicker, the portfolio selected in PortfolioComboBox, the volume and price from the corresponding SpinEdit. We register the order in Connector using the RegisterOrder method.<br /><a href='https://stocksharp.com/file/108062/image7717_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108062/image7717_png/?size=500x500" alt="image7717.png" title="image7717.png" /></a><br />Both handlers differ only by the order direction. <br />Let's make that the SpinEditPrice value is changed to the selected quote price when selecting a quote in the order book. To do this, we will create a handler for the SelectionChanged event at MarketDepthControl. In which we will update SpinEditPrice value by the price of the selected quote if the selected quote is not equal to zero<br /><a href='https://stocksharp.com/file/108063/image90_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108063/image90_png/?size=500x500" alt="image90.png" title="image90.png" /></a><br />We run the program to check.<br /><a href='https://stocksharp.com/file/108064/image8902_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108064/image8902_png/?size=500x500" alt="image8902.png" title="image8902.png" /></a><br /><br /><h2>Saving Market Data</h2><br />To save portfolios, securities, platforms, we need the CsvEntityRegistry class. We need to pass the entities storage location to it and call the Init method to load them.<br /><a href='https://stocksharp.com/file/108065/image7322_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108065/image7322_png/?size=500x500" alt="image7322.png" title="image7322.png" /></a><br />To save candles, trades, etc., we will need StorageRegistry.<br /><a href='https://stocksharp.com/file/108066/image809_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108066/image809_png/?size=500x500" alt="image809.png" title="image809.png" /></a><br />We will also need the SnapshotRegistry snapshot storages registry.<br /><a href='https://stocksharp.com/file/108067/image4003_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108067/image4003_png/?size=500x500" alt="image4003.png" title="image4003.png" /></a><br />All this we pass to Connector when it is created.<br /><a href='https://stocksharp.com/file/108068/image6704_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108068/image6704_png/?size=500x500" alt="image6704.png" title="image6704.png" /></a><br />Here I also specified that Connector will reconnect when the connection is broken, and also specified how many history days should be downloaded.<br />The Connector.LookupAll(); string queries the available data.<br /><a href='https://stocksharp.com/file/108069/image6016_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108069/image6016_png/?size=500x500" alt="image6016.png" title="image6016.png" /></a><br />After starting the application, we will see that new folders have appeared in the Date folder.<br /><a href='https://stocksharp.com/file/108070/image7577_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108070/image7577_png/?size=500x500" alt="image7577.png" title="image7577.png" /></a><br />And when reconnecting the security and portfolio panels will already be filled.<br /><br /><h2>Creating Strategy Panel</h2><br />I will create the strategy panel just like all previous panels.<br />We add another UserControl to the XAML folder. We call it StrategyControl. We split the screen form into two parts using the LayoutControl.<br />There will be a tab with a candle chart on the left side.<br /><a href='https://stocksharp.com/file/108071/image344_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108071/image344_png/?size=500x500" alt="image344.png" title="image344.png" /></a><br />As well as a tab with strategy statistics, <br /><a href='https://stocksharp.com/file/108072/image4907_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108072/image4907_png/?size=500x500" alt="image4907.png" title="image4907.png" /></a><br />Here I use StatisticParameterGrid to display strategy statistics and EquityCurveChart to display profit and loss chart.<br />In StatisticParameterGrid, we need to set some MaxHeight value, otherwise the application will not start.<br />The strategy properties in PropertyGridEx will be configured on the right side.<br /><a href='https://stocksharp.com/file/108073/image721_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108073/image721_png/?size=500x500" alt="image721.png" title="image721.png" /></a><br />As well as strategy start and stop buttons.<br /><a href='https://stocksharp.com/file/108074/image1047_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108074/image1047_png/?size=500x500" alt="image1047.png" title="image1047.png" /></a><br />Full code.<br /><a href='https://stocksharp.com/file/108075/image2510_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108075/image2510_png/?size=500x500" alt="image2510.png" title="image2510.png" /></a><br />In the StrategyControl constructor, we set Connector as a data source for PropertyGridEx, we carried out similar actions in almost every control.<br /><a href='https://stocksharp.com/file/108076/image8773_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108076/image8773_png/?size=500x500" alt="image8773.png" title="image8773.png" /></a><br />We need to somehow pass the strategy to our control. To do this, in StrategyControl I will create a BindStraregy method that will receive a strategy, save a link to it in the local variable, and also set a strategy in PropertyGridEx and StatisticParameterGrid.<br />Using the SetChart method, we pass the Chart candle chart to the strategy, after that, the Chart can be obtained in the strategy using the GetChart method. We also set the Connector for the strategy.<br /><a href='https://stocksharp.com/file/108077/image8230_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108077/image8230_png/?size=500x500" alt="image8230.png" title="image8230.png" /></a><br />When working with the profit and loss chart, it is necessary to take into account that the strategy may start and stop several times, so every time the strategy starts, the chart should be cleared. To do this, let's create the ResetEquityCurveChart method, in which we will first clear EquityCurveChart. After that we need to create graphic elements for EquityCurveChart, for them we can set a name, color and line type.<br /><a href='https://stocksharp.com/file/108078/image6360_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108078/image6360_png/?size=500x500" alt="image6360.png" title="image6360.png" /></a><br />Then, we subscribe to the PnL change event of the strategy and in this event handler we draw a new value on the EquityCurveChart profit loss chart.<br /><a href='https://stocksharp.com/file/108079/image3106_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108079/image3106_png/?size=500x500" alt="image3106.png" title="image3106.png" /></a><br />Full method code.<br /><a href='https://stocksharp.com/file/108080/image2024_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108080/image2024_png/?size=500x500" alt="image2024.png" title="image2024.png" /></a><br />We will call this method in the Start button click event handler. And also we will reset the strategy state and run it.<br /><a href='https://stocksharp.com/file/108081/image3375_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108081/image3375_png/?size=500x500" alt="image3375.png" title="image3375.png" /></a><br />We will stop the strategy in the Stop button click event handler.<br /><a href='https://stocksharp.com/file/108082/image3399_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108082/image3399_png/?size=500x500" alt="image3399.png" title="image3399.png" /></a><br />We add the created StrategyControl panel to the central part of MainWindow.<br /><a href='https://stocksharp.com/file/108083/image8678_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108083/image8678_png/?size=500x500" alt="image8678.png" title="image8678.png" /></a><br /><br /><h2>Creating Strategy</h2><br />For example, let's consider creating a simple strategy with candles. Which will buy if the candle is growing (green), and sell if the candle is falling (red).<br />Let's create another folder in the project and store all our strategies in it. We create a new class in this folder and call it SimpleStrategy. All S# strategies must be inherited from the base class Strategy.<br /><a href='https://stocksharp.com/file/108084/image1577_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108084/image1577_png/?size=500x500" alt="image1577.png" title="image1577.png" /></a><br />Since our strategy uses candles, we will create a public property CandleSeries, and set its default value in our strategy constructor.<br /><a href='https://stocksharp.com/file/108085/image442_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108085/image442_png/?size=500x500" alt="image442.png" title="image442.png" /></a><br />Here I specified that candles in CandleSeries will be TimeFrameCandle with time span of 15 seconds (TimeSpan.FromSeconds(15)). We can specify the candle creating mode for CandleSeries - BuildCandlesMode. I specified that candles will be built (MarketDataBuildModes.Build), by default they will be built from ticks, but we can specify other data types as well.<br />Since we made the CandleSeries a public property, the CandleSeries can be additionally configured from the PropertyGridEx described in the previous paragraph.<br />All strategies have methods that can be overridden, we will need to override the OnStarted method. Which is called before the launch of the strategy and allows to preset its starting state.<br /><a href='https://stocksharp.com/file/108086/image6026_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108086/image6026_png/?size=500x500" alt="image6026.png" title="image6026.png" /></a><br />Here we set the security for CandleSeries, which is specified in the PropertyGridEx. After that, we create a rule for processing the completed candle. See the documentation for details on working with rules. In the rule we specify the method that will process each completed candle, in our case it is the ProcessCandle method, it will be described later. After everything is set, we subscribe to the appearance of candles on the CandleSeries in connector using the SubscribeCandles method.<br />In our case, the ProcessCandle method contains the main strategy logic.<br /><a href='https://stocksharp.com/file/108087/image3324_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108087/image3324_png/?size=500x500" alt="image3324.png" title="image3324.png" /></a><br />First of all, we need to determine whether the candle is real-time or historical, if the candle is historical, we ignore it. Not all strategies require this, for example, for strategies based on order books, this is not required, since order books are always real-time. There is no general way to determine whether a candle is real-time or historical, and in each strategy this problem will have to be solved independently depending on the strategy requirements. In this case, I will simply compare the candle closing time with the connector time, and if it does not exceed a certain lag, then I consider the candle real-time.<br /><a href='https://stocksharp.com/file/108088/image2732_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108088/image2732_png/?size=500x500" alt="image2732.png" title="image2732.png" /></a><br />Next, we consider what candle it is and what the strategy current position. If the candle is growing, then at a position equal to 0, we will open a position with a market order for the volume set by us in PropertyGridEx. If the candle is growing and the position is less than 0, we reverse the position.<br /><a href='https://stocksharp.com/file/108089/image4474_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108089/image4474_png/?size=500x500" alt="image4474.png" title="image4474.png" /></a><br />We do opposite actions for a falling candle.<br /><a href='https://stocksharp.com/file/108090/image5127_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108090/image5127_png/?size=500x500" alt="image5127.png" title="image5127.png" /></a><br />At the moment, our strategy is ready to work. It should be passed to SimpleStrategyControl, which we created in the previous paragraph using the BindStraregy method. We do this in the MainWindow constructor immediately after the MainWindow components are initialized.<br /><a href='https://stocksharp.com/file/108091/image374_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108091/image374_png/?size=500x500" alt="image374.png" title="image374.png" /></a><br />We run the program to check.<br /><a href='https://stocksharp.com/file/108092/image9399_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108092/image9399_png/?size=500x500" alt="image9399.png" title="image9399.png" /></a><br /><a href='https://stocksharp.com/file/108093/image5010_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108093/image5010_png/?size=500x500" alt="image5010.png" title="image5010.png" /></a><br />The strategy works, trades are made, but there are no candles and trades on the chart yet.<br /><br /><h2>Adding Candles and Trades to Chart from Strategy</h2><br />In the paragraph about the strategy panel, we passed the Chart candle chart to the strategy using the SetChart method. In the OnStarted strategy method, we check whether the strategy has a chart set, and if it is set, then we initialize the chart, as well as subscribe to the events of new own trade appearance and candle change.<br /><a href='https://stocksharp.com/file/108094/image5547_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108094/image5547_png/?size=500x500" alt="image5547.png" title="image5547.png" /></a><br />InitChart chart initialization method.<br /><a href='https://stocksharp.com/file/108095/image977_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108095/image977_png/?size=500x500" alt="image977.png" title="image977.png" /></a><br />Here we save the link to Chart in a local variable. We clear the chart. We also create chart elements for candles and trades and pass them to the chart.<br />The chart.GuiSync(()=>{ ... }); construct is necessary in order to initialize the chart in the main thread.<br />CandleSeriesProcessing is a method for drawing candles on a chart.<br /><a href='https://stocksharp.com/file/108096/image9921_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108096/image9921_png/?size=500x500" alt="image9921.png" title="image9921.png" /></a><br />Here we get a candle from the CandleSeriesProcessing event of the connector, create ChartDrawData to display it on the chart. We specify the time data.Group(candle.OpenTime), specify that the candle should be added to the candle element of the chart .Add(_chartCandleElement, candle);. And we specify that the chart should draw new data.<br />We perform similar actions for trades.<br /><a href='https://stocksharp.com/file/108097/image4611_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108097/image4611_png/?size=500x500" alt="image4611.png" title="image4611.png" /></a><br />We run the program to check.<br /><a href='https://stocksharp.com/file/108098/image944_png/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/108098/image944_png/?size=500x500" alt="image944.png" title="image944.png" /></a><br /><br /><h2>Short conclusion</h2><br />It is not necessary to spend a lot of time to create a complex and professional-looking application. In a few hours we created the fully-featured application with the ability to configure, display and trade directly.<br />Do not be afraid to try and create your own programs. I hope this paper will help you get used to this business.<br /><br />https://stocksharp.com/topic/10117/MetaTrader 5 connector is available now!2018-11-09T15:51:51Z2018-11-19T13:09:06ZЮрий Басанговhttps://stocksharp.com/users/7/info@stocksharp.com<a href='https://stocksharp.com/file/107973/mt5_jpeg/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/107973/mt5_jpeg/?size=500x500" alt="http://" title="http://" /></a><br />Hello dear friends! Today, we are completing the delivery of products within <a href="https://crowd.stocksharp.com/product/metatrader/" title="https://crowd.stocksharp.com/product/metatrader/">3rd crowdfunding round</a> and present connector to MT5.<br />Now the StockSharp platform allows trading by robots both through the most popular forex terminal MetaTrader 4 and through the 5th version of this product.<br /><br />Participation in the project is still possible <span style="color:green">by the same prices</span> <b>until November 12! </b><br /><br />We invite everyone who has not participated in the project <span style="font-size:120%"><span style="color:green"><a href="https://stocksharp.com/s/UyWJpxsI" title="https://stocksharp.com/s/UyWJpxsI">to get the lifetime license for only 500$</a></span></span>. Since November 12 <span style="color:red"><b>1000$!</b></span><br />Project participants, we invite you to get the connector <a href="https://stocksharp.com/forum/9916/MetaTrader-Connector-Instruction!/" title="https://stocksharp.com/forum/9916/MetaTrader-Connector-Instruction!/"><span style="font-size:120%">here</span></a>!<br />https://stocksharp.com/topic/9459/Synthetic Arbitrage is ready! Last chance to get!2018-05-17T16:21:29Z2018-05-17T16:21:57ZЮрий Басанговhttps://stocksharp.com/users/7/info@stocksharp.comDear friends!<br /><br />Our new robot - <span style="font-size:140%">synthetic arbitrage</span> for cryptocurrencies has finished last tests! <b>IT IS READY!</b><br /><br /><a href='https://stocksharp.com/file/106806/photo_2018-05-17_16-11-47_jpg/' class='lightview' data-lightview-options="skin: 'mac'" data-lightview-group='mixed'><img src="https://stocksharp.com/file/106806/photo_2018-05-17_16-11-47_jpg/?size=500x500" alt="http://" title="http://" /></a><br /><br />For <a href="https://crowd.stocksharp.com/product/cryptoconnectors-second-round/" title="https://crowd.stocksharp.com/product/cryptoconnectors-second-round/">crowdfunding participants</a> it will be available on 20th May!<br />You have last chance to enter with <b>the best deal!</b> <br />Only today and tomorrow we reduce the donation for the ready-to-use robot to <span style="color:green"><b>1000$</b></span>, as it was at first days of the campaign! We will finish the fund-raising and close new participations tomorrow!<br /><br />Make money on crypto arbitrage with us!<br /><br /><a href="https://crowd.stocksharp.com/product/cryptoconnectors-second-round/" title="https://crowd.stocksharp.com/product/cryptoconnectors-second-round/"><div align="center"><span style="font-size:140%"><span style="color:green">I want it!</span></span></div></a><br /> https://stocksharp.com/topic/8889/Retrieve Historical Candles2017-12-03T12:10:39Z2017-12-06T16:04:03ZHerchelhttps://stocksharp.com/users/100008/info@stocksharp.comHi.<br /><br />I'm enjoying using the S# API and so fat it's been easy to use.<br /><br />I'm retrieving some historical candles to backtest my robot on, and once I call trader.SubscribeCandles I get a new candle each time I get the trader.ProcessCandle event which works great. Is there an event that is fired to show that all candles have been received