Backtesting with TS intrabarordergeneration - futures io
futures io



Backtesting with TS intrabarordergeneration


Discussion in TradeStation

Updated
      Top Posters
    1. looks_one highlyimprobable with 6 posts (5 thanks)
    2. looks_two mtzimmer1 with 5 posts (3 thanks)
    3. looks_3 mattjack9708 with 1 posts (0 thanks)
    4. looks_4 kevinkdog with 1 posts (1 thanks)
    1. trending_up 1,097 views
    2. thumb_up 9 thanks given
    3. group 3 followers
    1. forum 12 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
 

Backtesting with TS intrabarordergeneration

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

So I've finished writing an algo for futures on TS using its Easylanguage. I've backtested all the way up till Aug 31, 2016 (I think that's as far as it goes) and I want to go live as soon as possible. Here's the thing: I turned on intrabarordergeneration and I have seen somewhere on this forum that it makes backtesting with TS inaccurate. Is there any way I can backtest more accurately then without having to create a backtesting platform? I am going to run the algo on Sim for a few days (it's a very simple algo) but what else should I do? Thanks!

Reply With Quote
The following user says Thank You to highlyimprobable for this post:

Journal Challenge April 2021 results (now extended!):
Competing for $1800 in prizes from Jigsaw
looks_oneMaking a Living with the Microsby sstheo
(76 thanks from 10 posts)
looks_twoSalao's Journalby Salao
(23 thanks from 5 posts)
looks_3Deetee’s DAX Trading Journal (time based)by Deetee
(15 thanks from 8 posts)
looks_4Learning to Profit - A journey in algorithms and optionsby Syntax
(12 thanks from 7 posts)
looks_5Rogue MNQ 2/21 Journeyby RogueJoules
(0 thanks from 2 posts)
 
Best Threads (Most Thanked)
in the last 7 days on futures io
The Crude Dude Oil Trading System
73 thanks
futures io site changelog and issues/problem reporting
71 thanks
Would You Sell Your System?
65 thanks
FIO Journal Challenge - April 2021 w/Jigsaw Trading
30 thanks
Big Mike in Ecuador
25 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: 793 since Dec 2018
Thanks: 2,178 given, 1,805 received


highlyimprobable View Post
So I've finished writing an algo for futures on TS using its Easylanguage. I've backtested all the way up till Aug 31, 2016 (I think that's as far as it goes) and I want to go live as soon as possible. Here's the thing: I turned on intrabarordergeneration and I have seen somewhere on this forum that it makes backtesting with TS inaccurate. Is there any way I can backtest more accurately then without having to create a backtesting platform? I am going to run the algo on Sim for a few days (it's a very simple algo) but what else should I do? Thanks!

It depends on what data resolution you need. Unless the system is an ultra short-term algorithm then 1 minute candles should be adequate for nearly everything. If you want the highest resolution possible you can use intrabarordergeneration and then specify to look inside the bar down to the tick. This will be the most accurate, but also the most time-consuming to download and test the dataset.

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
It depends on what data resolution you need. Unless the system is an ultra short-term algorithm then 1 minute candles should be adequate for nearly everything. If you want the highest resolution possible you can use intrabarordergeneration and then specify to look inside the bar down to the tick. This will be the most accurate, but also the most time-consuming to download and test the dataset.

I'm using 5 minute candles to see general trends and not enter and exit so quickly but I'm only holding positions for 40-60 minutes. There is too much noise with the 1 minute candle so I saw that the 5 minute is much better for my analysis. I set the intrabarordergeneration because sometimes I catch less of the momentum by the time I enter. I also set stop losses with the intrabarordergenerstion to True for that too because within 5 minutes I may lose 6000 when the stop loss is at 600. So, if I am understanding you correctly, the backtest shouldn't be that different from live?

Quick question about optimization/Walk-Forward optimization: I am walk-forward optimizing over a one year period (should this be longer?) with 35% of the data tested as out of sample test set. I don't think there's much overfitting (it's also a pretty simple algo) because I tested the algo against 1 year periods that don't include the training set or the test set and it performs as I want it to. Could you shed some light on how you perform optimizations on TS? I think I'm going to tweak the model parameters every few months using the TS optimization.

Reply With Quote
The following user says Thank You to highlyimprobable for this post:
 
(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: 793 since Dec 2018
Thanks: 2,178 given, 1,805 received

@highlyimprobable

You still need to specify the resolution with which to look inside the bar. I believe this is under strategy settings - I am away from my computer and not exactly sure.

All the strategies I trade are long term. (Daily candles) I backtest and optimize them first usually on SPY across the entire dataset I have. I then go in and ensure the strategy is performing acceptably well on correlated markets, such as QQQ, DIA and IWM. From there I test individual stocks. If the strategy performs well across all tests then I know I did not over-optimize it. This process also gives me quite a bit of faith in trading the strategy live.

If your strategy is written for equities I would recommend testing it on other correlated instruments. If it performs well then you are probably on to something.

-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)
  #5 (permalink)
highlyimprobable
ridgewood, NJ
 
 
Posts: 13 since Aug 2019
Thanks: 8 given, 6 received


mtzimmer1 View Post
@highlyimprobable

You still need to specify the resolution with which to look inside the bar. I believe this is under strategy settings - I am away from my computer and not exactly sure.

All the strategies I trade are long term. (Daily candles) I backtest and optimize them first usually on SPY across the entire dataset I have. I then go in and ensure the strategy is performing acceptably well on correlated markets, such as QQQ, DIA and IWM. From there I test individual stocks. If the strategy performs well across all tests then I know I did not over-optimize it. This process also gives me quite a bit of faith in trading the strategy live.

If your strategy is written for equities I would recommend testing it on other correlated instruments. If it performs well then you are probably on to something.

-Zimmer

So, I use the Format > Symbol > 5 minute intervals, but I think you are referring to the Format > Strategies > Properties for All > General > Back-Testing resolution > Use Look-Inside Bar Back-Testing (right?). If I set this to 1 tick, I guess this will be computationally heavy, but it would give the accurate back-testing results? Update: I don't think TS lets me set this to 1 tick as it says setting it to 1 tick will only allow me to back-test until 8/27/2019.

Thanks so much for your comments on back-testing in general, too!

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: 793 since Dec 2018
Thanks: 2,178 given, 1,805 received

You've got it. TS won't let you use that data until you download it from their servers. That does take a long time!
Try 1 minute instead of 1 tick. Should be much computationally heavy but also provide greater resolution than the 5 minute candles.

Without knowing the details of your code I'm not sure if there will be any benefit to looking inside the 5 minute bar. Is it possible for your strategy to trigger both an entry and an exit in the same bar? Is it possible for something to happen during the formation of the five minute bar that turns your entry condition false? If no to both, then you probably don't need to use a resolution greater than 5 minutes.

-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)
  #7 (permalink)
highlyimprobable
ridgewood, NJ
 
 
Posts: 13 since Aug 2019
Thanks: 8 given, 6 received

So, now, the profits are much smaller than before (around 4 times less) using the 1 minute bars, but at least now I will be going in with adjusted and reasonable expectations.


Quoting 
Without knowing the details of your code I'm not sure if there will be any benefit to looking inside the 5 minute bar. Is it possible for your strategy to trigger both an entry and an exit in the same bar? Is it possible for something to happen during the formation of the five minute bar that turns your entry condition false? If no to both, then you probably don't need to use a resolution greater than 5 minutes.

So, my entry and exits for Long/Short all depend on some sort of moving averages calculated using the close of the bar. When I turn on intrabarordergeneration, I understand that
 
Code
Buy numcontracts contracts next bar at market
means to buy that many contracts the next tick(?), but intrabarordergeneration should not affect the conditions for my entry/exit, right? So, to address one of your points, it is possible for something to happen during the five minute bar so that my entry condition is no longer true, but if my input is
 
Code
Price( Close )
and my moving averages are built on that, then shouldn't the Close refer to the Close of the last 5-minute bar?

I actually think there's a problem since after I turned it on, the algo is trading 8 times more than it used to.

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

Okay, here is a simple question. If you are calculating based on closing values why not just buy/sell on the close of the bar? That way there will be no separation between expectations and reality.

Follow me on Twitter Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #9 (permalink)
highlyimprobable
ridgewood, NJ
 
 
Posts: 13 since Aug 2019
Thanks: 8 given, 6 received


mtzimmer1 View Post
Okay, here is a simple question. If you are calculating based on closing values why not just buy/sell on the close of the bar? That way there will be no separation between expectations and reality.

Because my targets are set so close, buying at the close of the bar is very different when I backtest compared to buying at next bar at the market with intrabarordergeneration. I tried what you suggested and it seems to be a difference of no profit and profit.

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



highlyimprobable View Post
Because my targets are set so close, buying at the close of the bar is very different when I backtest compared to buying at next bar at the market with intrabarordergeneration. I tried what you suggested and it seems to be a difference of no profit and profit.

Interesting. Make sure you are not fooling yourself with the backtest. Watch it live on SIM and see if you can figure out the glitch.

I completely understand the desire to keep proprietary code private, BUT I am happy to take a look at the logic of your strategy if that would be any benefit to you. Feel free to PM me.

-Zimmer

Follow me on Twitter Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #11 (permalink)
highlyimprobable
ridgewood, NJ
 
 
Posts: 13 since Aug 2019
Thanks: 8 given, 6 received


mtzimmer1 View Post
Interesting. Make sure you are not fooling yourself with the backtest. Watch it live on SIM and see if you can figure out the glitch.

I completely understand the desire to keep proprietary code private, BUT I am happy to take a look at the logic of your strategy if that would be any benefit to you. Feel free to PM me.

-Zimmer

You are absolutely right about the SIM (Labor Day weekend is killing me with curiosity).

It would be great for second eyes to see what is going on, but I'll have to run that by my business partner. Thank you so much for all your help!

Reply With Quote
The following user says Thank You to highlyimprobable for this post:
 
(login for full post details)
  #12 (permalink)
mattjack9708
Wisconsin
 
 
Posts: 28 since Sep 2019
Thanks: 8 given, 7 received

This does not sound easy

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

Don't use intrabar order generation if you want an accurate backtest

Use 1 minute Look Inside Bar backtesting for most accuracy

Don't use SIM for anything other than verifying that orders are firing correctly. Trying to measure and compare performance results with TS sim is a TOTAL waste of time.

If you set up your strategy logic correctly, and avoid certain keywords (setpercenttrailing, for example), you should get a good match between backtest and live real money trading, assuming you have accurate results for slippage

It seems daunting at first, but once you get it, it becomes second nature.

Start with a simple strategy with "buy next bat at market" "sell next bar at market" etc. That will always work, and give excellent match between backtest and live (after accounting for slippage), except in very rare occasions.

Follow me on Twitter Reply With Quote
The following user says Thank You to kevinkdog for this post:


futures io Trading Community Platforms and Indicators TradeStation > Backtesting with TS intrabarordergeneration


Last Updated on September 2, 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