Click or drag to resize

Child strategies

With the Strategy, you can also create child strategies. For example, when you want to implement the trading process, which operates with standard (or previously implemented) algorithms, building them into a single chain:


Work with child strategies

To add a child strategy you should use the StrategyChildStrategies property. It is possible not to set StrategyConnector, StrategyPortfolio and StrategySecurity values for child strategies, and they are automatically filled when you add them to the parent strategy.

When adding a new child strategy, it automatically receives the state from the parent. For example, if the parent strategy is in operating state (ProcessStatesStarted), then the child is automatically set in the operating state (vice versa, in the case of the ProcessStatesStopped).

Therefore, to call the StrategyStart method for the child strategy is not necessary. It will be called automatically when the parental strategy starts. Thus, the StrategyStart method can be called only for the root strategies.

The parent strategy and all its child strategies are executed in parallel. This means that, if the iteration model has been selected, the TimeFrameStrategyOnProcess methods for child and parent strategies are executed in parallel. The same situation with the StrategyRules rules, the event model has been selected.

Note Note
The StrategyStop method for the child strategy, unlike StrategyStart, can be called at any time. For example, when the algorithm needs to forcibly stop the operation of the child strategy, while the algorithm of the child strategy itself has not yet been executed to the end (for example, to interrupt Quoting).

By default, child strategies are not associated with each other, and are executed independently. When you need to establish a dependency between the strategies, you must use the BasketStrategy class. This class allows you to specify conditions for the strategies terminations depending on each other through the BasketStrategyFinishModes indicators. For example, through the First value the condition set wherein all child strategies will be stopped, when at least one of them matched. The example of the BasketStrategy use is shown in the Take-profit and stop-loss.

Next Steps