# Overlap Studies Overlap studies are technical indicators that overlay directly on the price chart, providing trend-following and support/resistance level information. --- ## SMA - Simple Moving Average The Simple Moving Average calculates the arithmetic mean of prices over a specified period, providing a smoothed representation of price trends. ### Formula $$SMA = \frac{\sum_{i=0}^{n-1} price_i}{n}$$ where $n$ is the period. ### Parameters | Parameter | Type | Default | Range | Description | |-----------|------|---------|-------|-------------| | period | int | 20 | 1-100000 | Number of periods for averaging | ### Characteristics | Property | Value | |----------|-------| | Input | Close price | | Output | Single value (SMA) | | Lookback | period - 1 | | Memory | O(period) | ### API Usage ::::{tab-set} :::{tab-item} Python ```python from techkit import SMA # Object-oriented API sma = SMA(period=20) result = sma.update(close_price) if result.valid: print(f"SMA: {result.value:.2f}") # TA-Lib compatible API from techkit import talib_compat as ta sma_values = ta.SMA(close_prices, timeperiod=20) ``` ::: :::{tab-item} Node.js ```javascript const tk = require('techkit'); // Streaming API const sma = tk.sma(20); const result = sma.update(closePrice); // Batch API const values = tk.SMA(closePrices, 20); ``` ::: :::{tab-item} C++ ```cpp #include techkit::SMA sma(20); auto result = sma.update(closePrice); ``` ::: :::{tab-item} C ```c #include tk_indicator sma = tk_sma_new(20); tk_result r = tk_update(sma, closePrice); tk_free(sma); ``` ::: :::: ### Trading Usage - **Trend Identification**: Price above SMA = uptrend, below = downtrend - **Support/Resistance**: SMA acts as dynamic support/resistance level - **Crossover Signals**: Price crossing SMA indicates potential trend change - **Multiple Timeframes**: Use different periods (50, 200) for multi-timeframe analysis ### Common Period Values | Period | Use Case | |--------|----------| | 5-10 | Short-term trend, scalping | | 20 | Standard short-term trend | | 50 | Medium-term trend | | 200 | Long-term trend, major support/resistance | --- ## EMA - Exponential Moving Average The Exponential Moving Average gives more weight to recent prices, making it more responsive to price changes than SMA. ### Formula $$EMA_t = \alpha \times price_t + (1 - \alpha) \times EMA_{t-1}$$ where $\alpha = \frac{2}{period + 1}$ (smoothing factor). The first EMA value is initialized with the SMA of the first `period` values. ### Parameters | Parameter | Type | Default | Range | Description | |-----------|------|---------|-------|-------------| | period | int | 20 | 1-100000 | Number of periods for smoothing | ### Characteristics | Property | Value | |----------|-------| | Input | Close price | | Output | Single value (EMA) | | Lookback | period - 1 | | Memory | O(1) | ### API Usage ::::{tab-set} :::{tab-item} Python ```python from techkit import EMA ema = EMA(period=20) result = ema.update(close_price) if result.valid: print(f"EMA: {result.value:.2f}") # TA-Lib compatible from techkit import talib_compat as ta ema_values = ta.EMA(close_prices, timeperiod=20) ``` ::: :::{tab-item} Node.js ```javascript const ema = tk.ema(20); const result = ema.update(closePrice); ``` ::: :::{tab-item} C++ ```cpp techkit::EMA ema(20); auto result = ema.update(closePrice); ``` ::: :::{tab-item} C ```c tk_indicator ema = tk_ema_new(20); tk_result r = tk_update(ema, closePrice); ``` ::: :::: ### Trading Usage - **Faster Response**: EMA reacts quicker to price changes than SMA - **Trend Following**: Use EMA crossovers for entry/exit signals - **Golden Cross/Death Cross**: EMA(50) crossing EMA(200) signals major trend change - **Support/Resistance**: EMA provides dynamic support/resistance levels ### Common Period Values | Period | Use Case | |--------|----------| | 9-12 | Short-term momentum | | 21-26 | Medium-term trend | | 50 | Long-term trend | | 200 | Major trend filter | --- ## WMA - Weighted Moving Average The Weighted Moving Average assigns linearly increasing weights to more recent prices, providing a compromise between SMA and EMA responsiveness. ### Formula $$WMA = \frac{\sum_{i=0}^{n-1} (n-i) \times price_i}{\frac{n(n+1)}{2}}$$ where the most recent price has weight $n$, second most recent has weight $n-1$, and so on. ### Parameters | Parameter | Type | Default | Range | Description | |-----------|------|---------|-------|-------------| | period | int | 20 | 1-100000 | Number of periods for averaging | ### Characteristics | Property | Value | |----------|-------| | Input | Close price | | Output | Single value (WMA) | | Lookback | period - 1 | | Memory | O(period) | ### API Usage ::::{tab-set} :::{tab-item} Python ```python from techkit import WMA wma = WMA(period=20) result = wma.update(close_price) if result.valid: print(f"WMA: {result.value:.2f}") # TA-Lib compatible from techkit import talib_compat as ta wma_values = ta.WMA(close_prices, timeperiod=20) ``` ::: :::{tab-item} Node.js ```javascript const wma = tk.wma(20); const result = wma.update(closePrice); ``` ::: :::{tab-item} C++ ```cpp techkit::WMA wma(20); auto result = wma.update(closePrice); ``` ::: :::{tab-item} C ```c tk_indicator wma = tk_wma_new(20); tk_result r = tk_update(wma, closePrice); ``` ::: :::: ### Trading Usage - **Balanced Smoothing**: Less lag than SMA, more stable than EMA - **Trend Confirmation**: Use with other indicators for trend confirmation - **Support/Resistance**: WMA levels can act as support/resistance ### Common Period Values | Period | Use Case | |--------|----------| | 10-20 | Short-term trend | | 30-50 | Medium-term trend | --- ## DEMA - Double Exponential Moving Average The Double Exponential Moving Average reduces lag by applying EMA twice and subtracting the second EMA from twice the first EMA. ### Formula $$DEMA = 2 \times EMA(price) - EMA(EMA(price))$$ This formula reduces lag while maintaining trend-following characteristics. ### Parameters | Parameter | Type | Default | Range | Description | |-----------|------|---------|-------|-------------| | period | int | 20 | 1-100000 | EMA period for both calculations | ### Characteristics | Property | Value | |----------|-------| | Input | Close price | | Output | Single value (DEMA) | | Lookback | period - 1 | | Memory | O(1) | ### API Usage ::::{tab-set} :::{tab-item} Python ```python from techkit import DEMA dema = DEMA(period=20) result = dema.update(close_price) if result.valid: print(f"DEMA: {result.value:.2f}") # TA-Lib compatible from techkit import talib_compat as ta dema_values = ta.DEMA(close_prices, timeperiod=20) ``` ::: :::{tab-item} Node.js ```javascript const dema = tk.dema(20); const result = dema.update(closePrice); ``` ::: :::{tab-item} C++ ```cpp techkit::DEMA dema(20); auto result = dema.update(closePrice); ``` ::: :::{tab-item} C ```c tk_indicator dema = tk_dema_new(20); tk_result r = tk_update(dema, closePrice); ``` ::: :::: ### Trading Usage - **Reduced Lag**: DEMA responds faster than EMA to price changes - **Trend Following**: Excellent for capturing trend changes early - **Crossover Signals**: DEMA crossovers provide timely entry/exit signals ### Common Period Values | Period | Use Case | |--------|----------| | 10-15 | Short-term momentum | | 20-30 | Medium-term trend | --- ## TEMA - Triple Exponential Moving Average The Triple Exponential Moving Average applies triple smoothing to further reduce lag while maintaining trend-following properties. ### Formula $$TEMA = 3 \times EMA_1 - 3 \times EMA_2 + EMA_3$$ where: - $EMA_1 = EMA(price, period)$ - $EMA_2 = EMA(EMA_1, period)$ - $EMA_3 = EMA(EMA_2, period)$ ### Parameters | Parameter | Type | Default | Range | Description | |-----------|------|---------|-------|-------------| | period | int | 20 | 1-100000 | EMA period for all calculations | ### Characteristics | Property | Value | |----------|-------| | Input | Close price | | Output | Single value (TEMA) | | Lookback | period - 1 | | Memory | O(1) | ### API Usage ::::{tab-set} :::{tab-item} Python ```python from techkit import TEMA tema = TEMA(period=20) result = tema.update(close_price) if result.valid: print(f"TEMA: {result.value:.2f}") # TA-Lib compatible from techkit import talib_compat as ta tema_values = ta.TEMA(close_prices, timeperiod=20) ``` ::: :::{tab-item} Node.js ```javascript const tema = tk.tema(20); const result = tema.update(closePrice); ``` ::: :::{tab-item} C++ ```cpp techkit::TEMA tema(20); auto result = tema.update(closePrice); ``` ::: :::{tab-item} C ```c tk_indicator tema = tk_tema_new(20); tk_result r = tk_update(tema, closePrice); ``` ::: :::: ### Trading Usage - **Minimal Lag**: TEMA has the least lag among exponential moving averages - **Trend Following**: Excellent for fast-moving markets - **Sensitive**: More prone to whipsaws in choppy markets ### Common Period Values | Period | Use Case | |--------|----------| | 5-10 | Very short-term momentum | | 15-20 | Short-term trend | --- ## KAMA - Kaufman Adaptive Moving Average The Kaufman Adaptive Moving Average adapts its smoothing factor based on market efficiency, becoming more responsive in trending markets and less responsive in choppy markets. ### Formula $$KAMA_t = KAMA_{t-1} + SC \times (price_t - KAMA_{t-1})$$ where: - $ER = \frac{|price_t - price_{t-period}|}{\sum_{i=1}^{period} |price_i - price_{i-1}|}$ (Efficiency Ratio) - $SC = \left[ER \times (fast - slow) + slow\right]^2$ - $fast = \frac{2}{2+1} = 0.6667$ (fast smoothing constant) - $slow = \frac{2}{30+1} = 0.0645$ (slow smoothing constant) ### Parameters | Parameter | Type | Default | Range | Description | |-----------|------|---------|-------|-------------| | period | int | 10 | 1-100000 | Period for efficiency ratio calculation | ### Characteristics | Property | Value | |----------|-------| | Input | Close price | | Output | Single value (KAMA) | | Lookback | period - 1 | | Memory | O(period) | ### API Usage ::::{tab-set} :::{tab-item} Python ```python from techkit import KAMA kama = KAMA(period=10) result = kama.update(close_price) if result.valid: print(f"KAMA: {result.value:.2f}") # TA-Lib compatible from techkit import talib_compat as ta kama_values = ta.KAMA(close_prices, timeperiod=10) ``` ::: :::{tab-item} Node.js ```javascript const kama = tk.kama(10); const result = kama.update(closePrice); ``` ::: :::{tab-item} C++ ```cpp techkit::KAMA kama(10); auto result = kama.update(closePrice); ``` ::: :::{tab-item} C ```c tk_indicator kama = tk_kama_new(10); tk_result r = tk_update(kama, closePrice); ``` ::: :::: ### Trading Usage - **Adaptive Smoothing**: Automatically adjusts to market conditions - **Trend Following**: More responsive in trending markets - **Noise Reduction**: Less responsive in choppy markets, reducing false signals - **Support/Resistance**: KAMA levels act as dynamic support/resistance ### Common Period Values | Period | Use Case | |--------|----------| | 10 | Standard adaptive smoothing | | 20-30 | Longer-term adaptive trend | --- ## TRIMA - Triangular Moving Average The Triangular Moving Average applies SMA twice, creating a smoother average with a triangular weighting function. ### Formula $$TRIMA = SMA(SMA(price, \lceil n/2 \rceil), \lfloor n/2 \rfloor + 1)$$ For even periods: $TRIMA = SMA(SMA(price, n/2+1), n/2)$ For odd periods: $TRIMA = SMA(SMA(price, (n+1)/2), (n+1)/2)$ ### Parameters | Parameter | Type | Default | Range | Description | |-----------|------|---------|-------|-------------| | period | int | 20 | 1-100000 | Total period for triangular smoothing | ### Characteristics | Property | Value | |----------|-------| | Input | Close price | | Output | Single value (TRIMA) | | Lookback | period - 1 | | Memory | O(period) | ### API Usage ::::{tab-set} :::{tab-item} Python ```python from techkit import TRIMA trima = TRIMA(period=20) result = trima.update(close_price) if result.valid: print(f"TRIMA: {result.value:.2f}") # TA-Lib compatible from techkit import talib_compat as ta trima_values = ta.TRIMA(close_prices, timeperiod=20) ``` ::: :::{tab-item} Node.js ```javascript const trima = tk.trima(20); const result = trima.update(closePrice); ``` ::: :::{tab-item} C++ ```cpp techkit::TRIMA trima(20); auto result = trima.update(closePrice); ``` ::: :::{tab-item} C ```c tk_indicator trima = tk_trima_new(20); tk_result r = tk_update(trima, closePrice); ``` ::: :::: ### Trading Usage - **Smooth Trend**: TRIMA provides very smooth trend lines - **Lag**: More lag than SMA but smoother output - **Support/Resistance**: Strong support/resistance levels ### Common Period Values | Period | Use Case | |--------|----------| | 20-30 | Medium-term smooth trend | | 50 | Long-term smooth trend | --- ## T3 - Triple Exponential Moving Average (Tilson) The T3 moving average uses a generalized DEMA (GD) approach applied three times, providing smooth output with reduced lag. ### Formula T3 uses six EMAs with coefficients: - $c_1 = -v^3$ - $c_2 = 3v^2 + 3v^3$ - $c_3 = -6v^2 - 3v - 3v^3$ - $c_4 = 1 + 3v + v^3 + 3v^2$ where $v$ is the volume factor (default 0.7). $$T3 = c_1 \times EMA_6 + c_2 \times EMA_5 + c_3 \times EMA_4 + c_4 \times EMA_3$$ ### Parameters | Parameter | Type | Default | Range | Description | |-----------|------|---------|-------|-------------| | period | int | 20 | 1-100000 | EMA period for T3 calculation | | volume_factor | double | 0.7 | 0.0-1.0 | Smoothing factor (v-factor) | ### Characteristics | Property | Value | |----------|-------| | Input | Close price | | Output | Single value (T3) | | Lookback | 6 × (period - 1) | | Memory | O(1) | ### API Usage ::::{tab-set} :::{tab-item} Python ```python from techkit import T3 t3 = T3(period=20, volume_factor=0.7) result = t3.update(close_price) if result.valid: print(f"T3: {result.value:.2f}") # TA-Lib compatible from techkit import talib_compat as ta t3_values = ta.T3(close_prices, timeperiod=20, vfactor=0.7) ``` ::: :::{tab-item} Node.js ```javascript const t3 = tk.t3(20, 0.7); const result = t3.update(closePrice); ``` ::: :::{tab-item} C++ ```cpp techkit::T3 t3(20, 0.7); auto result = t3.update(closePrice); ``` ::: :::{tab-item} C ```c tk_indicator t3 = tk_t3_new(20, 0.7); tk_result r = tk_update(t3, closePrice); ``` ::: :::: ### Trading Usage - **Smooth with Low Lag**: T3 provides smooth output with minimal lag - **Volume Factor**: Lower v-factor (0.5-0.6) = smoother, higher (0.8-0.9) = more responsive - **Trend Following**: Excellent for trend identification ### Common Parameter Values | Period | Volume Factor | Use Case | |--------|---------------|----------| | 10-15 | 0.7 | Short-term trend | | 20-30 | 0.7 | Medium-term trend | | 20 | 0.5 | Very smooth trend | | 20 | 0.9 | More responsive trend | --- ## BBANDS - Bollinger Bands Bollinger Bands consist of a middle band (SMA) and two outer bands based on standard deviation, providing dynamic support/resistance levels and volatility information. ### Formula $$Middle = SMA(close, period)$$ $$Upper = Middle + nbdev_{up} \times \sigma$$ $$Lower = Middle - nbdev_{down} \times \sigma$$ where $\sigma$ is the standard deviation of prices over the period. ### Parameters | Parameter | Type | Default | Range | Description | |-----------|------|---------|-------|-------------| | period | int | 20 | 1-100000 | SMA period for middle band | | nbdev_up | double | 2.0 | 0.1-10.0 | Standard deviation multiplier for upper band | | nbdev_down | double | 2.0 | 0.1-10.0 | Standard deviation multiplier for lower band | | matype | int | 0 | 0-8 | Moving average type (0=SMA, 1=EMA, etc.) | ### Characteristics | Property | Value | |----------|-------| | Input | Close price | | Output | Three values (upper, middle, lower) | | Lookback | period - 1 | | Memory | O(period) | ### API Usage ::::{tab-set} :::{tab-item} Python ```python from techkit import BBANDS bbands = BBANDS(period=20, std_dev_up=2.0, std_dev_down=2.0) result = bbands.update(close_price) if result.valid: print(f"Upper: {result.upper:.2f}, Middle: {result.middle:.2f}, Lower: {result.lower:.2f}") # TA-Lib compatible from techkit import talib_compat as ta upper, middle, lower = ta.BBANDS(close_prices, timeperiod=20, nbdevup=2.0, nbdevdn=2.0) ``` ::: :::{tab-item} Node.js ```javascript const bbands = tk.bbands(20, 2.0, 2.0); const result = bbands.update(closePrice); // result.upper, result.middle, result.lower ``` ::: :::{tab-item} C++ ```cpp techkit::BBANDS bbands(20, 2.0, 2.0); auto result = bbands.update(closePrice); ``` ::: :::{tab-item} C ```c tk_indicator bbands = tk_bbands_new(20, 2.0, 2.0); tk_bbands_result r = tk_bbands_update(bbands, closePrice); // r.upper, r.middle, r.lower ``` ::: :::: ### Trading Usage - **Volatility Indicator**: Band width indicates volatility (wider = more volatile) - **Overbought/Oversold**: Price touching upper band = overbought, lower = oversold - **Squeeze**: Narrow bands indicate low volatility, often precedes big moves - **Support/Resistance**: Bands act as dynamic support/resistance levels - **Mean Reversion**: Price tends to revert to middle band ### Common Parameter Values | Period | nbdev | Use Case | |--------|-------|----------| | 20 | 2.0 | Standard Bollinger Bands | | 20 | 1.5 | Tighter bands, more signals | | 20 | 2.5 | Wider bands, fewer signals | | 10 | 2.0 | Short-term volatility | --- ## SAR - Parabolic Stop and Reverse The Parabolic SAR provides trailing stop levels and trend reversal signals, with the SAR point moving closer to price as the trend accelerates. ### Formula For uptrend: $$SAR_t = SAR_{t-1} + AF \times (EP - SAR_{t-1})$$ where: - $EP$ = Extreme Point (highest high in uptrend) - $AF$ = Acceleration Factor (starts at `acceleration`, increases by `acceleration` when new EP is reached, capped at `maximum`) For downtrend, the formula is inverted (uses lowest low as EP). ### Parameters | Parameter | Type | Default | Range | Description | |-----------|------|---------|-------|-------------| | acceleration | double | 0.02 | 0.001-0.1 | Initial acceleration factor | | maximum | double | 0.20 | 0.01-1.0 | Maximum acceleration factor | ### Characteristics | Property | Value | |----------|-------| | Input | OHLC (high, low) | | Output | Single value (SAR price level) | | Lookback | 1 | | Memory | O(1) | ### API Usage ::::{tab-set} :::{tab-item} Python ```python from techkit import SAR sar = SAR(acceleration=0.02, maximum=0.20) result = sar.update_ohlcv(open, high, low, close) if result.valid: print(f"SAR: {result.value:.2f}") # TA-Lib compatible from techkit import talib_compat as ta sar_values = ta.SAR(high, low, acceleration=0.02, maximum=0.20) ``` ::: :::{tab-item} Node.js ```javascript const sar = tk.sar(0.02, 0.20); const result = sar.updateOHLCV({open, high, low, close}); ``` ::: :::{tab-item} C++ ```cpp techkit::SAR sar(0.02, 0.20); techkit::OHLCV bar{open, high, low, close, volume}; auto result = sar.update(bar); ``` ::: :::{tab-item} C ```c tk_indicator sar = tk_sar_new(0.02, 0.20); tk_ohlcv bar = {open, high, low, close, volume}; tk_result r = tk_update_ohlcv(sar, &bar); ``` ::: :::: ### Trading Usage - **Trailing Stop**: SAR provides dynamic trailing stop levels - **Trend Following**: SAR below price = uptrend, above = downtrend - **Reversal Signal**: Price crossing SAR indicates trend reversal - **Stop Loss**: Use SAR as stop loss level - **Acceleration**: Higher acceleration = tighter stops, more reversals ### Common Parameter Values | Acceleration | Maximum | Use Case | |--------------|---------|----------| | 0.02 | 0.20 | Standard SAR (most common) | | 0.01 | 0.10 | Slower, wider stops | | 0.03 | 0.30 | Faster, tighter stops | --- ## MIDPOINT - MidPoint over Period The MidPoint indicator calculates the midpoint between the highest high and lowest low over a specified period. ### Formula $$MIDPOINT = \frac{highest + lowest}{2}$$ where `highest` and `lowest` are the maximum and minimum close prices over the period. ### Parameters | Parameter | Type | Default | Range | Description | |-----------|------|---------|-------|-------------| | period | int | 14 | 1-100000 | Number of periods for high/low calculation | ### Characteristics | Property | Value | |----------|-------| | Input | Close price | | Output | Single value (midpoint) | | Lookback | period - 1 | | Memory | O(period) | ### API Usage ::::{tab-set} :::{tab-item} Python ```python from techkit import MIDPOINT midpoint = MIDPOINT(period=14) result = midpoint.update(close_price) if result.valid: print(f"MidPoint: {result.value:.2f}") # TA-Lib compatible from techkit import talib_compat as ta midpoint_values = ta.MIDPOINT(close_prices, timeperiod=14) ``` ::: :::{tab-item} Node.js ```javascript const midpoint = tk.midpoint(14); const result = midpoint.update(closePrice); ``` ::: :::{tab-item} C++ ```cpp techkit::MIDPOINT midpoint(14); auto result = midpoint.update(closePrice); ``` ::: :::{tab-item} C ```c tk_indicator midpoint = tk_midpoint_new(14); tk_result r = tk_update(midpoint, closePrice); ``` ::: :::: ### Trading Usage - **Support/Resistance**: MidPoint acts as a support/resistance level - **Range Trading**: Useful in ranging markets - **Price Position**: Compare current price to MidPoint to gauge position in range ### Common Period Values | Period | Use Case | |--------|----------| | 14 | Standard midpoint | | 20-30 | Longer-term midpoint | --- ## MIDPRICE - Midpoint Price over Period The MidPrice indicator calculates the midpoint between the highest high and lowest low (using high and low prices, not close). ### Formula $$MIDPRICE = \frac{highest\_high + lowest\_low}{2}$$ where `highest_high` and `lowest_low` are the maximum high and minimum low prices over the period. ### Parameters | Parameter | Type | Default | Range | Description | |-----------|------|---------|-------|-------------| | period | int | 14 | 1-100000 | Number of periods for high/low calculation | ### Characteristics | Property | Value | |----------|-------| | Input | OHLC (high, low) | | Output | Single value (midprice) | | Lookback | period - 1 | | Memory | O(period) | ### API Usage ::::{tab-set} :::{tab-item} Python ```python from techkit import MIDPRICE midprice = MIDPRICE(period=14) result = midprice.update_ohlcv(open, high, low, close) if result.valid: print(f"MidPrice: {result.value:.2f}") # TA-Lib compatible from techkit import talib_compat as ta midprice_values = ta.MIDPRICE(high, low, timeperiod=14) ``` ::: :::{tab-item} Node.js ```javascript const midprice = tk.midprice(14); const result = midprice.updateOHLCV({open, high, low, close}); ``` ::: :::{tab-item} C++ ```cpp techkit::MIDPRICE midprice(14); techkit::OHLCV bar{open, high, low, close, volume}; auto result = midprice.update(bar); ``` ::: :::{tab-item} C ```c tk_indicator midprice = tk_midprice_new(14); tk_ohlcv bar = {open, high, low, close, volume}; tk_result r = tk_update_ohlcv(midprice, &bar); ``` ::: :::: ### Trading Usage - **True Range Midpoint**: Uses actual high/low range, more accurate than MidPoint - **Support/Resistance**: MidPrice provides support/resistance levels - **Range Analysis**: Compare current price to MidPrice for range position ### Common Period Values | Period | Use Case | |--------|----------| | 14 | Standard midprice | | 20-30 | Longer-term midprice | --- ## MA - Moving Average (Generic) The MA function is a generic wrapper that supports multiple moving average types, allowing easy switching between different MA algorithms. ### Parameters | Parameter | Type | Default | Range | Description | |-----------|------|---------|-------|-------------| | period | int | 20 | 1-100000 | Number of periods | | matype | int | 0 | 0-8 | Moving average type (see table below) | ### MA Type Values | Value | Type | Description | |-------|------|-------------| | 0 | SMA | Simple Moving Average | | 1 | EMA | Exponential Moving Average | | 2 | WMA | Weighted Moving Average | | 3 | DEMA | Double Exponential Moving Average | | 4 | TEMA | Triple Exponential Moving Average | | 5 | TRIMA | Triangular Moving Average | | 6 | KAMA | Kaufman Adaptive Moving Average | | 7 | MAMA | MESA Adaptive Moving Average | | 8 | T3 | Triple Exponential Moving Average (T3) | ### Characteristics | Property | Value | |----------|-------| | Input | Close price | | Output | Single value (MA) | | Lookback | Depends on matype (typically period - 1) | | Memory | Depends on matype | ### API Usage ::::{tab-set} :::{tab-item} Python ```python from techkit import MA # Use SMA (matype=0) ma = MA(period=20, matype=0) result = ma.update(close_price) # Use EMA (matype=1) ma = MA(period=20, matype=1) result = ma.update(close_price) # TA-Lib compatible from techkit import talib_compat as ta ma_values = ta.MA(close_prices, timeperiod=20, matype=0) # SMA ``` ::: :::{tab-item} Node.js ```javascript const ma = tk.ma(20, 0); // period=20, matype=0 (SMA) const result = ma.update(closePrice); ``` ::: :::{tab-item} C++ ```cpp techkit::MA ma(20, techkit::MA_SMA); auto result = ma.update(closePrice); ``` ::: :::{tab-item} C ```c tk_indicator ma = tk_ma_new(20, TK_MA_SMA); tk_result r = tk_update(ma, closePrice); ``` ::: :::: ### Trading Usage - **Flexible MA Selection**: Switch between MA types without changing code - **Strategy Testing**: Test different MA types for optimal performance - **Compatibility**: Matches TA-Lib's MA function interface --- ## MAVP - Moving Average with Variable Period The MAVP indicator calculates moving averages with a variable period that changes for each bar, allowing adaptive smoothing based on market conditions. ### Parameters | Parameter | Type | Default | Range | Description | |-----------|------|---------|-------|-------------| | min_period | int | 2 | 1-100000 | Minimum period allowed | | max_period | int | 30 | 1-100000 | Maximum period allowed | | matype | int | 0 | 0-8 | Moving average type (see MA section) | ### Characteristics | Property | Value | |----------|-------| | Input | Close price + period value (per bar) | | Output | Single value (MA with variable period) | | Lookback | max_period - 1 | | Memory | O(max_period) | ### API Usage ::::{tab-set} :::{tab-item} Python ```python from techkit import MAVP mavp = MAVP(min_period=2, max_period=30, matype=0) # Each update requires both price and period result = mavp.update_with_period(close_price, period_value) # TA-Lib compatible from techkit import talib_compat as ta ma_values = ta.MAVP(close_prices, periods_array, minperiod=2, maxperiod=30, matype=0) ``` ::: :::{tab-item} Node.js ```javascript const mavp = tk.mavp(2, 30, 0); const result = mavp.updateWithPeriod(closePrice, periodValue); ``` ::: :::{tab-item} C++ ```cpp techkit::MAVP mavp(2, 30, techkit::MA_SMA); auto result = mavp.updateWithPeriod(closePrice, periodValue); ``` ::: :::{tab-item} C ```c tk_indicator mavp = tk_mavp_new(2, 30, TK_MA_SMA); tk_result r = tk_mavp_update(mavp, closePrice, periodValue); ``` ::: :::: ### Trading Usage - **Adaptive Smoothing**: Period adapts to market volatility - **Volatility-Based**: Use higher periods in volatile markets, lower in calm markets - **Custom Logic**: Implement your own period selection logic based on indicators ### Common Parameter Values | min_period | max_period | matype | Use Case | |------------|------------|--------|----------| | 2 | 30 | 0 (SMA) | Standard variable MA | | 5 | 50 | 1 (EMA) | Longer-term variable MA | --- ## MAMA - MESA Adaptive Moving Average The MESA Adaptive Moving Average uses Hilbert Transform to detect cycle periods and adapts the smoothing factor accordingly. ### Parameters | Parameter | Type | Default | Range | Description | |-----------|------|---------|-------|-------------| | fastlimit | double | 0.5 | 0.01-0.99 | Upper limit for fast smoothing | | slowlimit | double | 0.05 | 0.01-0.99 | Lower limit for slow smoothing | ### Characteristics | Property | Value | |----------|-------| | Input | Close price | | Output | Two values (mama, fama) | | Lookback | 32 (approximate) | | Memory | O(1) | ### API Usage ::::{tab-set} :::{tab-item} Python ```python from techkit import MAMA mama = MAMA(fastlimit=0.5, slowlimit=0.05) result = mama.update(close_price) if result.valid: print(f"MAMA: {result.mama:.2f}, FAMA: {result.fama:.2f}") # TA-Lib compatible from techkit import talib_compat as ta mama, fama = ta.MAMA(close_prices, fastlimit=0.5, slowlimit=0.05) ``` ::: :::{tab-item} Node.js ```javascript const mama = tk.mama(0.5, 0.05); const result = mama.update(closePrice); // result.mama, result.fama ``` ::: :::{tab-item} C++ ```cpp techkit::MAMA mama(0.5, 0.05); auto result = mama.update(closePrice); ``` ::: :::{tab-item} C ```c tk_indicator mama = tk_mama_new(0.5, 0.05); tk_mama_result r = tk_mama_update(mama, closePrice); // r.mama, r.fama ``` ::: :::: ### Trading Usage - **Cycle-Based Adaptation**: Adapts to market cycles automatically - **MAMA/FAMA Crossovers**: MAMA crossing FAMA provides entry/exit signals - **Trend Following**: Excellent for trend-following strategies - **Fast/Slow Limits**: Adjust limits to control adaptation speed ### Common Parameter Values | fastlimit | slowlimit | Use Case | |-----------|-----------|----------| | 0.5 | 0.05 | Standard MAMA (most common) | | 0.6 | 0.04 | Faster adaptation | | 0.4 | 0.06 | Slower adaptation | --- ## HT_TRENDLINE - Hilbert Transform Instantaneous Trendline The HT_TRENDLINE uses Hilbert Transform to create a smooth trendline that adapts to market cycles, providing a lag-free trend indicator. ### Parameters No parameters required. ### Characteristics | Property | Value | |----------|-------| | Input | Close price | | Output | Single value (trendline) | | Lookback | 32 (approximate) | | Memory | O(1) | ### API Usage ::::{tab-set} :::{tab-item} Python ```python from techkit import HT_TRENDLINE ht_trendline = HT_TRENDLINE() result = ht_trendline.update(close_price) if result.valid: print(f"HT Trendline: {result.value:.2f}") # TA-Lib compatible from techkit import talib_compat as ta trendline_values = ta.HT_TRENDLINE(close_prices) ``` ::: :::{tab-item} Node.js ```javascript const ht_trendline = tk.ht_trendline(); const result = ht_trendline.update(closePrice); ``` ::: :::{tab-item} C++ ```cpp techkit::HT_TRENDLINE ht_trendline; auto result = ht_trendline.update(closePrice); ``` ::: :::{tab-item} C ```c tk_indicator ht_trendline = tk_ht_trendline_new(); tk_result r = tk_update(ht_trendline, closePrice); ``` ::: :::: ### Trading Usage - **Lag-Free Trend**: HT_TRENDLINE has minimal lag compared to traditional MAs - **Cycle Adaptation**: Automatically adapts to market cycles - **Trend Identification**: Price above trendline = uptrend, below = downtrend - **Support/Resistance**: Trendline acts as dynamic support/resistance --- ## SAREXT - Parabolic SAR Extended The SAREXT (Parabolic SAR Extended) provides enhanced control over SAR behavior with separate acceleration factors for long and short positions, and additional parameters for fine-tuning. ### Parameters | Parameter | Type | Default | Range | Description | |-----------|------|---------|-------|-------------| | start_value | double | 0.0 | Any | Initial SAR value (0 = auto-detect) | | offset_on_reverse | double | 0.0 | Any | Offset added/subtracted on trend reversal | | accel_init_long | double | 0.02 | 0.001-0.1 | Initial AF for long positions | | accel_long | double | 0.02 | 0.001-0.1 | AF increment for long positions | | accel_max_long | double | 0.20 | 0.01-1.0 | Maximum AF for long positions | | accel_init_short | double | 0.02 | 0.001-0.1 | Initial AF for short positions | | accel_short | double | 0.02 | 0.001-0.1 | AF increment for short positions | | accel_max_short | double | 0.20 | 0.01-1.0 | Maximum AF for short positions | ### Characteristics | Property | Value | |----------|-------| | Input | OHLC (high, low) | | Output | Single value (SAR price level) | | Lookback | 1 | | Memory | O(1) | ### API Usage ::::{tab-set} :::{tab-item} Python ```python from techkit import SAREXT sarext = SAREXT( start_value=0.0, offset_on_reverse=0.0, accel_init_long=0.02, accel_long=0.02, accel_max_long=0.20, accel_init_short=0.02, accel_short=0.02, accel_max_short=0.20 ) result = sarext.update_ohlcv(open, high, low, close) if result.valid: print(f"SAREXT: {result.value:.2f}") # TA-Lib compatible from techkit import talib_compat as ta sar_values = ta.SAREXT( high, low, startvalue=0.0, offsetonreverse=0.0, accelerationinitlong=0.02, accelerationlong=0.02, accelerationmaxlong=0.20, accelerationinitshort=0.02, accelerationshort=0.02, accelerationmaxshort=0.20 ) ``` ::: :::{tab-item} Node.js ```javascript const sarext = tk.sarext(0.0, 0.0, 0.02, 0.02, 0.20, 0.02, 0.02, 0.20); const result = sarext.updateOHLCV({open, high, low, close}); ``` ::: :::{tab-item} C++ ```cpp techkit::SAREXT sarext(0.0, 0.0, 0.02, 0.02, 0.20, 0.02, 0.02, 0.20); techkit::OHLCV bar{open, high, low, close, volume}; auto result = sarext.update(bar); ``` ::: :::{tab-item} C ```c tk_indicator sarext = tk_sarext_new( 0.0, 0.0, 0.02, 0.02, 0.20, 0.02, 0.02, 0.20 ); tk_ohlcv bar = {open, high, low, close, volume}; tk_result r = tk_update_ohlcv(sarext, &bar); ``` ::: :::: ### Trading Usage - **Asymmetric Stops**: Different acceleration for long vs short positions - **Custom Initialization**: Set start_value for specific entry points - **Reversal Offset**: offset_on_reverse adjusts SAR on trend reversals - **Advanced Control**: Fine-tune SAR behavior for specific trading strategies ### Common Parameter Values | Use Case | Long AF | Short AF | Notes | |----------|---------|----------|-------| | Standard | 0.02/0.20 | 0.02/0.20 | Same as regular SAR | | Tighter Long Stops | 0.03/0.30 | 0.02/0.20 | Faster stops for long positions | | Tighter Short Stops | 0.02/0.20 | 0.03/0.30 | Faster stops for short positions | --- ## Related Indicators - **Price Transform**: AVGPRICE, MEDPRICE, TYPPRICE, WCLPRICE - **Statistics**: STDDEV, VAR for volatility-based bands - **Cycle Indicators**: HT_TRENDLINE uses Hilbert Transform for cycle detection