For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

incorrect 2 hour resampling



  • I ran a backtest, and i was comparing it with tradingview's data for accuracy. one trading day is composed with 6 and a half hours, and if i am using the 2 hour resampled timeframe based on 1 minutes data, that leaves one 2 hour bar that is composed of actually 30 minutes of data. Because there is 3 complete 2 hour bar ( the first six hours of the day ), and one 2 hour bar ( which is the last 30 minutes of the trading day ). when looking at tradingview's data of the 2 hour time frame, that 2 hour bar that is composed of 30 minutes worth of data, is showing as the last 2 hour bar printed on the day, but when using backtrader, the 2 Hour bar composed of 30 minutes worth of data is printed as the first 2 hour bar of the day. This throws off all the other calculations.
    Is there anyway which 2 hour bar is the bar that is derived from 30 minutes worth of data?


  • administrators

    Your problem is probably fully clear in your mind ...

    But your explanation is confusing (at least for me, others may disagree), doesn't make any sense and lacks basics like: separate things in different lines/bullet points, presenting data, code and logs.



  • Every trading day is composed of thirteen 30 min periods. Each single trading day is also broken up into four 2 hour periods. Each trading day has 6.5 hours in it. 6.5 is not evenly divisible by 2 hours. This means that one of the four 2 hour periods will be using data that is actually 30 mins long. Backtrader makes the 2 hours period that is composed of 30 mins worth of data as the first 2 hour period of the day (this is the first 30 minutes of the trading day). When trying to compare a strategy that was created using a different platform, like tradingview.com, the 2 hour period data is inconsistent. Tradingview.com, as well as real time data for live trade execution, uses the last 2 hour period/candle stick of the day as the 2 hour candle stick that is composed of 30 min data (because remember, 6.5 is not evenly divisible by 2 so this last candle stick of the day would equal the .5 remainder), as opposed to backtrader which uses the first 30 mins of the data from the day to print (the .5 remainder) 2 hour candle stick. In backtrader, is there any way I can change the 2 hour period that is using 30 mins worth of data(the .5 remainder) to the last 2 hour period of the trading day instead of it being the first 2 hour period/candle stick of the trading day?



  • @backtrader Every trading day is composed of thirteen 30 min periods. Each single trading day is also broken up into four 2 hour periods. Each trading day has 6.5 hours in it. 6.5 is not evenly divisible by 2 hours. This means that one of the four 2 hour periods will be using data that is actually 30 mins long. Backtrader makes the 2 hours period that is composed of 30 mins worth of data as the first 2 hour period of the day (this is the first 30 minutes of the trading day). When trying to compare a strategy that was created using a different platform, like tradingview.com, the 2 hour period data is inconsistent. Tradingview.com, as well as real time data for live trade execution, uses the last 2 hour period/candle stick of the day as the 2 hour candle stick that is composed of 30 min data (because remember, 6.5 is not evenly divisible by 2 so this last candle stick of the day would equal the .5 remainder), as opposed to backtrader which uses the first 30 mins of the data from the day to print (the .5 remainder) 2 hour candle stick. In backtrader, is there any way I can change the 2 hour period that is using 30 mins worth of data(the .5 remainder) to the last 2 hour period of the trading day instead of it being the first 2 hour period/candle stick of the trading day?


Log in to reply
 

});