Live trades do not match those of the backtest
Forums › ProRealTime English forum › ProOrder support › Live trades do not match those of the backtest
- This topic has 30 replies, 5 voices, and was last updated 6 months ago by Tropic.
-
-
06/12/2024 at 9:12 AM #233782
Hi, I’ll tell you about a problem I had with my account. I hope you can help me.
I coded a trading system for the Nasdaq 1min timeframe and backtested it on 1 Million bars. Then I put it live for about 1 month and did the backtest again, the result is that the trades it made live are totally different from the backtest!
Can anyone explain to me how this is possible?I also contacted IG support and the technical report on PRT and for 3 weeks now they have been saying that they are still analyzing the problem and can’t give me an answer (which is shameful I would say).
Another thing I can tell you is that by lowering the bars with which I backtest the code (around 50k bars) the backtest trades begin to be similar to live trades.
But I obviously want the 1 million bar backtest to contain the trades that it also makes live because obviously I would like to rely on this backtest to put the system live.
I hope you can help me, I don’t know who to turn to anymore.
Thank you!
06/12/2024 at 10:02 AM #233796Depending on the code, running a backtest ‘starting from’ exactly same time and date as your Live running Algo started may give a better comparison of Backtest Trades vs Live Trades.
Try above and let us know your findings splease.
06/12/2024 at 12:11 PM #233804Yes, if I start the backtest from when I put the algo live (which is around 20k bars) the trades match.
But I’m interested in whether they match even if I do the backtest with 1kk bars because that’s what I want to base my work on, but unfortunately this doesn’t happen. Why?
Basically there are different backtests on the same asset and timeframe (Nasdaq 1 minute), which is very strange considering that the graph and the asset price data is always the same, it doesn’t change if I do a backtest with 20k or 1kk bars, only the date of start of backtest changes.
I hope I explained myself.
06/12/2024 at 12:24 PM #233805But I’m interested in whether they match even if I do the backtest with 1kk bars because that’s what I want to base my work on, but unfortunately this doesn’t happen. Why?
If your Live Algo ALSO started 1kk bars ago (at exact same time / date) then the trades may (nearly) match.
Reason: Backtest of 1kk bars may result in a trade being (already) open when you start your Live running Algo (which will not have a trade open when you start the Live Algo so you are startying mis-matched from the very beginning).
The above scenario can result in trades not exactly matching-up for a long time (maybe never?) ?
It depends on the strategy in the code re entry and exit conditions.
06/12/2024 at 1:10 PM #23380706/12/2024 at 2:29 PM #233810Hi Tropic,
Yes, if I start the backtest from when I put the algo live (which is around 20k bars) the trades match.
Grahal already said it indirectly, but you must not start the backtest “around” some number, but within a Live period without position so the backtest willrun into the exact same first trade as Live did.
If you then still see major differences, it will be about your “backtesting capabilities”. This is harder to explain, but for example the price changes throughout time and if you deal with this “wrongly”, then a time/trade in the past does not bear the same value (e.g. of your SL).Good luck now !
Peter1 user thanked author for this post.
06/13/2024 at 12:39 AM #233814@PeterSt and @GraHal, so the idea here is to start ‘flat’, okay, this makes sense, it’s like zeroing whatever you can think of, a baseline.
How does preload bars affect this? Reading somewhere it’s EMA and other indicators etc need some history or perhaps anything that relies upon a ‘chunk’ of initial sized data to work with, that too makes sense, assuming I’m on the right page.
Reading back a long while back Peter said that your auto-trader will/can ‘accumulate’ bars. Does this mean you might need to run it initially, while maintaining a flat position and acquiring enough of a dataset to work with? Is this a thing? Bit confused as to how it might work. Do you ‘start’ the system forcing a zero tally or no trading initially, pause re-cfg then go gain (not sure if this can be done) or code it to commence upon meeting the data bar count you need to blast off.
Does the Demo help here?
06/13/2024 at 1:44 AM #233817Inv, yes, the “preload” sure is a thing. I started typing that in my previous post, but thought it would over-complicate. Thus indeed, start when Live was Flat, but give the Backtest sufficient air to do its thing with Averages and such.
It would be true that a lot of my codes is about “start through” which is another subject in this realm, BUT which can be avoided when all is completely linear in the first place. And, linearity consumes … 90% of my (1000+++ lines of code(s)) ?
Yep. This includes aforementioned price change. Or what about your portfolio in AUD while trading Nasdaq, eh ? Now it includes currency rate changes as well. And if you think you got that covered, there’s also still points involved. They too change over time (same as price, but your code may think to avoid price by working with points – it won’t).… And if you covered for all of this, you won’t be able to understand your own code any more. At least that is my problem. So if something needs to change (like starting Commodity contracts) then you won’t know where to be any more; it’s all (recursively) influencing matter which ever back was consistent but which will start to pile up.
Reading back a long while back Peter said that your auto-trader will/can ‘accumulate’ bars.
This is mainly about Money Management. But again, when all has been set up fully linearly, this won’t bother for the Entries and Exits. For the Gain, yes, but this is something to look through easily.
I think proper backtesting really is a skill. And as with so many things I say : one could graduate on it (as in : 4 years of university may master it finally).Does the Demo help here?
IMHO not, because it takes way too long. Trial all in Live is my devise, and of course reserve some $ for that. It’s just part of the game (again, IMO). It’s like running a business. It takes a lot of time investment (re-trial over and over) and it requires $ investment just the same. No free lunch is not really applicable, but it comes to mind.
Regards !
Peter1 user thanked author for this post.
06/13/2024 at 2:57 AM #233819Are there bar limits w/in an autotrader?
If so, can you trigger a system to only start once a predefined bar count has elapsed post 10,000 bar preload?
For example, system starts with 10k preload but only starts to execute after 20k bars have elapsed in total (10k preload + 10k live) ….
I’m not sure how to give ‘anything’ a bit of air to live, just trying to get a handle on whether we can ‘start deciding’ after 20kbars have elapsed in live auto-trader mode (not only the back test) to leverage the 20k. Apologies I’m unfamiliar with the process.
06/13/2024 at 5:22 AM #233820but give the Backtest sufficient air to do its thing with Averages and such.
So how does this work when you only have 10k bar preload in a live environment when ave. etc might need more –
This is the gist of my initial qu. ….
06/13/2024 at 6:44 AM #233822Apologies for dropping in OP.
Similar topic has come up before re: mixed TF and how bar counts affect outcomes wrt HTF when they exist as part of a strat. run on a LTF.
You responded there @PeterSt but couldn’t negotiate my ramblings to remember as much …. perhaps we could be of similar ilk. Ramble On.
https://www.prorealcode.com/topic/htf-coding-and-preload-bars/
06/13/2024 at 8:26 AM #233824So how does this work when you only have 10k bar preload in a live environment when ave. etc might need more –
Sitting back and thinking … 😉
What you suggest, I think, is that Backtest will build up that history on the fly (but not for the very first trade, as there the 10K Preload counts just the same) but that all further trades may benefit from the extra “preload” by that time. So yeah, that will imply a difference with backtesting on the Live situation either because a. the Backtest starts earlier than the date/time the Live started (now Backtest will have more preload than Live) or because b. Backtest was started later because you possibly can’t see when Live started because in aftermath you can only see the first trade (which surely may not have occurred after processing of 10K -but MORE (Entry-OK just did not occur after 10K bars but later)).
Ad a.: This will be an illegal situation because you won’t be able to have the first trades of both Backtest and Live synchronised.
In either case you can only do this (and this is what I do) :
Friggle as long as it takes in order to get the first trade synchronised. After that it should be fine (but with 10K bars required for Preload all bets may be off).To be honest, this got me thinking about stuff I never think about. But also : I don’t use this kind of matter. And you know, that is strategy as such just the same; avoid uncertainty.
One should not even start to think about relying on matter which is unknown.Even more bets are off when the Backtesting is not representative for the future’s reality anyway. Thus, we now talk about mimicking Live in retrospect (via Backtesting) but that is the most easy part of it all (but if you can’t do that, then forget about Autotrading all together – think about this please). The art of this game, of course, is creating a Backtest which will reoccur in the future.
Easier said than done ?1 user thanked author for this post.
06/13/2024 at 10:03 AM #233831creating a Backtest which will reoccur in the future.
This may go down like a ‘lead balloon‘ 🙂 and it’s not really a reply to Peter, but more to Inverse … it is because of above conundrum that I optimise over 10K bars or even 1K bars if on 1 Hour Timeframe for example.
Over 10k bars, I dont have to suffer the enthusiasm-sapping slowness of a long optimise, but also … recent price action is more akin to immediate future price action than 1,000,000 bars in the past (as most on here seem to aspire to?).
If the last 10K bars have all been on a strong uptrend and price is clearly turning strongly down, then I might optimise over 5k bars … this to include 2.5k bars of uptrend and 2.5k bars of recent turning downtrend.
Above logic likely not aligns with many others thinking on here!?
Not quite 4 years university (as PeterSt joked) but 8 years a heavy user / optimiser with PRT.
06/13/2024 at 10:36 AM #233835@ PeterSt, thankfully, I’ve been able to dig out other posts that have confirmed where I land and that is perhaps w/in the 10k limit. You also commented in those threads.
It’s pretty straight forward, said by you and others, you seem to have your Riddler hat on today – I must be lucky … 😉
In the event your auto-system requirement exceeds the 10k preload limit (requires a larger dataset) to trigger trades, it could either:
a. not trade until there’s enough data
or;
b. perhaps trigger erroneously, with a variation seen between live and back testing, perhaps making back testing superfluous when sufficient data’s just not there if 10k caps. It will be code dependent (said by others AND YOU).
What’s lead me to these qu. is:
I have seen, indicators, return lets call them ‘indifferent’ prints to cli – at times – but more importantly be dependent entirely upon chart bar ‘count’ – not back testing, not anything overly complicated but indicators and never the less a presence – which are clearly erroneous prints as a reflection of bar count (or are they).
I have also been chasing errors due to packet loss (which does not affect you because you do no client side eval – you’re past it and it’s mostly server side now for you – congrats you now know it all /s).
I’ve never implied half of what you’re saying and I’m sure you’re not thinking too hard about this at all – be careful, while sitting back, you don’t simply fall off your chair. FWIW, your 2nd para comes close as does the 4th wrt to how you deal with your setup (assuming that’s what you do and it’s not a misdirect).
Your 2nd last and last paragraph was lost on me.
My initial objective in using PRT was to ‘housekeep’ not auto-trade and I’m not reliant on any auto-trading but it’s peaked my interest and I’d like to see where the journey could go, it’s got legs.
I’ve been told by friends/associates that until PRT have an APAC presence that I should not waste my time, and so I’ve moved to a more resilient setup that will, maybe, circumvent data transmission issues in play and hopefully not waste my time. They run global backbones and see it from there POV and don’t get my effort given I’m retired but I like PRT – I’m also looking seriously at succession etc. The person I’ve earmarked is completing there doctorate and is a blue sky candidate at deep mind (science, not google), they’re keen but they’re next level societal contributors and I can’t impose my will on them, in fact they are one of my children, the baby of the brood. You think you have problems explaining yourself to your son, think again.
I’m not sure why you see my questions as SO difficult, perhaps they’re beneath you, menial. So far you’ve managed to really go off the beaten path with replies to me, do I threaten you, lol, are you terrified of giving away your ‘secret sauce’….. I’ve always taken a path less travelled myself but brother I think you’re ahead on that front.
More ways to skin a cat than cans on coke out there. It’s all in the idea.
/rant
06/13/2024 at 11:52 AM #233836No lead balloon there but perhaps a ‘stairway’……
I’m in agreeance @GraHal and is inline with my KISS take on life. Wow 8yrs is a long time.
I’ve tried to tackle what I’d like to achieve in terms of small opportunities by ‘drawing text’ to screen and dumps to cli. Marrying an understanding? developed over many decades, (most of which has been screen time trading futures with my own bloomberg term with what started as LQUAY Futures here in AUS) – then inject those ‘indicators’ into an auto-trader etc etc . So I’m a newb on the PRT front but not really a trading newb (always learning though) – I can’t quite pip your ’85 crude comment from the other thread but I’m not that far off – both you and others on thread are so far ahead it’s not even funny – 8 years, wow (again). May as well give up now!
Although my background is in engineering, I was an ‘early work from home’ consultant, yeah one of those, who did as they pleased for the most part, the scars I left behind in the ICCU, so it’s not been all beers n skittles.
I DO appreciate everyone’s feedback but Peter likes to derail what I’m getting at (as times, sport I guess), and I apologise if I’ve misinterpreted Peter. It’s quite possible that because of my lack of IP that I’m unable to interpret there post and that’s on me.
I DO expect though, that I’m likely to screw the pooch when I make my foray into auto-trading and is WHY I’m here trying to harness as much IP as I can. Professionally I lived in the grey and release note’s, contributed to global buildout of what we know now as the ‘Internet’. I would be going against the grain, period, I didn’t ask so many questions.
I like what you’ve said about optimisation post down turn and how you might optimise over 5k bars – I like it because I have no idea what it means (eg: how to do it w/in PRT, and I’m okay with that, I can learn) – other than you needing to tweak outcomes based on env. needs, it lends itself to knowing your animal and tools well enough.
Thanks for taking the time to post.
Now I need to make sure that I can ‘fit’ within a 10k preload …. !
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on