Live MACD Demo

This demo uses the PineTS library to load the market data and calculate the indicators, and QFChart library for visualizing the results.


Loading Data ...


About MACD (Moving Average Convergence Divergence)

What is MACD?

The MACD (Moving Average Convergence Divergence) is one of the most popular and widely-used technical analysis indicators in trading. Developed by Gerald Appel in the late 1970s, MACD is a momentum oscillator that shows the relationship between two exponential moving averages (EMAs) of a security's price. It helps traders identify potential trend changes, momentum shifts, and buy/sell signals in financial markets.

How MACD Works

The MACD indicator consists of three main components:

Trading with MACD

Traders use MACD in several ways:

MACD with QFChart & PineTS

This demo showcases a real-time MACD implementation using QFChart for visualization and PineTS for indicator calculation. Here's what makes this implementation special:

Technical Implementation

PineTS handles the data fetching and MACD calculation using Pine Script v5 syntax, which is transpiled to JavaScript at runtime. The indicator uses incremental calculation with state management, ensuring O(1) performance per bar update rather than recalculating the entire history.

QFChart (built on Apache ECharts) renders the MACD in a separate pane with customizable height, automatically handling Y-axis scaling, series data mapping, and real-time updates through the updateData() API.

Use Cases

Getting Started

To use this MACD implementation in your own project:

  1. Install QFChart: npm install @quantforge/qfchart
  2. Install PineTS: npm install @quantforge/pinets
  3. Create a chart container: <div id="chart"></div>
  4. Initialize with PineTS streaming and add the MACD indicator as shown in this demo's source code

View the source code of this page to see the complete implementation. The demo uses Binance market data for BTC/USDT on the 1-minute timeframe, but you can easily adapt it to any symbol or timeframe supported by your data provider.

Learn More

For more information about technical indicators, Pine Script, and advanced charting techniques: