Tick by tick vs. timeframe
Forums › ProRealTime English forum › ProOrder support › Tick by tick vs. timeframe
- This topic has 12 replies, 6 voices, and was last updated 1 year ago by kt.
Tagged: backtest, candlestick, candlesticks, live, tick, tick-by-tick.mode
-
-
09/28/2023 at 1:33 PM #221743
Hi Experts,
If using, e.g a 5-min timeframe chart, with a tick by tick backtest, does it means the automated trading system should be executed at the minimum timeframe, say 1 second, in order to achieve the closest result vs backtest, assuming there is 1 tick per second . (Yes I do understand backtest does not represent future result)
09/28/2023 at 2:01 PM #221744automated trading system should be executed at the minimum timeframe, say 1 second,
If using a 5 min Timeframe on your chart and a tick by tick backtest then it is fine to use either a 5 min Timeframe in your code or any Timefrme in your code less than 5 mins as you prefer.
There is no need to backtest at 1 second timeframe when using tick by tick backtest.
09/28/2023 at 9:25 PM #221760Hi Grahal,
Is my understanding correct?
When I use a 5-minute timeframe for tuning the indicators and backtest with tick-by-tick data, the backtest will simulate the actions and results based on each tick movement within the 5-minute bars. This means there could be multiple ticks within one 5-minute bar, and the system would make decisions and calculate results based on these individual ticks.
However, when I run the system in a 5-minute timeframe in real-time trading, it typically means that the code execution and decision-making occur at the end of each 5-minute bar. This is a fundamental difference compared to tick-based backtesting, where actions can occur within the bar.
So, while my indicators and strategies might perform well in a tick-based backtest, real-time execution in a 5-minute timeframe may yield different results due to the discrete nature of 5-minute bar intervals. It’s essential to be aware of this distinction when transitioning from backtesting to live trading.
so I should trade at a low timeframe regardless of the timeframe used in tick by tick backtest based on the reason mentioned.
09/29/2023 at 2:41 AM #221761Backtest is a simulation of what happened in the past, therefore candlesticks need to be rebuilt from scratch each time. So considering a candiestick as a whole or as N ticks makes a big diffference. That’s when tick-by-tick is helpful.
LIVE trading works while candlesticks are being formed, so it’s tick-by-tick only. This has nothing to do with the execution and of strategies at the closing of each candlestick. SL and TP are always hit when THAT price tick arrives. The execution of AT-MARKET orders only is affected by the closing of candlesticks (and this is where MTF and lower TFs come handy) as pending orders are always working in tick-by-tick mode.
When you backtest your code, the current X-minute candlestick will have to be rebuilt after X minutes, that’s when tick-by-tick mode is helpful.
LIVE trading can’t be but in tick-by-tick mode.
09/29/2023 at 2:54 AM #221763Hi Robert,
Thanks for explaining.
What I meant was:
- develop system code and initially backtest it using a 5-minute timeframe instrument with tick-by-tick data,
- then optimize the code variables through a walk-forward process still with tick-by-tick data, and
- finally run the optimized system in a 1-second interval during live trading to ensure it closely emulates tick-based backtesting, accounting for the high-speed nature of real trading
In the past, and even today, I’ve been running my systems based on the 5-minute timeframe used during backtesting. However, I’m now contemplating the tick-by-tick option and questioning whether I should execute the optimized 5-minute system with a 1-second interval in live trading. I’m seeking clarity on this decision.
Thanks again.
KT
09/29/2023 at 3:22 AM #221765Tick-by-tick mode only affects backtesting.
LIVE trading can’t be but in tick-by-tick mode.
Running a strategy on a 1-second TF means it is executed at the fastest pace available, every second, but in a second several ticks may arrive.
Choosing a lower TF ensures your decisions, such as placing AT-MARKET entry or exit orders, are evaluated the sooner, but all pending orders are evaluated as ticks arrive, even several times in a second.
If you need to decide whether setting a breakeven or not, this can only be done when a candle closes, so a Daily, 5-minute or 1-second TF may make a big difference. But once you have placed a pending order at the breakeven price, that order will be triggered no matter if a candlestick is being formed and what TF it comes from, just when a tick with that price arrives from the market.
09/29/2023 at 3:36 AM #221766Hi Robert,
To provide more context, my trading system incorporates multiple timeframes (240 minutes, 60 minutes, 5 minutes, and 1 minute) and employs entry and sell triggers based on the crossing of X and Y indicators within the 1-minute timeframe.
Notably, it doesn’t rely on timeframes (TF), stop-loss (SL) orders, or ‘updateonclose’ functionality. If I use 1 sec TF in the backtest, PRT would limit the data for other TF which I wish to keep.
The dilemma I face is that when running the system in a 1-minute timeframe, it potentially misses multiple ticks compared to the backtested results. I’m contemplating whether, even though the system doesn’t utilize a 1-second indicator, it might be prudent to operate it with a 1-second interval in live trading to align more closely with the backtesting outcomes.
I apologize for the back-and-forth; I’m trying to grasp the concept, and I’m concerned that I might have overlooked something fundamental
KT
09/29/2023 at 4:00 AM #22176709/29/2023 at 5:24 AM #221768Hi kt,
Indeed it looks like you are missing a concept, but in a fashion which is hard t see-through. Therefore it is easy to talk passed each other. So as a third person, let me try. 🙂
If using, e.g a 5-min timeframe chart, with a tick by tick backtest, does it means the automated trading system should be executed at the minimum timeframe, say 1 second, in order to achieve the closest result vs backtest, assuming there is 1 tick per second . (Yes I do understand backtest does not represent future result)
First off, there won’t be any difference between backtesting and Live. So let’s keep that in mind – you should always fall back on that to the sense of “why do they keep on telling me this ?!?” – then you give yourself a chance of grasping it.
I will repeat but rephrase what Robert tells :
Tick by tick mode in backtesting is normally always On and it should be always On. There should not even be a checkbox for it. All what would happen when it is Off, is that no two trades within one bar will be dealt with in “Live” fashion. The implication of that : when you’d have a 5 minute TF and you imply two trades within that 5 minute bar, they will happen but in a prosperous way (thus in Live the Strategy will always workout for the worse – sorry for my English). So have tick by tick mode On, and Live will respond the same.
It is all about pending orders. So without Pending Orders, there can’t be more trades within one bar. Thus read Roberto’s posts again, and keep that in mind. Btw, Pending Order : A Limit or Stop Order which is set at a price, and where touching the price will (normally) let fill the order. This is opposed to a Market Order, which will never “trade” within the bar (unless it is slowly filled)- it will only trade at the start of a bar, which is when your code executes. When does your code execute ? at the end of a bar and actually between that and the new bar. It is the most essential to grasp this. If you do ? read once again Robert’s posts.When tick by tick mode would be Off (remember, it never should be), the Pending Orders are now also executed at the end of the bar. Not good, because that never will be reality.
When this all starts to dawn on you (maybe it already did !), there’s one crucial aspect to understand : how does the TF of the chart relate to the TF commands …
The TF of the chart brings you the response to “time”. Thus, if the TF of the chart is 5 minutes, you never can respond faster than at the 5 minute interval (which is fixed, like 10:00, 10:05, 10:10, 10:15 etc.). The ticks will be there anyway, with the notice that a tick is a trade of someone (it is not a timeframe element – it is a trade). This means two things :
– Your program code is executed at the 5 minute interval only (not faster and also not slower);
– Market orders will be given to the broker at that same interval;
BUT
– Pending Orders will be executed (filled) when the price is touched.
and
– The TF commands in your code are only there to work with the averages at a slower level – they don’t depict the responsiveness of your System; the TF of the chart depicts that and the smart falling back to that TF (with TF commands of the same time as the chart) makes or breaks your System.Never anywhere there’s a difference between backtesting and Live (or Demo for that matter). Even the ticks are real with backtesting (as in : how they happened in the past), but of course it is about the past only. One thing though : if you let run your backtest in Live (“Forward testing”), you will see that the behavior is 100% the same, as long as you in your code can capture all for reality (like spread, which you actually can’t). Thus :
Put in Graph and GraphOnPrice commands, let that just run while looking at a Live chart and you will see that all behaves the same regardless (but use tick by tick mode 😉 ). Below an example of that, though this obviously shows the past. :-). This is from yesterday. Point obviously is : you can compare with Live (the green and red trade icons are Live) only when you have a Strategy Live first (Demo is allowed just the same). If you now incorporate all there is for mimicking Live with Backtest, you will see all shows up the same.There is no need to even think it will be different.
Now you can do it too.Peter
09/29/2023 at 7:45 AM #221771FYI : This happened minutes ago in real time. Thus, this is about the Forward Testing I was talking about (chart is at 1 minute).
In the second screenshot you see the detail from the past of an Exit and the small triangle showing that this has been an in-bar trade by means of a Stop Order (with Live only very slightly different entry price difference). The Entry a bit later virtually shows one triangle (both are exactly overlaid) but this entry was done by means of a Market Order.
For completeness, the third screenshot shows an in-bar Entry of a Limit Order.And while we are at it anyway, the fourth screenshot shows a Limit Order again, in bar, that happening 1 minute ago (thus that is Forward Testing again, next to the Live situation). I am not sure whether I can claim that because this is forward testing, the triangles always will overlay exactly. Hence, Backtesting in forward mode will always use Live data ? I think so.
As I said, now you can do it too; this all just works fine without attention (but have tick by tick for the Backtesting set to On).
09/29/2023 at 8:27 AM #221778Tick-by-tick testing in backtests are used to test if the order could have been stopped because of price crossing target profit or stoploss prices. It doesn’t mean that it runs the code on each tick.
Behavior of code is always: read at Close and orders launched at next open, with or without tick-by-tick box checked.
09/29/2023 at 9:13 AM #221781When you first look at indicators and trading systems, they are always executed based on the chosen time frame, namely on the “Close” of the candle… (this has nothing to do with the “tickdata”)
When you choose a faster time frame, your indicators and trading system will react faster but will always be executed on the “Close” of the respective time frame…
So here everyone weighs up which time frame they should use for a certain system /indicator where you could argue that a fast time frame offers more possibilities than a slow time frame, but everyone has their own opinion about that.
So again, indicators and trading systems are executed based on the time frame and not on “tick data”…
Tick data only relates to the execution of orders (excluding “market orders”),
When you use TP, SL, Limits, Stops, etc. these orders are “placed” with the relevant broker and will be executed when they are hit, when a “tick” matches (touches) the level of the order then it will be executed… So “tick data” only refers to the execution of the orders placed…
09/29/2023 at 11:42 PM #221841Alright! I believe I’m starting to grasp it
I’ve created a diagram just to clarify my initial confusion, illustrating the inquiry about a backtest’s outcome and a real-time test result. And everyone has been patient in explaining that “tick-based” in backtesting doesn’t imply a tick-based action trigger discernible by the human eye, as I misunderstood
Thanks to All!
-
AuthorPosts
Find exclusive trading pro-tools on