Skip to content

Tutorial 125 | Finding a strategy fill price

Two ways of ascertaining fill price for hypothetical strategy orders

Dummy trades to demonstrate finding the strategy fill prices

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.

If you want to save some time typing, the tutorial program is available below for download. Additionally, Gold Pass members can download the tutorial program for free.

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

See the video and notes below for more information.

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

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.

After purchase you will be redirected to a download page, so don’t close the browser.

 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

Gold Pass area

Gold pass members, make sure that you are logged in to download the tutorial 125 program for free.
This content is for members only.

Please let me know if you spot any bugs or errors or have questions.

THESE INDICATORS, SHOW ME STUDIES, STRATEGIES AND OTHER PROGRAMS HAVE BEEN INCLUDED SOLELY FOR EDUCATIONAL PURPOSES.

TO THE BEST OF MARKPLEX CORPORATION’S KNOWLEDGE, ALL OF THE INFORMATION ON THIS PAGE IS CORRECT, AND IT IS PROVIDED IN THE HOPE THAT IT WILL BE USEFUL. HOWEVER, MARKPLEX CORPORATION ASSUMES NO LIABILITY FOR ANY DAMAGES, DIRECT OR OTHERWISE, RESULTING FROM THE USE OF THIS INFORMATION AND/OR PROGRAM(S) DESCRIBED, AND NO WARRANTY IS MADE REGARDING ITS ACCURACY OR COMPLETENESS. USE OF THIS INFORMATION AND/OR PROGRAMS DESCRIBED IS AT YOUR OWN RISK.

ANY EASYLANGUAGE OR POWERLANGUAGE TRADING STRATEGIES, SIGNALS, STUDIES, INDICATORS, SHOWME STUDIES, PAINTBAR STUDIES, PROBABILITYMAP STUDIES, ACTIVITYBAR STUDIES, FUNCTIONS (AND PARTS THEREOF) AND ASSOCIATED TECHNIQUES REFERRED TO, INCLUDED IN OR ATTACHED TO THIS TUTORIAL OR PROGRAM DESCRIPTION ARE EXAMPLES ONLY, AND HAVE BEEN INCLUDED SOLELY FOR EDUCATIONAL PURPOSES. MARKPLEX CORPORATION. DOES NOT RECOMMEND THAT YOU USE ANY SUCH TRADING STRATEGIES, SIGNALS, STUDIES, INDICATORS, SHOWME STUDIES, PAINTBAR STUDIES, PROBABILITYMAP STUDIES, ACTIVITYBAR STUDIES, FUNCTIONS (OR ANY PARTS THEREOF) OR TECHNIQUES. THE USE OF ANY SUCH TRADING STRATEGIES, SIGNALS, STUDIES, INDICATORS, SHOWME STUDIES, PAINTBAR STUDIES, PROBABILITYMAP STUDIES, ACTIVITYBAR STUDIES, FUNCTIONS AND TECHNIQUES DOES NOT GUARANTEE THAT YOU WILL MAKE PROFITS, INCREASE PROFITS, OR MINIMIZE LOSSES.