# Tutorial 125 | Finding a strategy fill price

## Two ways of ascertaining fill price for hypothetical strategy orders

Tutorial 125 demonstrates two ways to find out the fill prices for strategy orders.

This might be useful, for example, in a situation where a future entry or target price is determined by the exit price of another trade.

In this tutorial I create a simple ‘dummy’ trade with three exits. Two of the exits are market orders based on bar date and time. The third is a market order based on bar date, time and price level. The exit prices and other information are printed in the print log (see below). For this tutorial Use Look-Inside-Bar-Backtesting is selected in ‘Properties for all‘ and set to 1 minute. In Strategy-Format in the Calculation tab, ‘Enable intrabar order generation and calculation‘ is selected.

#### Programming lessons in _Tutorial125

The tutorial demonstrates how to:

• Set the Look-Inside-Bar-Backtesting and Enable intrabar order generation and calculation options
• Store values for the last tick
• Use Intrabarpersist variables
• Use the StrategyHost object and create up an order fill event
• Determine order direction, quantity and price from the StrategyHost
• The use of the ExitPrice reserved word

### How _Tutorial125 works

The tutorial shows two different ways in which exit prices can be determined in a strategy. In the first, the program keeps a record of the number of contracts open for the current tick and the last tick. If the number of contracts changes from one tick to another the program outputs  the number of contracts sold, the price and the value of ExitPrice( 1 ).

ExitPrice( 1 ) returns 0 until the trade is completely closed.

The second way to determine the exit price is to use the StrategyHost object (not available in MultiCharts). In the tutorial a StrategyHost object is created using the toolbox  An order fill event is then created and after an order is filled relevant information from the StrategyHost is printed in the print log.

[download_box]If you wish to save yourself some time typing in the code for _Tutorial125, the UNPROTECTED TradeStation indicator  ( _Tutorial125) containing tutorial program (i.e. the EasyLanguage is fully functional and you can see the source code) is available for IMMEDIATE download for \$19.95- by clicking the ‘add to cart’ button. The program works with TradeStation, but not MultiCharts.
After download the programs can be opened, you will be able to see the program code and modify it if you wish.

### Video explanation of tutorial 125

#### Contents of the print log

The following is the information printed to the print log as in the video.

```Information from strategy host 1171213.00 900.00 Buy 6 Contracts
at 2665.00

Information from strategy host 1171213.00 1000.00 Sell 3 Contracts
at 2666.25

1171213.00 1000.00 Cts sold 3.00
Exit Price 2666.25
ExitPrice( 1 ) 0.00

Information from strategy host 1171213.00 1400.00 Sell 1 Contracts
at 2666.00

1171213.00 1400.00 Cts sold 1.00
Exit Price 2666.00
ExitPrice( 1 ) 0.00

FALSE 2667.75
FALSE 2668.25
FALSE 2666.50
FALSE 2667.00
FALSE 2667.00
FALSE 2667.00
FALSE 2669.50
Information from strategy host 1171213.00 1433.00 Sell 2 Contracts
at 2668.75

1171213.00 1433.00 Cts sold 2.00
Exit Price 2668.75
ExitPrice( 1 ) 2668.75

TRUE 2668.75
FALSE 2668.75
FALSE 2668.50
FALSE 2669.25
FALSE 2669.00
FALSE 2669.00
```