User Submitted: by Brian Haviland
One of the best features of Investor/RT is the ability to specify entry and exit prices for a backtest in a very precise way. Many programs force you to enter or exit at the close of the one-minute bar, which of course could be an eternity in terms of daytrading. Likewise one should be able to choose an amount for slippage to make trading more realistic. Here are some step's I've used to set up my trading systems. There may be other/better ways but these seem to work. Thanks to Chad and Bill for helping me with these. Note that the following system is designed to demonstrate some techniques -- it's not designed to be traded as is. Say the entry for a system is based on a break of the 930 to 1000 high with no more than one signal between 1000 and 1030 and we want the entry price to be .05 above the trigger price to allow for slippage. Using a 1min periodicity system the setup signals are: IF(TIME = 931) THEN (SET(V#1, HI)) ...which initializes V#1 at the high of the first 1min bar. NO ACTION on the rule
IF(TIME = 931) THEN (SET(V#3, TNUM)) ...which will help us limit the trades to one per day per symbol NO ACTION on the rule
IF(TIME <= 1000 AND HI > V#1) THEN (SET(V#1, HI)) ...which updates V#1 to the high of the day up until 1000am NO ACTION on the rule
SET(V#4, V#1+.05) ...which sets the entry price at .05 above the trigger price NO ACTION on the rule
(HI > V#1) AND (TIME>=1000 AND TIME <1030) AND (TNUM = V#3) ...which is the entry rule, select CONFIRM on the action which will force the next rule to act when the entry conditions are met
SHOW HI AND SHOW V#1 AND SHOW V#4 AND SHOW V#6 AND SHOW V#7 ...which will display all the specified data when a trade happens to let us check it. Set the Action at BUY and, say, 5000 Dollars, the rule price is set to V#4. On the Backtest Setup window I use the 1 share block size so that each trade will have a similar dollar size value in the backtest. Be sure to fill out other items on the backtest page as needed.
The exit rules in this example are set for three possibilities: a 4% profit target, a 2% stop or a time exit at 11:30.
SET(V#6,(V#1*1.04)-.05) ...Sets the profit target and knocks off .05 for slippage. Note that the profit target is based on the signal price and not the entry price since in real trading the slippage could be more or less than .05. NO ACTION on the rule
SET(V#7,(V#1*.98)-.05) ...Sets the Stop price. NO ACTION on the rule
HI >= V#1 * 1.04 ...is the profit target exit signal. Set action to SELL $5000 at V#6 (in fact this will close out the position regardless of the "current" value).
LO < V#1 * 0.98 ...is the stop loss exit. Set action to sell $5000 at V#7
TIME>=1130 ...is the time exit Set action to sell $5000 at the Close price.
One of the smart things about Investor/RT is that before it sets a price with a formula like the above, it will check the historical trading on the bar to see if that price actually occurred -- if not it will go as close as possible. Say for example the 30min high is 28.18 -- the slippage-adjusted price above is 28.23, but if the high of the signal bar is only 28.21 then the entry will take place at 28.21.
Here are the rules as printed out on the DTL report:
RULE 1: 1 Minute: If SET_VI_HI then NO ACTION
SIGNAL=SET_VI_HI: IF(TIME = 931) THEN (SET(V#1, HI))ELEM=TIME:Backtest Time (hhmm)
ELEM=V#1:3HI
ELEM=HI:High
RULE 2: 1 Minute: If SET_V3_TNUM then NO ACTION
SIGNAL=SET_V3_TNUM: IF(TIME = 931) THEN (SET(V#3, TNUM))ELEM=TIME:Backtest Time (hhmm)
ELEM=V#3:Entry
ELEM=TNUM:Trade Number (Backtesting)
RULE 3: 1 Minute: If V1_UPDATER_ten then NO ACTION
SIGNAL=V1_UPDATER_ten: IF(TIME V#1) THEN (SET(V#1, HI))ELEM=TIME:Backtest Time (hhmm)
ELEM=HI:High
ELEM=V#1:3HI
RULE 4: 1 Minute: If SET_V4_V1_PLUS_FIVE then NO ACTION
SIGNAL=SET_V4_V1_PLUS_FIVE: SET(V#4, V#1+.05)ELEM=V#4:V#4
ELEM=V#1:3HI
RULE 5: 1 Minute: If BUY_test then CONFIRM using next rule
SIGNAL=BUY_test: (HI > V#1) AND (TIME>=1000 AND TIME ELEM=HI:HighELEM=V#1:3HI
ELEM=TIME:Backtest Time (hhmm)
ELEM=TNUM:Trade Number (Backtesting)
ELEM=V#3:Entry
RULE 6: 1 Minute: If test_show then BUY $5000 at Value V#4 price
SIGNAL=test_show: SHOW HI AND SHOW V#1 AND SHOW V#4 AND SHOW V#6 AND SHOW V#7ELEM=HI:High
ELEM=V#1:3HI
ELEM=V#4:V#4
ELEM=V#6:V#6
ELEM=V#7:V#7
RULE 7: 1 Minute: If SET_V6_LONG_TARGET_104V1_MINUS_ then NO ACTION
SIGNAL=SET_V6_LONG_TARGET_104V1_MINUS_: SET(V#6,(V#1*1.04)-.05)ELEM=V#6:V#6
ELEM=V#1:3HI
RULE 8: 1 Minute: If SET_V7_LONG_STOP_98V1_MINUS then NO ACTION
SIGNAL=SET_V7_LONG_STOP_98V1_MINUS: SET(V#7,(V#1*.98)-.05)ELEM=V#1:3HI
ELEM=V#7:V#7
RULE 9: 1 Minute: If LONG_PROFIT_HI_GTE_104V1_TARGET then SELL $5000 at Value V#6 price
SIGNAL=LONG_PROFIT_HI_GTE_104V1_TARGET: HI >= V#1 * 1.04ELEM=HI:High
ELEM=V#1:3HI
RULE 10: 1 Minute: If LONG_LO_LT_98V1_STOP then SELL $5000 at Value V#7 price
SIGNAL=LONG_LO_LT_98V1_STOP: LO ELEM=LO:LowELEM=V#1:3HI
RULE 11: 1 Minute: If TIME_EXIT then SELL $5000 at Close price
SIGNAL=TIME_EXIT: TIME>=1130ELEM=TIME:Backtest Time (hhmm)