NexusFi: Find Your Edge


Home Menu

 





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 kevinkdog with 2 posts (3 thanks)
    4. looks_4 mattjack9708 with 1 posts (0 thanks)
    1. trending_up 3,663 views
    2. thumb_up 11 thanks given
    3. group 4 followers
    1. forum 14 posts
    2. attach_file 0 attachments




 
Search this Thread

Backtesting with TS intrabarordergeneration

  #1 (permalink)
highlyimprobable
ridgewood, NJ
 
Posts: 13 since Aug 2019
Thanks Given: 8
Thanks Received: 6

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
Thanked by:

Can you help answer these questions
from other members on NexusFi?
Increase in trading performance by 75%
The Elite Circle
Trade idea based off three indicators.
Traders Hideout
Better Renko Gaps
The Elite Circle
How to apply profiles
Traders Hideout
REcommedations for programming help
Sierra Chart
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
36 thanks
Tao te Trade: way of the WLD
24 thanks
Spoo-nalysis ES e-mini futures S&P 500
21 thanks
Bigger Wins or Fewer Losses?
19 thanks
GFIs1 1 DAX trade per day journal
16 thanks
  #2 (permalink)
 
mtzimmer1's Avatar
 mtzimmer1 
Upstate NY
Recovering Method Hopper
 
Experience: Intermediate
Platform: TOS
Broker: TD Ameritrade
Trading: Equities, Treasuries, Gold
Posts: 840 since Dec 2018
Thanks Given: 2,201
Thanks Received: 1,918


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 NexusFi Trade Journal Reply With Quote
Thanked by:
  #3 (permalink)
highlyimprobable
ridgewood, NJ
 
Posts: 13 since Aug 2019
Thanks Given: 8
Thanks Received: 6



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
Thanked by:
  #4 (permalink)
 
mtzimmer1's Avatar
 mtzimmer1 
Upstate NY
Recovering Method Hopper
 
Experience: Intermediate
Platform: TOS
Broker: TD Ameritrade
Trading: Equities, Treasuries, Gold
Posts: 840 since Dec 2018
Thanks Given: 2,201
Thanks Received: 1,918

@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 NexusFi Trade Journal Reply With Quote
Thanked by:
  #5 (permalink)
highlyimprobable
ridgewood, NJ
 
Posts: 13 since Aug 2019
Thanks Given: 8
Thanks Received: 6


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
Thanked by:
  #6 (permalink)
 
mtzimmer1's Avatar
 mtzimmer1 
Upstate NY
Recovering Method Hopper
 
Experience: Intermediate
Platform: TOS
Broker: TD Ameritrade
Trading: Equities, Treasuries, Gold
Posts: 840 since Dec 2018
Thanks Given: 2,201
Thanks Received: 1,918

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 NexusFi Trade Journal Reply With Quote
Thanked by:
  #7 (permalink)
highlyimprobable
ridgewood, NJ
 
Posts: 13 since Aug 2019
Thanks Given: 8
Thanks Received: 6

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
Thanked by:
  #8 (permalink)
 
mtzimmer1's Avatar
 mtzimmer1 
Upstate NY
Recovering Method Hopper
 
Experience: Intermediate
Platform: TOS
Broker: TD Ameritrade
Trading: Equities, Treasuries, Gold
Posts: 840 since Dec 2018
Thanks Given: 2,201
Thanks Received: 1,918

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 NexusFi Trade Journal Reply With Quote
  #9 (permalink)
highlyimprobable
ridgewood, NJ
 
Posts: 13 since Aug 2019
Thanks Given: 8
Thanks Received: 6


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
  #10 (permalink)
 
mtzimmer1's Avatar
 mtzimmer1 
Upstate NY
Recovering Method Hopper
 
Experience: Intermediate
Platform: TOS
Broker: TD Ameritrade
Trading: Equities, Treasuries, Gold
Posts: 840 since Dec 2018
Thanks Given: 2,201
Thanks Received: 1,918



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 NexusFi Trade Journal Reply With Quote




Last Updated on December 9, 2022


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts