Indicator is a Golang module that provides an extensive set of technical analysis indicators, strategies, and a framework for backtesting.
An extensive technical analysis library for algorithmic trading - 80+ indicators and backtesting framework.
- Enhanced Code Quality: A complete rewrite was undertaken to achieve and maintain at least 90% code coverage.
- Improved Testability: Each indicator and strategy have dedicated test data in CSV format for easier validation.
- Streamlined Data Handling: The library was rewritten to operate on data streams (Go channels) for both inputs and outputs. If you prefer using slices, helper functions like helper.SliceToChan and helper.ChanToSlice are available. Alternatively, you can still use the v1 version.
- Configurable Indicators and Strategies: All indicators and strategies were designed to be fully configurable with no preset values.
- Generics Support: The library leverages Golang generics to support various numeric data formats.
There is also a TypeScript version of this module at Indicator TS.
-
Strict Educational, Research, and Informational Purpose Notice: This repository, software library, documentation, and all associated tools, mathematical models, indicator calculations, example strategies, and backtesting utilities are provided strictly and solely for educational, academic, and research purposes. Nothing contained herein constitutes, or is intended to constitute, investment, financial, tax, legal, or trading advice. No communication or output from this software shall be construed as a recommendation, endorsement, solicitation, or offer to buy or sell any security, commodity, currency, digital asset, or other financial instrument.
-
Non-Advisory and Non-Fiduciary Status: The Indicator Authors, maintainers, contributors, and copyright holders are not registered investment advisers (RIAs), registered broker-dealers, commodity trading advisors (CTAs), commodity pool operators (CPOs), financial planners, or tax advisors with the U.S. Securities and Exchange Commission (SEC), the U.S. Commodity Futures Trading Commission (CFTC), the Financial Industry Regulatory Authority (FINRA), or any other regulatory agency or authority in any jurisdiction. The maintainers do not act in any fiduciary capacity, and no fiduciary, advisory, or professional-client relationship is established through the use of, contribution to, or access to this software.
-
Risk Disclosure Regarding Substantial Trading Losses and Leverage: Trading and investing in equities, options, futures, foreign exchange (Forex), commodities, and cryptocurrencies carries substantial risk of loss and is not suitable for all individuals or investors. Prices of financial instruments fluctuate significantly and unpredictably. The use of leverage, margin, or derivative contracts can rapidly amplify losses as well as gains, potentially resulting in the complete loss of all invested capital or losses exceeding initial deposits. You should carefully consider whether trading is appropriate for you in light of your personal financial condition, experience level, and risk tolerance, and you should consult with qualified, licensed financial advisors before making any investment or trading decisions.
-
CFTC-Style Hypothetical and Backtested Performance Disclosure (CFTC Rule 4.41): Hypothetical, simulated, or backtested performance results have inherent and significant limitations. Unlike an actual performance record, simulated results do not represent actual trading. Because trades have not actually been executed, results may over- or under-compensate for the impact, if any, of certain market factors, including but not limited to lack of liquidity, order execution delays, market impact, exchange fees, slippage, and spread. Furthermore, hypothetical and simulated trading programs are designed with the benefit of hindsight and retrospective knowledge of historical price movements. No representation or warranty is being made that any account, strategy, or portfolio will or is likely to achieve profits, avoid losses, or experience outcomes similar to those illustrated in any backtest, example, or simulation.
-
"AS IS" Software Liability Limitation & Disclaimers: This software is provided on an "AS IS" and "AS AVAILABLE" basis, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, ACCURACY, COMPLETENESS, AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS, MAINTAINERS, CONTRIBUTORS, OR COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, FINANCIAL LOSSES, TRADING LOSSES, LOSS OF CAPITAL, LOSS OF PROFITS, LOSS OF DATA, SYSTEM FAILURES, INACCURATE CALCULATIONS, OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND UNDER ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
The following list of indicators are currently supported by this package:
- Absolute Price Oscillator (APO)
- Aroon Indicator
- Balance of Power (BoP)
- Chande Forecast Oscillator (CFO)
- Commodity Channel Index (CCI)
- Envelope
- Hull Moving Average (HMA)
- Detrended Price Oscillator (DPO)
- Double Exponential Moving Average (DEMA)
- Exponential Moving Average (EMA)
- Kaufman's Adaptive Moving Average (KAMA)
- Know Sure Thing (KST)
- Mass Index (MI)
- McGinley Dynamic
- Moving Average Convergence Divergence (MACD)
- Moving Least Square (MLS)
- Moving Linear Regression (MLR)
- Moving Max
- Moving Min
- Moving Sum
- Pivot Point
- Random Index (KDJ)
- Rate of Change (ROC)
- Stochastic
- Slow Stochastic
- Schaff Trend Cycle (STC)
- Rolling Moving Average (RMA)
- Simple Moving Average (SMA)
- Since Change
- Slope
- Smoothed Moving Average (SMMA)
- Triple Exponential Moving Average (TEMA)
- Triangular Moving Average (TRIMA)
- Triple Exponential Average (TRIX)
- True Strength Index (TSI)
- Tillson T3
- Typical Price
- Volume Weighted Moving Average (VWMA)
- Weighted Close
- Weighted Moving Average (WMA)
- Awesome Oscillator
- Chaikin Oscillator
- Connors RSI
- Coppock Curve
- Elder-Ray Index
- Fisher Transform
- Ichimoku Cloud
- Internal Bar Strength (IBS)
- Martin Pring's Special K
- Percentage Price Oscillator (PPO)
- Percentage Volume Oscillator (PVO)
- Qstick
- Relative Strength Index (RSI)
- Relative Vigor Index (RVI)
- Stochastic Oscillator
- Stochastic RSI
- TD Sequential
- Ultimate Oscillator
- Williams R
- Percent B
- Acceleration Bands
- Annualized Historical Volatility (AHV)
- Average True Range (ATR)
- Bollinger Band Width
- Bollinger Bands
- Chandelier Exit
- Choppiness Index (CHOP)
- Donchian Channel (DC)
- Historical Volatility (HV)
- Keltner Channel (KC)
- Moving Standard Deviation (Std)
- Projection Oscillator (PO)
- Super Trend
- True Range (TR)
- Ulcer Index (UI)
- Z-Score
- Accumulation/Distribution (A/D)
- Chaikin Money Flow (CMF)
- Ease of Movement (EMV)
- Force Index (FI)
- Klinger Volume Oscillator (KVO)
- Money Flow Index (MFI)
- Money Flow Multiplier (MFM)
- Money Flow Volume (MFV)
- Negative Volume Index (NVI)
- On-Balance Volume (OBV)
- Volume Price Trend (VPT)
- Volume Weighted Average Price (VWAP)
The following concrete strategies are provided in the examples/ directory purely as illustrative demonstrations on how developers can consume the core indicator mathematics and generic backtesting framework. They are intended strictly for educational and research purposes:
- Alligator Strategy
- Absolute Price Oscillator (APO) Strategy
- Aroon Strategy
- Balance of Power (BoP) Strategy
- Chande Forecast Oscillator Strategy
- Commodity Channel Index (CCI) Strategy
- Double Exponential Moving Average (DEMA) Strategy
- Envelope Strategy
- Golden Cross Strategy
- Hull Moving Average (HMA) Strategy
- Kaufman's Adaptive Moving Average (KAMA) Strategy
- Moving Average Convergence Divergence (MACD) Strategy
- Qstick Strategy
- Random Index (KDJ) Strategy
- Smoothed Moving Average (SMMA) Strategy
- Triangular Moving Average (TRIMA) Strategy
- Triple Exponential Average (TRIX) Strategy
- Triple Moving Average Crossover Strategy
- True Strength Index (TSI) Strategy
- Volume Weighted Moving Average (VWMA) Strategy
- Weighted Close Strategy
- Awesome Oscillator Strategy
- Coppock Curve Strategy
- Elder Ray Strategy
- Ichimoku Cloud Strategy
- RSI Strategy
- Stochastic Oscillator Strategy
- Stochastic RSI Strategy
- Triple RSI Strategy
- Williams R Strategy
- Chaikin Money Flow Strategy
- Ease of Movement Strategy
- Force Index Strategy
- Money Flow Index Strategy
- Negative Volume Index Strategy
- On-Balance Volume (OBV) Strategy
- Percent Band and MFI Strategy
- Weighted Average Price Strategy
Compound strategies demonstrate merging multiple indicator signals into unified actions using various logical combinations.
Decorator strategies offer an illustrative way to alter or filter the recommendations of underlying strategies.
Repository serves as a centralized storage and retrieval location for asset snapshots.
The following repository implementations are provided.
The Sync function facilitates the synchronization of assets between designated source and target repositories by employing multi-worker concurrency for enhanced efficiency. This function serves the purpose of procuring the most recent snapshots from remote repositories and seamlessly transferring them to local repositories, such as file system repositories.
The indicator-sync command line tool also offers the capability of synchronizing data between the Tiingo Repository and the File System Repository. To illustrate its usage, consider the following example command:
$ indicator-sync \
-source-name tiingo \
-source-config $TIINGO_KEY \
-target-name filesystem \
-target-config /home/user/assets \
-days 30This command effectively retrieves the most recent snapshots for assets residing within the /home/user/assets directory from the Tiingo Repository. In the event that the local asset file is devoid of content, it automatically extends its reach to synchronize 30 days' worth of snapshots, ensuring a comprehensive and up-to-date repository.
The Backtest functionality, using the Outcome, evaluates the hypothetical performance of specified strategies applied to a defined set of historical asset data. It generates comprehensive visual representations for each strategy-asset pairing.
import (
"github.com/cinar/indicator/v2/asset"
"github.com/cinar/indicator/v2/backtest"
"github.com/cinar/indicator/v2/examples/trend"
)
report := backtest.NewHTMLReport(outputDir)
bt := backtest.NewBacktest(repository, report)
bt.Names = append(bt.Names, "brk-b")
bt.Strategies = append(bt.Strategies, trend.NewApoStrategy())
err = bt.Run()
if err != nil {
t.Fatal(err)
}The indicator-backtest command line tool empowers users to conduct comprehensive backtesting of assets residing within a specified repository. It does not run any strategy by default โ you must explicitly name the strategies to backtest with the -strategies flag, culminating in the generation of detailed reports within a designated output directory.
$ indicator-backtest \
-repository-name filesystem \
-repository-config /home/user/assets \
-report-config /home/user/reports \
-strategies apo,macd,rsi \
-workers 1Run indicator-backtest -list-strategies to print the full list of strategy names that are available to pass to -strategies.
The easiest way to get started is using our Docker image. It handles everything - syncing market data from Tiingo and generating backtest reports - in a single command.
# Get your free Tiingo API key at: https://www.tiingo.com/
# Run backtest for specific assets
docker run -it --rm \
-v $(pwd)/output:/app/output \
ghcr.io/cinar/indicator:latest \
--api-key YOUR_TIINGO_API_KEY \
--days 365 \
--assets aapl msft googl \
--strategies apo,macd,rsi
# View results (macOS)
open output/index.html
# View results (Linux)
xdg-open output/index.html| Flag | Description | Default |
|---|---|---|
--api-key |
Tiingo API key (required) | - |
--days |
Days of historical data to fetch | 365 |
--last |
Days to backtest | 365 |
--assets |
Space-separated ticker symbols (default: all) | all |
--strategies |
Comma-separated strategy names to backtest (required) | - |
--output |
Output directory for reports | /app/output |
Run docker run --rm --entrypoint ./indicator-backtest ghcr.io/cinar/indicator:latest -list-strategies to see the available strategy names.
# Backtest all available assets for 1 year
docker run -it --rm \
-v $(pwd)/reports:/app/output \
ghcr.io/cinar/indicator:latest \
--api-key YOUR_TIINGO_API_KEY \
--strategies apo,macd,rsi
# Backtest specific stocks for last 6 months, test last 30 days
docker run -it --rm \
-v $(pwd)/reports:/app/output \
ghcr.io/cinar/indicator:latest \
--api-key YOUR_TIINGO_API_KEY \
--days 180 \
--last 30 \
--assets aapl msft googl amzn \
--strategies apo,macd,rsi
# Custom output directory
docker run -it --rm \
-v /path/to/my/reports:/app/output \
ghcr.io/cinar/indicator:latest \
--api-key YOUR_TIINGO_API_KEY \
--strategies apo,macd,rsi \
--output /app/outputdocker build -t indicator .
docker run -it --rm -v $(pwd)/output:/app/output indicator --api-key YOUR_KEYInstall package.
go get github.com/cinar/indicator/v2Import indicator.
import (
"github.com/cinar/indicator/v2"
)Indicator Go is part of a broader ecosystem of technical analysis tools:
- Indicator TS - TypeScript/JavaScript implementation of the same indicators and strategies
Indicator is a community-supported project. The following companies, organizations, and individuals help make our work possible. Become a sponsor and help us continue to grow!
Anyone can contribute to Indicator library. Please make sure to read our Contributor Covenant Code of Conduct guide first. Follow the How to Contribute to Indicator to contribute. Signining a Contributor Agreement is also required to contribute to the project.
The v2.x.x and above are dual-licensed under GNU AGPLv3 License and a commercial license. For free use and modifications of the code, you can use the AGPLv3 license. If you require commercial license with different terms, please contact the maintainers.
Copyright (c) 2021-2026 The Indicator Authors.
The source code is provided under GNU AGPLv3 License.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
The version v1.x.x is provided under MIT License.
Copyright (c) 2021-2026 The Indicator Authors.
The source code is provided under MIT License.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
- TD Sequentialยฎ is a registered trademark of DeMark Analytics, LLC. This library is an independent open-source mathematical implementation and is not affiliated with, sponsored by, or endorsed by DeMark Analytics, LLC.
- Bollinger Bandsยฎ is a registered trademark of John Bollinger.
- ConnorsRSIยฎ is a registered trademark of Connors Group, Inc.
- All other product names, logos, and brands mentioned herein are trademarks or registered trademarks of their respective owners. Mention of third-party products, services, or trademarks is for nominative identification and educational purposes only and does not imply affiliation or endorsement.
