Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
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 for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
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.
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.
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.
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!
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.
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.
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
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
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.
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.
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.