BuyAtLimit

BuyAtLimit

In the tab, there are two overloads of the method for opening long positions with limit orders.

public Position BuyAtLimit(decimal volume, decimal priceLimit)

The method takes two parameters – volume and the price for the opening order. It creates and returns a new position with the state PositionStateType.Opening. The closing price of the last candlestick is passed as the price to the method. The use of the method in the code looks like this:

public Position BuyAtLimit(decimal volume, decimal priceLimit, string signalType)

This overload of the method takes a third parameter in the form of a string indicating the signal for opening the position.

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

2. Open a position using the BuyAtLimit method, passing the volume, price, and the name of the signal to the method.

3. Access the SignalTypeOpen field on the position instance to obtain its value and output an informational message in the log about which signal was involved.

As a result, we can see the names of the signals in the position tables in the program interface.

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