TradeStation Back-testing/Intra-bar Order Generation/Slippage - futures io
futures io



TradeStation Back-testing/Intra-bar Order Generation/Slippage


Discussion in TradeStation

Updated
    1. trending_up 1,287 views
    2. thumb_up 11 thanks given
    3. group 3 followers
    1. forum 13 posts
    2. attach_file 0 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

TradeStation Back-testing/Intra-bar Order Generation/Slippage

(login for full post details)
  #1 (permalink)
highlyimprobable
ridgewood, NJ
 
 
Posts: 13 since Aug 2019
Thanks: 8 given, 6 received

Some of my questions here is a continuation of my previous post here:

I am trying to automate a strategy on TS using its EasyLanguage. Previously, I used intrabarordergeneration (IOG) and with a 5-minute backtesting, the results looked great but as mtzimmer1 suggested in the post above, I switched the resolution to 1 tick over a month, and the results were pretty disappointing. (This is because I am using 5-minute intervals and my positions last anywhere from 5 min to 2 hours with an average of 50 minutes). I don't know if I am going to use IOG in the near future, and I understand that if I turn on IOG, the orders for entry/exit are placed at the next tick if the entry/exit conditions are satisfied. Something that I don't really understand from the description of IOG on the EasyLanguage page is the following:
If I have a moving average of the past 5 periods (5-minute intervals) and IOG is turned on, then how is it calculating the moving average? It is definitely not of the past 5 ticks, so is it taking each tick and then going back 5, 10, 15, 25 minutes and taking the average? If I am saying Close[1] is that the previous tick or the Close of the previous 5-minute bar?

Now, for my next question. So, I've turned IOG off except for my Stop Losses and Profit Targets. Every entry and exit that I have defined is executed
This Bar at Close
If IOG is turned off for entry/exit and I am running 5-minute intervals on my strategy, I would expect that back-testing at the 5-minute interval would not be much different than back-testing tick by tick except for slippage in my stop losses. Now, why is this completely wrong? I compare the back-testing and they are completely different. The 5-minute makes decent profit after commission over a few days while the tick by tick does not. Is this all slippage? It doesn't make sense for it to be this different since the backtesting should factor in High/Low for Stop Losses, right?

Reply With Quote

Journal Challenge April 2021 results (now extended!):
Competing for $1800 in prizes from Jigsaw
looks_oneMaking a Living with the Microsby sstheo
(106 thanks from 17 posts)
looks_twoSalao's Journalby Salao
(32 thanks from 8 posts)
looks_3Deetee’s DAX Trading Journal (time based)by Deetee
(28 thanks from 11 posts)
looks_4Learning to Profit - A journey in algorithms and optionsby Syntax
(14 thanks from 9 posts)
looks_5Maybe a little bit different journalby Malykubo
(9 thanks from 8 posts)
 
Best Threads (Most Thanked)
in the last 7 days on futures io
Would You Sell Your System?
73 thanks
The Crude Dude Oil Trading System
42 thanks
Big Mike in Ecuador
40 thanks
The New Micro Contract - MICRO BITCOIN coming May 2021
25 thanks
futures io site changelog and issues/problem reporting
24 thanks
 
(login for full post details)
  #2 (permalink)
 mtzimmer1 
Legendary Recovering Method Hopper
Upstate NY
 
Experience: Intermediate
Platform: TOS
Broker: TD Ameritrade
Trading: Equities, Treasuries, Gold
 
mtzimmer1's Avatar
 
Posts: 798 since Dec 2018
Thanks: 2,178 given, 1,810 received

I'm not sure exactly why the difference in results is occurring but it usually has to do with how the strategy is coded. (What logic is used)

As far as the other question goes... IOG calculates the current price as the "close" until the bar itself actually closes. Say a five minute bar opens at 100.00. One minute in it has traded up to 100.24 and has satisfied the moving average condition; the order will be filled the moment the condition is met. We do not know what the close will be four minutes from now, and for that reason the tentative "close" is calculated as the last transacted tick.

I hope this answers at least half of your question.

-Zimmer

Follow me on Twitter Visit my futures io Trade Journal Reply With Quote
The following user says Thank You to mtzimmer1 for this post:
 
(login for full post details)
  #3 (permalink)
highlyimprobable
ridgewood, NJ
 
 
Posts: 13 since Aug 2019
Thanks: 8 given, 6 received



mtzimmer1 View Post
I'm not sure exactly why the difference in results is occurring but it usually has to do with how the strategy is coded. (What logic is used)

As far as the other question goes... IOG calculates the current price as the "close" until the bar itself actually closes. Say a five minute bar opens at 100.00. One minute in it has traded up to 100.24 and has satisfied the moving average condition; the order will be filled the moment the condition is met. We do not know what the close will be four minutes from now, and for that reason the tentative "close" is calculated as the last transacted tick.

I hope this answers at least half of your question.

-Zimmer

