Indicator · Pine Script v6 · Own pane

TTM Wave

by mihakralj

This indicator plots six MACD histogram channels from exponential moving averages.

View on GitHub

GitHub stars99on the repository
Pine versionv6current
Lines of code67
Settings1inputs
LicenceApache-2.0
Last update4 weeks ago27 Sep 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

67 lines of Pine Script v6 from lib/oscillators/ttm_wave/ttm_wave.pine, published under Apache-2.0. Keep the author's credit and licence lines when you reuse it.

ttm_wave.pine
// Licensed under the Apache License, Version 2.0
// © mihakralj
//@version=6
indicator("TTM Wave (TTM_WAVE)", "TTM_WAVE", overlay=false)

//@function EMA — standard exponential moving average for MACD computation.
//@param src Source series
//@param length EMA period
//@returns EMA value
ema_calc(series float src, simple int length) =>
    float alpha = 2.0 / (length + 1)
    var float result = 0.0
    result := bar_index == 0 ? src : alpha * src + (1 - alpha) * result
    result

//@function MACD histogram — (fast_ema - slow_ema) - signal_ema(fast_ema - slow_ema)
//          This is the second derivative of momentum: acceleration of the spread.
//@param src Source series
//@param fast Fast EMA period
//@param slow Slow EMA period
//@param signal Signal EMA period (same as slow for TTM Wave)
//@returns MACD histogram value
macd_hist(series float src, simple int fast, simple int slow, simple int signal) =>
    float fast_ema = ema_calc(src, fast)
    float slow_ema = ema_calc(src, slow)
    float macd_line = fast_ema - slow_ema
    float signal_line = ema_calc(macd_line, signal)
    macd_line - signal_line

//@function TTM Wave — six parallel MACD histogram channels at Fibonacci periods.
//          Wave A (short-term):  channels 1 (8,34,34) and 2 (8,55,55)
//          Wave B (medium-term): channels 3 (8,89,89) and 4 (8,144,144)
//          Wave C (long-term):   channels 5 (8,233,233) and 6 (8,377,377)
//          All channels share fast period 8. Signal period equals slow period.
//@param src Source series (default: close)
//@returns [waveA1, waveA2, waveB1, waveB2, waveC1, waveC2]
//@reference John Carter, "Mastering the Trade" (2005, 2012)
//@optimized Six independent EMA cascades, O(1) per bar per channel
ttm_wave(series float src) =>
    float waveA1 = macd_hist(src, 8, 34,  34)
    float waveA2 = macd_hist(src, 8, 55,  55)
    float waveB1 = macd_hist(src, 8, 89,  89)
    float waveB2 = macd_hist(src, 8, 144, 144)
    float waveC1 = macd_hist(src, 8, 233, 233)
    float waveC2 = macd_hist(src, 8, 377, 377)
    [waveA1, waveA2, waveB1, waveB2, waveC1, waveC2]

// ── Inputs ──
float i_src = input.source(close, "Source")

// ── Calculation ──
[waveA1, waveA2, waveB1, waveB2, waveC1, waveC2] = ttm_wave(i_src)

// ── Plot (thinkorswim color convention) ──
// Wave A: yellow/green (short-term momentum)
plot(waveA1, "Wave A1", color=color.yellow, style=plot.style_histogram, linewidth=2)
plot(waveA2, "Wave A2", color=color.lime,   style=plot.style_histogram, linewidth=2)

// Wave B: magenta/pink (medium-term momentum)
plot(waveB1, "Wave B1", color=color.fuchsia, style=plot.style_histogram, linewidth=2)
plot(waveB2, "Wave B2", color=color.new(color.fuchsia, 40), style=plot.style_histogram, linewidth=2)

// Wave C: red/orange (long-term momentum)
plot(waveC1, "Wave C1", color=color.red,    style=plot.style_histogram, linewidth=2)
plot(waveC2, "Wave C2", color=color.orange, style=plot.style_histogram, linewidth=2)

hline(0, "Zero", color=color.gray, linestyle=hline.style_dotted)

Overview

Fast period is eight and the signal period equals each Fibonacci slow period: 34, 55, 89, 144, 233, and 377. Wave A shows short-term momentum, Wave B medium-term, and Wave C long-term. Histograms use distinct colors and a dotted zero line in a separate pane. The only setting changes the price source. It is an indicator with no trade entries, exits, or stops.

Details

Published by

mihakralj on GitHub

Type

Indicator, Pine Script v6

Draws

Separate pane below the chart

Category

Oscillators & momentum

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

algorithmic-tradingcsharpdotnetpinescriptpythonquantitative-financesimdta-libtechnical-analysistechnical-indicators

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Sourcesourceclosei_src
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

Asymmetrical RSI

by everget
948 stars

Asymmetrical RSI is an indicator that computes a custom relative strength index from the rate of change of a user-selected source. It plots the resulting ARSI line in a separate pane with color coding that turns green above the overbought level and red below t

Indicator v4 Oscillators & momentum
Updated 10 days ago · GPL-3.0 GitHub repository of Asymmetrical RSI

This indicator calculates momentum setups based on the Relative Strength Index (RSI) and plots in a separate pane. It offers multiple scanning modes such as Continuous Break, Continuous Retracement, Flip Break, Flip Retracement, and both regular and hidden div

Indicator v6 Oscillators & momentumDivergence Repaints
Updated 1 year ago · MPL-2.0 GitHub repository of Momentum Setup - RSI Directional Momentum Indicator

Beep Boop

by magic8bot
409 stars

This indicator calculates a modified MACD oscillator and signal line alongside a trend EMA filter, plotting the output as a stylized column histogram in a separate pane. Instead of plotting true MACD distance, it quantifies positive and negative histogram mome

Indicator v4 Oscillators & momentumTrend
Updated 3 years ago · MIT GitHub repository of Beep Boop
261 stars

This indicator demonstrates an experimental graph-style scatter visualization within a separate pane using Pine Script arrays. It tracks two features across recent bars: the single-bar price change and a scaled 14-period Relative Strength Index. Values are loa

Indicator v4 Oscillators & momentum
Updated 4 years ago · None stated GitHub repository of Example: Graph Style - 4th Dimension RSI

KD指標

by TaichiS
219 stars

This script calculates and plots a Stochastic Oscillator (KD indicator) in a separate chart pane. It determines the fast stochastic value over a 9-period lookback, then applies a 3-period Simple Moving Average (SMA) to create the %K line, and a second 3-period

Indicator v4 Oscillators & momentum
Updated 5 years ago · None stated GitHub repository of KD指標

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers