Exit functions are required for liquidating an open position placed through XLS Trader. Exits are similar to Entries but with a few subtle differences. As an example, we will create a couple of exits in cells A6 and A7. In A7, we will use a limit order, and the parameters will look as follows:
Exit Parameters |
Example (see image below for context) |
Formula: |
A5 (cell references do not require quotes) |
Order: |
Limit(,,2638.75,"GTC","Sell") (functions do not require quotes) |
When: |
(this parameter is optional, but requires a cell reference) |
Name: |
“limitEx” (user defined strings require quotes) |
In the above Order parameter you don’t have to set this parameter to “Sell” when you specify an exit for an entry formula (when the 1st parameter references either Buy() or Sell() formula) the side of your exit will be deduced. The only time you need to specify this parameter is when you set a system-level exit (when the 1st parameter references the TradeSystem() formula).
Again, Exits are required to close open entries. The first parameter of an exit is a reference to a trading system or a specific entry function. In the example above, we have chosen the only entry we have created, which is in cell A5 and was named “Long1”.
The “Order” parameter is identical to the one used in entries, and can infer many of its parameters from the context of the entry specified. In this example, the entry order in cell A5 specifies a symbol, size, side, so we can leave any of those parameters blank in an exit function for that entry. In the image above, the “Order” preview shows that it is taking information from “Long1.” Even though the size was left blank and appears as “0” in the preview, when “Long1” is filled, the exit will use the size of that entry as the size for this parameter when placing the exit.
The “When” parameter is optional when using order types other than market. When left blank, they are always true. So if your exit is a profit target based on your entry price, your exit order type might be a limit order with a price equal to “B4 + 2.5.” In the example above, if the entry order was filled at 2638.50, the exit would enter a limit order immediately at 2641.
In cell A6 in the above example, we have an exit that specifies a market order. In this case, we would want to specify the cell for the “When” that contains a condition to trigger that order. Cell B6, in this example, might be a moving average crossover formula, or a volatility spike condition. If the buy entry in A5 has a position, and cell B6 turns true, then that exit function would send a market order. Any working Exit orders would be canceled when A5 entry position turns to 0. All other exit functions will do nothing since there is no longer a position in the A5 entry.