Automated Price Break Out Detection: Algorithmic Trading In Python

  Рет қаралды 46,169

CodeTrading

CodeTrading

9 ай бұрын

Unlock the power of automated price breakout detection with our Python coding tutorial! In this video, we delve into creating a breakout indicator that can identify key levels based on multiple bounces in a trading asset's price. The script covers the coding process step by step, and you can find the downloadable source code in the description below.
📈 Pattern Detection and Key Zones:
Learn how to recognize patterns where an asset bounces multiple times around an average key level. We define key zones rather than exact levels, allowing for flexibility in tuning. The algorithm observes price movements, generating breakout signals when a candle closes above the upper zone edge for a bullish breakout or below the lower zone edge for a bearish setup.
⚙️ Customization and Combination:
Discover the versatility of this breakout strategy by combining it with other indicators like the moving average. We explore how to use the breakout pattern in conjunction with the MA curve to identify potential uptrends or downtrends, providing valuable insights into market momentum.
🧠 Algorithm Parameters and Avoiding Bias:
As we dive into coding, we consider essential parameters like the gap window and backcandles window to prevent lookahead bias. The gap window ensures accurate signal detection, while the backcandles window defines the range for identifying pivot points and support/resistance levels.
🔧 Code Along - Python Automation:
Follow along as we code the entire process in Python, automating the detection and signaling for breakout patterns. Our approach ensures practicality and adaptability, allowing you to explore different scenarios by adjusting the width of the key zone.
📊 Enhance Your Trading Strategy:
Whether you're a beginner or an experienced trader, incorporating automated breakout detection can significantly enhance your trading strategy. Stay ahead of market trends and capitalize on potential opportunities with this comprehensive Python tutorial.
💲 Discount Coupon for My Udemy course on Algorithmic Trading:
bit.ly/CouponAlgorithmicTrading
Download the Source Code:
drive.google.com/file/d/1V9eJ...
And the Data file:
drive.google.com/file/d/1qIki...
👍 Like, Subscribe, and Share for More Insights:
If you find value in this tutorial, don't forget to like, subscribe, and share with fellow traders and coding enthusiasts. Stay tuned for more coding experiments, algorithmic trading insights, and practical tutorials to elevate your financial journey. Happy coding! 🖥️📈 #tradingalgorithms #pythoncoding #breakouttrading

