Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
179 views
14 pages
Using Machine Learning To Locate Support and Resistance Lines For Stocks
Using Machine Learning to Locate Support and Resistance Lines for Stocks
Uploaded by
FabioSantos
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download
Save
Save Using Machine Learning to Locate Support and Resis... For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
0 ratings
0% found this document useful (0 votes)
179 views
14 pages
Using Machine Learning To Locate Support and Resistance Lines For Stocks
Using Machine Learning to Locate Support and Resistance Lines for Stocks
Uploaded by
FabioSantos
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save Using Machine Learning to Locate Support and Resis... For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
Download
Save Using Machine Learning to Locate Support and Resis... For Later
You are on page 1
/ 14
Search
Fullscreen
rng Lea Spr ar Raa nat Sek |b Sahl Sage |The S|, 22 Mas You have 1 free member-only story left this month. Sign up for Medium and get an extra one Using Machine Learning to Locate Support and Resistance Lines for Stocks suna'Sagan ("55 san: Sinead‘Support and Resistance Support and Resistance lines are defined as certain levels of the assets price at which the price action may stop and/or reverse due to a larger number of interested investors in those price levels. They could be detected using the stock’s historical data. You could read this article for more information, Machine Learning The reason why I decided to use Machine Learning for this process is because it tends to be more appropriate than giving a computer a set of commands to follow using the data and executing it. With Machine Learning, the computer itself utilizes the data in order to recognize correlation and patterns between them. Basically, if you give the computer a series of a stocks data at which the stock price hits a certain level multipleMoxinedinanivaherg- rete naingntaleutroant po ar ass esr Sk Sih Sgn |The S|. 22 times but tends to get rejected by it, it should be able to classify this pattern. Atthe same time, we could have two types of these rejections, one as the stock price is moving up and the other as it moves down. One method to solve this is using unsupervised classification. Unsupervised classification is a type of machine learning that looks for previously undetected patterns in a data set with no pre-existing labels using minimum human supervision. The computer would find similarities among data sets and arrange them in different clusters and classifications. In this example we will be using K-means clustering. In simple terms, it tries to create K number of clusters (collection of data points aggregated together because of certain similarities) based on the number of centroids we need in the dataset. A centroid is the imaginary or real location representing the center of the cluster.Moninedinanivahserg- rete maintenant Python Iwill be using the Yahoo Finance API to download our data. It also allows you to get data for various different intervals. I will be using the 1 n interval for one day. There could be support and resistance areas on any interval you look at- the longer the interval the stronger they would be. ute First thing to do is import the Python libraries we need- sklearn, yfinance, pandas, numpy, and matplotlib. After that we define the start and end dates (Ipicked the day I wrote this article) and the ticker then inputs them into the yfinance function. We will also be separating the low and high data into different variables. 8 stylese(‘eploe')26 ow = pl.oatatrne(éntanatal'Low'], nden-dats inden) sf rane(dataneata gh", Andescdatatndex) When you print out the data it should look something like this. We will be given the date and time, open, high, low, close, and volume.reece Sc [by Sala The Sa [22 |n Stock Data How could we figure out the number of clusters that is best to split our data into? As discussed earlier, we need to figure out the value of K. This also becomes more difficult as the dimension of the data increases. There are two popular methods to accomplish this- Elbow Method and the Silhouette Method. I ‘will be doing it both ways to demonstrate and compare. 1. The Elbow Method: In this method, we pick a range for the values of K, then apply K-Means clustering using each of the values of K. Find the average distance of each point in a cluster to its centroid, and represent it in a plot. After that we pick the optimum value of K using the plot. The picture shown below is the graph of the Inertia vs the K value. Inertia is defined as the mean squared distance between each instance and its closest centroid. In simpler terms, it is the graph of the mean distance of each point in the clusters from its centroids vs the number of clusters. Moxinedinamivahierg- rete raion teleutrotanteoisinnsnerontokesT 4900825 waar ar Redrc tester Sk oy Sih As you can see, the average distance decreases as the number of clusters increases. Increasing the value of K will decrease the inertia for your model. An inertia of 0 would mean each point is 0 distance to its cluster center. In order to find the optimum number of clusters we need to look at where the rate of change of the distance decreases suddenly. Using the graph, we can conclude that 4 is an optimal value for K. 150 100 50 Inertia vk Meese an cotninmetin‘on sinedun ool ysrgartie aring-beale-uppor-andsensinr-nemforockitt BHD tain Sey Sua To Sa a, 202% Man ‘What we were basically doing is picking the value of K which will separate the clusters the best. We tried to test K=2,3,4. As you can see in this picture, K=4 fits the best. eMeans Cistering 2 cet get_optinayciusters(eata, saturation polnt-.5): 6 ves 5 kapadals = 0 © far An rangeta, ste) ° ncans = Wcans(aeusterst) we reas. Ft(enta) a ess. apnea neta) 2 sels. ppend(eneans)tn Maire tearing ool ipa are Renee Bc [by StalaanTe Sa [22h 34 pltsplot(ragets.21), wes) 28 ne 3 25 455 the value oF K (elbow faint) 19 owclusters = get_optini.ctusters(4)(3] 20° ngn_clastens ~ get_optinaclusters(hgh)(3] 25 datal Clore"] plot(ctgrtzes(e,8), e-'") 2. The Silhouette Method __ (0) -a(o) (0) = Trax {a(o), b(0)} Moxinedinamivahierg- rete raion teleutrotanteoisinnsnerontokesT 4900825 areece Sc [by Sala The Sa [22 |n * s(o) is the silhouette coefficient of the data point 0 * a(o) is the average distance between 0 and all the other data points in the cluster to which o belongs * b(0) is the minimum average distance from 0 to all clusters to which o does not belong The silhouette coefficient is a value between -1 and 1. Value of 1 means clusters are well apart from each other and clearly distinguished. 0 means clusters are indifferent, or the distance is not significant. -1 means clusters ‘were not assigned properly. The silhouette value measures how similar a point is to its own cluster (cohesion) compared to other clusters (separation). In order to get the silhouette score we average all the points out. After calculating it for each of the K values, we pick the value with the highest score, As you can see in the picture below, the silhouette score for K=3 was the highest for both the values of the high(red) and low(blue) stock prices. Moxinedinamivahierg- rete raion teleutrotanteoisinnsnerontokesT 4900825 soar ered tester Sk oy Saha 2 4 6 8 10 Siovette Scores veK stincing the optinunk using the siltoveteewethoe et eptinu.fvazuecenta) D K.meat = 0 for Je range, aes) ncane = keane(aslustere = K)(S0(eata) sath] = kneans sfk}-(ithourttescorefdata, Ibels)) eptinus_eluster = ksodel [noel bey ge®)] ple-plet(range(2.22),sid.values()) returaoptinun_cluster Moxinedinamivahierg- rete buingntaleutsotanteoisinninerontoks 14900825tain Sey Sua To Sa a, 202% Man 1 = opeinun_jvlue(nish) 26. ighuel = eptir_tvalueow) 22 datal chose] plotteiestzer6,8), e704) 22 pltsaeblinetsy coe, 1s") 25 pltsaahbinets, cor, le") inbscpy hot win © by ite view re Elbow vs Silhouette After we received our K values using both methods, we use the center of each cluster as the support and resistances for our stock. Since we came up with a K value of 3 using the Silhouette and 4 using the Elbow that will be the number of supports and resistances we will plot on our graphs. beech Moxinedinamivahierg- rete naingntaleutrotanteousinensnerontke 14300025 saElbow Method Sihovette Method Moxinedinamivahierg- rete raion teleutrotanteoisinnsnerontokesT 4900825 sapr anced these ik yi 1S 22 Although we got different results for both, by looking at the chart you could see how the Elbow method had better drawn supports and resistances. Itis always best to use both methods just to make sure you select the most optimal number of clusters in K-means clustering DataSclence acre ring StockMarket_ Tracing Python Learn more, Make Medium yours. are your thinki Moxinedinanivaherg- rete naingntaleutroant
You might also like
Lorentzian Algorithm Trading Strategy
PDF
No ratings yet
Lorentzian Algorithm Trading Strategy
20 pages
The Rimc Model
PDF
No ratings yet
The Rimc Model
15 pages
Buy Limit and Sell Limit
PDF
100% (1)
Buy Limit and Sell Limit
2 pages
Day Trading Entries and Exits The Best Day Trading Entry and Exit Signals For Forex, Stocks and Cryptocurrency in 2024 (High... (Harnett, David) (Z-Library)
PDF
No ratings yet
Day Trading Entries and Exits The Best Day Trading Entry and Exit Signals For Forex, Stocks and Cryptocurrency in 2024 (High... (Harnett, David) (Z-Library)
76 pages
SmartCandles Pro User Guide
PDF
No ratings yet
SmartCandles Pro User Guide
53 pages
Dax Key Levels Summary
PDF
100% (1)
Dax Key Levels Summary
6 pages
Heiken-Ashi Trading - The Full Guide in Python
PDF
100% (2)
Heiken-Ashi Trading - The Full Guide in Python
14 pages
Chapter 3. Machine Learning - Full
PDF
No ratings yet
Chapter 3. Machine Learning - Full
18 pages
ATMA Technical Analysis
PDF
100% (1)
ATMA Technical Analysis
86 pages
Liquidation Levels - by Leviathan
PDF
No ratings yet
Liquidation Levels - by Leviathan
5 pages
Technical Analysis Range Break Trading Cheat Sheet
PDF
100% (1)
Technical Analysis Range Break Trading Cheat Sheet
2 pages
Lab Report6 - B21CI014
PDF
No ratings yet
Lab Report6 - B21CI014
8 pages
CSC649 Lecture 3 Unsupervised ML - KMeansClustering
PDF
No ratings yet
CSC649 Lecture 3 Unsupervised ML - KMeansClustering
22 pages
What Is Day Trading How To Get It Started - PART 2
PDF
No ratings yet
What Is Day Trading How To Get It Started - PART 2
8 pages
Binary Decisions Dallas 02212012
PDF
No ratings yet
Binary Decisions Dallas 02212012
79 pages
Hidden Divergence - Chamane's Guidelines
PDF
100% (1)
Hidden Divergence - Chamane's Guidelines
13 pages
Gold Digger AI
PDF
No ratings yet
Gold Digger AI
3 pages
Trader 27 - Osfl
PDF
No ratings yet
Trader 27 - Osfl
10 pages
Gold (2003) - FX Trading Via Recurrent Reinforcement Learning PDF
PDF
No ratings yet
Gold (2003) - FX Trading Via Recurrent Reinforcement Learning PDF
8 pages
PATs Technical Analysis
PDF
No ratings yet
PATs Technical Analysis
9 pages
The SQN Indicator Market Regimes
PDF
No ratings yet
The SQN Indicator Market Regimes
4 pages
Conditions Indicators 9
PDF
No ratings yet
Conditions Indicators 9
11 pages
Vscore July1
PDF
No ratings yet
Vscore July1
2 pages
Trading Relative Strength Leaders in Weak Markets
PDF
No ratings yet
Trading Relative Strength Leaders in Weak Markets
12 pages
NSK New Text Document
PDF
100% (1)
NSK New Text Document
3 pages
Happ Harmonic Pattern Trading Tips.01
PDF
No ratings yet
Happ Harmonic Pattern Trading Tips.01
26 pages
Test Strategy in MetaTrader 4 With Tick Precision
PDF
0% (1)
Test Strategy in MetaTrader 4 With Tick Precision
15 pages
Supply and Demand Trading
PDF
No ratings yet
Supply and Demand Trading
4 pages
Algorithmic Trading Models - Breakouts
PDF
No ratings yet
Algorithmic Trading Models - Breakouts
10 pages
Momentum Trading: Using Pre-Market Trading and Range Breakouts
PDF
No ratings yet
Momentum Trading: Using Pre-Market Trading and Range Breakouts
7 pages
3 Triple in 1 Trade Trades PDF
PDF
No ratings yet
3 Triple in 1 Trade Trades PDF
7 pages
How To Trade Wedge Chart Patterns
PDF
No ratings yet
How To Trade Wedge Chart Patterns
6 pages
Trend Detection: by Arthur Merrill
PDF
No ratings yet
Trend Detection: by Arthur Merrill
3 pages
Bookmap Education Part 1
PDF
No ratings yet
Bookmap Education Part 1
45 pages
Extract Pages From Larry Pesavento & Leslie Jouflas - Trade What You See. How To Profit From Patterns Recognotion - Extract - OPRS
PDF
No ratings yet
Extract Pages From Larry Pesavento & Leslie Jouflas - Trade What You See. How To Profit From Patterns Recognotion - Extract - OPRS
6 pages
ML DSBA Lab7
PDF
No ratings yet
ML DSBA Lab7
6 pages
Proof3 Compressed
PDF
No ratings yet
Proof3 Compressed
102 pages
Vbo Fvbo
PDF
No ratings yet
Vbo Fvbo
6 pages
V12 C01 Priceos
PDF
No ratings yet
V12 C01 Priceos
13 pages
3 Chart Patterns Cheat Sheet
PDF
No ratings yet
3 Chart Patterns Cheat Sheet
7 pages
"These Are Just Rough Notes For References" What Is K-Means Clustering
PDF
No ratings yet
"These Are Just Rough Notes For References" What Is K-Means Clustering
9 pages
Andro STME
PDF
No ratings yet
Andro STME
17 pages
Python Basics
PDF
No ratings yet
Python Basics
15 pages
TOP Ultimate Breakout Quick Start Guide PDF
PDF
No ratings yet
TOP Ultimate Breakout Quick Start Guide PDF
13 pages
Black Dog Instructions 24 Feb 09
PDF
No ratings yet
Black Dog Instructions 24 Feb 09
111 pages
WINNER: Trading Software $1000 WINNER: Trading Software $500
PDF
No ratings yet
WINNER: Trading Software $1000 WINNER: Trading Software $500
7 pages
Indicator Manual: Ealtime Upply and Emand
PDF
100% (1)
Indicator Manual: Ealtime Upply and Emand
19 pages
Metastock Secrets: Lient Mail Onsultations
PDF
No ratings yet
Metastock Secrets: Lient Mail Onsultations
8 pages
TMS V19 Manual
PDF
No ratings yet
TMS V19 Manual
17 pages
Forex Volume Indicator
PDF
No ratings yet
Forex Volume Indicator
6 pages
Tools Used For Price Action Trading
PDF
No ratings yet
Tools Used For Price Action Trading
3 pages
Introduction of Markets: Stock Market Complete Course For Beginner
PDF
No ratings yet
Introduction of Markets: Stock Market Complete Course For Beginner
2 pages
01-Futures Checklists-All
PDF
No ratings yet
01-Futures Checklists-All
13 pages
1 Hour Tunnel Method Forex Strategy
PDF
No ratings yet
1 Hour Tunnel Method Forex Strategy
7 pages
Limit Order Book As A Market For Liquidity
PDF
No ratings yet
Limit Order Book As A Market For Liquidity
48 pages
Pivot Calculation: (Hemant)
PDF
0% (1)
Pivot Calculation: (Hemant)
9 pages
Price Action Webinar Recordings
PDF
No ratings yet
Price Action Webinar Recordings
2 pages
Order Block Forex Robot MT4 Manual
PDF
No ratings yet
Order Block Forex Robot MT4 Manual
10 pages
Estimate Support and Resistance of A Stock With Python
PDF
No ratings yet
Estimate Support and Resistance of A Stock With Python
18 pages
Gap Trading. An Introduction & Back-Test in Python
PDF
No ratings yet
Gap Trading. An Introduction & Back-Test in Python
15 pages
Trading Strategy - Technical Analysis With Python TA-Lib
PDF
No ratings yet
Trading Strategy - Technical Analysis With Python TA-Lib
12 pages
Crabel Toby - Day Trading With Short Term Price Patterns
PDF
No ratings yet
Crabel Toby - Day Trading With Short Term Price Patterns
298 pages
The RSI Delta Indicator. Enhancing Momentum Trading
PDF
No ratings yet
The RSI Delta Indicator. Enhancing Momentum Trading
21 pages
How To Trade Forex Using Roboforex Strategyquant Software
PDF
No ratings yet
How To Trade Forex Using Roboforex Strategyquant Software
44 pages
Using Machine Learning To Locate Support and Resistance Lines For Stocks - by Suhail Saqan - The Startup - Jan, 2021 - Medium
PDF
No ratings yet
Using Machine Learning To Locate Support and Resistance Lines For Stocks - by Suhail Saqan - The Startup - Jan, 2021 - Medium
14 pages
The Augmented Bollinger Bands
PDF
No ratings yet
The Augmented Bollinger Bands
23 pages
Creating A Modified Fisher Transformation For Profitable Trading.
PDF
No ratings yet
Creating A Modified Fisher Transformation For Profitable Trading.
21 pages
Importing High Quality Tick Data On MetaTrader 4 & 5
PDF
No ratings yet
Importing High Quality Tick Data On MetaTrader 4 & 5
34 pages
Building A Stock Option Valuation Model With Python Part II
PDF
No ratings yet
Building A Stock Option Valuation Model With Python Part II
18 pages
Time Series Forecasting With 2D Convolutions
PDF
No ratings yet
Time Series Forecasting With 2D Convolutions
33 pages
A Review of Reinforcement Learning For Financial Time Series Prediction and Portfolio Optimization
PDF
No ratings yet
A Review of Reinforcement Learning For Financial Time Series Prediction and Portfolio Optimization
38 pages
Technical Indicators and GRU-LSTM To Predict Stock Price
PDF
No ratings yet
Technical Indicators and GRU-LSTM To Predict Stock Price
36 pages
Building A Stock Option Valuation Model With Python Part I
PDF
No ratings yet
Building A Stock Option Valuation Model With Python Part I
17 pages
How To Export Data From Quant Data Manager and Import To Metatrader 5
PDF
No ratings yet
How To Export Data From Quant Data Manager and Import To Metatrader 5
18 pages
How I Created A Bitcoin Trading Algorithm Using Sentiment Analysis With A 29% Return
PDF
No ratings yet
How I Created A Bitcoin Trading Algorithm Using Sentiment Analysis With A 29% Return
10 pages
V25 C10 193verv
PDF
No ratings yet
V25 C10 193verv
10 pages
Guppy Multiple Moving Average
PDF
No ratings yet
Guppy Multiple Moving Average
6 pages
Pivot Formula
PDF
100% (1)
Pivot Formula
1 page
Back Testing With 99 Percent Modelling V1
PDF
No ratings yet
Back Testing With 99 Percent Modelling V1
4 pages