
In this post, we will talk about the events that you will need when creating robots for pair trading in OsEngine, as well as some properties of the BotTabPair class.
Public Int PairsWithPositionsCount - a property through which you can find out the number of pairs for which there are currently open positions. It can be used as follows:

Fig.1. Implementation of checking the maximum number of concurrently open positions per pair.
PairIndicatorValue - a class implementing one unit of a pair indicator. Correlation and cointegration will be returned as a List of such values. It contains:
• Time - creation time.
• Value - indicator value over time.
Events designed for trading logic that can be subscribed to from BotTabPair:

1. CorrelationChangeEvent - occurs when the correlation for a pair changes. It returns List<PairIndicatorValue> and the pair (PairToTrade) for which the event occurred.
2. CointegrationChangeEvent - occurs when the cointegration for a pair changes. It returns List<PairIndicatorValue> and the pair (PairToTrade) for which the event occurred.
3. CointegrationPositionSideChangeEvent - occurs when the current deviation position relative to the lines on the deviation chart changes. It returns the side on which the current deviation is located (CointegrationLineSide) and the pair (PairToTrade) for which the event occurred.
4. PairToTradeCreateEvent - occurs when a new pair is created within BotTabPair.
Subscription and event handler for updating the cointegration side:

The location of the robot referenced in the above screenshots:

If you have any difficulties or questions, please write to the support chat. Link