Hi again Mr. Zimmer! Ah, so what you are saying is that with IOG on with your example (which my question is completely related to but I phrased terribly), when the moving average condition is satisfied, say at exactly 10:26:00 and for simplicity a simple moving average, the simple moving average calculation is (Price(10:26) + Price(10:21) + Price(10:16) + Price(10:11) + Price(10:06))/5, right?

I will check my strategy code again to see what the difference is, but you don't think slippage is the problem? I checked the first page of the trades list and I think the trades (time and position) were all the same in the 5-minute back-testing and the tick by tick except for the losses/profits.

Reply With Quote
 
(login for full post details)
  #4 (permalink)
 mtzimmer1 
Legendary Recovering Method Hopper
Upstate NY
 
Experience: Intermediate
Platform: TOS
Broker: TD Ameritrade
Trading: Equities, Treasuries, Gold
 
mtzimmer1's Avatar
 
Posts: 798 since Dec 2018
Thanks: 2,178 given, 1,810 received


highlyimprobable View Post
when the moving average condition is satisfied, say at exactly 10:26:00 and for simplicity a simple moving average, the simple moving average calculation is (Price(10:26) + Price(10:21) + Price(10:16) + Price(10:11) + Price(10:06))/5, right?

Almost.

It is actually (Price(10:25) + Price(10:20) + Price(10:15) + Price(10:10) + Price(10:06))/5

It maintains the previous closes that have already been completed but uses last tick for the "close" of the currently un-closed bar.

Follow me on Twitter Visit my futures io Trade Journal Reply With Quote
The following user says Thank You to mtzimmer1 for this post:
 
(login for full post details)
  #5 (permalink)
highlyimprobable
ridgewood, NJ
 
 
Posts: 13 since Aug 2019
Thanks: 8 given, 6 received


mtzimmer1 View Post
Almost.

It is actually (Price(10:25) + Price(10:20) + Price(10:15) + Price(10:10) + Price(10:06))/5

It maintains the previous closes that have already been completed but uses last tick for the "close" of the currently un-closed bar.

Do you mean

(Price(10:25) + Price(10:20) + Price(10:15) + Price(10:10) + Price(10:26))/5

instead because 10:25 to 10:30 is the un-closed 5-minute bar?

So, it actually gives more emphasis to more recent prices.

Reply With Quote
The following user says Thank You to highlyimprobable for this post:
 
(login for full post details)
  #6 (permalink)
 mtzimmer1 
Legendary Recovering Method Hopper
Upstate NY
 
Experience: Intermediate
Platform: TOS
Broker: TD Ameritrade
Trading: Equities, Treasuries, Gold
 
mtzimmer1's Avatar
 
Posts: 798 since Dec 2018
Thanks: 2,178 given, 1,810 received


highlyimprobable View Post
Do you mean



(Price(10:25) + Price(10:20) + Price(10:15) + Price(10:10) + Price(10:26))/5



instead because 10:25 to 10:30 is the un-closed 5-minute bar?



So, it actually gives more emphasis to more recent prices.



Sorry for the error! Yes that is correct 10:26!

Emphasis should be equal to all five data points. Sum all five, and divide by five. Equal weighting!

Follow me on Twitter Visit my futures io Trade Journal Reply With Quote
The following user says Thank You to mtzimmer1 for this post:
 
(login for full post details)
  #7 (permalink)
highlyimprobable
ridgewood, NJ
 
 
Posts: 13 since Aug 2019
Thanks: 8 given, 6 received


mtzimmer1 View Post
Sorry for the error! Yes that is correct 10:26!

Emphasis should be equal to all five data points. Sum all five, and divide by five. Equal weighting!

Yes, I understand the weighting is equal, but I meant more along the lines of the following reasoning. With IOG on, the SMA is taking an average of values that are closer to the current time than with IOG off, where we have an average is spaced evenly by 5 minutes.

Thanks for all your help!

Reply With Quote
 
(login for full post details)
  #8 (permalink)
 kevinkdog   is a Vendor
 
 
Posts: 2,985 since Jul 2012
Thanks: 1,589 given, 5,925 received

You can easily see what is going on with IBOG by using a print statement:

var:bl(" ");
print(date,bl,time,bl,close,bl,close[1],bl,close[2],bl,close[3],bl,close[4],bl,close[5]);

My experience with IBOG is limited, as years ago I found it did not backtest the way I though it should, and results were so puzzling at times I thought I'd lose my mind.

My hair stopped falling out (OK, more slowly fell out) once I gave up on IBOG...

Follow me on Twitter Reply With Quote
The following 2 users say Thank You to kevinkdog for this post:
 
(login for full post details)
  #9 (permalink)
highlyimprobable
ridgewood, NJ
 
 
Posts: 13 since Aug 2019
Thanks: 8 given, 6 received


kevinkdog View Post
You can easily see what is going on with IBOG by using a print statement:

var:bl(" ");
print(date,bl,time,bl,close,bl,close[1],bl,close[2],bl,close[3],bl,close[4],bl,close[5]);

My experience with IBOG is limited, as years ago I found it did not backtest the way I though it should, and results were so puzzling at times I thought I'd lose my mind.

My hair stopped falling out (OK, more slowly fell out) once I gave up on IBOG...

