Plotting TA-Lib indicators¶
TA-Lib indicators are compatible with both pandas nad polars backends.
In [2]:
Copied!
from mplchart.chart import Chart
from mplchart.samples import sample_prices
from mplchart.primitives import Candlesticks, OHLC, Volume, LinePlot, Pane
from talib.abstract import Function
prices = sample_prices(backend="polars")
from mplchart.chart import Chart
from mplchart.samples import sample_prices
from mplchart.primitives import Candlesticks, OHLC, Volume, LinePlot, Pane
from talib.abstract import Function
prices = sample_prices(backend="polars")
Candlesticks with SMA, RSI and MACD¶
In [3]:
Copied!
title = "Candlesticks with SMA, RSI, and MACD"
Chart(prices, title=title, max_bars=250).plot(
Candlesticks(),
Function("SMA", 50),
Function("SMA", 200),
Pane("above"),
Function("RSI"),
Pane("below"),
Function("MACD")
).show()
title = "Candlesticks with SMA, RSI, and MACD"
Chart(prices, title=title, max_bars=250).plot(
Candlesticks(),
Function("SMA", 50),
Function("SMA", 200),
Pane("above"),
Function("RSI"),
Pane("below"),
Function("MACD")
).show()
Bollinger Bands¶
In [4]:
Copied!
title = "Bollinger Bands"
Chart(prices, title=title, max_bars=150).plot(
Candlesticks(),
Function("BBANDS", 20),
).show()
title = "Bollinger Bands"
Chart(prices, title=title, max_bars=150).plot(
Candlesticks(),
Function("BBANDS", 20),
).show()
Stochastic Oscillator¶
In [5]:
Copied!
title = "Stochastic Oscillator"
Chart(prices, title=title, max_bars=250).plot(
Candlesticks(),
Pane("below"),
Function("STOCH")
).show()
title = "Stochastic Oscillator"
Chart(prices, title=title, max_bars=250).plot(
Candlesticks(),
Pane("below"),
Function("STOCH")
).show()
Parabolic Stop and Reverse¶
In [6]:
Copied!
title = "Parabolic Stop and Reverse"
Chart(prices, title=title, max_bars=150).plot(
Candlesticks(),
Function("SAR") @ LinePlot(style="marker"),
).show()
title = "Parabolic Stop and Reverse"
Chart(prices, title=title, max_bars=150).plot(
Candlesticks(),
Function("SAR") @ LinePlot(style="marker"),
).show()
Hilbert Transform¶
In [7]:
Copied!
title = "Hilbert Transform"
Chart(prices, title=title, max_bars=150).plot(
Candlesticks(),
Pane("below"),
Function("HT_SINE"),
Pane("below"),
Function("HT_DCPHASE"),
Pane("below"),
Function("HT_DCPERIOD")
).show()
title = "Hilbert Transform"
Chart(prices, title=title, max_bars=150).plot(
Candlesticks(),
Pane("below"),
Function("HT_SINE"),
Pane("below"),
Function("HT_DCPHASE"),
Pane("below"),
Function("HT_DCPERIOD")
).show()
In [ ]:
Copied!