Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=5
- indicator(title='UCS_Murrey\'s Math Oscillator', shorttitle='UCS_MMLO', overlay=false, precision=4)
- import loxx/loxxdynamiczone/3
- import jdehorty/KernelFunctions/2
- // Inputs
- length = input.int(432, minval=10, title='Look back Length')
- mult = input(0.186, title='Mutiplier; Only Supports 0.125 = 1/8')
- lines = input(true, title='Show Murrey Math Fractals')
- bc = input(false, title='Show Bar Colors Based On Oscillator')
- roundn(x, n) =>
- mult2 = 1
- if n != 0
- for i = 1 to math.abs(n)
- mult2 := mult2 * 10
- n >= 0 ? math.round(x * mult2) / mult2 : math.round(x / mult2) * mult2
- // Donchanin Channel
- test1 = array.new<float>(1441)
- test1.set(0,na)
- test2 = array.new<float>(1441)
- test2.set(0,na)
- len = input(0)
- for i = 1 to 144
- test1.set(i, ta.lowest(low,i))
- test2.set(i, ta.highest(high,i))
- loavg = array.avg(test1)
- hiavg = array.avg(test2)
- range_1 = hiavg - loavg
- multiplier = range_1 * mult
- midline = loavg + multiplier * 4
- oscillator = (close - midline) / (range_1 / 2)
- if oscillator > 1.125
- oscillator := 1.125
- if oscillator < -1.125
- oscillator := -1.125
- len2 = input(12)
- maosc = KernelFunctions.locallyPeriodic(oscillator,len2,len2,len2)
- col2 = color.gray
- if maosc[0]>maosc[1]
- col2 := color.green
- if maosc[0]<maosc[1]
- col2 := color.red
- a = oscillator > 0 and oscillator < mult * 2
- b = oscillator > 0 and oscillator < mult * 4
- c = oscillator > 0 and oscillator < mult * 6
- d = oscillator > 0 and oscillator < mult * 8
- z = oscillator < 0 and oscillator > -mult * 2
- y = oscillator < 0 and oscillator > -mult * 4
- x = oscillator < 0 and oscillator > -mult * 6
- w = oscillator < 0 and oscillator > -mult * 8
- colordef = a ? #00bcd4 : b ? #089981 : c ? #4caf50 : d ? #008000 : z ? #ffeb3b : y ? #ff9800 : x ? #f23645 : w ? #801922 : color.blue
- if oscillator == -1.125
- colordef := #1848cc
- if oscillator == 1.125
- colordef := #26c6da
- plot(oscillator, color=colordef, title='Murrey Math Oscillator', style=plot.style_columns, trackprice = true)
- a1 = plot(maosc, color= col2, style = plot.style_stepline, linewidth = 2)
- plot(0, title='Zero Line', color=color.new(color.white, 0), linewidth=2)
- plot(lines == 1 ? mult * 1 : na, title=' Positive 1', color=color.new(color.gray, 0), linewidth=1)
- plot(lines == 1 ? mult * 2 : na, title='First Positive Quadrant', color=color.new(color.white, 0), linewidth=1)
- plot(lines == 1 ? mult * 3 : na, title=' Positive 3', color=color.new(color.gray, 0), linewidth=1)
- plot(lines == 1 ? mult * 4 : na, title='Second Positive Quadrant', color=color.new(color.white, 0), linewidth=1)
- plot(lines == 1 ? mult * 5 : na, title=' Positive 5', color=color.new(color.gray, 0), linewidth=1)
- p3 = plot(lines == 1 ? mult * 6 : na, title='Third Positive Quadrant', color=color.new(color.white, 0), linewidth=2)
- plot(lines == 1 ? mult * 7 : na, title=' Positive 7', color=color.new(color.gray, 0), linewidth=1)
- p4 = plot(lines == 1 ? mult * 8 : na, title='Fourth Positive Quadrant', color=color.new(color.white, 0), linewidth=1)
- plot(lines == 1 ? -mult * 1 : na, title=' Negative 1', color=color.new(color.gray, 0), linewidth=1)
- plot(lines == 1 ? -mult * 2 : na, title='First Negative Quadrant', color=color.new(color.white, 0), linewidth=1)
- plot(lines == 1 ? -mult * 3 : na, title=' Negative 3', color=color.new(color.gray, 0), linewidth=1)
- plot(lines == 1 ? -mult * 4 : na, title='Second Negative Quadrant', color=color.new(color.white, 0), linewidth=1)
- plot(lines == 1 ? -mult * 5 : na, title=' Negative 5', color=color.new(color.gray, 0), linewidth=1)
- p2 = plot(lines == 1 ? -mult * 6 : na, title='Third Negative Quadrant', color=color.new(color.white, 0), linewidth=2)
- plot(lines == 1 ? -mult * 7 : na, title=' Negative 7', color=color.new(color.gray, 0), linewidth=1)
- p1 = plot(lines == 1 ? -mult * 8 : na, title='Fourth Negative Quadrant', color=color.new(color.white, 0), linewidth=1)
- fill(p1, p2, color=color.rgb(76, 175, 79, 77))
- fill(p3, p4, color=color.rgb(255, 82, 82, 77))
- // Bar Color Oversold and Overbought
- bcolor = bc == 1 ? colordef : na
- barcolor(bcolor)
- prob1 = input(0.99)
- prob2 = input(0.80)
- bl1 = loxxdynamiczone.dZone("buy", oscillator, prob1, 27)
- sl1 = loxxdynamiczone.dZone("sell", oscillator, prob1, 27)
- zli = loxxdynamiczone.dZone("sell", oscillator, prob2, 27)
- zli2 = loxxdynamiczone.dZone("buy", oscillator, prob2, 27)
- mid = loxxdynamiczone.dZone("buy", oscillator, .50, 27)
- plot(bl1, color = color.red, style = plot.style_stepline, linewidth = 2)
- plot(sl1, color = color.green, style = plot.style_stepline, linewidth = 2)
- a2 = plot(mid, color = color.white, style = plot.style_stepline, trackprice = true)
- col3 = color.gray
- stepoffup = false
- if oscillator[1]<=sl1[1] and oscillator[0]>sl1[0] and oscillator[1]<0
- stepoffup := true
- plotshape(stepoffup,style=shape.triangleup, color=color.green, location=location.bottom)
- if oscillator > maosc
- col3 := color.rgb(76, 175, 79, 77)
- if oscillator < maosc
- col3 := color.rgb(255, 82, 82, 77)
- if maosc > mid
- col3 := color.rgb(76, 175, 79, 77)
- if maosc < mid
- col3 := color.rgb(255, 82, 82, 77)
- fill(a1,a2,color = col3)
- hist0a = oscillator[0]
- hist1a = oscillator[1]
- hist2a = oscillator[2]
- hist3a = oscillator[3]
- hist4a = oscillator[4]
- hist0 = roundn(hist0a,4)
- hist1 = roundn(hist1a,4)
- hist2 = roundn(hist2a,4)
- hist3 = roundn(hist3a,4)
- hist4 = roundn(hist4a,4)
- var table hista0 = table.new(position.top_right, 1, 7)
- col4 = color.gray
- col5 = color.gray
- col6 = color.gray
- col7 = color.gray
- if hist0 > hist1
- col4 := color.green
- if hist0 < hist1
- col4 := color.red
- if hist1 > hist2
- col5 := color.green
- if hist1 < hist2
- col5 := color.red
- if hist2 > hist3
- col6 := color.green
- if hist2 < hist3
- col6 := color.red
- if hist3 > hist4
- col7 := color.green
- if hist3 < hist4
- col7 := color.red
- var mastate = "null"
- macol = color.gray
- if oscillator > maosc
- mastate := "above MA"
- macol := color.green
- if oscillator < maosc
- mastate := "below MA"
- macol := color.red
- var pstate = "null"
- pcol = color.gray
- if oscillator > mid
- pstate := "above 0.5"
- pcol := color.green
- if oscillator < mid
- pstate := "below 0.5"
- pcol := color.red
- var mapstate = "null"
- mapcol = color.gray
- if maosc > mid
- mapstate := "MA above 0.5"
- mapcol := color.green
- if maosc < mid
- mapstate := "MA below 0.5"
- mapcol := color.red
- if barstate.islast
- table.cell(hista0, 0, 0, str.tostring(hist0), text_color = col4)
- table.cell(hista0, 0, 1, str.tostring(hist1), text_color = col5)
- table.cell(hista0, 0, 2, str.tostring(hist2), text_color = col6)
- table.cell(hista0, 0, 3, str.tostring(hist3), text_color = col7)
- table.cell(hista0, 0, 4, str.tostring(mastate), text_color = macol)
- table.cell(hista0, 0, 5, str.tostring(pstate), text_color = pcol)
- table.cell(hista0, 0, 6, str.tostring(mapstate), text_color = mapcol)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement