In this section you will learn how to use the Exit condition to exit a trade. When using the Exit clause, the system exits the trade at the same point in the bar as it entered the trade. For example, if the trade was initiated on the Close, the Exit will also be on the Close.
Exiting a trade via the Exit condition is very easy. In fact, it is the same process as constructing the When condition for entering the trade. All you have to do is to specify the set of conditions that must be satisfied for a trade to be exited. In the example, suppose you want to exit the trade when the Close of US crosses below the 30 day moving average of the Close of US. To do this, go to the Exit pane and select Individual from the list.

Next, select the Condition button
and choose Custom Event from the list. In
the Custom Event window enter
US for the symbol. Select the Continue button. In the Conditional Operator pane select the radial button
for crosses below. Select the Continue button.
In the Right Attribute pane, select
the Studies ![]()
button. This will bring up a window that will allow
you to choose from a list of studies. Select the study named average and select the OK
button. The Study: average
window displays.

Select the Attribute button and
enter US for the symbol. Select the Add
Attribute to Query ![]()
button to close the window. Next, select the
Time Period button. Enter 30
and select Days then select OK to close the window. Select OK to close the Study:
average window.
You will return to the Right
Attribute window. Note that the Studies ![]()
button is highlighted to show that you have made
entries. Select the OK button to close
the Custom Event window and add the
syntax to your query.
The query will match the following:
There are four other methods of exiting a trade. These are discussed, in brief, at the end of this chapter and in detail in the next chapter. |
1: ORDER
1.1: Buy 1 contract of Close of US
Enter on the close
WHEN
Date is after 1/1/1980
AND
US crosses above 30 day average of US
EXIT individual
US crosses below 30 day average of USYou are done! You have just learned how to specify a simple P/L
query in XMIM. All you need to do now is execute the query by either
selecting the Report ![]()
or Graph ![]()
button from the toolbar. The Report window shows just some of the calculations.
Depending on your needs, the system can present summary and/or detailed
analysis. For more information on setting the Report options, see the
section, "Execute
Options" in the XMIM User Guide.
There are basically five ways to exit a trade:
Use the Exit condition in the order block. The Exit condition, discussed above, allows you to specify the exit rules that apply to trades initiated in the SAME order block. This is what you did in the preceding example.
Place an Exit order (similar to placing a buy order) in the same or another order block. This approach, because it can be used in a separate order block, provides the full flexibility of order blocks and WHEN conditions. Use this method when the exit conditions are complicated.
Allow the system to exit a trade on reverse signal. In the Execute Options window, in the Order tab under the Entry & Exit pane, one can also select Exit On Reverse Signal (Exit On Reverse Signal is the system default). If this option is selected, the system will exit a long when a short signal is generated (and vice versa) for the same security.
Exit all open trades at the end of the day by deselecting Maintain Positions Overnight in the Execute Options window, Order tab under the Entry & Exit pane. The system default has this option selected.
Specify Exit price parameters (e.g., stop loss) in the Exit portion of the ORDER window. The Exit price parameters allow you to conveniently specify price conditions that will cause an exit (such as stop losses, trailing stops, or profit objectives).
A discussion of all exit types, along with examples, is presented in the next chapter.