Multi-timeframe Strategies in Backtesting.py

  Рет қаралды 10,695

Chad Thackray

Chad Thackray

Күн бұрын

Пікірлер: 29
@ashxos
@ashxos Жыл бұрын
Thank you Chad! Your video has translated into my fully functional backtesting system. Cheers!
@fiftyghoststrading8500
@fiftyghoststrading8500 2 жыл бұрын
Thank you for this tutorial, it's helpful! Is there a way to check for a signal on the daily, but then use 1-min, 5-min, whatever for the actual entry? Both would be based on price action, not an indicator
@dimasjimenez3396
@dimasjimenez3396 Жыл бұрын
That's what he explains here when he says you should start from a lower timeframe and resample to a larger one. If you wanna validate a signal on the daily timeframe and take the position in a let's say 5m timeframe, you should feed the 5m dataframe, resample to 1H, set the signals there and then evaluate those signals and take the trade based on that evaluation, but in the 5m timeframe. I think the tricky part here is to set the signal, since it's way more difficult to spot them based on price action rather than in an indicator.
@ghazanferali366
@ghazanferali366 2 жыл бұрын
Thanks very much, solved a long lasting problem. I am having another problem. I have backtested a strategy in which I haven't provided the size of strategy to keep every signal using 100% of cash. But when I am checking the trades, there are lot of very small unwarranted trades of around 1$ value. How can I exclude these trades
@vinayakassajjanshetty7231
@vinayakassajjanshetty7231 7 ай бұрын
Hey bro, you can think practically this is not live trading its showing you the possible conditions that could have taken place by t he conditions you mentioned too enter the trade, so its the refining time you need after what you got the analysis, If you want to some targeted money analysis, you can use the backtest.optimisation and plot the heat map you will have the better view of your trades performance. if my explanation differs your question, Please do teach me Thankyou.
@MrBradleykong
@MrBradleykong 6 ай бұрын
Hi Chad, is there any way to draw two or more data series on one single plot?(overlay = False)
@davidberry8511
@davidberry8511 2 жыл бұрын
Thanks for your great tutorials
@iiii05
@iiii05 Жыл бұрын
Hi @chad. I’m having a problem using resampling_apply with the Adx, as I have to pass the high, low, close and the time period from ta lib. It works fine when using I() but when using resampling_i think because there are more than one series, it’s not liking it. Any ideas of the statement I’d use please?
@nb9797
@nb9797 Жыл бұрын
same here
@vinayakassajjanshetty7231
@vinayakassajjanshetty7231 7 ай бұрын
Hi @iiii05, I think my reply is little late as I have seen the video now and your reply, for the problem you mentioned, If you carefully look the def init() its just that you are creating new set of data(defining your own conditions like 10 mins data or 1 hour data from 1 min data candle sticks), as the I () function takes care of the each sample output converting the type of the sample to numpy, but that is not the case in the resample_I() ass there is no self conditions defined in it There are two ways but 2nd one is more efficient what I think, 1. Check the output condition of I() it is numpy type as you are using pandas it will be pandas.series and in resample_I() is not defined you have to provide the numpy data. 2. as you are using pandas_ta lib you can use the resample sizing function outside the backtesting class and add the new column to the data frame and now you can normally use the I() and test your startegy Note:(I like the second method) If you have found some efficient solution please so teach me , Thankyou
@tessalittle2411
@tessalittle2411 Жыл бұрын
Awesome video - I am curious - what approach would you suggest if I were to screen for Highest time frame in range where K% of stochastic RSI is above/or just crossing 80 - I need the Time frame to be returned. I have seen some people using vectorization. I will be doing this for 4 different time frame sets.
@datascientistaspirants4540
@datascientistaspirants4540 3 ай бұрын
Does it work for multi timeframe where the timeframes are 3h and 4h? The data for these two timeframes will be combined and and provided as input to the backtesting. The problem I am facing is in every 12h timestamp there are duplicate entry of OHLC data (coming from both 3h and 4h). Backtesting framework take input data having unique datetime index. Hence it shows error.
@mgarciabarua
@mgarciabarua Жыл бұрын
Hi Chad, Thanks for your amazing videos. I have a 1Min timeframe but I'm try to get the ATR for 5Min: self.atr5m = resample_apply('5Min', ta.atr, self.data.High.s, self.data.Low, self.data.Close, length=14) but I'm getting this: -> 129 raise RuntimeError(f'Indicator "{name}" errored with exception: {e}') 131 if isinstance(value, pd.DataFrame): 132 value = value.values.T RuntimeError: Indicator "atr(H[5Min],L,C,14)" errored with exception: input array lengths are different
@vinayakassajjanshetty7231
@vinayakassajjanshetty7231 7 ай бұрын
Hey bro, you are getting this error because the backtest only work with the datatype numpy series not panda series, in resample_apply() there is no conversion for this as such present in the I(), so you have to do it manually.
@danielfenollfreire3022
@danielfenollfreire3022 2 жыл бұрын
anyone having the TypeError( TypeError: Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, but got an instance of 'RangeIndex' error when using the resampler despite having formatted the index of the data to DateTimeIndex?
@MrDenfish
@MrDenfish Жыл бұрын
yes, I saw this when resample_apply("H"... was used, resample_apply('1H'... fixed the issue, not sure if this helps but I saw this error when I made the typo.
@miltonfernandez9832
@miltonfernandez9832 Жыл бұрын
Same here, i wonder if you already fixed it
@alexanderlunel7899
@alexanderlunel7899 11 ай бұрын
same here too
@drcesarvarela
@drcesarvarela 2 жыл бұрын
Genious!
@mssafy2592
@mssafy2592 2 жыл бұрын
How to know how many time the price crossed a certain level of price ?
@ChadThackray
@ChadThackray 2 жыл бұрын
You have all the previous price history in self.data, so you can just write a function that scans through there for a specific price level
@anilmm2005
@anilmm2005 Жыл бұрын
Thank you for wonderful help @chad
@ahmetsuatyildiz4836
@ahmetsuatyildiz4836 2 жыл бұрын
Could you connect this video with custom indicator video?
@ChadThackray
@ChadThackray 2 жыл бұрын
Yeah you can do both multi-timeframe and use your own custom indicators
@ahmetsuatyildiz4836
@ahmetsuatyildiz4836 2 жыл бұрын
@@ChadThackray How is the ao indicator MTF code statement? I would like to see it at the end of the video.
@ahmetsuatyildiz4836
@ahmetsuatyildiz4836 2 жыл бұрын
I did not understand why it did not calculate the following. There is no error, but the values are filled with nan. I see only +1 and -1 (decision column) self.super1_w = resample_apply( 'W-FRI',ta.supertrend, self.data.High.s, self.data.Low.s, self.data.Close.s, length=10, multiplier=1.0, plot=True)
@bryan-9742
@bryan-9742 2 жыл бұрын
very good chad
@ghazanferali366
@ghazanferali366 2 жыл бұрын
Actually I only want the trade to be executed if there's no active trade in place already. Also my strategy can go both long and short.
@ChadThackray
@ChadThackray 2 жыл бұрын
I believe you can do something like `if not self.position` somewhere within the next() function and then anything inside that if statement will only be execute if you don't have a position
Walk Forward Optimization in Python with Backtesting.py
1:03:20
Chad Thackray
Рет қаралды 18 М.
Backtest Validation in Python (Fooled By Randomness)
17:36
Chad Thackray
Рет қаралды 7 М.
BAYGUYSTAN | 1 СЕРИЯ | bayGUYS
36:55
bayGUYS
Рет қаралды 1,9 МЛН
Что-что Мурсдей говорит? 💭 #симбочка #симба #мурсдей
00:19
Vectorbt for beginners - Full Python Course
3:59:04
Chad Thackray
Рет қаралды 80 М.
Custom Indicators In Backtesting.py - Python Deep Dive
35:19
Chad Thackray
Рет қаралды 32 М.
How To Resample Time Series Data Using Pandas To Enhance Analysis
9:20
10x Data Scraping with AsyncIO / Concurrency
24:05
Chad Thackray
Рет қаралды 2,8 М.
Backtesting.py - Full course in python
1:09:34
Chad Thackray
Рет қаралды 208 М.
Auto-detect Support and Resistance in Python
17:06
Chad Thackray
Рет қаралды 24 М.
Backtest Your Dollar Cost Average Strategy easily in Python
25:07
Chad Thackray
Рет қаралды 11 М.
Backtesting Stock Trading Strategies in Python
17:48
NeuralNine
Рет қаралды 40 М.