Trailing Stop Backtest For Algorithmic Trading in Python

  Рет қаралды 15,269

CodeTrading

CodeTrading

Күн бұрын

Пікірлер: 56
@gdydbjsiuxvsnsjdx
@gdydbjsiuxvsnsjdx 2 жыл бұрын
Excellent content.. was looking for exactly this.. however, one variation that I am looking for is to break-even stops. For example, after the price reaches 1R, the SL could be moved to the entry point (or break even point) and then the SL starts trailing from there forward. Thanks anyway for the video.. keep this coming!
@CodeTradingCafe
@CodeTradingCafe 2 жыл бұрын
Hi thank you for your comment, actually yes I see what you mean, there are different variations of trade management, it's worth backtesting some of them. Good luck, see you around I guess
@1cBoris
@1cBoris 2 жыл бұрын
Hi, sorry for my english. Thanks for your videos, they are amazing. If we get the current price from the order book, for analysis and real trading, the stop loss will work much earlier than at the end of the candle. The candle looks like one beautiful movement, and there is a lot of volatility hidden inside.
@CodeTradingCafe
@CodeTradingCafe 2 жыл бұрын
You are right, one way of avoiding this is to put SL outside the candle range, but you have to test the system again to make sure the odds are on your side. Thank you for sharing your ideas, good luck!
@LIL_MISSA
@LIL_MISSA 4 ай бұрын
Keep up the good work man, i love your codes and explanations ❤
@CodeTradingCafe
@CodeTradingCafe 4 ай бұрын
Glad you like them! Thank you for your support, much appreciated!
@DKFBJ
@DKFBJ 2 ай бұрын
Thank you for the very nice video! How can i find the "backtest.py" file? Used in "from backtest import Strategy, Backtest" I could not find out where this was posted. Have a great day
@CodeTradingCafe
@CodeTradingCafe 2 ай бұрын
Hi, you need to install the package using pip: pip install backtesting Good luck
@DKFBJ
@DKFBJ 2 ай бұрын
@@CodeTradingCafe Thank you for the quick response! Should just have figured this myself haha, have a great day
@johnmorales7531
@johnmorales7531 2 жыл бұрын
I just intalled Python to learn and be able to practice all this nice algoritms. Thanks for help people to learn.
@CodeTradingCafe
@CodeTradingCafe 2 жыл бұрын
Good luck, remember learn slow but regular work don't get discouraged if it takes time
@cryptolicious3738
@cryptolicious3738 2 жыл бұрын
great video ! i really enjoyed this study of tsl tp strategies!
@CodeTradingCafe
@CodeTradingCafe 2 жыл бұрын
Thank you, are you interested in coding as well?
@paulbrown5839
@paulbrown5839 2 жыл бұрын
I like the idea of using ATR to adjust the stoploss at the end of every bar ... but instead of using ATR you should try a realtime volatility pulled in from somewhere else, maybe options market. ATR is too slow. Thoughts?
@CodeTradingCafe
@CodeTradingCafe 2 жыл бұрын
I guess something like a custom function checking the ATR and the lowest/highest points of few previous candles then providing something around these values would be an improvement. But if trying to get the info from elsewhere the algo can as well keep an eye on the different correlated currencies...
@paulbrown5839
@paulbrown5839 2 жыл бұрын
@@CodeTradingCafe ATR is telling you what the volatility was, not what it is. $EVZ might be better, and that is based on 1 month currency options.
@CodeTradingCafe
@CodeTradingCafe 2 жыл бұрын
Will check it out hopefully it's reliable
@sibiljas3628
@sibiljas3628 2 жыл бұрын
You are best . I wanted continue ❤❤❤
@CodeTradingCafe
@CodeTradingCafe 2 жыл бұрын
Thanks a lot for your support 😊
@rafalsza
@rafalsza 2 жыл бұрын
Great video. Did you tried vectorb for backtesting instead?
@CodeTradingCafe
@CodeTradingCafe 2 жыл бұрын
I did have a look at it, to be honest I wasn't happy with their documentation, it was too time consuming to guess their functions so I simply moved to backtesting py
@sergiopadronarellano5437
@sergiopadronarellano5437 Жыл бұрын
Thanks a lot for sharing knowledge, code and video, very very usefull all your videos
@CodeTradingCafe
@CodeTradingCafe Жыл бұрын
Thank you for your support, it makes a difference
@yanchobeats
@yanchobeats 2 жыл бұрын
Can you please clarify what these atr_f and ratio_f stand for and what 0.2 and 1 mean at 11:30. When I try this params on my algo (I am testing it on 1min timeframe) I get instantly taken out of the position. Thank you for the awesome work!
@CodeTradingCafe
@CodeTradingCafe 2 жыл бұрын
The first is a ratio variable to define SL from ATR so SL distance is atrf * ATR, and the second is the TP SL ratio. Hope this helps, good luck!
@mcdawgzy
@mcdawgzy 9 ай бұрын
Awesome video, thanks so much for sharing
@CodeTradingCafe
@CodeTradingCafe 9 ай бұрын
Thanks for watching!
@a.winath4024
@a.winath4024 2 жыл бұрын
Thank you so much friend!
@CodeTradingCafe
@CodeTradingCafe 2 жыл бұрын
Thank you for your appreciation
@jeffb9967
@jeffb9967 7 ай бұрын
hello and thank you for your great videos. Could you please tell me if these stop loss's work with crypto trading, in particular, ccxt and kucoin exchange, and will it work with any exchange?
@CodeTradingCafe
@CodeTradingCafe 7 ай бұрын
Hi, thank you for your support, in principle yes any technical chart is the same, so the same SL TP principles can be applied.
@sylas9762
@sylas9762 Жыл бұрын
Hi is there anyway to backtest trailing and stop loss using pct( percentage of profit/loss), rather than ATR? and is there indicator or mathematic way to identify low volatility of the market and sideway market? Thank you in advance.
@CodeTradingCafe
@CodeTradingCafe Жыл бұрын
Hi definitely you can use percentage distance instead of ATR, it's relatively simple. Regarding identifying low volatility you can use ATR it's a good volatility indicator or check this video kzbin.info/www/bejne/ppncZmp6j7R8rcU you can detect narrow channels for low volatility. I hope this helps!
@aidakhalil1394
@aidakhalil1394 2 жыл бұрын
Bravooo👌
@CodeTradingCafe
@CodeTradingCafe 2 жыл бұрын
:) thank you
@walduss7939
@walduss7939 2 жыл бұрын
Thanks to share.
@CodeTradingCafe
@CodeTradingCafe 2 жыл бұрын
Thank you for your support 😊
@yuvalbra
@yuvalbra 2 жыл бұрын
thanks, great video knowlage, can you share the code
@CodeTradingCafe
@CodeTradingCafe 2 жыл бұрын
done it's in the description, enjoy coding
@FootfunI
@FootfunI 2 жыл бұрын
Thank you for your very interesting and exciting video. I have question, if it writes that file is not found and the problem have to be in the second cell, where is code: df = pd.read_csv("EURUSD_Candlestick_1_D_ASK_05.05.2003-30.06.2021.csv"), what i have to do with it?
@CodeTradingCafe
@CodeTradingCafe 2 жыл бұрын
Hi you can put the file in the same folder as the python file to.be found. Or try including the path in the code l.
@FootfunI
@FootfunI 2 жыл бұрын
@@CodeTradingCafe Will I pissed you off if I ask you for code you are writing about? I am really lost.
@CodeTradingCafe
@CodeTradingCafe 2 жыл бұрын
@@FootfunI no worries, just copy your error message here I will try to help. If it's unfound file try rechecking the name of the file and the path.
@FootfunI
@FootfunI 2 жыл бұрын
@@CodeTradingCafe FileNotFoundError Input In [2], in () 1 import pandas as pd ----> 2 df = pd.read_csv("EURUSD_Candlestick_4_Hour_ASK_05.05.2003-16.10.2021.csv") 3 df.columns=['time', 'open', 'high', 'low', 'close', 'volume'] 4 #Check if NA values are in data File ~\anaconda3\lib\site-packages\pandas\util\_decorators.py:311, in deprecate_nonkeyword_arguments..decorate..wrapper(*args, **kwargs) 305 if len(args) > num_allow_args: 306 warnings.warn( 307 msg.format(arguments=arguments), 308 FutureWarning, 309 stacklevel=stacklevel, 310 ) --> 311 return func(*args, **kwargs)
@CodeTradingCafe
@CodeTradingCafe 2 жыл бұрын
@@FootfunI yes it can't find the file you can put both python code file and data file in the same folder or include the path from the read_csv function
@paulbrown5839
@paulbrown5839 2 жыл бұрын
hey man , why dont you show your sharpe ratio?
@CodeTradingCafe
@CodeTradingCafe 2 жыл бұрын
Never thought about it to be honest, but also I am afraid not everyone is familiar with it so it's worth a video on its own...
@paulbrown5839
@paulbrown5839 2 жыл бұрын
@@CodeTradingCafe Anybody watching these videos knows what it is, i think.
@paulbrown5839
@paulbrown5839 2 жыл бұрын
@@CodeTradingCafe It would be good to show Sharpe in your videos. It's the only way we can compare your strategy to others because you don't show your vol either.
@kodzuvu
@kodzuvu 2 жыл бұрын
How to run auto trade on any Brocker?
@CodeTradingCafe
@CodeTradingCafe 2 жыл бұрын
Hi, it doesn't work for any broker because each broker has its own API, so the best way is first choose the broker and then learn their API... Now this wad the easy part... Now comes finding a winning strategy to automate :) this is a lifetime teaser
@Dr.jayfrancis
@Dr.jayfrancis 2 жыл бұрын
Some day, I'll understand these advanced algos.. but not now xD
@CodeTradingCafe
@CodeTradingCafe 2 жыл бұрын
Keep up the good work it will take some time
RSI Divergence Automated In Python | Algorithmic Trading
35:22
CodeTrading
Рет қаралды 35 М.
Stop Losses in Backtesting.py
27:08
Chad Thackray
Рет қаралды 16 М.
The selfish The Joker was taught a lesson by Officer Rabbit. #funny #supersiblings
00:12
Funny superhero siblings
Рет қаралды 11 МЛН
How do Cats Eat Watermelon? 🍉
00:21
One More
Рет қаралды 13 МЛН
Price Trend Detection Using Machine Learning For Trading
31:07
CodeTrading
Рет қаралды 35 М.
Backtesting.py - Full course in python
1:09:34
Chad Thackray
Рет қаралды 190 М.
How Financial Firms Actually Make Money
22:40
QuantPy
Рет қаралды 355 М.
Automated RSI Scalping Strategy Tested In Python
33:32
CodeTrading
Рет қаралды 15 М.
Automated Price Action Trading Strategy In Python
32:48
CodeTrading
Рет қаралды 48 М.
Bjarne Stroustrup: C++ | Lex Fridman Podcast #48
1:47:13
Lex Fridman
Рет қаралды 1 МЛН
Algorithmic Trading in Python - MACD: Construction and Backtest
24:27
How to Use a Trailing Stop Loss (Order Types Explained)
10:06
Arvabelle
Рет қаралды 759 М.
FastAPI Course for Beginners
1:04:33
freeCodeCamp.org
Рет қаралды 333 М.