- Simple API
- Built-in parameters validation
- Includes thorough documentation
- A wide variety of Oscillators, Overlays, Volatility, Trend and Volume indicators, Pivot Points and Candlestick Patterns.
go get github.com/jellydator/tango
All of the tools must be created using New* function. It performs
parameters validation and returns an object that is capable of working
with data slices.
The main calculations are done using Calc method. The return types varies
based on the tool.
A simple use case could look like this:
func main() {
sma, err := tango.NewSMA(3)
if err != nil {
// handle the error.
}
dataPoints := []decimal.Decimal{
decimal.NewFromInt(2),
decimal.NewFromInt(3),
decimal.NewFromInt(4),
}
// the value is 3
value, err := sma.Calc(dataPoints)
if err != nil {
// handle the error.
}
}For the calculation to be successful, the Calc method should receive only the
information that it requires. In some scenarios, it might not be known how many
data points is needed, for this, a Count method may be used.
func CalculateMA(ma tango.MA, values []decimal.Decimal) (decimal.Decimal, error) {
requiredValues := ma.Count()
if len(values) < requiredValues {
return decimal.Zero, errors.New("invalid count of values")
}
return ma.Calc(values[:requiredValues])
}Indicators that work with full candles instead of a single data points
slice accept a []Candle (or a single Candle) ordered from the
oldest to the newest.
- Aroon
- CCI (Commodity Channel Index)
- Fibonacci Levels; Based on Fibonacci Retracement, however trend calculation must be done separately.
- ROC (Rate of Change)
- RSI (Relative Strength Index)
- StochRSI (Stochastic Relative Strength Index)
- Stoch (Stochastic)
- WilliamsR (Williams %R)
- BB (Bollinger Bands)
- DEMA (Double Exponential Moving Average)
- EMA (Exponential Moving Average)
- HMA (Hull Moving Average)
- SMA (Simple Moving Average)
- VWAP (Volume-Weighted Average Price)
- WMA (Weighted Moving Average)
- ADX (Average Directional Index) along with both directional index values
- Ichimoku (Ichimoku Cloud)
- PSAR (Parabolic Stop and Reverse)
- SuperTrend
The PivotPoints indicator calculates the pivot point along with three
resistance and three support levels from the candle of the preceding
period. Supported calculation variants: classic,
fibonacci and camarilla.
The CandlestickPattern type evaluates whether a series of candles
matches a given pattern. Single candle patterns: hammer, hanging-man,
inverted-hammer, shooting-star, long-legged-doji, dragonfly-doji,
gravestone-doji, bullish-marubozu, bearish-marubozu and spinning-top.
Double candle patterns: bullish-engulfing, bearish-engulfing,
bullish-harami, bearish-harami, piercing-line, dark-cloud-cover,
tweezer-top and tweezer-bottom. Triple candle patterns: morning-star,
evening-star, three-white-soldiers and three-black-crows.