Strategies in StockSharp
Introduction
StockSharp provides a powerful infrastructure for creating, testing, and running trading strategies. The foundation for developing algorithmic trading strategies is the base class Strategy, which provides a set of standard functions and abstractions for working with market data, executing trading operations, and analyzing results.
Navigation
Strategy Basics
Market Data Subscriptions in Strategies - Detailed guide on using market data subscriptions in strategies. Explains creating and configuring subscriptions, managing their lifecycle, and monitoring their state.
Indicators in Strategies - Information about working with technical analysis indicators in strategies. Covers adding indicators to a strategy, controlling their formation, and using them in trading logic.
Trading Operations in Strategies - Guide to performing trading operations in strategies. Describes methods for creating and sending orders, closing positions, and monitoring their status.
Position Protection - Description of mechanisms for protecting open positions using Take Profit and Stop Loss. Examines local and server approaches to position protection.
Strategy Parameters - Guide to working with strategy parameters through StrategyParam<T>. Describes how to create configurable parameters, set their display in GUI, and use them in optimization.
Logging in Strategies - Guide to using the logging mechanism in strategies for tracking and debugging algorithm performance.
Advanced Features
Strategy Platform Compatibility - Recommendations for creating strategies compatible with various StockSharp platforms: Designer, Shell, Runner, and cloud testing.
High-Level APIs in Strategies - Description of high-level methods to simplify working with subscriptions, indicators, charts, and position protection. Explains how to write cleaner code by focusing on trading logic.
Working with Charts in Strategies - Guide to visualizing strategy data on a chart. Explains how to access the chart, create areas, add elements, and render data.
Saving and Loading Settings - Description of the mechanism for saving and loading strategy settings through Strategy.Save and Strategy.Load methods.
State Loading - Guide to loading previously executed orders and trades into a strategy, for example, when restarting a strategy during a trading session.
Price Rounding - Guide to correctly rounding prices in strategies using the ShrinkPrice method.
Unit Type - Description of the Unit data type to simplify arithmetic operations on quantities like percentages, points, or pips.
Event Model - Explanation of the strategy event model based on IMarketRule. Covers creating rules to react to market events, combining conditions, and managing rule lifecycles.
Getting Started with Strategy Development
To begin developing your own strategy, it is recommended to:
Familiarize yourself with the basics of working with strategies to understand the general principles of strategies in StockSharp.
Study the Market Data Subscriptions in Strategies section to understand the mechanism of receiving and processing market data.
Review the Indicators in Strategies section to understand working with technical analysis indicators.
Explore the Trading Operations in Strategies section to understand trading operation mechanisms.
Examine the Strategy Parameters section to learn about strategy configuration mechanisms.
Get acquainted with the High-Level APIs in Strategies section to simplify strategy code using built-in high-level functions.
Strategy Testing
StockSharp provides various methods for testing strategies:
- Historical Data Testing - Allows evaluating strategy effectiveness on historical data.
- Parameter Optimization - Helps find optimal strategy parameter values.
- Virtual Account Testing - Allows checking strategy performance in real-time mode without risking real funds.
Detailed descriptions of testing methods and strategy performance evaluation can be found in the Testing section.