CloseAtMarket

CloseAtMarket

In the tab, there are 2 methods that close a position using a market order:

public void CloseAtMarket(Position position, decimal volume)

1. position – the position that needs to be closed;

2. volume – the volume being closed;

1. If there are no open positions and a long position is opened upon meeting additional conditions.

2. If there is an open position, it is closed at the market using the CloseAtMarket method.

public void CloseAtMarket(Position position, decimal volume, string signalType)

1. position – the position that needs to be closed;

2. volume – the volume being closed;

3. signalType – the type of signal for closure;

Let's see how this method can be used in the code:

1. If there is an open position and the price is below the SMA, the thread enters the conditional construct.

2. Closes the position using the CloseAtMarket method by passing the appropriate signal.

3. If there is an open position and the candle open time is greater than the set time mark, the thread enters the conditional construct.

4. Closes the position by passing another signal.

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