Backtesting with TS intrabarordergeneration - futures io
futures io futures trading



Backtesting with TS intrabarordergeneration


Discussion in TradeStation

Updated by kevinkdog
      Top Posters
    1. looks_one highlyimprobable with 6 posts (5 thanks)
    2. looks_two mtzimmer1 with 5 posts (3 thanks)
    3. looks_3 kevinkdog with 1 posts (1 thanks)
    4. looks_4 mattjack9708 with 1 posts (0 thanks)
    1. trending_up 705 views
    2. thumb_up 9 thanks given
    3. group 3 followers
    1. forum 12 replies
    2. attach_file 0 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 100,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)
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:

Can you help answer these questions
from other members on futures io?
Think or swim earnings move calculation
Brokers
Linear Regression Slope Indicator
TradeStation
Anyone scalp the Mini-DAX (FDXM)?
Emini and Emicro Index
FYI plot bug & workaround: changing color or width is delayed 1 bar
EasyLanguage Programming
Any Jim Dalton's June 2020 Intensive Graduates?
Emini and Emicro Index
 
Best Threads (Most Thanked)
in the last 7 days on futures io
Are sharks watching on the other side?
52 thanks
Sierra Chart ACSIL for Beginners.
45 thanks
Earn2Trade (Helios) - "The Gauntlet"
26 thanks
VWAP for stock index futures trading?
16 thanks
FIO Journal Challenge - June 2020 w/SharkIndicators
15 thanks
 
(login for full post details)
  #2 (permalink)
Legendary Market Wizard
Bluffton, SC
 
Experience: Intermediate
Platform: TOS
Trading: Equities, Treasuries, Gold
 
mtzimmer1's Avatar
 
Posts: 604 since Dec 2018
Thanks: 1,587 given, 1,293 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.

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)
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)
Legendary Market Wizard
Bluffton, SC
 
Experience: Intermediate
Platform: TOS
Trading: Equities, Treasuries, Gold
 
mtzimmer1's Avatar
 
Posts: 604 since Dec 2018
Thanks: 1,587 given, 1,293 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

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)
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)
Legendary Market Wizard
Bluffton, SC
 
Experience: Intermediate
Platform: TOS
Trading: Equities, Treasuries, Gold
 
mtzimmer1's Avatar
 
Posts: 604 since Dec 2018
Thanks: 1,587 given, 1,293 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

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)
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)
Legendary Market Wizard
Bluffton, SC
 
Experience: Intermediate
Platform: TOS
Trading: Equities, Treasuries, Gold
 
mtzimmer1's Avatar
 
Posts: 604 since Dec 2018
Thanks: 1,587 given, 1,293 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.

Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #9 (permalink)
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)
Legendary Market Wizard
Bluffton, SC
 
Experience: Intermediate
Platform: TOS
Trading: Equities, Treasuries, Gold
 
mtzimmer1's Avatar
 
Posts: 604 since Dec 2018
Thanks: 1,587 given, 1,293 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

Visit my futures io Trade Journal Reply With Quote


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


September 2, 2019


Upcoming Webinars and Events
 

Free BloodHound Licenses for everyone!

June
 

Every journal equals ten meals for the hungry

June
     



Copyright © 2020 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