QTrade Indicators
A collection of technical analysis indicators for trading, written in Rust. Each indicator is gated behind a Cargo feature flag so you only compile what you need.
Provided Indicators
| Indicator | Feature | Description |
|---|---|---|
| Median Price | median_price |
(high + low) / 2 |
| True Range | tr |
Volatility measure: max(H-L, |H-pC|, |L-pC|) |
| Simple Moving Average | sma |
Arithmetic mean over a sliding window |
| Smoothed Moving Average | smma |
Modified moving average with smoother response |
| Exponential Moving Average | ema |
Exponentially weighted moving average |
| Running Moving Average | rma |
Wilder's smoothing (α = 1/N) |
| Weighted Moving Average | wma |
Linearly weighted moving average |
| Average True Range | atr |
ATR with 5 smoothing engines (SMA, SMMA, EMA, RMA, WMA) |
| MACD | macd |
Moving Average Convergence Divergence (histogram, signal, MACD line) |
| Supertrend | supertrend |
Trend-following indicator with upper/lower bands |
| Williams Fractals | wf |
Local price extreme points for support/resistance |
Feature Flags
This crate uses Cargo feature flags to enable indicators individually:
[]
= { = "0.1", = ["sma", "ema", "macd"] }
Some features automatically enable others:
atrenablestr,sma,smma,ema,rma,wmamacdenablesema
For development and testing, enable all features:
[]
= { = "0.1", = ["dev"] }
Usage
Add the crate to your Cargo.toml:
[]
= { = "0.1", = ["sma"] }
Simple Moving Average
use ;
let data = vec!;
let setting = SettingSma ;
let sma = calculate_sma.unwrap;
// sma = [0.0, 0.0, 2.0, 3.0, 4.0]
MACD
use ;
let data: = .map.collect;
let setting = SettingMacd ;
let macd = calculate_macd.unwrap;
Supertrend
use ;
let close = vec!;
let median = vec!;
let atr = vec!;
let setting = SettingSupertrend ;
let st = calculate_supertrend.unwrap;
println!; // Up
API Documentation
Full API documentation is available on docs.rs.
Minimum Supported Rust Version (MSRV)
Rust 1.85 or later (Rust 2024 edition).
License
Licensed under the Apache License, Version 2.0. See LICENSE for details.