Murrey Math lines Fluid version

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #175724 quote
    juansa
    Participant
    Junior

    Hello everybody,

    I need help with a script that is not very popular but in my opinion it is very important, currently there is a version which works in prt is quite chaotic, but in the Tradingview platform it works more fluid.

     

    Code that i found: https://www.prorealcode.com/topic/niveles-de-murrey-math/

    
    
    //Trading view Code:
    
    //@version=4
    // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
    // © ceyhun
    
    //Original Code https://tr.tradingview.com/v/x8ZRlmof/
    
    study("Murrey Math Lines", title="MML", overlay=true)
    //-- get inputs
    string res1 = input(title="Resolution",type=input.resolution,defval="D")
    int frame = input(defval=64, title="Frame Size", type=input.integer, minval=8, maxval=256)
    float mult = input(defval=1.5, title="Frame Multiplier", type=input.float, minval=1.0, maxval=2.0, step=0.5)
    bool wicks = input(defval=true, title="Ignore Wicks?")
    
    //-- defines
    logTen = log(10)
    log8 = log(8)
    log2 = log(2)
    lookback = round(frame * mult)
    
    ss = syminfo.tickerid
    
    string res = res1=="" ? timeframe.period : res1
    
    o = security(ss, res, open)
    c = security(ss, res, close)
    h = security(ss, res, high)
    l = security(ss, res, low)
    
    uPrice = wicks == true ? max(o, c) : h
    lPrice = wicks == true ? min(o, c) : l
    
    //-- find highest/lowest price over specified lookback
    vLow1 = lowest(lPrice, lookback)
    vHigh1 = highest(uPrice, lookback)
    vLow = security(ss, res, vLow1)
    vHigh = security(ss, res, vHigh1)
    vDist = vHigh - vLow
    //-- if low price is < 0 then adjust accordingly
    tmpHigh = vLow < 0 ? 0 - vLow : vHigh
    tmpLow = vLow < 0 ? 0 - vLow - vDist : vLow
    
    //-- determine if price shift is in place
    shift = vLow < 0 ? true : false
    
    //-- calculate scale frame
    sfVar = log(0.4 * tmpHigh) / logTen - floor(log(0.4 * tmpHigh) / logTen)
    SR = tmpHigh > 25 ? 
    sfVar > 0 ? exp(logTen * (floor(log(0.4 * tmpHigh) / logTen) + 1)) : 
    exp(logTen * floor(log(0.4 * tmpHigh) / logTen)) : 
    100 * exp(log8 * floor(log(0.005 * tmpHigh) / log8))
    nVar1 = log(SR / (tmpHigh - tmpLow)) / log8
    nVar2 = nVar1 - floor(nVar1)
    N = nVar1 <= 0 ? 0 : nVar2 == 0 ? floor(nVar1) : floor(nVar1) + 1
    
    //-- calculate scale interval and temporary frame top and bottom
    SI = SR * exp(-N * log8)
    M = floor(1.0 / log2 * log((tmpHigh - tmpLow) / SI) + 0.0000001)
    I = round((tmpHigh + tmpLow) * 0.5 / (SI * exp((M - 1) * log2)))
    
    Bot = (I - 1) * SI * exp((M - 1) * log2)
    Top = (I + 1) * SI * exp((M - 1) * log2)
    
    //-- determine if frame shift is required
    doShift = tmpHigh - Top > 0.25 * (Top - Bot) or Bot - tmpLow > 0.25 * (Top - Bot)
    
    ER = doShift == true ? 1 : 0
    
    MM = ER == 0 ? M : ER == 1 and M < 2 ? M + 1 : 0
    NN = ER == 0 ? N : ER == 1 and M < 2 ? N : N - 1
    
    //-- recalculate scale interval and top and bottom of frame, if necessary
    finalSI = ER == 1 ? SR * exp(-NN * log8) : SI
    finalI = ER == 1 ? round((tmpHigh + tmpLow) * 0.5 / (finalSI * exp((MM - 1) * log2))) : I
    finalBot = ER == 1 ? (finalI - 1) * finalSI * exp((MM - 1) * log2) : Bot
    finalTop = ER == 1 ? (finalI + 1) * finalSI * exp((MM - 1) * log2) : Top
    
    //-- determine the increment
    Increment = (finalTop - finalBot) / 8
    
    //-- determine the absolute top
    absTop = shift == true ? -(finalBot - 3 * Increment) : finalTop + 3 * Increment
    
    //-- create our Murrey line variables based on absolute top and the increment
    Plus38 = absTop
    Plus28 = absTop - Increment
    Plus18 = absTop - 2 * Increment
    EightEight = absTop - 3 * Increment
    SevenEight = absTop - 4 * Increment
    SixEight = absTop - 5 * Increment
    FiveEight = absTop - 6 * Increment
    FourEight = absTop - 7 * Increment
    ThreeEight = absTop - 8 * Increment
    TwoEight = absTop - 9 * Increment
    OneEight = absTop - 10 * Increment
    ZeroEight = absTop - 11 * Increment
    Minus18 = absTop - 12 * Increment
    Minus28 = absTop - 13 * Increment
    Minus38 = absTop - 14 * Increment
    
    //-- plot the lines and we are done
    plot(Plus38, title="+3/8 Imminent Bearish reversal", style=plot.style_circles, color=#008000, linewidth=1)
    plot(Plus28, title="+2/8 Extreme Overshoot conditions, can reverse anytime", style=plot.style_circles, color=#FF0000, linewidth=1)
    plot(Plus18, title="+1/8 Overshoot conditions", style=plot.style_circles, color=#808080, linewidth=1)
    plot(EightEight, title="8/8 Ultimate resistance, extremely overbought conditions", style=plot.style_circles, color=#0000FF, linewidth=2)
    plot(SevenEight, title="7/8 Weak level, place to stop and reverse", style=plot.style_circles, color=#808080, linewidth=1)
    plot(SixEight, title="6/8 Strong pivot reverse", style=plot.style_circles, color=#FF0000, linewidth=1)
    plot(FiveEight, title="5/8 Top of trading range", style=plot.style_circles, color=#008000, linewidth=1)
    plot(FourEight, title="4/8 Major support/resistance pivot point", style=plot.style_circles, color=#0000FF, linewidth=2)
    plot(ThreeEight, title="3/8 Bottom of trading range", style=plot.style_circles, color=#008000, linewidth=1)
    plot(TwoEight, title="2/8 Strong, Pivot, reverse", style=plot.style_circles, color=#FF0000, linewidth=1)
    plot(OneEight, title="1/8 Weak, place to stop and reverse", style=plot.style_circles, color=#808080, linewidth=1)
    plot(ZeroEight, title="0/8 Hardest line to fall below, oversold conditions", style=plot.style_circles, color=#0000FF, linewidth=2)
    plot(Minus18, title="-1/8 Oversold conditions", style=plot.style_circles, color=#808080, linewidth=1)
    plot(Minus28, title="-2/8 Extreme oversold conditions, can reverse anytime", style=plot.style_circles, color=#FF0000, linewidth=1)
    plot(Minus38, title="-3/8 Imminent bullish reversal ", style=plot.style_circles, color=#008000, linewidth=1)
    
    
    // Function outputs 1 when it's the first bar of the D/W/M/Y
    is_newbar(res) =>
    ch = 0
    if(res == 'Y')
    t = year(time('D'))
    ch := change(t) != 0 ? 1 : 0
    else
    t = time(res)
    ch := change(t) != 0 ? 1 : 0
    ch
    
    ////////////
    // ALERTS //
    ot = crossover(close, Plus38) or crossunder(close, Plus38) or crossover(close, Plus28) or crossunder(close, Plus28) or crossover(close, Plus18) or crossunder(close, Plus18) or crossover(close, EightEight) or crossunder(close, EightEight) or crossover(close, SevenEight) or crossunder(close, SevenEight) or crossover(close, SixEight) or crossunder(close, SixEight) or crossover(close, FiveEight) or crossunder(close, FiveEight) or crossover(close, FourEight) or crossunder(close, FourEight) or crossover(close, ThreeEight) or crossunder(close, ThreeEight) or crossover(close, TwoEight) or crossunder(close, TwoEight) or crossover(close, OneEight) or crossunder(close, OneEight) or crossover(close, ZeroEight) or crossunder(close, ZeroEight) or crossover(close, Minus18) or crossunder(close, Minus18) or crossover(close, Minus28) or crossunder(close, Minus28) or crossover(close, Minus38) or crossunder(close, Minus38)
    
    alertcondition(ot, title="Alert me when Octaves Change!", message="Octaves Change - Alert!")
    
    alertcondition(not is_newbar('D') and crossover(close, Plus38), "Crossover +3/8", "Crossover +3/8")
    alertcondition(not is_newbar('D') and crossover(close, Plus28), "Crossover +2/8", "Crossover +2/8")
    alertcondition(not is_newbar('D') and crossover(close, Plus18), "Crossover +1/8", "Crossover +1/8")
    alertcondition(not is_newbar('D') and crossover(close, EightEight), "Crossover 8/8", "Crossover 8/8")
    alertcondition(not is_newbar('D') and crossover(close, SevenEight), "Crossover 7/8", "Crossover 7/8")
    alertcondition(not is_newbar('D') and crossover(close, SixEight), "Crossover 6/8", "Crossover 6/8")
    alertcondition(not is_newbar('D') and crossover(close, FiveEight), "Crossover 5/8", "Crossover 5/8")
    alertcondition(not is_newbar('D') and crossover(close, FourEight), "Crossover 4/8", "Crossover 4/8")
    alertcondition(not is_newbar('D') and crossover(close, ThreeEight), "Crossover 3/8", "Crossover 3/8")
    alertcondition(not is_newbar('D') and crossover(close, TwoEight), "Crossover 2/8", "Crossover 2/8")
    alertcondition(not is_newbar('D') and crossover(close, OneEight), "Crossover 1/8", "Crossover 1/8")
    alertcondition(not is_newbar('D') and crossover(close, ZeroEight), "Crossover 0/8", "Crossover 0/8")
    alertcondition(not is_newbar('D') and crossover(close, Minus18), "Crossover -1/8", "Crossover -1/8")
    alertcondition(not is_newbar('D') and crossover(close, Minus28), "Crossover -2/8", "Crossover -2/8")
    alertcondition(not is_newbar('D') and crossover(close, Minus38), "Crossover -3/8", "Crossover -3/8")
    
    
    alertcondition(not is_newbar('D') and crossunder(close, Plus38), "Crossunder +3/8", "Crossunder +3/8")
    alertcondition(not is_newbar('D') and crossunder(close, Plus28), "Crossunder +2/8", "Crossunder +2/8")
    alertcondition(not is_newbar('D') and crossunder(close, Plus18), "Crossunder +1/8", "Crossunder +1/8")
    alertcondition(not is_newbar('D') and crossunder(close, EightEight), "Crossunder 8/8", "Crossunder 8/8")
    alertcondition(not is_newbar('D') and crossunder(close, SevenEight), "Crossunder 7/8", "Crossunder 7/8")
    alertcondition(not is_newbar('D') and crossunder(close, SixEight), "Crossunder 6/8", "Crossunder 6/8")
    alertcondition(not is_newbar('D') and crossunder(close, FiveEight), "Crossunder 5/8", "Crossunder 5/8")
    alertcondition(not is_newbar('D') and crossunder(close, ThreeEight), "Crossunder 4/8", "Crossunder 4/8")
    alertcondition(not is_newbar('D') and crossunder(close, FourEight), "Crossunder 3/8", "Crossunder 3/8")
    alertcondition(not is_newbar('D') and crossunder(close, TwoEight), "Crossunder 2/8", "Crossunder 2/8")
    alertcondition(not is_newbar('D') and crossunder(close, OneEight), "Crossunder 1/8", "Crossunder 1/8")
    alertcondition(not is_newbar('D') and crossunder(close, ZeroEight), "Crossunder 0/8", "Crossunder 0/8")
    alertcondition(not is_newbar('D') and crossunder(close, Minus18), "Crossunder -1/8", "Crossunder -1/8")
    alertcondition(not is_newbar('D') and crossunder(close, Minus28), "Crossunder -2/8", "Crossunder -2/8")
    alertcondition(not is_newbar('D') and crossunder(close, Minus38), "Crossunder -3/8", "Crossunder -3/8")
    murrey-tradingviewCapture.jpg murrey-tradingviewCapture.jpg
    #176183 quote
    Nicolas
    Keymaster
    Master
    #176184 quote
    juansa
    Participant
    Junior

    If I have already checked these versions, but the only one that comes close is this Murrey Niveles, it is not clear or fast like the one I propose since this indicator is very important the price action depending on the support / resistance level and it cannot be appreciated, Metatrader or Tradingview currently is much more friendly

     

    This

    capture-murrey-prt-forum.jpg capture-murrey-prt-forum.jpg
    #176191 quote
    robertogozzi
    Moderator
    Master

    Do not embed your pics within the post itself, rather use the SELECT button.

    Embedding pics will greatly impair the speed of the website.

    Thank you 🙂

    juansa thanked this post
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Murrey Math lines Fluid version


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
juansa @juansa Participant
Summary

This topic contains 3 replies,
has 3 voices, and was last updated by robertogozzi
4 years, 5 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 08/19/2021
Status: Active
Attachments: 2 files
Logo Logo
Loading...