# Technical indicators (/features/indicators/technical-indicators)

## Hurst exponent \[#hurst-exponent]

New in v2024.6.19

✅ Estimating the Hurst exponent provides insight into whether your data is a pure white-noise random
process or exhibits underlying trends. VBT offers five (!) different implementations.

```python title="Plot rolling Hurst exponent by method"
>>> data = vbt.YFData.pull("BTC-USD", start="12 months ago")
>>> hurst = vbt.HURST.run(data.close, method=["standard", "logrs", "rs", "dma", "dsod"])
>>> fig = vbt.make_subplots(specs=[[dict(secondary_y=True)]])
>>> data.plot(plot_volume=False, ohlc_trace_kwargs=dict(opacity=0.3), fig=fig)
>>> fig = hurst.hurst.vbt.plot(fig=fig, add_trace_kwargs=dict(secondary_y=True))
>>> fig = fig.select_range(start=hurst.param_defaults["window"])
>>> fig.show()
```

Rolling Hurst exponent by method over BTC-USD market data. [Figure data (JSON)](/assets/figures/features/indicators/hurst.78d7278fc132.json)

## Smart Money Concepts \[#smart-money-concepts]

New in v2024.6.19

✅ VBT integrates most of the indicators from the
[Smart Money Concepts (SMC)](https://github.com/joshyattridge/smart-money-concepts) library.

```python title="Plot previous high and low"
>>> data = vbt.YFData.pull("BTC-USD", start="6 months ago")
>>> phl = vbt.smc("previous_high_low").run(  # (1)
...     data.open,
...     data.high,
...     data.low,
...     data.close,
...     data.volume,
...     time_frame=vbt.Default("7D")
... )
>>> fig = data.plot()
>>> phl.previous_high.rename("previous_high").vbt.plot(fig=fig)
>>> phl.previous_low.rename("previous_low").vbt.plot(fig=fig)
>>> (phl.broken_high == 1).rename("broken_high").vbt.signals.plot_as_markers(
...     y=phl.previous_high,
...     trace_kwargs=dict(marker=dict(color="limegreen")),
...     fig=fig
... )
>>> (phl.broken_low == 1).rename("broken_low").vbt.signals.plot_as_markers(
...     y=phl.previous_low,
...     trace_kwargs=dict(marker=dict(color="orangered")),
...     fig=fig
... )
>>> fig.show()
```

1.  Each SMC indicator requires OHLCV.

BTC-USD OHLCV with previous weekly highs and lows and broken-level markers. [Figure data (JSON)](/assets/figures/features/indicators/smart-money-concepts.2c91e487d04e.json)

## Lightweight TA-Lib \[#lightweight-ta-lib]

New in 1.14.0

✅ TA-Lib functions wrapped with the indicator factory are very powerful because, unlike the official
TA-Lib implementation, they can broadcast, handle DataFrames, skip missing values, and even resample to a
different timeframe. Although TA-Lib functions are very fast, wrapping them with the indicator factory
adds some overhead. To keep both the speed of TA-Lib and the power of VBT, the added features have
been separated into a lightweight function that you can call just like a regular TA-Lib function.

```python title="Run and plot an RSI resampled to the monthly timeframe"
>>> data = vbt.YFData.pull("BTC-USD")
>>> run_rsi = vbt.talib_func("rsi")
>>> rsi = run_rsi(data.close, timeperiod=12, timeframe="M")  # (1)
>>> rsi
Date
2014-09-17 00:00:00+00:00          NaN
2014-09-18 00:00:00+00:00          NaN
2014-09-19 00:00:00+00:00          NaN
2014-09-20 00:00:00+00:00          NaN
2014-09-21 00:00:00+00:00          NaN
                                   ...
2024-01-18 00:00:00+00:00    64.210811
2024-01-19 00:00:00+00:00    64.210811
2024-01-20 00:00:00+00:00    64.210811
2024-01-21 00:00:00+00:00    64.210811
2024-01-22 00:00:00+00:00    64.210811
Freq: D, Name: Close, Length: 3415, dtype: float64

>>> plot_rsi = vbt.talib_plot_func("rsi")
>>> plot_rsi(rsi).show()
```

1.  Parameters are applied to the target timeframe.

BTC-USD RSI resampled to the monthly timeframe. [Figure data (JSON)](/assets/figures/features/indicators/native-ta-lib.d96222a6f261.json)

## Technical indicators \[#technical-indicators]

New in 1.7.0

✅ VBT integrates most of the indicators and consensus classes from freqtrade's
[technical](https://github.com/freqtrade/technical) library.

```python title="Compute and plot the summary consensus with a one-liner"
>>> vbt.YFData.pull("BTC-USD").run("sumcon", smooth=100).plot().show()
```

Smoothed technical indicator buy and sell summary consensus for BTC-USD. [Figure data (JSON)](/assets/figures/features/indicators/summary-consensus.0a262862e34f.json)

## Renko chart \[#renko-chart]

New in 1.7.0

✅ Unlike regular charts, a [Renko chart](https://www.investopedia.com/terms/r/renkochart.asp)
is built using price movements. Each "brick" appears when the price changes by a specified amount.
Because the output has irregular time intervals, only one column can be processed at once. As with
everything, VBT's implementation can translate a huge number of data points very fast thanks to Numba.

```python title="Resample closing price into a Renko format"
>>> data = vbt.YFData.pull("BTC-USD", start="2021", end="2022")
>>> renko_ohlc = data.close.vbt.to_renko_ohlc(1000, reset_index=True)  # (1)
>>> renko_ohlc.vbt.ohlcv.plot().show()
```

1.  Bitcoin is very volatile, so the brick size is set to 1000.

BTC-USD closing price resampled into a Renko OHLC chart. [Figure data (JSON)](/assets/figures/features/indicators/renko-chart.4982a9891b2d.json)

## Rolling OLS \[#rolling-ols]

New in 1.3.0

✅ Rolling regressions are models for analyzing changing relationships among variables over time.
In VBT, this is implemented as an indicator that takes two time series and returns the slope, intercept,
prediction, error, and the z-score of the error at each time step. This indicator can be used for
cointegration tests, such as determining optimal rebalancing timings in pairs trading, and is also
(literally) 1000x faster than the statsmodels equivalent
[RollingOLS](https://www.statsmodels.org/dev/generated/statsmodels.regression.rolling.RollingOLS.html) 🔥

```python title="Determine the spread between BTC and ETH"
>>> data = vbt.YFData.pull(
...     ["BTC-USD", "ETH-USD"],
...     start="2022",
...     end="2023",
...     missing_index="drop"
... )
>>> ols = vbt.OLS.run(
...     data.get("Close", "BTC-USD"),
...     data.get("Close", "ETH-USD")
... )
>>> ols.plot_zscore().show()
```

Rolling OLS spread z-score between BTC and ETH during 2022. [Figure data (JSON)](/assets/figures/features/indicators/rolling-ols.4b021c8f0823.json)

## TA-Lib time frames \[#ta-lib-time-frames]

New in 1.2.0

✅ Comparing indicators on different time frames involves many nuances. Now, all TA-Lib indicators
support a parameter that resamples the input arrays to a target time frame, calculates the indicator, and
then resamples the output arrays back to the original time frame. This makes parameterized MTF analysis
easier than ever!

```python title="Run SMA on multiple time frames and display the whole thing as a heatmap"
>>> h1_data = vbt.BinanceData.pull(
...     "BTCUSDT",
...     start="3 months ago UTC",
...     timeframe="1h"
... )
>>> mtf_sma = vbt.talib("SMA").run(
...     h1_data.close,
...     timeperiod=14,
...     timeframe=["1d", "4h", "1h"],
...     skipna=True
... )
>>> mtf_sma.real.vbt.ts_heatmap().show()
```

BTCUSDT simple moving averages across hourly, four-hour, and daily timeframes. [Figure data (JSON)](/assets/figures/features/indicators/ta-lib-time-frames.a70363fe5509.json)

!!! info "Tutorial"
    Learn more in the [MTF analysis](/tutorials/mtf-analysis) tutorial.

## TA-Lib plotting \[#ta-lib-plotting]

New in 1.0.9

✅ Every TA-Lib indicator is fully capable of plotting itself, based entirely on output flags!

```python
>>> data = vbt.YFData.pull("BTC-USD", start="2020", end="2021")

>>> vbt.talib("MACD").run(data.close).plot().show()
```

TA-Lib MACD, signal, and histogram for BTC-USD during 2020. [Figure data (JSON)](/assets/figures/features/indicators/ta-lib.ce381192f226.json)

## WorldQuant Alphas \[#worldquant-alphas]

New in 1.0.8

✅ Each of [WorldQuant's 101 Formulaic Alphas](https://arxiv.org/pdf/1601.00991.pdf) is now available
as an indicator 👀

```python title="Run the first alpha"
>>> data = vbt.YFData.pull(["BTC-USD", "ETH-USD", "XRP-USD"], missing_index="drop")

>>> vbt.wqa101(1).run(data.close).out
symbol                      BTC-USD   ETH-USD   XRP-USD
Date
2017-11-09 00:00:00+00:00  0.166667  0.166667  0.166667
2017-11-10 00:00:00+00:00  0.166667  0.166667  0.166667
2017-11-11 00:00:00+00:00  0.166667  0.166667  0.166667
2017-11-12 00:00:00+00:00  0.166667  0.166667  0.166667
2017-11-13 00:00:00+00:00  0.166667  0.166667  0.166667
...                             ...       ...       ...
2023-01-31 00:00:00+00:00  0.166667  0.166667  0.166667
2023-02-01 00:00:00+00:00  0.000000  0.000000  0.500000
2023-02-02 00:00:00+00:00  0.000000  0.000000  0.500000
2023-02-03 00:00:00+00:00  0.000000  0.500000  0.000000
2023-02-04 00:00:00+00:00 -0.166667  0.333333  0.333333

[1914 rows x 3 columns]
```
