Indicator · Pine Script v6 · On the chart

Rolling Largest Impulse Murreys Lines

by regalouisei· code credited to RicardoSantos

Calculates Murrey Math Lines support and resistance levels anchored to the largest price impulse found within a rolling lookback window via Kadane's algorithm.

View on GitHub

GitHub stars2on the repository
Pine versionv6current
Lines of code180
Settings40inputs
LicenceNone statedfile: MPL-2.0
Last update8 months ago25 Feb 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

180 lines of Pine Script v6 from pinescript/editors_picks/rolling-largest-impulse-murreys-lines.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

rolling-largest-impulse-murreys-lines.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RicardoSantos

//@version=6
indicator(title='Rolling largest Impulse Murreys Lines', overlay=true, max_bars_back=500)

import RicardoSantos/FunctionArrayMaxSubKadanesAlgorithm/2 as msub
import RicardoSantos/ColorExtension/6 as colore

// helpers:
line_style_switch (string _style) =>
    switch (_style)
        ('dashed') => line.style_dashed
        ('dotted') => line.style_dotted
        ('solid') => line.style_solid
line_extend_switch (string _extend) =>
    switch (_extend)
        ('left') => extend.left
        ('right') => extend.right
        ('both') => extend.both
        ('none') => extend.none
label_textsize(string _size) =>
    switch (_size)
        ('auto') => size.auto
        ('huge') => size.huge
        ('large') => size.large
        ('normal') => size.normal
        ('small') => size.small
        ('tiny') => size.tiny
// inputs:
g_param = 'Parameters'
int window_size = input.int(defval=250, title='Window Size', minval=1, maxval=500, tooltip='size of data to search for largest impulse swing.', group=g_param)
bool direction = 'Bull' == input.string(defval='Bull', title='Direction of impulse', options=['Bull', 'Bear'], tooltip='prefered direction of impulse.', group=g_param)
float i_inversion_rate = input.float(defval=1.0, title='Inversion Rate', minval=0.0, maxval=1.0, tooltip='Inversion rate used to mirror the base line.', group=g_param)

