SellAtMarket

SellAtMarket

In the BotTabSimple class, there are two overloads of the SellAtMarket method.

public Position SellAtMarket(decimal volume)

The public method sends a signal to the connector for selling at the market price, taking only the volume of the operation as a single parameter. It creates and returns a new position with the state PositionStateType.Opening. In the code, the use of the method looks like this:

The second variant accepts an additional parameter in the form of a string indicating the signal for opening a position. The method's signature:

public Position SellAtMarket(decimal volume, string signalType)

The signalType parameter can contain any value set in the strategy algorithm. Using an entry signal is convenient for separating positions within a single robot.

Let's modify our example:

1. Create a variable of type string and initialize it with an appropriate value depending on the current market time.

2. Open a position at the market by passing the name of the signal to the method.

3. Access the SignalTypeOpen field on the instance of the created position to obtain its value, and display an informational message in the log about which signal was used.

As a result, we can see the names of the signals in the positions tables in the software interface:

It is worth noting that both methods emulate a market order using a limit one if the connector does not support execution at the market.

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