Chart Strategies. Basics

Modified on Thu, 18 May 2023 at 04:10 PM

Functionality of Chart Strategies allows receiving and processing the whole set of data available in indicators and performing trading operations on the basis of these data.

The ChartStrategy class is inherited from the Indicator class. Thus, strategies have the full functionality of indicators.

Помимо функционала индикаторов, в стратегиях имеются дополнительные свойства и методы, отвечающие за торговый функционал:


  • Security - trading instrument
  • Portfolio - selected portfolio
  • Connector - trading connection
  • MyTrades - list of trades
  • Orders - list of orders
  • CurrentPosition - volume of the strategy current position
  • AveragePrice - average price of the strategy current position
  • State - strategy state (could be Stopped, Started and Suspended)

Main strategy public methods:

  • OpenOrder - method of opening a new order
  • ModifyOrder - method of modifying an order
  • CancelOrder - method of cancelling an order
  • ShrinkPrice - rounding the transferred price to the trading instrument tick size
  • RaiseShowNotification - method, allowing visualization of notifications in the platform

Strategy virtual methods, which, if necessary, have to be redefined in the created strategy:

  • OnStarted - is called when a strategy is started
  • OnSuspended - is called when a strategy is suspended (for example, in situations when a chart with a strategy has been closed)
  • OnStopping - is called before stopping a strategy
  • OnStopped - is called when a strategy has been stopped
  • OnCurrentPositionChanged - is called when changing the strategy current position
  • CanProcess - returns whether it is possible to trade at this moment. By default, the method checks whether a strategy has been started and the most recent bar is processed at this moment.

Strategy positions.

Every strategy holds its position inside. This position could differ from the general position on the account.

The account general position could be received through the TradingManager.Position property.

The strategy internal position could be received through the CurrentPosition and AveragePrice properties.

Important! When a strategy is stopped, its internal position is reset to zero. It is extremely desirable to redefine the OnStopping method and realize the logic of closing internal positions and cancelling the posted orders in it.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article