Strategy properties and methods

Modified on Mon, 15 May 2023 at 04:52 PM

Main properties of the strategy:

  • 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
  • PnL - strategy profit in ticks
  • BestBid, BestAsk - best sell and buy prices
  • State - state of the strategy (could be Stopped, Started andSuspended)
  • DisplayName - displayed name of the strategy

Main public methods of the strategy:

  • OpenOrder - method of opening a new order
  • ModifyOrder - method of modifying an order
  • CancelOrder - method of cancelling an order
  • ShrinkPrice - rounding the sent price to the trading instrument tick size

Virtual strategy methods, which should be redefined (if necessary) in the created strategy:

  • OnActivated - called when the strategy is activated
  • OnStarted - called when the strategy is started
  • OnSuspended - called when the strategy is suspended (for example, when the chart with the strategy has been closed)
  • OnStopped - called when the strategy is stopped
  • OnOpenOrder(Order order, bool isAutomated = true) - called when the user tries to open an order. If the flag isAutomated=true, it means that the order is opened by the strategy. If the flag = false, it means that the order is opened by the user from the platform.
  • OnModifyOrder - called when the user tries to modify the order
  • OnCancelOrder - called when the user tries to cancel the order
  • OnMarketDepth - changes of data in the order book
  • OnBestBidAsk - changes of the best bid/ask
  • OnNewTrade - new tick
  • OnNewPosition - appearance of a new position
  • OnCurrentPositionChanged - change of the current position
  • OnPnLChanged - change of PnL
  • OnNewOrder - appearance of a new order
  • OnOrderChanged - change of an order
  • OnOrderRegisterFailed - error of posting an order
  • OnOrderCancelFailed - error of cancelling an order
  • OnNewMyTrade - new own trade (execution)

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