g_style = 'Line Options'
i_base_color = input.color(defval=color.silver, title='Base', inline='b', group=g_style, display=display.none)
i_base_extend = line_extend_switch(input.string(defval='none', options=['left', 'right', 'both', 'none'], title='', inline='b', group=g_style, display=display.none))
i_base_style = line_style_switch(input.string(defval='solid', options=['dashed', 'dotted', 'solid'], title='', inline='b', group=g_style, display=display.none))
i_base_width = input.int(defval=1, minval=0, title='', tooltip='Base line properties.', inline='b', group=g_style, display=display.none)
i_invr_color = input.color(defval=color.silver, title='Inverse', inline='i', group=g_style, display=display.none)
i_invr_extend = line_extend_switch(input.string(defval='none', options=['left', 'right', 'both', 'none'], title='', inline='i', group=g_style, display=display.none))
i_invr_style = line_style_switch(input.string(defval='dashed', options=['dashed', 'dotted', 'solid'], title='', inline='i', group=g_style, display=display.none))
i_invr_width = input.int(defval=1, minval=0, title='', tooltip='Inverse line properties.', inline='i', group=g_style, display=display.none)
i_extend = line_extend_switch(input.string(defval='left', options=['left', 'right', 'both', 'none'], title='MML Extend', inline='00', group=g_style, display=display.none))
i_labels = input.bool(defval=true, title='', inline='00', group=g_style, display=display.none)
i_labels_textsize = input.string(defval='small', options=['auto', 'huge', 'large', 'normal', 'small', 'tiny'], title='Labels', inline='00', group=g_style, display=display.none)
i_mm01_color  = input.color(defval=color.gray, title='-2/8',                                                        inline='01', group=g_style, display=display.none)
i_mm01_style  = line_style_switch(input.string(defval='dotted', options=['dashed', 'dotted', 'solid'], title='',    inline='01', group=g_style, display=display.none))
i_mm01_width  = input.int(defval=1, minval=0, title='', tooltip='-2/8 line properties.',                            inline='01', group=g_style, display=display.none)
i_mm02_color  = input.color(defval=color.gray, title='-1/8',                                                        inline='02', group=g_style, display=display.none)
i_mm02_style  = line_style_switch(input.string(defval='dashed', options=['dashed', 'dotted', 'solid'], title='',    inline='02', group=g_style, display=display.none))
i_mm02_width  = input.int(defval=1, minval=0, title='', tooltip='-1/8 line properties.',                            inline='02', group=g_style, display=display.none)
i_mm03_color  = input.color(defval=color.aqua, title=' 0/8',                                                        inline='03', group=g_style, display=display.none)
i_mm03_style  = line_style_switch(input.string(defval='solid' , options=['dashed', 'dotted', 'solid'], title='',    inline='03', group=g_style, display=display.none))
i_mm03_width  = input.int(defval=2, minval=0, title='', tooltip=' 0/8 line properties.',                            inline='03', group=g_style, display=display.none)
i_mm04_color  = input.color(defval=color.gray, title=' 1/8',                                                        inline='04', group=g_style, display=display.none)
i_mm04_style  = line_style_switch(input.string(defval='dashed' , options=['dashed', 'dotted', 'solid'], title='',   inline='04', group=g_style, display=display.none))
i_mm04_width  = input.int(defval=1, minval=0, title='', tooltip=' 1/8 line properties.',                            inline='04', group=g_style, display=display.none)
i_mm05_color  = input.color(defval=color.gray, title=' 2/8',                                                        inline='05', group=g_style, display=display.none)
i_mm05_style  = line_style_switch(input.string(defval='solid' , options=['dashed', 'dotted', 'solid'], title='',    inline='05', group=g_style, display=display.none))
i_mm05_width  = input.int(defval=1, minval=0, title='', tooltip=' 2/8 line properties.',                            inline='05', group=g_style, display=display.none)
i_mm06_color  = input.color(defval=color.gray, title=' 3/8',                                                        inline='06', group=g_style, display=display.none)
i_mm06_style  = line_style_switch(input.string(defval='dashed' , options=['dashed', 'dotted', 'solid'], title='',   inline='06', group=g_style, display=display.none))
i_mm06_width  = input.int(defval=1, minval=0, title='', tooltip=' 3/8 line properties.',                            inline='06', group=g_style, display=display.none)
i_mm07_color  = input.color(defval=color.lime, title=' 4/8',                                                        inline='07', group=g_style, display=display.none)
i_mm07_style  = line_style_switch(input.string(defval='solid' , options=['dashed', 'dotted', 'solid'], title='',    inline='07', group=g_style, display=display.none))
i_mm07_width  = input.int(defval=2, minval=0, title='', tooltip=' 4/8 line properties.',                            inline='07', group=g_style, display=display.none)
i_mm08_color  = input.color(defval=color.gray, title=' 5/8',                                                        inline='08', group=g_style, display=display.none)
i_mm08_style  = line_style_switch(input.string(defval='dashed' , options=['dashed', 'dotted', 'solid'], title='',   inline='08', group=g_style, display=display.none))
i_mm08_width  = input.int(defval=1, minval=0, title='', tooltip=' 5/8 line properties.',                            inline='08', group=g_style, display=display.none)
i_mm09_color  = input.color(defval=color.gray, title=' 6/8',                                                        inline='09', group=g_style, display=display.none)
i_mm09_style  = line_style_switch(input.string(defval='solid' , options=['dashed', 'dotted', 'solid'], title='',    inline='09', group=g_style, display=display.none))
i_mm09_width  = input.int(defval=1, minval=0, title='', tooltip=' 6/8 line properties.',                            inline='09', group=g_style, display=display.none)
i_mm10_color  = input.color(defval=color.gray, title=' 7/8',                                                        inline='10', group=g_style, display=display.none)
i_mm10_style  = line_style_switch(input.string(defval='dashed' , options=['dashed', 'dotted', 'solid'], title='',   inline='10', group=g_style, display=display.none))
i_mm10_width  = input.int(defval=1, minval=0, title='', tooltip=' 7/8 line properties.',                            inline='10', group=g_style, display=display.none)
i_mm11_color  = input.color(defval=color.aqua, title=' 8/8',                                                        inline='11', group=g_style, display=display.none)
i_mm11_style  = line_style_switch(input.string(defval='solid' , options=['dashed', 'dotted', 'solid'], title='',    inline='11', group=g_style, display=display.none))
i_mm11_width  = input.int(defval=2, minval=0, title='', tooltip=' 8/8 line properties.',                            inline='11', group=g_style, display=display.none)
i_mm12_color  = input.color(defval=color.gray, title=' 9/8',                                                        inline='12', group=g_style, display=display.none)
i_mm12_style  = line_style_switch(input.string(defval='dashed' , options=['dashed', 'dotted', 'solid'], title='',   inline='12', group=g_style, display=display.none))
i_mm12_width  = input.int(defval=1, minval=0, title='', tooltip=' 9/8 line properties.',                            inline='12', group=g_style, display=display.none)
i_mm13_color  = input.color(defval=color.gray, title='10/8',                                                        inline='13', group=g_style, display=display.none)
i_mm13_style  = line_style_switch(input.string(defval='dotted' , options=['dashed', 'dotted', 'solid'], title='',   inline='13', group=g_style, display=display.none))
i_mm13_width  = input.int(defval=1, minval=0, title='', tooltip='10/8 line properties.',                            inline='13', group=g_style, display=display.none)
// prepare data:
float hl = (direction ? +1.0 : -1.0) * ta.change(high * low)

