Timeframe- Shouldn’t it give the same results?
Forums › ProRealTime English forum › ProOrder support › Timeframe- Shouldn’t it give the same results?
- This topic has 11 replies, 4 voices, and was last updated 2 years ago by robertogozzi.
-
-
04/12/2021 at 10:05 AM #166820
Im about to try using the Timeframe code to have different rules in the script for condition to open and close. Like the conditions to open would “run” on the 4 hour chart and then a coded Stop to be updated on lets say 1 hour.
But when I started to try this out and looked to “validate” I got confused as what I thougt would give the same result didnt, here’s an example.
Example in Backtest
Using the DAX index
The same fixed Time Period of 3 weeksScenario 1
Time Unit 4 hoursScenario 2
Time Unit 1 hour
And using the TF code in the beginning of script1Timeframe (4 hours, updateonclose)Shoudnt the reslust be the same for those scenarios or have I missunderstood something?
1 user thanked author for this post.
04/12/2021 at 10:21 AM #166829Post an example, please.
04/12/2021 at 4:22 PM #166873Okey, here’s an example with the most basic code =)
But it illustrates the point or my question at least. As I would think the results should be the same in both cases.Both are run on DAX within the same “Time Period” in Backtest.
For reference, without timeframe. 4 hour chart12345678910111213141516// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated// Conditions to enter long positionsc1 = (close >= close[1])IF c1 THENBUY 1 CONTRACT AT MARKETENDIF// Conditions to exit long positionsc2 = (close <= close[1])IF c2 THENSELL AT MARKETENDIFExample 1
on the 4 hour chart with bellow code will give result Xon 1 hour chart123456789101112131415161718// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivatedtimeframe (4 hour, updateonclose)// Conditions to enter long positionsc1 = (close >= close[1])IF c1 THENBUY 1 CONTRACT AT MARKETENDIF// Conditions to exit long positionsc2 = (close <= close[1])IF c2 THENSELL AT MARKETENDIFExample 2
on the 1 hour chart, and added Timeframe to be 4 hour gives result Y (not same “X”)As I’ve understood it the Timeframe code would “wait” until it has passed 4 hours (in my example) to run the bellow code?
So that if you run the same script on a 4 hour chart or on a 1 hour chart and with “timeframe 4 hour” it should both give the same result?04/12/2021 at 6:31 PM #166882It’s because with the same number of units, the 1-hour TF allows only approx. 1/4th of the time available for backtest.
04/13/2021 at 8:36 AM #166905thanks for replying. But I didn’t really understand, could you elaborate?
04/13/2021 at 8:46 AM #16690704/13/2021 at 9:35 AM #166916He means that 100k 4 hour candles represents 400k hours whilst 100k 1 hour candles only represents 100k hours. You can’t get the same results from different size data samples.
That logic I can understand.
However, when Im doing the testing Im using the same load of data (I guess) as Im using the same “Time Period” (Start and End Time) in Backtest, lets say 1 week of data, not letting the BT run on a fix amount of bars to load.So If im using the same period 1 week, mon-fri, and in Scenario 1: use the 4 hour chart, it would load 30 hours (bars), (24*5)/4, and then run “c1” upon close.
And in Scenario 2: use the 1 hour chart, it would load 120 hours (bars), 24*5, and with added Timeframe (4 hour, updateonclose) it should run “c1” on every 4th hour (bar) ie 120/4=30, the same number of hour, bars, as on 4 hour chart?04/13/2021 at 9:46 AM #16691704/13/2021 at 10:23 AM #16692604/13/2021 at 11:06 AM #1669411 week of data is approx. 30 4-hour bars and 120 1-hour bars, completely different!
04/29/2021 at 1:01 PM #1683841 week of data is approx. 30 4-hour bars and 120 1-hour bars, completely different!
Yes of course that’s a big difference.
But that doesn’t help me understand Why the result is not the same (or at least very similar if some trades would be out-of-sync).As I understood the function; using your numbers, loading 120 1-hour bar and then use TimeFrame 4 hour, updateonclose, wouldn’t the system then use 30 bars, every 4th 1-hour bar? ie the same as directly running on the 4-hour chart?
(Im basically wondering how the TimeFrame update is calculated? in order to understand Why the result is not the same)
04/29/2021 at 11:28 PM #168420Got it!
The 4-hour TF opens a few more trades than the 1-hour TF (on the same time range) because tjhe 4-hour TF has a sunday bar, which the 1-hour TF hasn’t.
So on that missing candle the entry condition can be true and the 4-hour bar opens a trade, while the 1-hour doesn’t!
(see attached pic with Jan. 18th 2021 compared, the 4-hour Sunday bar is in the upper chart, circled in red)
-
AuthorPosts