How to find Bitcoin support and resistance levels using the derivative of a price probability density function

Edgar Moraes
Coinmonks
Published in
4 min readFeb 14, 2022

--

Introduction

Support and resistance levels are essentials for big traders and refer to price levels at which an exchange rate trend is likely to be interrupted or reversed [1,2].

Normally, support and resistance are found by tracing trend lines, pivot point, round numbers, moving averages, Fibonacci sequence, and other indicators.

Hence, the present study was designed to investigate the potential of Differentiation (Fundamental Theorem of Calculus) of a price probability density function (PDF) for finding support and resistance levels, in other words, when you can buy or sell using Probability Theory.

Data treatment

Prices from Coingecko were used [3]. Data import, pre-processing and mathematics procedures were carried out using R software [4] with Signal Processing (signal) package [5]. All data processing was performed using the free R software from the R Foundation for Statistical Computing. Use R!

How to find Bitcoin Supports and Resistances

Download R (www.r-project.org). Install and open. Install geckor package [6] and extract Bitcoin prices from Coingecko:

> install.packages(“geckor”)
> library(“geckor”)
> btc.i = coin_history( coin_id = “bitcoin”, vs_currency = “usd”, days = “1825”)

If we want to visualize the Bitcoin (BTC) Price Chart (Figure 1), we can provide the price graph as the at argument:

> plot(btc.i$timestamp, btc.i$price, type=”l”, col=”orange2", main = “BTC-USD”, xlab=”time”, ylab=”BTC price (usd)”)
> abline(h=c(10000,20000,30000,40000,50000,60000,70000), col=”gray”, lwd=2, lty=3)

Figure 1. Bitcoin (BTC) Price Chart.

The goal of this study was to determine the probability density function (PDF) of Bitcoin price to find the support and resistance levels. A common way of plotting the PDF (Figure 2) in R is to apply the functions hist and density to plot histograms:

> hist(btc.i$price,breaks=480,col = “orange”, main=”Histogram of Prices (USD)”, xlab=”Price (USD)”, ylab=”Freq”, prob = TRUE, las=1)
> lines(density(btc.i$price), lwd = 4,col=”yellow”)

Figure 2. Histogram of Bitcoin Prices (orange bars) and its PDF (yellow line).

The important information from Figure 2 is that impossible to find the end of each price movement. In this way, a derivative test was used to locate the critical points of the bitcoin PDF, in other words, these critical points represent an interruption or reversion of the price movement. We can derivative the probability distribution function by using the function sgolayfilt from the signal package [7].

> HIST.a <- density(btc.i$price)
> install.packages(“signal”)
> library(“signal”)
> HIST.a.sg = sgolayfilt(HIST.a$y, n=7, m=1)
> plot(HIST.a$x[140:512],HIST.a.sg[140:512], type=”l”, col=”green”, main = “Support and Resistance Zones”, ylab=”PDF derivative”, xlab=”Price”, xlim=c(27000,70000))
> axis(1,c(20000,30000,40000,50000,60000,70000))
> text(HIST.a$x[213], HIST.a.sg[213], labels = round(HIST.a$x[213],2))
> text(HIST.a$x[238], HIST.a.sg[238], labels = round(HIST.a$x[238],2))
> text(HIST.a$x[287], HIST.a.sg[287], labels = round(HIST.a$x[287],2))
> text(HIST.a$x[315], HIST.a.sg[315], labels = round(HIST.a$x[315],2))
> text(HIST.a$x[367], HIST.a.sg[367], labels = round(HIST.a$x[367],2))
> text(HIST.a$x[401], HIST.a.sg[401], labels = round(HIST.a$x[401],2))
> text(HIST.a$x[428], HIST.a.sg[428], labels = round(HIST.a$x[428],2))
> text(HIST.a$x[336], HIST.a.sg[336], labels = round(HIST.a$x[336],2))

Figure 3. Support and Resistance zones of Bitcoin.

Note that max and min functions select the largest and smallest values in their arguments.

Conclusion

This simple proposal was an excellent opportunity to show traders a new way to find support and resistance levels based on statistics. In addition, the method can be applied for other digital assets just by changing the coin in coin_history function. In other words, there are no different ways for different coins. In the present case Bitcoin supports and resistances were found together for the completion of the study.

If you like this content, consider the tip:

BTC: bc1qljlmuwq9gyvn7uhvwwypsj4x8hcetuzhw9quh0

BNB: bnb159am7huy53mg7sygnklrtxkahkdk2qxzmnk0gw

BUSD: bnb159am7huy53mg7sygnklrtxkahkdk2qxzmnk0gw

Acknowledgments

The author is grateful to Satoshi Nakamoto, Hal Finney, Nick Szabo, Changpeng Zhao, Sabrina Moraes, and André Fauth.

References

1. Osler, Carol L., Support for Resistance: Technical Analysis and Intraday Exchange Rates. Economic Policy Review, Vol. 6, №2, July 2000, Available at SSRN: https://ssrn.com/abstract=888805

2. Support and Resistance Lines: What to Know (investopedia.com)

3. www.coingecko.com

4. https://www.R-project.org/

5. https://cran.r-project.org/web/packages/signal/index.html

6. Sergey Mastitsky (2021). geckor: R Client for the ‘CoinGecko’ API. R package version 0.2.0. https://CRAN.R-project.org/package=geckor

7. signal developers (2013). signal: Signal processing. URL: http://r-forge.r-project.org/projects/signal/

Join Coinmonks Telegram Channel and Youtube Channel learn about crypto trading and investing

Also Read

--

--