Ahahaha, I think I am about to close the chapter that is IBOG. It seems like there is a huge potential with IBOG, but understanding the intricacies of it might not be worth it. Do you have any ideas as to why the back-testing for 5-minute is significantly different from the tick by tick when IBOG is only turned on for stop losses and profit targets?

Yes, you are completely right about the Print function (I am so used to having the Print results next to my code when I execute it that I completely ignore it when I'm on TS).

Reply With Quote
 
(login for full post details)
  #10 (permalink)
 kevinkdog   is a Vendor
 
 
Posts: 2,985 since Jul 2012
Thanks: 1,589 given, 5,925 received



highlyimprobable View Post
Ahahaha, I think I am about to close the chapter that is IBOG. It seems like there is a huge potential with IBOG, but understanding the intricacies of it might not be worth it. Do you have any ideas as to why the back-testing for 5-minute is significantly different from the tick by tick when IBOG is only turned on for stop losses and profit targets?

Yes, you are completely right about the Print function (I am so used to having the Print results next to my code when I execute it that I completely ignore it when I'm on TS).

I could guess at what might be going on, but to really know I'd have to see the code in cases like this. (I'm not asking to see it, to be clear.)

The huge potential you see with IBOG is likely just tricks being played on the backtest engine. IN other words, not real.

Follow me on Twitter Reply With Quote
The following 2 users say Thank You to kevinkdog for this post:
 
(login for full post details)
  #11 (permalink)
highlyimprobable
ridgewood, NJ
 
 
Posts: 13 since Aug 2019
Thanks: 8 given, 6 received


kevinkdog View Post
I could guess at what might be going on, but to really know I'd have to see the code in cases like this. (I'm not asking to see it, to be clear.)

The huge potential you see with IBOG is likely just tricks being played on the backtest engine. IN other words, not real.

Actually, I don't know why but the code was actually buy next bar at market, which I know now is a completely different scenario. Here is a simpler version of the code below anyways.
 
Code
FastMA = Average( FastPrice, FastLength );
MedMA = Average( MedPrice, MedLength );
SlowMA = Average( SlowPrice, SlowLength );

AveragesAlignedL = FastMA > MedMA and MedMA > SlowMA;

if CurrentBar > 15 and AveragesAlignedL and CurrentContracts = 0 then
	Buy numcontracts contracts next bar at market;
I know next bar at market is completely different from this bar on close, especially if you're trading on volatility, but it would still be great to learn your reasoning for the difference with backtesting.

Reply With Quote
 
(login for full post details)
  #12 (permalink)
 kevinkdog   is a Vendor
 
 
Posts: 2,985 since Jul 2012
Thanks: 1,589 given, 5,925 received


highlyimprobable View Post
Actually, I don't know why but the code was actually buy next bar at market, which I know now is a completely different scenario. Here is a simpler version of the code below anyways.
 
Code
FastMA = Average( FastPrice, FastLength );
MedMA = Average( MedPrice, MedLength );
SlowMA = Average( SlowPrice, SlowLength );

AveragesAlignedL = FastMA > MedMA and MedMA > SlowMA;

if CurrentBar > 15 and AveragesAlignedL and CurrentContracts = 0 then
	Buy numcontracts contracts next bar at market;
I know next bar at market is completely different from this bar on close, especially if you're trading on volatility, but it would still be great to learn your reasoning for the difference with backtesting.


Without IBOG on, this code when backtested will match live results very well. Just don;t forget to include slippage in backtest.

Follow me on Twitter Reply With Quote
The following user says Thank You to kevinkdog for this post:
 
(login for full post details)
  #13 (permalink)
highlyimprobable
ridgewood, NJ
 
 
Posts: 13 since Aug 2019
Thanks: 8 given, 6 received


kevinkdog View Post
Without IBOG on, this code when backtested will match live results very well. Just don;t forget to include slippage in backtest.

To be sure, you are saying that the 5 minute interval backtesting with the SMA with orders to buy next bar at market will match the live results? Or, the tick by tick?

Reply With Quote
 
(login for full post details)
  #14 (permalink)
 kevinkdog   is a Vendor
 
 
Posts: 2,985 since Jul 2012
Thanks: 1,589 given, 5,925 received


highlyimprobable View Post
To be sure, you are saying that the 5 minute interval backtesting with the SMA with orders to buy next bar at market will match the live results? Or, the tick by tick?

The strategy you show (which is just an entry), with IBOG off, will show the same results as live with Look Inside Bar Backtesting off, or equal to 1 minute, or equal to 1 tick resolution.

But that could change depending on the exits you use...

Follow me on Twitter Reply With Quote
The following 2 users say Thank You to kevinkdog for this post:


futures io Trading Community Platforms and Indicators TradeStation > TradeStation Back-testing/Intra-bar Order Generation/Slippage


Last Updated on September 3, 2019


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Journal Challenge w/$1,800 in prizes!

April

Seven Trading Mistakes Solved With Smart Trading Tools w/Brannigan Barrett

Elite only
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts