Technical Indicators
Importing relevant libraries and initialising the environment.
1
import sigtech.framework as sig
2
import sigtech.framework.signal.library.technical_indicators as tech_ind
3
4
sig.init()
Copied!
Getting the settlement history for a security
1
future = sig.obj.get("BTCZ21 CURNCY")
2
3
# Get settlement history
4
future.history()
Copied!

This indicator measures the strength of a trend, not the direction.
Note: close, high and low arguments can be replaced by passing df=prices_df where prices_df contains (case-insensitive) columns of 'Open', 'High' and 'Low'.
Python
Output
1
2
high = future.history(field="HighPrice"),
3
low = future.history(field="LowPrice"),
4
close = future.history(field="LastPrice"),
5
window = 50,
6
ewma = True
7
)
8
9
Copied! ## Average True Range

Average True Range is used to find the average true range for the supplied prices (degree of price volatility). ATR is the EWMA of the true range = max(high_t, close_{t-1}) - min(low_t, close_{t-1}).
Note: close, high and low arguments can be replaced by passing df=prices_df where prices_df contains (case-insensitive) columns of 'Open', 'High' and 'Low'.
Python
Output
1
atr = tech_ind.average_true_range(
2
high = future.history(field="HighPrice"),
3
low = future.history(field="LowPrice"),
4
close = future.history(field="LastPrice"),
5
window = 50
6
)
7
8
atr.plot()
Copied! ## Bollinger Bands

They represent the percentage position of the close price inside the Bollinger band.
Python
Output
1
boll = tech_ind.boll(
2
high = future.history(field="HighPrice"),
3
low = future.history(field="LowPrice"),
4
close = future.history(field="LastPrice"),
5
window = 50
6
)
7
8
boll.plot()
Copied! ## KDJ Indicator

The stochastic indicator KDJ is a statistical system used for the analysis of securities. It accepts the closing price, highest price and lowest price of the calculation interval selected. It calculates the immature random value RSV of the last calculation cycle using the relationship between the inputs, and then calculate the K value, D value and J value according to the smooth moving average method.
Python
Output
1
kdj = tech_ind.kdj(
2
high = future.history(field="HighPrice"),
3
low = future.history(field="LowPrice"),
4
close = future.history(field="LastPrice"),
5
window = 300,
6
k_smooth = 1,
7
d_smooth = 1,
8
j_smooth = 1
9
)
10
11
kdj.plot()
Copied! ## MACD

Moving average convergence divergence (MACD) is a trend-following momentum indicator that shows the relationship between two moving averages of a security’s price. The MACD is calculated by subtracting the 26-period exponential moving average (EMA) from the 12-period EMA.
Python
Output
1
macd = tech_ind.macd(
2
close = future.history(field="LastPrice"),
3
short_window = 12,
4
long_window = 26
5
)
6
7
macd["MACD"].plot()
Copied! ## WR

WR Indicator.
Williams %R indicator is a momentum indicator of values between 0 and negative 100. Readings closer to -100 are considered oversold, those closer to 0 and considered overbought.
Python
Output
1
wr = tech_ind.wr(
2
high = future.history(field="HighPrice"),
3
low = future.history(field="LowPrice"),
4
close = future.history(field="LastPrice"),
5
window = 50,
6
ewma = False
7
)
8
9
wr.plot()
Copied! 