Automated Price Action Trading Strategy In Python

  Рет қаралды 48,696

CodeTrading

CodeTrading

Күн бұрын

Пікірлер: 124
@pauleasther
@pauleasther Жыл бұрын
Congrats on not having a clickbait title like, “Make Millions Overnight” or suchlike as used by so many Tubers. Instead a professional honest approach.
@CodeTradingCafe
@CodeTradingCafe Жыл бұрын
Thank you for your appreciation, I am glad you enjoyed the content. In fact I am happy with the coding part most of the time so no need to oversell any indicator, they all have some pros and cons.
@alpsgrin4501
@alpsgrin4501 3 жыл бұрын
on 26.07 you are talking about the up trend is a very smart idea, but you can implement this condition not to trade against the market by setting in the code if the last 3-4 candles are bullish, then we trade, if bearish, then we do not, for example. It is necessary in the code to indicate the NUMBER of PREDING candles, this is the MOST IMPORTANT condition in addition
@CodeTradingCafe
@CodeTradingCafe 3 жыл бұрын
Hi, sorry for the delay, I had to check in detail, adding the filtering method is good but we will be decreasing the sensitivity of our model therefore yielding no more than ~3 trades per year, maybe this is good to implement for lower timeframes (H4 or H1)
@alpsgrin4501
@alpsgrin4501 3 жыл бұрын
Good afternoon, you do not need to worry, such videos cannot be too long))) in everything related to money, there is always not enough information and thanks for the strong video
@CodeTradingCafe
@CodeTradingCafe 3 жыл бұрын
Lol well it reminds me years ago trying to learn trading all I was stumbling on was the moving average strategy in like 6 min vids...plenty of them, nothing that helpful... Times have changed and the field is evolving quickly, today's techniques are really powerful. Maybe I will try to automate this strategy in another video.
@doge2themoon373
@doge2themoon373 2 жыл бұрын
happy to find your channel, I've been looking to start in python and find this very helpful
@CodeTradingCafe
@CodeTradingCafe 2 жыл бұрын
Thank you for your comment, check my playlists there is one on learning python it might be helpful, and good luck, it will be fun you will see!
@drjenniferderm
@drjenniferderm 3 жыл бұрын
Very thorough explanation!! Great content!
@CodeTradingCafe
@CodeTradingCafe 3 жыл бұрын
Thanks a lot for your support.
@tigerpainset8792
@tigerpainset8792 Жыл бұрын
Thank you much for sharing videos from novice programmer from thailand :-)
@CodeTradingCafe
@CodeTradingCafe Жыл бұрын
Thank you for your support!
@prabhattiwari5089
@prabhattiwari5089 2 жыл бұрын
@CodeTrading, you are a gem.💎 Thank you so much for sharing these amazing videos.
@CodeTradingCafe
@CodeTradingCafe 2 жыл бұрын
Thank you for your support
@bikramssharemarkettradingc7366
@bikramssharemarkettradingc7366 2 жыл бұрын
I saw your prev SR level video pls mention it in the description of video, I think prev video should be seen prior this video
@CodeTradingCafe
@CodeTradingCafe 2 жыл бұрын
Thank you I agree with you I will add a link.
@MrHamish1998
@MrHamish1998 2 жыл бұрын
This is a great video and strategy! I think there is look forward bias in the signal calculation though. When iterating through subrow to calculate the support and resistances the subrow finishes on 'row' which is the present day. This is fed in to the support and resistance functions which look n1 candles behind the row input and n2 candles in front so you would have to know what n2 candles are in to the future. Just food for thought. Correct me if I'm wrong because I've been staring at this code all day!
@CodeTradingCafe
@CodeTradingCafe 2 жыл бұрын
Hi, thank you for your comment, the right boundary in Python is excluded meaning if I write [row-5:row] in fact it goes from row-5 up to row-1 I hope it makes sense
@MrHamish1998
@MrHamish1998 2 жыл бұрын
@@CodeTradingCafe I see, but the current row is included in the iteration: For subrow in range(row-backcandles+n1, row+1): if support (df, subrow, n1, n2): SS.append(df.low[subrow]) So if the code is looking forward n2 candles when subrow = row ?
@CodeTradingCafe
@CodeTradingCafe 2 жыл бұрын
@@MrHamish1998 actually you're correct, the subrow should stop at row+1-n2 I think it wouldn't affect our results much because it's an error only triggered when the current candle is support or resistance along with previous 45 candles (we simply got lucky with this) this reminded me of the same type of mistake I was commenting on an article years ago. Thank you for pointing this out
@MrHamish1998
@MrHamish1998 2 жыл бұрын
@@CodeTradingCafe I backtested it with the look forward bias using backtesting module on 15min and 5min timeframes on 5 cryptos using ATR as TP. Results were incredible (+1000% APY). After fixing the look forward bias returns went to +10-20%. So still profitable. I reckon using volume and large time frame SRs as well as your wedge breaks and head and shoulders in your other videos this could be a serious trading bot! Either way you’ve helped my coding a lot with these videos and inspired some ideas!
@MrHamish1998
@MrHamish1998 2 жыл бұрын
@@CodeTradingCafe also because we’re iterating through each row then every candle backwards within BackCandles every support/resistance found will become the current row at some point. Easily fixed though. Bit of tweaking and this strategy is a weapon
@sawfhsawfh2024
@sawfhsawfh2024 3 жыл бұрын
Thank you so much for sharing 🙂
@CodeTradingCafe
@CodeTradingCafe 3 жыл бұрын
Thank you for your support, and good luck.
@alpsgrin4501
@alpsgrin4501 3 жыл бұрын
at 26.45, you found a 585 candle well suited to our conditions, but why did the scanner miss the next candle right behind it? she perfectly suited all conditions! Is this an ERROR IN THE CODE? SCAN SKIP MAYBE MORE THAN ONCE, I DIDN'T NOTICE BUT IT'S WORTH CHECKING I THINK! AND YOU?
@CodeTradingCafe
@CodeTradingCafe 3 жыл бұрын
Well spotted ! in fact it might not be an error but I suspect that it wasn't taken as a signal because in the function isstar() we have a minimum candle body difference to consider (the variable is called bodydiffmin check video 8:28) so maybe the candle is "too small" to make a signal, ... there is one way to find out decrease the value of the bodydiffmin or simply check the body length of this particular candle.
@arieltoledosoto9343
@arieltoledosoto9343 Жыл бұрын
Oooh geez! This channel is amazing! Thanks for your jog. It's very nice.
@CodeTradingCafe
@CodeTradingCafe Жыл бұрын
Glad you enjoy it! thank you for your support.
@kingsanket123
@kingsanket123 Жыл бұрын
Great content.. Thanks a lot ! I have one query. Why are you not using TAlib to detect candlestick patterns?
@CodeTradingCafe
@CodeTradingCafe Жыл бұрын
Hi by the time I started doing these codes candles were still freshly introduced in TAlib. Another reason is I like to control the ratios of the patterns like the wick versus candle body and size of the engulfing candle etc... but I don't mind using TAlib if you know what's happening under the hood.
@alpsgrin4501
@alpsgrin4501 3 жыл бұрын
how to carry out the process of automatic optimization of the stop loss and take profit parameters, as solved in the metatrader in backtesting, and how would you decide to INDENT in the code from the resistance and support lines in order to sell at the distance from the resistance line found in the backtest, for example ?
@CodeTradingCafe
@CodeTradingCafe 3 жыл бұрын
I think I understand what you mean, we will have to include most of the code in this video in a big for loop that checks different SL values or distances to price, then you keep the SL distance yielding highest income, in machine learning this is close to overfiting in the sense that it would work fine on previous data where you did your adjustments but it doesn't necessarily work well on future data. Anyway to optimise any parameter the code can be included in a for loop changing the parameter and checking the outcome.
@alpsgrin4501
@alpsgrin4501 3 жыл бұрын
@@CodeTradingCafe I think this is a very good idea for a new video, automatic optimization and finding exactly in pips the price of the stop loss and take profit, as well as the trailing stop and the step of following the price, display the clarified parameters in the table. This will improve profits and help reduce losses. The first rule of the trader))) cut losses
@securiosityy
@securiosityy 2 ай бұрын
Great content! Thank you so much for sharing this. I love how flexible this is and how much room it leaves to playing around with these functions and doing my own testing.
@CodeTradingCafe
@CodeTradingCafe 2 ай бұрын
Glad it was helpful! Thank you for your support.
@alpsgrin4501
@alpsgrin4501 3 жыл бұрын
How would we optimize the automatic finding of the exact stop loss in pips, so that backtesting itself on historical data checks how much optimal in pips the stop would be on the found candles to enter a trade, of course, count the indent from the resistance line
@CodeTradingCafe
@CodeTradingCafe 3 жыл бұрын
I can see you are deep into this type of analysis! some day it will pay!
@bikramssharemarkettradingc7366
@bikramssharemarkettradingc7366 2 жыл бұрын
@@CodeTradingCafe thank you
@germanslobo
@germanslobo 2 жыл бұрын
Thanks, amazing video, I learned a lot!
@CodeTradingCafe
@CodeTradingCafe 2 жыл бұрын
Thank you for your support, glad the videos is helpful
@alpsgrin4501
@alpsgrin4501 3 жыл бұрын
at 28.40 there will be no false positive triggering))) if you indicate what I just wrote about, do not enter the deal in short, if the previous candles are 3-4, SPECIFY IN CODE !!! There were Bulls
@CodeTradingCafe
@CodeTradingCafe 3 жыл бұрын
Yes but at the same time we are looking for engulfing signals around resistance/supports so we expect a reversal, I am not sure if I add one more condition we would still have any signals at all. We can investigate this anyway, the code is ready so I can add the condition and see what it does...
@jasonh686
@jasonh686 4 ай бұрын
Thanks!
@CodeTradingCafe
@CodeTradingCafe 4 ай бұрын
Thank you for your support! much appreciated.
@alpsgrin4501
@alpsgrin4501 3 жыл бұрын
I know the main mistake of the trailing stop. IT DOESN'T WORK UNTIL THE PRICE TOUCHES IT IN THE BACKWARD DIRECTION, which is very inconvenient! What is your opinion? does the trailing start from the moment you place an order in your code? and it immediately follows the price at a certain distance of 10-15 pips?
@CodeTradingCafe
@CodeTradingCafe 3 жыл бұрын
In my opinion the trailing distance shouldn't be a constant like 10 or 15 or something else pips, mainly because the market is different every day, if I have to test trailing stop I would use the distance of the stop loss as described in the video as a start but also have to think about modifying the trail distance (making it smaller) as you get closer from a "fictive" take profit value, make like a function where the trailing distance shrinks linearly until a certain point which is the "TP" then the distance remains constant for the rest of the time. (I know it's complex/annoying but we can't use linear or constant thinking on nonlinear market, and you have to give enough room for your trade to move especially at the beginning). Another way to fix the distance of a trailing stop is using ATR values takes into account the market volatility.
@JohnQuezadaHuayamave
@JohnQuezadaHuayamave Жыл бұрын
Como siempre son excelentes videos los que tienes.
@CodeTradingCafe
@CodeTradingCafe Жыл бұрын
Gracias amigo :) thank you for your support!
@bostjan.gajsler
@bostjan.gajsler 9 ай бұрын
Great work! Excellent!
@CodeTradingCafe
@CodeTradingCafe 9 ай бұрын
Thank you :)
@shivamdubey4783
@shivamdubey4783 Жыл бұрын
Sir what is prerequisite for starting your course I know python besides that what else you need to know
@CodeTradingCafe
@CodeTradingCafe Жыл бұрын
Hi, python then more python and again python. Later you need to get familiar with trading strategies and some algorithmic trading books. Good luck!
@maverick456-33
@maverick456-33 Жыл бұрын
Very Good Tutorial !
@CodeTradingCafe
@CodeTradingCafe Жыл бұрын
Thank you for your support, much appreciated.
@paultenzer1361
@paultenzer1361 2 жыл бұрын
Really great video, thanks for putting this out and giving us the source code too. Thanks bro you saved me a ton of pain
@CodeTradingCafe
@CodeTradingCafe 2 жыл бұрын
Thank you for your support, finally some of my work is being discovered 🙂 happy these codes are of use
@alabaalaba2810
@alabaalaba2810 3 жыл бұрын
Great!
@CodeTradingCafe
@CodeTradingCafe 3 жыл бұрын
Thank you, I will try to show a bot using this
@flydr2
@flydr2 2 жыл бұрын
Thanks Again!
@CodeTradingCafe
@CodeTradingCafe 2 жыл бұрын
...and for your support 😊
@yeardol
@yeardol 7 ай бұрын
Symmetrical exit maybe 😊 according to the strategy
@CodeTradingCafe
@CodeTradingCafe 7 ай бұрын
There is only one way to find out :)
@username42
@username42 Жыл бұрын
how can we put this into tradingview pinescript as strategy indicator?
@CodeTradingCafe
@CodeTradingCafe Жыл бұрын
Hi honestly I am not familiar with tradingview coding language but it shouldn't be very different from any. I mainly prefer python because it has machine learning and neural networks libraries.
@jasonh686
@jasonh686 4 ай бұрын
Thank you for your amazing videos. They are always so clear and very helpful and I have learned a lot from them. I am having an issue with determining support and resistance as I get the following attribute error when trying to create my ss and rr lists: 'DataFrame' object has no attribute 'low'. The data from my broker exports the low values under the column '', however I have defined my low as = list(df['']). Am I doing something wrong? Your help would be greatly appreciated.
@CodeTradingCafe
@CodeTradingCafe 4 ай бұрын
Glad you like them! Thank you for your support. Actually yes the error you are encountering is related to the names of the columns, for example if the title of the column is LOW you to change all the occurrences of low to LOW... just as you did, now since you are still getting the error it means that there is still an unchanged 'low' somewhere in your code. Check it out again and let me know if it works.
@jasonh686
@jasonh686 4 ай бұрын
@@CodeTradingCafe Thank you for your response and help with this! I've looked through the code again and all instances seem to be correct, but I am still getting the error. I can email you a screenshot of the error message if you think that would help?
@CodeTradingCafe
@CodeTradingCafe 4 ай бұрын
Send me a screenshot maybe I can figure it out
@jasonh686
@jasonh686 4 ай бұрын
@@CodeTradingCafe Thank you very much Sir, I really appreciate it!
@kaderryans1909
@kaderryans1909 Жыл бұрын
What platform can we use this code on? Tradingview, mt4, mt5 ? Thanks
@CodeTradingCafe
@CodeTradingCafe Жыл бұрын
Hi this code is in Python language so you need python installed to run it, it doesn't work on mt nor tradingview. However the algorithm can be translated to mt or tradingview
@kaderryans1909
@kaderryans1909 Жыл бұрын
@@CodeTradingCafe OK thanks
@Damientrades
@Damientrades 3 жыл бұрын
Hey man great content learning alot from your coding skills could u do a video on connecting to mt5 api with python to implement some of these strategies in the back testing terminal on mt5 binace connection would be cool aswell
@CodeTradingCafe
@CodeTradingCafe 3 жыл бұрын
Hi, thank you for your comment, I understand what you mean, I have already thought about it but dropped the idea since we can backtest in python. However, note that these particular strategies can be written in mql language relatively easily because there is no Machine Learning involved (main reason I chose Python was being able to include ML models).
@philandrews197
@philandrews197 Жыл бұрын
Thank you for your work. I'm probably being an idiot, but I can't get the algo to find the data file. Do I need to save it at a particular location so it can be found by the algo please?
@CodeTradingCafe
@CodeTradingCafe Жыл бұрын
Thank you for your support! The easiest is to keep the data file in the same folder just next to the jupyter notebook python file. Let me know if it worked.
@philandrews197
@philandrews197 Жыл бұрын
@@CodeTradingCafe Thanks, works now!
@jancihak1682
@jancihak1682 6 ай бұрын
Hi, may I ask if I will test this strategy for example to data of BTC/USD. The column "amount" will represent pips, but how many lots/units am I trading actually?
@CodeTradingCafe
@CodeTradingCafe 6 ай бұрын
Hi, good question, actually this is not included in the code nor the video, so we are assuming one full bitcoin in trade, now if you want to make things easier as a full backtest, in my most recent videos I am using backtesting.py for backtests and you can include the trade size in it. Check this one for example kzbin.info/www/bejne/eWTFmWmPabGjfdU
@identicalgd2446
@identicalgd2446 2 ай бұрын
why does trend and amount not come out as integers but fractions with weird 0.182 or some random numbers
@CodeTradingCafe
@CodeTradingCafe 2 ай бұрын
Hi, actually at some point trend is integer but at the end of the notebook apparently the column was overwritten by the Amount values (for some reason... mistake)
@identicalgd2446
@identicalgd2446 2 ай бұрын
@@CodeTradingCafe hello, I figured it out, the return value was for amount not for return trendk
@CodeTradingCafe
@CodeTradingCafe 2 ай бұрын
Thank you for letting me know, good luck!
@sararhymestvhindi5481
@sararhymestvhindi5481 Жыл бұрын
Could you please help me how to implement the strategy in indian market on index options
@CodeTradingCafe
@CodeTradingCafe Жыл бұрын
You need to backtest first to make sure it's profitable
@arezkimihoubi1825
@arezkimihoubi1825 Жыл бұрын
is it possible to implement python code in MT4 station ?
@CodeTradingCafe
@CodeTradingCafe Жыл бұрын
Hi, yes using mql4 language you can translate any Python code to run in mt4.
@ongnatstudio9967
@ongnatstudio9967 Жыл бұрын
thank you so much! But can you add English subtitle pls ?
@CodeTradingCafe
@CodeTradingCafe Жыл бұрын
Are the auto generated captions working?
@SasanTavakoli-r2w
@SasanTavakoli-r2w 9 ай бұрын
how can i get quotex otc candlestick data such as open, hight,low... in python ?
@CodeTradingCafe
@CodeTradingCafe 9 ай бұрын
Hi, you might try dukascopy they might have data published.
@SubspaceAlgo
@SubspaceAlgo Жыл бұрын
May I privately share an idea for consideration?
@CodeTradingCafe
@CodeTradingCafe Жыл бұрын
Hi, sure you can send me an email, the address is in the about section of this channel.
@SubspaceAlgo
@SubspaceAlgo Жыл бұрын
@@CodeTradingCafe Sent.
@alpsgrin4501
@alpsgrin4501 3 жыл бұрын
Why don't you go from static, in real time, it is much more informative to see which candle on the chart is false positive, if you mark all the found candles with arrows showing the direction of entering a deal, a green arrow up long, or a red short down, then you will not need to manually drive in the numbers of the found candles
@CodeTradingCafe
@CodeTradingCafe 3 жыл бұрын
It's a good idea but there's still a problem where you can fit only a certain number of candles into a visible frame, but yeah I see what you mean I will look into it
@alpsgrin4501
@alpsgrin4501 3 жыл бұрын
@@CodeTradingCafe no problem, you can implement horizontal scrolling scrolling from the first candle in our dataset, for example 10 years and 3000 candles, the graph is drawn in Cartesian coordinates, a new candle will be drawn along the X-axis every time, and the previous ones will disappear behind the visible field to the left, how in any real-time platform charts with new candles are drawn, let's leave, for example, beautiful large, convenient size 30 visible candles, the rest behind the canvas, just scrolling to view
@cybergrimreaper6669
@cybergrimreaper6669 7 ай бұрын
hello, what is the barsupfront variable its gives an error thats its not defined
@CodeTradingCafe
@CodeTradingCafe 7 ай бұрын
These are the bars to look for in the future, shouldn't run at the end of the dataframe.
@cybergrimreaper6669
@cybergrimreaper6669 7 ай бұрын
@@CodeTradingCafe does it have to be defined before the loop?
@CodeTradingCafe
@CodeTradingCafe 7 ай бұрын
I assume so because it's used inside the loop.
@paulmc7309
@paulmc7309 Жыл бұрын
any idea why its now getting multiple errors ?
@CodeTradingCafe
@CodeTradingCafe Жыл бұрын
Hi, it shouldn't get errors I think the code is still the same. Can you mention the type of errors you are getting?
@paulmc7309
@paulmc7309 Жыл бұрын
@@CodeTradingCafe high it was my fault, its all good....awesome code. I didnt put the csv in the correct file location...school boy error....
@CodeTradingCafe
@CodeTradingCafe Жыл бұрын
It's good it's working! good luck for your experiments.
@paulmc7309
@paulmc7309 Жыл бұрын
@@CodeTradingCafe hi its all good, great channel... I was wondering if you coded something a bit different like HTF say 2H indicators using data from 30mins? For S&R try Gann SQ of 9... a strategy I am looking at is 30min data Stochast(5,3,3) & BB(20) & Gann SQ of 9 S & R, (use this for close to S & R) isStar or isDoji, then HTF indicators: 72 EMA 144 EMA , ADX 56. For BUY 72EMA>144EMA, ADX D+>D-, isStar or isDoji, below BB low, Stoch70. Its just something a bit different from using single TF with single TF indicators and using Gann for S & R.
@programmingbezaleel
@programmingbezaleel Жыл бұрын
where do u get the data csv
@CodeTradingCafe
@CodeTradingCafe Жыл бұрын
Yfinance, my broker and Dukascopy. Good luck!
@MERAJ_2421
@MERAJ_2421 3 ай бұрын
❤🎉
@CodeTradingCafe
@CodeTradingCafe 3 ай бұрын
Thank you for your support.
@MERAJ_2421
@MERAJ_2421 3 ай бұрын
@@CodeTradingCafe ur most welcome
@akam0707
@akam0707 Жыл бұрын
This strategy is good compare to other strategy that use indicator like rsi, macd and so on, because it is lagging and i think i can throw rsi , macd into rubbish.🤣🤣🤣🤣
@CodeTradingCafe
@CodeTradingCafe Жыл бұрын
actually you can still use RSI or other indicators for exit strategies but not for the entry. And you are right support resistance and price action are better for entry signals. Good luck (check also my videos on VWAP and Bollinger Bands they provide good hints as well)
@akam0707
@akam0707 Жыл бұрын
@@CodeTradingCafe because i have my friend that are programmer (data scientist) , he does not use rsi, macd and standard indicator on tradingview for strategies, he use mean reversion, multi time frame analysis and price movement or volatility analysis in his trading strategy.
@CodeTradingCafe
@CodeTradingCafe Жыл бұрын
Multi timeframe is powerful reversals are less noisy on higher timeframes and entry points are clearer on lower timeframes.
Automated Support and Resistance Detection in PYTHON
19:25
CodeTrading
Рет қаралды 64 М.
НАШЛА ДЕНЬГИ🙀@VERONIKAborsch
00:38
МишАня
Рет қаралды 2,9 МЛН
Synyptas 4 | Арамызда бір сатқын бар ! | 4 Bolim
17:24
Good teacher wows kids with practical examples #shorts
00:32
I migliori trucchetti di Fabiosa
Рет қаралды 13 МЛН
How To Backtest A Trading Strategy in Python
21:00
CodeTrading
Рет қаралды 60 М.
How do Graphics Cards Work?  Exploring GPU Architecture
28:30
Branch Education
Рет қаралды 520 М.
Automated Price Break Out Detection: Algorithmic Trading In Python
16:34
Auto-detect Support and Resistance in Python
17:06
Chad Thackray
Рет қаралды 22 М.
I Found The Hidden Trading Pattern That Controls All Markets
13:53
RSI Divergence Automated In Python | Algorithmic Trading
35:22
CodeTrading
Рет қаралды 36 М.
НАШЛА ДЕНЬГИ🙀@VERONIKAborsch
00:38
МишАня
Рет қаралды 2,9 МЛН