Skip to content

Commit 94c475d

Browse files
MML update
1 parent bbdd5ed commit 94c475d

File tree

1 file changed

+52
-17
lines changed

1 file changed

+52
-17
lines changed

[RS][UCS]Murrey's Math Oscillator Modification.pinescript

+52-17
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,67 @@
1+
12
// Created & Developed by Ucsgears, based on Murrey Math Line Principle
23
// Version 2 - March, 12 - 2015
34
// Modification - sometime around 2016~ RicardoSantos
4-
// V4 update - 03-06-2020 RicardoSantos
5-
5+
// V4 update - 2020-06-03 RicardoSantos
6+
// multiple methods - 2020-06-13 RicardoSantos
67
//@version=4
78
study(title="[RS][UCS]Murrey's Math Oscillator Modification", shorttitle="[RS][UCS]MMLO", overlay=false, precision = 2)
89

910
// Inputs
11+
string m_donchian = 'donchian channel'
12+
string m_cumdev = 'cumulative deviation'
13+
string m_decenv = 'decay envelope'
14+
15+
string method = input(defval=m_donchian, options=[m_donchian, m_cumdev, m_decenv])
1016
int length = input(defval=4, minval = 1, title = "Look back Length")
1117
float mult = input(0.125)
1218
bool lines = input(defval=true, title="Show Murrey Math Fractals")
1319
bool bc = input(defval=true, title="Show Bar Colors Based On Oscillator")
1420

15-
1621
//-----------------------------------------------------
17-
f_mo(_length, _multiplier)=>
18-
float _cumdev = cum(stdev(close, 4)) / (bar_index + 1)
19-
float _mdev = _cumdev * _length
20-
//--
21-
var float _oscdev = hlc3
22-
float _previous = nz(_oscdev[1], hlc3)
23-
if open - _mdev > _previous
24-
_oscdev := _previous + _cumdev
25-
else if open + _cumdev * _length < _previous
26-
_oscdev := _previous - _cumdev
22+
f_mo(_method, _length, _multiplier)=>
23+
float _oscillator = 0.0
24+
float _lvl_range = _multiplier
25+
if _method == m_cumdev
26+
float _cumdev = cum(stdev(close, 4)) / (bar_index + 1)
27+
float _mdev = _cumdev * _length
28+
//--
29+
var float _oscdev = hlc3
30+
float _previous = nz(_oscdev[1], hlc3)
31+
if open - _mdev > _previous
32+
_oscdev := _previous + _cumdev
33+
else if open + _cumdev * _length < _previous
34+
_oscdev := _previous - _cumdev
35+
else
36+
_oscdev := _previous
37+
_oscillator := (close - _oscdev) / (_cumdev * (_length * 10))
38+
else if _method == m_donchian
39+
float _hi = highest(high, _length)
40+
float _lo = lowest(low, _length)
41+
float _range = _hi - _lo
42+
float _lvl_range = _range * _multiplier
43+
float _midline = avg(_hi, _lo)//_lo + _lvl_range * 4
44+
45+
_oscillator := (close - _midline) / (_range / 2)
46+
else if _method == m_decenv
47+
var float _hi = high
48+
var float _lo = low
49+
if high > _hi
50+
_hi := high
51+
else
52+
_hi := max(avg(nz(_hi) * (1.0 - _multiplier), high * (1.0 + _multiplier)), high)
53+
if low < _lo
54+
_lo := low
55+
else
56+
_lo := min(avg(nz(_lo) * (1.0 - _multiplier), low * (1.0 + _multiplier)), low)
57+
58+
float _range = _hi - _lo
59+
float _lvl_range = _range * _multiplier
60+
float _midline = avg(_hi, _lo)//_lo + _lvl_range * 4
61+
float _c = ema(close, _length)
62+
_oscillator := 0 - (_c - _midline) / (_range / 2)
2763
else
28-
_oscdev := _previous
29-
float _oscillator = (close - _oscdev) / (_cumdev * (_length * 10))
64+
_oscillator := na
3065
//--
3166
color _col = na
3267
if _oscillator > 0
@@ -57,7 +92,7 @@ f_mo(_length, _multiplier)=>
5792
[_oscillator, _col]
5893

5994
//-----------------------------------------------------
60-
[oscillator, colordef] = f_mo(length, mult)
95+
[oscillator, colordef] = f_mo(method, length, mult)
6196

6297
plot(series=oscillator, color=colordef, title="Murrey Math Oscillator", style=plot.style_columns, transp = 60)
6398
plot(0, title="Zero Line", color=color.gray, linewidth=4)
@@ -76,4 +111,4 @@ fill (p3,p4, color = color.lime)
76111

77112
// Bar Color Oversold and Overbought
78113
bcolor = bc == 1 ? colordef : na
79-
barcolor(bcolor)
114+
barcolor(bcolor)

0 commit comments

Comments
 (0)