var float[] samples = array.new_float(size=window_size, initial_value=0.0)
array.unshift(samples, hl)
array.pop(samples)

// find the largest impulse in the data samples:
[ki_max, ki_start, ki_end] = msub.indices(samples)

bool is_new_impulse = ta.change(ki_start + ki_end) != 0

// initialize the lines:
var line[] lines = array.new_line(15)
var label[] labels = array.new_label(15)
if barstate.isfirst
    // base line:
    array.set(lines,  0, line.new(bar_index, 0.0, bar_index, 0.0, xloc.bar_index, i_base_extend, i_base_color, i_base_style, i_base_width))
    array.set(lines,  1, line.new(bar_index, 0.0, bar_index, 0.0, xloc.bar_index, i_invr_extend, i_invr_color, i_invr_style, i_invr_width))
    //from lowest octave to highest:
    array.set(lines,  2, line.new(bar_index, 0.0, bar_index, 0.0, xloc.bar_index, i_extend, i_mm01_color, i_mm01_style, i_mm01_width))
    array.set(lines,  3, line.new(bar_index, 0.0, bar_index, 0.0, xloc.bar_index, i_extend, i_mm02_color, i_mm02_style, i_mm02_width))
    array.set(lines,  4, line.new(bar_index, 0.0, bar_index, 0.0, xloc.bar_index, i_extend, i_mm03_color, i_mm03_style, i_mm03_width))
    array.set(lines,  5, line.new(bar_index, 0.0, bar_index, 0.0, xloc.bar_index, i_extend, i_mm04_color, i_mm04_style, i_mm04_width))
    array.set(lines,  6, line.new(bar_index, 0.0, bar_index, 0.0, xloc.bar_index, i_extend, i_mm05_color, i_mm05_style, i_mm05_width))
    array.set(lines,  7, line.new(bar_index, 0.0, bar_index, 0.0, xloc.bar_index, i_extend, i_mm06_color, i_mm06_style, i_mm06_width))
    array.set(lines,  8, line.new(bar_index, 0.0, bar_index, 0.0, xloc.bar_index, i_extend, i_mm07_color, i_mm07_style, i_mm07_width))
    array.set(lines,  9, line.new(bar_index, 0.0, bar_index, 0.0, xloc.bar_index, i_extend, i_mm08_color, i_mm08_style, i_mm08_width))
    array.set(lines, 10, line.new(bar_index, 0.0, bar_index, 0.0, xloc.bar_index, i_extend, i_mm09_color, i_mm09_style, i_mm09_width))
    array.set(lines, 11, line.new(bar_index, 0.0, bar_index, 0.0, xloc.bar_index, i_extend, i_mm10_color, i_mm10_style, i_mm10_width))
    array.set(lines, 12, line.new(bar_index, 0.0, bar_index, 0.0, xloc.bar_index, i_extend, i_mm11_color, i_mm11_style, i_mm11_width))
    array.set(lines, 13, line.new(bar_index, 0.0, bar_index, 0.0, xloc.bar_index, i_extend, i_mm12_color, i_mm12_style, i_mm12_width))
    array.set(lines, 14, line.new(bar_index, 0.0, bar_index, 0.0, xloc.bar_index, i_extend, i_mm13_color, i_mm13_style, i_mm13_width))
    //labels
    if i_labels
        array.set(labels,  2, label.new(bar_index, 0.0, '-2/8', color=i_mm01_color, style=label.style_label_right, textcolor=colore.invert(i_mm01_color), size=i_labels_textsize))
        array.set(labels,  3, label.new(bar_index, 0.0, '-1/8', color=i_mm02_color, style=label.style_label_right, textcolor=colore.invert(i_mm02_color), size=i_labels_textsize))
        array.set(labels,  4, label.new(bar_index, 0.0, ' 0/8', color=i_mm03_color, style=label.style_label_right, textcolor=colore.invert(i_mm03_color), size=i_labels_textsize))
        array.set(labels,  5, label.new(bar_index, 0.0, ' 1/8', color=i_mm04_color, style=label.style_label_right, textcolor=colore.invert(i_mm04_color), size=i_labels_textsize))
        array.set(labels,  6, label.new(bar_index, 0.0, ' 2/8', color=i_mm05_color, style=label.style_label_right, textcolor=colore.invert(i_mm05_color), size=i_labels_textsize))
        array.set(labels,  7, label.new(bar_index, 0.0, ' 3/8', color=i_mm06_color, style=label.style_label_right, textcolor=colore.invert(i_mm06_color), size=i_labels_textsize))
        array.set(labels,  8, label.new(bar_index, 0.0, ' 4/8', color=i_mm07_color, style=label.style_label_right, textcolor=colore.invert(i_mm07_color), size=i_labels_textsize))
        array.set(labels,  9, label.new(bar_index, 0.0, ' 5/8', color=i_mm08_color, style=label.style_label_right, textcolor=colore.invert(i_mm08_color), size=i_labels_textsize))
        array.set(labels, 10, label.new(bar_index, 0.0, ' 6/8', color=i_mm09_color, style=label.style_label_right, textcolor=colore.invert(i_mm09_color), size=i_labels_textsize))
        array.set(labels, 11, label.new(bar_index, 0.0, ' 7/8', color=i_mm10_color, style=label.style_label_right, textcolor=colore.invert(i_mm10_color), size=i_labels_textsize))
        array.set(labels, 12, label.new(bar_index, 0.0, ' 8/8', color=i_mm11_color, style=label.style_label_right, textcolor=colore.invert(i_mm11_color), size=i_labels_textsize))
        array.set(labels, 13, label.new(bar_index, 0.0, ' 9/8', color=i_mm12_color, style=label.style_label_right, textcolor=colore.invert(i_mm12_color), size=i_labels_textsize))
        array.set(labels, 14, label.new(bar_index, 0.0, '10/8', color=i_mm13_color, style=label.style_label_right, textcolor=colore.invert(i_mm13_color), size=i_labels_textsize))

update_label (int _n, int _x, float _y) => //{
    label _label = array.get(labels, _n)
    label.set_xy(_label, _x, _y)
//}
update_bline (int _n, int _x1, float _y1, int _x2, float _y2) => //{
    line _line = array.get(lines, _n)
    line.set_xy1(_line, _x1, _y1)
    line.set_xy2(_line, _x2, _y2)
//}
update_mline (int _n, int _x1, int _x2, float _y) => //{
    line _line = array.get(lines, _n)
    line.set_xy1(_line, _x1, _y)
    line.set_xy2(_line, _x2, _y)
    if i_labels
        update_label(_n, _x2, _y)
//}

if is_new_impulse
    float _start_value = hl2[ki_start]
    float _end_value = hl2[ki_end]
    int _x1 = bar_index - ki_start
    int _x2 = bar_index - ki_end
    float _y1 = low[ki_start]
    float _y2 = high[ki_end]
    if _end_value < _start_value
        _y1 := high[ki_start]
        _y2 := low[ki_end]

    float _range = _y2 - _y1

    update_bline(00, _x1, _y1, _x2, _y2)
    update_bline(01, _x1, _y1, _x1+(_x1-_x2), _y1+(_y2-_y1)*i_inversion_rate)
    update_mline(02, _x1, _x2, _y1 + _range * -0.250)
    update_mline(03, _x1, _x2, _y1 + _range * -0.125)
    update_mline(04, _x1, _x2, _y1)
    update_mline(05, _x1, _x2, _y1 + _range * 0.125)
    update_mline(06, _x1, _x2, _y1 + _range * 0.250)
    update_mline(07, _x1, _x2, _y1 + _range * 0.375)
    update_mline(08, _x1, _x2, _y1 + _range * 0.500)
    update_mline(09, _x1, _x2, _y1 + _range * 0.625)
    update_mline(10, _x1, _x2, _y1 + _range * 0.750)
    update_mline(11, _x1, _x2, _y1 + _range * 0.875)
    update_mline(12, _x1, _x2, _y1 + _range * 1.000)
    update_mline(13, _x1, _x2, _y1 + _range * 1.125)
    update_mline(14, _x1, _x2, _y1 + _range * 1.250)

