Chad-Thackray
This video tutorial covers using Python to detect uptrends and downtrends in the closing price of an asset by labeling higher highs and higher lows in the price movement. The process can be automated and used as a filter for other indicators that work best when trending in a particular direction. The section also covers data processing steps for getting candlestick data, trimming down the data frame, and calculating the average true range. The video explains how to use the Savitzky-Golay filter from the scipy module to smooth out price data, how to detect higher highs and higher lows in Python using a while loop and conditional statements, and how to turn the trend detection algorithm into an animation using Python. Additionally, the presenter explains how to use a smooth curve instead of a regular price curve to detect uptrends and downtrends and how to display the animation using HTML5 video and save it as an HTML file.
detects uptrends and downtrends in the closing price of an asset is discussed in this section. The process involves labeling higher highs and higher lows in the price movement which can then be used to identify if the graph is in an uptrend or downtrend. By using Python, this process can be automated and used as a filter for other indicators that work best when trending in a particular direction. The section also covers the data processing steps involved in getting candlestick data, trimming down the data frame, and calculating the average true range. The plotted price data is then smoothened out to identify turning points for overall trends rather than single bar movements.
In this section, the video tutorial covers how to use the Savitzky-Golay filter from the scipy module to smooth out price data and retain overall trends, allowing for the detection of extrema or the maximum and minimum points. The smoothing forms a polynomial curve that fits well with past data points, and the filter helps remove spiky noise from the price data. The function takes in data, tuning parameters, and outputs a graph that can be plotted on top of the original price data. The extrema points are detected using the find_peaks function that determines the specificity of the detected minima and maxima by adjusting settings such as distance, width, and prominence. The result of the function is a print peaks index that specifies the index or time at which there was a peak for plotting.
In this section, the video explains how to detect higher highs and higher lows in Python using a while loop and conditional statements. The code uses a variable called "up run length" to keep track of the length of the current uptrend, setting it to zero initially if there is no uptrend detected. The while loop checks whether the most recent high is greater than the previous high and the most recent low is greater than the previous low. If this is true for a certain number of successive peaks, an uptrend is detected and the background color of the graph is changed to green. Otherwise, if there is no uptrend, the background color is set to white. The same logic can be applied to detect downtrends using lower highs and lower lows.
In this section, the speaker explains how to turn their trend detection algorithm into an animation using Python. The syntax is mostly the same as in the previous example, but there are a few differences to note. The number of bars displayed on the graph and how far back the function looks for maxima and minima are defined by the "bars in frame" variable. The Y limit and X limit are also set. Then, during the animate function, the speaker grabs only the bars up until the current day to avoid any look-ahead bias and includes extra frames to avoid too much curving around in the beginning of the animation. The data is set for each line during the animation, and the Y limits are changed to keep the animation nicely zoomed in as the market continues its journey.
In this section, the presenter explains how to use a smooth curve instead of a regular price curve to detect uptrends and downtrends. The reason for this is that the regular price curve is more spiky, and using it would result in a janky and jumpy rendering of the animation. The presenter also adds a down run, sets the peaks and troughs values, and uses an if-else statement to change the color of the lines based on the trend. Finally, the presenter explains how to display the animation using HTML5 video and how to save it as an HTML file. The presenter suggests setting the graphics backend to matplotlib inline, or to QT or some other kind if it doesn't work.
No videos found.
No related videos found.
No music found.