Пікірлер: 147
@BahaaOsman
@BahaaOsman 21 сағат бұрын
Excellent work! Thanks. A future modification can be to add code that validates a breakout. You want to avoid fake breakouts. This can only be validated when a breakout is detected followed by a retest of the identified level then a confirmation candle in the right direction is detected. I would also add volume to the algorithm. A good breakout always occurs with strong volume
@frankgrannell
@frankgrannell 8 ай бұрын
I'm a beginner. I learnt a lot from this video. Thanks.
@CodeTradingCafe
@CodeTradingCafe 8 ай бұрын
Glad it was helpful! Thank you for your comment.
@weiwei2587
@weiwei2587 2 ай бұрын
Great tutorial and clear explanation!
@CodeTradingCafe
@CodeTradingCafe 2 ай бұрын
Glad it was helpful! thank you!
@samilawsy7845
@samilawsy7845 9 ай бұрын
Thank you for this very beautiful video. And code ❤
@CodeTradingCafe
@CodeTradingCafe 8 ай бұрын
Glad you liked it! thank you for your support!
@ruilacerda7469
@ruilacerda7469 8 ай бұрын
congratz for your work.all best.
@CodeTradingCafe
@CodeTradingCafe 8 ай бұрын
Thank you for your support!
@bombasticiti
@bombasticiti 7 ай бұрын
Thanks brother, Wonderful Code
@CodeTradingCafe
@CodeTradingCafe 7 ай бұрын
You are welcome, I am glad it's helpful. Thank you for your support.
@nuweariho6884
@nuweariho6884 4 ай бұрын
You have no idea how I tried to code this trendline with Python today and my head almost caught fire and it wasnt working well😂. I just finished coding now I was comparing with yours and i must say your code is pretty beautiful 🎉. Thank you very much. Am looking forward to re coding it in a new way.😮
@CodeTradingCafe
@CodeTradingCafe 4 ай бұрын
Glad it helped! my code is not as elegant there are some improvements to make it more professional... but it works :)
@rahulrana892
@rahulrana892 4 ай бұрын
​@@CodeTradingCafe paste your code to chatgpt & ask it to optimize :)
@farzadkhajeh870
@farzadkhajeh870 3 ай бұрын
thanks dear , it's cool
@CodeTradingCafe
@CodeTradingCafe 3 ай бұрын
I'm glad you like it, thank you for your support.
@Exzal123
@Exzal123 5 ай бұрын
Damn Python seems soooo nice !! I begin an introductory course and will clearly go through your content as soon as I'll be more geared ! Sooo tired of backtesting manually... Would rather like to code for 10h instead instead of having to do 1000h of backtesting...
@CodeTradingCafe
@CodeTradingCafe 5 ай бұрын
Manual backtesting is tiring, you will enjoy python and the possibilities are endless.
@DoctaV
@DoctaV 9 ай бұрын
I really enjoy your content. An idea for a video that would be interesting to me and probably others: managing different time periods / higher time frame confirmations. When I use pandas to resample, it will do stuff like adding in weekends automatically with NaN values which is annoying (I probably don't understand the most efficient ways to do this). Also, would be interested to seeing your approach to building a signal function or stop loss strategy that look at multiple time frames simultaneously -- for instance, look for price break out at 5M but only go long if 4H is in uptrend. Keep up the good work! 👍
@CodeTradingCafe
@CodeTradingCafe 9 ай бұрын
Thank you so much for your support. Multi-timeframe trading is definitely a good idea that was requested before, my bad I am trying to avoid synching frames together just afraid of the quality of the data. But... I must do it!
@DoctaV
@DoctaV 9 ай бұрын
@@CodeTradingCafe my idea for how to do this (which I'm planning to work on soon) is to use dt.hour and dt.minute dataframe operations to find if my current 1M candle is within the range of larger 15M candle (for instance). no idea if this is the best approach but seems reasonable to me. If I put together something working before you post a video about this, I'll send the code your way.
@CodeTradingCafe
@CodeTradingCafe 9 ай бұрын
I think once the multi timeframe approach is opened, there is plenty to investigate, the more I am thinking about it the more I feel it's a priority now.
@GascanNBK
@GascanNBK 9 ай бұрын
you can use this line of code to get rid of the NaN's in pandas dataframe: item.table.dropna(inplace=True)
@tmbao
@tmbao 7 ай бұрын
Actualy we dont need higher timeframe because in every timeframe it self have full info about MS. Break on 4h equal 5m. Many trader need high timeframe because they analyze with two eyes. We just get a lot ohlcv item.
@ronaktawde
@ronaktawde 4 ай бұрын
Hey very nice code video. one suggestion that for learning purpose you can take candle index and plot it on different chart. for example chart1 = 0 to 2000 and chart2 = 2001 to 4000 etc. and so on.
@CodeTradingCafe
@CodeTradingCafe 4 ай бұрын
Thank you for your support, and for the tip, actually yes we can split into different figures.
@viaanfc
@viaanfc 6 ай бұрын
thanks
@CodeTradingCafe
@CodeTradingCafe 6 ай бұрын
You're welcome! thank you for your comment.
@Rocky-iy2zb
@Rocky-iy2zb 7 ай бұрын
Really nice , can you make a video on opening range breakout strategy
@CodeTradingCafe
@CodeTradingCafe 7 ай бұрын
Thank you, yes I will add it to a long list, but meanwhile if you are in a hurry this can be done by adapting the current video with some modifications, just compute the support let's say on the first couple of hours of the day (opening hours).
@esquire9445
@esquire9445 9 ай бұрын
Good jon
@CodeTradingCafe
@CodeTradingCafe 9 ай бұрын
Thank you!
@InAeyMinute
@InAeyMinute 8 ай бұрын
first of all thank you u so much for such great effort i have 2 questions 1 - how we can start use this in a real time data instead of historical so we can detect what breakouts of current market 2 - and how we can get a notification for any break out signal for example on our email what am trynna say i want to Strat using this indicator for real time trading
@CodeTradingCafe
@CodeTradingCafe 8 ай бұрын
Hi, thank you for your comment, for real time data you need to connect through your brokers API, as an example check this video: kzfaq.info/get/bejne/jcmWfsSLsZraoHU.html Regarding the notifications check this one: kzfaq.info/get/bejne/j796acyDvbndZo0.html Good luck!
@keelynsbradley2873
@keelynsbradley2873 9 ай бұрын
Thank you for this content ! Now you detected the break of structure, how do you code the trade part ?
@CodeTradingCafe
@CodeTradingCafe 9 ай бұрын
probably next video :)
@sushka4122
@sushka4122 9 ай бұрын
Thank you for the video! Do you think this signal can be used for machine learning?
@CodeTradingCafe
@CodeTradingCafe 9 ай бұрын
Thank you for your support, we could try it but I am afraid it might add noise to the current state of the signal. But there is only one way to find out :)
@minymaker
@minymaker 4 ай бұрын
ya you can use it for blockchain too
@veds-art-world
@veds-art-world 5 ай бұрын
Have you created any video on converting live market stream data to OHLC candles and then analyzing any of your strategy live and if it matches perform buy or sell order based on signals?
@CodeTradingCafe
@CodeTradingCafe 5 ай бұрын
Hi, check this video, it's a live trading bot testing: kzfaq.info/get/bejne/mMCYp9mnq9OVZ3U.html
@GascanNBK
@GascanNBK 9 ай бұрын
Well done
@CodeTradingCafe
@CodeTradingCafe 9 ай бұрын
Thank you, glad you liked it!
@GascanNBK
@GascanNBK 9 ай бұрын
I like to ask you these two questions: 1. How does this strategy avoid fake breakouts? 2. How do you scan to find symbols to trade this strategy on?
@CodeTradingCafe
@CodeTradingCafe 8 ай бұрын
So far we don't avoid fake breakouts we just deal with them in trade and risk management. Symbols I just try on different assets and see where it works.
@GascanNBK
@GascanNBK 8 ай бұрын
I am just working on a scanner to scan my broker's 900 symbols for strength and weakness to get a short watchlist around 10 assets for different strategies i.e MACD, RSI, Advance/Decline or so but i'm not shure what's the best strategy to scan for.
@enotbert
@enotbert 9 ай бұрын
Hi there. Another awesome video. While playing with my data pivot points are very often placed on neighboring candles. I tried to get rid of this issue by increasing the pivot window, but it didn't work. The only solution I was able to implement was to disallow placing a pivot point if there is already one next to it. But I have a feeling that this is not the right solution. How else can I solve this situation?
@CodeTradingCafe
@CodeTradingCafe 9 ай бұрын
Thank you for your support. The reason you may have 2 close pivots is because they might have the same extreme value (high or low) but the way you are proposing is also good just discard a pivot if one of the same level is very close, at the end you need one pivot placed in each "zone/area". Good luck!
@khalidtaalibi274
@khalidtaalibi274 8 ай бұрын
Thanks you i m for Morocco i love your videos
@CodeTradingCafe
@CodeTradingCafe 8 ай бұрын
Thank you Khalid for your support! Beautiful country :)
@khalidtaalibi274
@khalidtaalibi274 8 ай бұрын
@@CodeTradingCafe welcome to Morocco in any time bro i have a simple question in code modul Lstm the day interval i have problems i have trede losses i have changed in 1 h interval for your opinion is God for to work of the module if yes a must change something als in the code for adapter with 1 h interval.thank you very much
@CodeTradingCafe
@CodeTradingCafe 8 ай бұрын
Hi, honestly I tried LSTM for trading and all I can say is that it doesn't work well, if you're doing it for education purposes then it's good but for trading it's not as good.
@khalidtaalibi274
@khalidtaalibi274 8 ай бұрын
@@CodeTradingCafe thanks you very much yes i want to try with demon account and si how it worksk. The last question what the perfect time the run the code in beginning of open the Marchés ?
@CodeTradingCafe
@CodeTradingCafe 8 ай бұрын
I think the algos work well during the US session
@aaronsarinana1654
@aaronsarinana1654 9 ай бұрын
Quick question about your Udemy course, do you cover how to put your code in a live environment? I mean, with a real broker. Thanks for the video!
@CodeTradingCafe
@CodeTradingCafe 9 ай бұрын
I do but very briefly, it's actually also covered here on the channel for Oanda: kzfaq.info/get/bejne/jcmWfsSLsZraoHU.html
@Exzal123
@Exzal123 5 ай бұрын
Do you have a video explaining how to code a strategy using 2 timeframe ? (Like HTF is having a signal, and then the confirmation is done on a LTF) cheers
@CodeTradingCafe
@CodeTradingCafe 5 ай бұрын
Not yet, I have something in mind and on my todo list, but it's only a matter of time and priority.
@muneebahmed292
@muneebahmed292 8 ай бұрын
Very nice and informative video...But I have one query regarding that how we can use this code on daily basis for the breakouts...I mean it worked absolutely fine for previously loaded data but if we want the stocks or scripts from the collection of scripts..how we can optimize this script ???
@CodeTradingCafe
@CodeTradingCafe 8 ай бұрын
Hi, thank you. We can use the function detect_pattern using different dataframes for different assets, the only modification is to move some parameters as input argument for the function because these will be asset dependent (like the zone width for example).
@Ana-------lyse1234
@Ana-------lyse1234 6 ай бұрын
you are there great man for learn code, but i have request use yahoo for data
@CodeTradingCafe
@CodeTradingCafe 6 ай бұрын
Hi thank you, Yahoo finance package yfinance for python is not supported anymore and some of the data I got was not reliable.
@user-vm1yx2vc4b
@user-vm1yx2vc4b 5 ай бұрын
Great video! Can you code for Darvas Box?
@CodeTradingCafe
@CodeTradingCafe 5 ай бұрын
Sure we can, but in my opinion it's almost the same as break out pattern strategy.
@AnilSharma-sf4tr
@AnilSharma-sf4tr 5 ай бұрын
Thank you very much Dr. really enjoy your work. Just wondering do you offer any private one-to-one consulting? If so, would you mind dropping me a message?
@CodeTradingCafe
@CodeTradingCafe 5 ай бұрын
Hi, thank you for your support. I can try to help you through email, my email is in the about section of this channel.
@AnilSharma-sf4tr
@AnilSharma-sf4tr 5 ай бұрын
@@CodeTradingCafe thank you so much for getting back to me. I did look at the about section but couldn’t find one. I just found links for the other courses.
@CodeTradingCafe
@CodeTradingCafe 5 ай бұрын
Sorry, it's codingntrading gmail com
@tigoes
@tigoes 4 ай бұрын
"zone might change". Thats the whole point. Tried using atr? Using the fraction of the range between 2 zones?
@CodeTradingCafe
@CodeTradingCafe 4 ай бұрын
No haven't tried with ATR but the idea is to define a max zone width, I think out of experience a trader can somehow set it for a given asset.
@afiqyahya3398
@afiqyahya3398 8 ай бұрын
I am not sure but it will be great if you can upload the source code as well in github since i cannot access google drive,blocked by my IT
@CodeTradingCafe
@CodeTradingCafe 8 ай бұрын
How are you surviving without the codes! I definitely should set a git repo for this channel!
@Medvech
@Medvech 9 ай бұрын
Could you rewrite this to detect channel break. I mean now we can detect only breaking of horizontal channel (or price level). It's can be ok for the Forex, but not for the stock definitely.
@CodeTradingCafe
@CodeTradingCafe 9 ай бұрын
Yes with a similar approach it can be rewritten for channels I can do it for the coming weeks/videos, might need some time though.
@davidsaurel4012
@davidsaurel4012 8 ай бұрын
Already did a video about channel break out detection using linear regression no ?
@echentj
@echentj 7 ай бұрын
Hi ,Thank your for such a good pointing. After I have integrated MT5 to get real data. What i get from the function of 'isPivot' is always zero, hence when the code run towards the end of the coding, the return of function 'pattern detected' also become zero. I have tried a few way but still i get zero result. So could you point out what could be the cause of this? Thank you.
@CodeTradingCafe
@CodeTradingCafe 7 ай бұрын
Hi, I suspect the number of windowed candles (window parameter) and the timeframe are not matching try changing the parameters decreasing the window to 1 for example, if the problem persists then there is a problem within the function, check for small bugs like the columns names, the casing (upper or lower first letters...). The funciton should return something even for real data.
@echentj
@echentj 7 ай бұрын
i did what you have told, set data collection to H1, window = 1, 'is_Pivot' did return data. But not the 'pattern_detected' function. Could you please explain more why such parameter will return data. Thank you. On top of that, previously when i use df.tail() to check the 'is_Pivot' output. Although the ' is_Pivot' output show zero but the code manage to plot graph with pivot mark on candle. Why is that so? Thank you. @@CodeTradingCafe
@CodeTradingCafe
@CodeTradingCafe 7 ай бұрын
Hi, at this point it's hard to debug online, but mainly the constants or hard coded values in the code they work for specific assets and timeframes if you change one you need to adjust the other.
@SsTradingFx
@SsTradingFx 8 ай бұрын
Do you make a tradingview indicator for forex ?
@CodeTradingCafe
@CodeTradingCafe 8 ай бұрын
Hi, sorry no tradingview just python and backtesting.
@anso_10101
@anso_10101 5 ай бұрын
What development environment are you using?
@CodeTradingCafe
@CodeTradingCafe 5 ай бұрын
Python, the editor is VScode
@Softbit-Website-Builder
@Softbit-Website-Builder 8 ай бұрын
can we used this stratgy in live trade
@CodeTradingCafe
@CodeTradingCafe 8 ай бұрын
You can, but this is one indicator you might want to combine it with another one for confirmation and of course a better trade management is crucial.
@LolkeDijkstra
@LolkeDijkstra 9 күн бұрын
Hi, I didn't really get where you downloaded the data from. I downloaded daily data from Yahoo finance for the same period and noticed that the data is actually quite different. Could you share the source with us? Thanks in advance!
@CodeTradingCafe
@CodeTradingCafe 8 күн бұрын
Hi, you can try Dukascopy, or your broker.
@user-qk4nm8vx7i
@user-qk4nm8vx7i 8 ай бұрын
hii Does it connect to the Interactive Brokers system?
@CodeTradingCafe
@CodeTradingCafe 8 ай бұрын
Currently no, but we can add the IB API functions to make it work.
@muhammadkhalil5290
@muhammadkhalil5290 6 ай бұрын
What code editor you are using?
@CodeTradingCafe
@CodeTradingCafe 6 ай бұрын
VScode Microsoft
@startupworld497
@startupworld497 Ай бұрын
what is the backtesting result for this strategy ?
@CodeTradingCafe
@CodeTradingCafe Ай бұрын
As is not well, but it has to be combined with other indicators (mainly trend indicators) to provide good potential.
@ScrollWithSantoshh
@ScrollWithSantoshh 2 ай бұрын
What would be the value of zone_with and other parameters for 1 min data, im not getting any level breaks
@CodeTradingCafe
@CodeTradingCafe 2 ай бұрын
It's hard to give a value this depends on the asset, check the charts it's easier to set a number visually.
@djprisma847
@djprisma847 4 ай бұрын
Can u give me the URL from the page, where u downloaded it. thx 3:30
@CodeTradingCafe
@CodeTradingCafe 4 ай бұрын
it's Dukascopy bank they provide data as well.
@vladislaviy
@vladislaviy 5 ай бұрын
nice! are you making money with it?
@CodeTradingCafe
@CodeTradingCafe 5 ай бұрын
Hi, thank you, no not this strategy, I don't run many strategies only few.
@seifyehia9113
@seifyehia9113 8 ай бұрын
Can you give a discount on Data Analysis With Pandas And NumPy In Python course?
@CodeTradingCafe
@CodeTradingCafe 8 ай бұрын
Sure www.udemy.com/course/data-analysis-with-pandas-and-numpy-in-python/?couponCode=7B9ACF76734A59AA0CB4 Good luck!
@luttycorp
@luttycorp 4 ай бұрын
i recomend you get the code then watch the video while adding your own comments in the code
@CodeTradingCafe
@CodeTradingCafe 4 ай бұрын
Thank you, I agree, it's a good way to go through the session/video.
@luttycorp
@luttycorp 4 ай бұрын
@@CodeTradingCafe IS there a way i can send you code built around your work am now to programing so i keep running into errors concering the table information being used for other parts of the code
@CCNATamilTutorials
@CCNATamilTutorials 9 ай бұрын
Hi sir, i need Automatic trading bot for binomo platform based, 1min buy sell scalping strategy
@CodeTradingCafe
@CodeTradingCafe 9 ай бұрын
Hi, I am not familiar with binomo I am not sure they provide a python API.
@CCNATamilTutorials
@CCNATamilTutorials 9 ай бұрын
@@CodeTradingCafe fine I understand, I have a scalping strategy for binary options trading ( 1min buy and sell concept) , need a bit for auto trading, what can I do, how to search.
@kudzovu
@kudzovu 9 ай бұрын
wow, you are very handsome
@CodeTradingCafe
@CodeTradingCafe 8 ай бұрын
lol, thank you!
@krunalpatelbiotech
@krunalpatelbiotech 3 ай бұрын
Not useful for real trade. Need Realtime signal generated from bunch of stocks list, not from just single stock. If you want to become profitable.
@CodeTradingCafe
@CodeTradingCafe 3 ай бұрын
The same method/function can be cloned and used for as many stocks and currencies as needed, at the end it's the same algorithm that we can repeat... But I agree with you, I would change the function to make it applicable for live data instead of ready/historical data.
@trocchiettoski
@trocchiettoski 2 ай бұрын
@@CodeTradingCafe one of the main challenges i have with your videos is 1) how with elegance to adapt a trading strategy for one stock to multiple stocks to make a scan. I usually cut the number of candles ex [-50:] but in this way could have more than one signal 2) adapt from forex to stock.As your channel is educational maybe could be appreciated a video where you explain how to address some daily jobs as the ones above. Personally instead of a fixed width i adapt with atr or bollinger to detect stocks breakout, because the difference between an high and the mean of the 3 points can be really variable depending by the level of price. Another solution would be to use a percentage. Thanks for the nice content
@kamleshkumar-yy2rw
@kamleshkumar-yy2rw 24 күн бұрын
At least you do this basic part on your own, he has explained well about the algorithm on historical data. Those who understood the algorithm can refactor the code a bit to run on live candle data. 😂
@AnmWorshipSong
@AnmWorshipSong 9 ай бұрын
hi how to contact you any telegram id ?
@CodeTradingCafe
@CodeTradingCafe 9 ай бұрын
My email is in the about section, no telegram sorry, good luck!
Predict The Stock Market With Machine Learning And Python
35:55
Dataquest
Рет қаралды 658 М.
Iron Chin ✅ Isaih made this look too easy
00:13
Power Slap
Рет қаралды 36 МЛН
IQ Level: 10000
00:10
Younes Zarou
Рет қаралды 11 МЛН
Trading with Python: Simple Scalping Strategy
13:47
CodeTrading
Рет қаралды 87 М.
Rayner Teo Bollinger Bands Strategy Backtest In Python High Return
23:29
Mastering SUPPORT & RESISTANCES using Python!
11:42
Algovibes
Рет қаралды 21 М.
Finding Breakout Candidates with Python and Pandas
29:33
Part Time Larry
Рет қаралды 69 М.
Technical Analysis with TradingView in Python
9:53
NeuralNine
Рет қаралды 29 М.
The Complete Guide to Python Virtual Environments!
15:52
teclado
Рет қаралды 338 М.
Iron Chin ✅ Isaih made this look too easy
00:13
Power Slap
Рет қаралды 36 МЛН