Overview

Rolling Largest Impulse Murreys Lines projects fractional Murrey grid lines alongside base and inverse lines with text labels directly on the price chart. Main settings allow configuring the window size, selecting bullish or bearish impulse direction, modifying inversion rates, and adjusting line styles and extensions.

Details

Published by

regalouisei on GitHub

Code credit

RicardoSantos, as written in the script's header

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Support & resistance

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.

Settings

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

SettingTypeDefaultVariable
Window Sizeint250window_size
Direction of impulsestringBullDirection of impulse
Inversion Ratefloat1.0i_inversion_rate
Basecolorcolor.silveri_base_color
stringnone
stringsolid
i_base_widthint1i_base_width
Inversecolorcolor.silveri_invr_color
stringnone
stringdashed
i_invr_widthint1i_invr_width
MML ExtendstringleftMML Extend
Show all 40 settings
SettingTypeDefaultVariable
i_labelsbooltruei_labels
Labelsstringsmalli_labels_textsize
-2/8colorcolor.grayi_mm01_color
stringdotted
i_mm01_widthint1i_mm01_width
-1/8colorcolor.grayi_mm02_color
stringdashed
i_mm02_widthint1i_mm02_width
 0/8colorcolor.aquai_mm03_color
stringsolid
i_mm03_widthint2i_mm03_width
 1/8colorcolor.grayi_mm04_color
stringdashed
i_mm04_widthint1i_mm04_width
 2/8colorcolor.grayi_mm05_color
stringsolid
i_mm05_widthint1i_mm05_width
 3/8colorcolor.grayi_mm06_color
stringdashed
i_mm06_widthint1i_mm06_width
 4/8colorcolor.limei_mm07_color
stringsolid
i_mm07_widthint2i_mm07_width
 5/8colorcolor.grayi_mm08_color
stringdashed
i_mm08_widthint1i_mm08_width
 6/8colorcolor.grayi_mm09_color
stringsolid
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

948 stars

Moving Average Channel plots separate simple moving averages for upper and lower bands on the price chart. It fills the space between bands with semi-transparent color and colors bars green above the upper band, red below the lower band, or gray in between. Us

Indicator v4 Moving averagesSupport & resistance
Updated 10 days ago · GPL-3.0 GitHub repository of Moving Average Channel

ICT Equal Highs and Lows

by ArunKBhaskar
575 stars

This overlay indicator finds pivot highs and lows on the price chart and compares the last two highs and the last two lows. When the percentage difference between a pair is below the Equal HL threshold, it treats them as equal levels and draws a box. Left and

Indicator v5 SMC / ICT / price actionSupport & resistance
Updated 1 year ago · MPL-2.0 GitHub repository of ICT Equal Highs and Lows
330 stars

This indicator monitors multiple cryptocurrency symbols for trading signals. It calculates and plots entry prices, take profit, and stop loss levels for each symbol including BTCUSDT, ETHUSDT, BNBUSDT and others. Price crossovers trigger buy, sell or close ale

Indicator v5 Support & resistanceScreeners & dashboards
Updated 2 months ago · None stated GitHub repository of Multi Alert Long/Short [Alorse]

This overlay indicator draws a fixed-range volume profile on the price chart, splitting traded activity into up and down volume at each price level. It also plots a sentiment profile, a developing point of control, and value-area high and low around a configur

Indicator v5 VolumeSupport & resistance
Updated 2 months ago · MIT GitHub repository of Volume Profile and Indicator by DGT

BZ-tracker

by Allen1212
303 stars

The BZ-tracker indicator marks ARK Invest buy and sell transactions on stock charts with labels. It plots green labels for purchases and red labels for sales, each annotated with a multiplier such as X1 or X2 to show the number of ARK ETFs trading the stock on

Indicator v4 Support & resistanceScreeners & dashboards
Updated 2 years ago · None stated GitHub repository of BZ-tracker

Function - Linear Regression

by ricardosantos79
261 stars

This indicator fits a linear regression through stored pivot highs and lows and draws the resulting channel on the price chart. A function returns predicted values, maximum and minimum deviations, and the average absolute deviation. Confirmed two-bar pivots up

Indicator v5 TrendSupport & resistance
Updated 4 years ago · None stated GitHub repository of Function - Linear Regression

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