#### BenTen

##### Administrative

**Staff**

**VIP**

Hello, Murrey Math lovers, Thanks for those who showed interest on this. Based on a request, I have updated the plot / candle coloring, for Version - 2. This has been in the queue for a while. There was a Glitch found with the Multiplier. Will Fix in the next version. The Current Version (and the previous version) only supports 1/8 fractions. Will not support 0.25. The code needs to be updated, to automate the fractal line glitches for other ratios, Planned for future update. Good Luck and Enjoy the Colorful Oscillator. Please keep your suggestions flowing. Lets make it better.

**Script #1: Simple. No lower study. Just paint bars (green = bullish and red = bearish)**

Code:

```
# Murrey's Math Oscillator
# Assembled by BenTen at useThinkScript.com
# Converted from https://www.tradingview.com/script/VQPnbiQd-UCS-Murrey-s-Math-Oscillator-V2/
# This is a stripped down or the original version. No lower study. Just simple paint bars.
input length = 100;
input mult = 0.125;
def hi = highest(high, length);
def lo = lowest(low, length);
def range = hi - lo;
def multiplier = (range) * mult;
def midline = lo + multiplier * 4;
def oscillator = (close - midline) / (range / 2);
def a = oscillator > 0 and oscillator<mult*2;
def b = oscillator > 0 and oscillator < mult*4;
def c = oscillator > 0 and oscillator < mult*6;
def d = oscillator > 0 and oscillator < mult*8;
def z = oscillator < 0 and oscillator > -mult*2;
def y = oscillator < 0 and oscillator > -mult*4;
def x = oscillator < 0 and oscillator > -mult*6;
def w = oscillator < 0 and oscillator > -mult*8;
assignPriceColor(if a or b or c or d then color.green else if w or z or y or x then color.red else color.white);
```

**Script #2: Just paint bars. No lower study. But with color variations added.**

Code:

```
# Murrey's Math Oscillator
# Assembled by BenTen at useThinkScript.com
# Converted from https://www.tradingview.com/script/VQPnbiQd-UCS-Murrey-s-Math-Oscillator-V2/
# This is also a stripped down version. But it has color variations for paint bars.
input length = 100;
input mult = 0.125;
def hi = highest(high, length);
def lo = lowest(low, length);
def range = hi - lo;
def multiplier = (range) * mult;
def midline = lo + multiplier * 4;
def oscillator = (close - midline) / (range / 2);
def a = oscillator > 0 and oscillator<mult*2;
def b = oscillator > 0 and oscillator < mult*4;
def c = oscillator > 0 and oscillator<mult*6;
def d = oscillator > 0 and oscillator < mult*8;
def z = oscillator < 0 and oscillator > -mult*2;
def y = oscillator < 0 and oscillator > -mult*4;
def x = oscillator < 0 and oscillator > -mult*6;
def w = oscillator < 0 and oscillator > -mult*8;
assignPriceColor(if a then CreateColor(173, 255, 47) else if b then CreateColor(50, 205, 50) else if c then CreateColor(60, 179, 113) else if d then CreateColor(0, 128, 0) else if z then CreateColor(205, 92, 92) else if y then CreateColor(250, 128, 114) else if x then CreateColor(255, 160, 122) else if w then CreateColor(255, 0, 0) else color.white);
```

**Script #3: Complete version. Just like the original script from TradingView.**

Code:

```
# Murrey's Math Oscillator
# Assembled by BenTen at useThinkScript.com
# Converted from https://www.tradingview.com/script/VQPnbiQd-UCS-Murrey-s-Math-Oscillator-V2/
declare lower;
input length = 100;
input mult = 0.125;
def hi = highest(high, length);
def lo = lowest(low, length);
def range = hi - lo;
def multiplier = (range) * mult;
def midline = lo + multiplier * 4;
def oscillator = (close - midline) / (range / 2);
def a = oscillator > 0 and oscillator<mult*2;
def b = oscillator > 0 and oscillator < mult*4;
def c = oscillator > 0 and oscillator<mult*6;
def d = oscillator > 0 and oscillator < mult*8;
def z = oscillator < 0 and oscillator > -mult*2;
def y = oscillator < 0 and oscillator > -mult*4;
def x = oscillator < 0 and oscillator > -mult*6;
def w = oscillator < 0 and oscillator > -mult*8;
plot histogram = oscillator;
histogram.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
histogram.AssignValueColor(if a then CreateColor(173, 255, 47) else if b then CreateColor(50, 205, 50) else if c then CreateColor(60, 179, 113) else if d then CreateColor(0, 128, 0) else if z then CreateColor(205, 92, 92) else if y then CreateColor(250, 128, 114) else if x then CreateColor(255, 160, 122) else if w then CreateColor(255, 0, 0) else color.white);
plot upper_l1 = mult*6;
plot upper_l2 = mult*8;
plot lower_l1 = -mult*6;
plot lower_l2 = -mult*8;
upper_l1.AssignValueColor(color.gray);
upper_l2.AssignValueColor(color.gray);
lower_l1.AssignValueColor(color.gray);
lower_l2.AssignValueColor(color.gray);
AddCloud(upper_l1, upper_l2, color.orange, color.orange);
AddCloud(lower_l1, lower_l2, color.lime, color.lime);
#assignPriceColor(if a or b or c or d then color.green else if w or z or y or x then color.red else color.white);
assignPriceColor(if a then CreateColor(173, 255, 47) else if b then CreateColor(50, 205, 50) else if c then CreateColor(60, 179, 113) else if d then CreateColor(0, 128, 0) else if z then CreateColor(205, 92, 92) else if y then CreateColor(250, 128, 114) else if x then CreateColor(255, 160, 122) else if w then CreateColor(255, 0, 0) else color.white);
```