
In this article, we will examine a specific sequence of instruments for trading in currency arbitrage. We will delve into more detail than the source, as this is where our trading logic resides and someone may want to modify it.
Relationship between BotTabPolygon and PolygonToTrade.
BotTabPolygon - a data source that implements the IIBotTab interface.
PolygonToTrade - another, more low-level class that is directly responsible for trading a specific sequence of three instruments.
Each BotTabPolygon can have multiple sequences inside:

This architecture allows:
1. Applying common settings to sequences.
2. Quickly creating hundreds of instrument sequences for trading through the automatic creation of sequences from user interfaces.
3. Handling signals from hundreds of sequences with a single code.
In this article, we will examine the code of PolygonToTrade:

Location in OsEngine.

Regions within the class.

1. Service code and constructor.
2. Public properties and settings.
3. Trading logic.
4. Incoming and outgoing events.
5. Logging.
Service. Constructor. Region.

1. Constructor. It takes as input:
a. Unique sequence name. It must be unique to save object settings to the file system.
b. The type of program that creates an instance of the sequence.
2. Field for unique sequence names.
3. Unique sequence number within this source. This is necessary for smooth sorting of sequences in BotTabPolygon.
4. Method to load object settings from the file system.
5. Method to save object settings to the file system.
6. Method to delete the object.
7. Property that turns data feed on or off for the object. This property is invoked when the user clicks on the on/off checkbox in the robot table in the simplified interface.
8. Property that enables or disables the emulator within the sources in the sequence. This property is called when the user clicks on the Emulator on/off checkbox in the robot table in the simplified interface.
9. Property that saves the position of the control panel in the user interface. Open/closed.
Properties and settings. Region.
All of this can be called from the robot sequence.

1. HavePosition. Property. Returns true if there are positions for any internal source.
2. Trading sources.
3. Representation of the sequence in a neat string expression.
4. Instant profit for the sequence in absolute terms.
5. Instant profit for the sequence in percentages.
6. Sides of the trade for instruments in the sequences.
7. Currencies in the sequence. From the starting to the final.
8. Volumes in the sequence. From the starting to the final.
9. Profit for generating a signal to the top from the object.
10. Signal type when the profit for the sequence is exceeded.
11. Separator for the names of pairs in the sequence. Used if there is a separator in the exchange.
12. Type of commission subtracted during the calculation of profitability and volumes for the sequence.
13. Size of commission subtracted during the calculation of profitability and volumes for the sequence.
14. Whether to subtract the commission size from the volumes.
15. Type of delay between placed orders.
16. Delay between placed orders in MLS.
17. Order price type. Limit / Market.
18. Slippage for limit orders.
19. Checks for the correctness of the sequence. And the starting currency matches the ending one.
Logic. Region.

1. Call logic for trading the sequence.
2. Method to send an order per pair.
3. Method to check the completion of trading on the sequence.
4. Position status per pair traded in the sequence.
5. Processing of events for successful opening of positions per pair in the sequence.
6. Processing of events for error in opening a position per pair in the sequence.
Events. Region.

1. Mechanism for calculating the sequence's profit.
2. Outgoing events when the profit on the sequence changes.
If you have any difficulties or questions, please write to the support chat. Link