Murrey's Math Trend System for ThinkorSwim

@Lambert58 Are you pretty familiar with murrey math? I have been checking into this and can't seem to figure out how the lines are technically supposed to be drawn. What defines the 0/8 and 8/8 range? Where do they start from, or in other words what defines the high-low range? From what I can tell it can't be a simple high-low range of a look back period of 100 like in this indicator because it doesn't allow +1/8, +2/8, -1/8, -2/8, etc. levels.
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Hey Horserider, good script. Works great for Day Trading! However, when I change the timeframe to Weekly the script does not work. I went into the script and changed the default to Weekly and it did not work either. What am I doing wrong? The MM levels stay in the Day setting.
 
@San @Antares66 @Ninja Bull Guess people want to input time frame for this. I see it was coded for "Day" so your efforts were ignored. Redid the code so give this one a try. May not be true MM Harmonics. Is SJ's version.

Code:
# SJ_Murray's Math Harmonics

# May not be true MM Harmonics.
#In the study by SJ all lines were cyan. Changed the line colors to what made sense to me so no real significance to line colors. Adjust them as you wish. #Horserider 12/20/2019

input showbubble = yes;
input showOnlyToday = yes;
input agg = aggregationPeriod.DAY;
def RangeHigh = high(period = agg)[0];
def RangeLow = low(period = agg)[0];
def RangeSize = AbsValue(RangeHigh - RangeLow);
def MMLevel8 = 8 / 8;
def MMLevel7 = 7 / 8;
def MMLevel6 = 6 / 8;
def MMLevel5 = 5 / 8;
def MMLevel4 = 4 / 8;
def MMLevel3 = 3 / 8;
def MMLevel2 = 2 / 8;
def MMLevel1 = 1 / 8;
def MMLevel0 = 0 / 8;



def MML7 = RangeLow + RangeSize * (MMLevel7);
def MML6 = RangeLow + RangeSize * (MMLevel6);
def MML5 = RangeLow + RangeSize * (MMLevel5);
def MML4 = RangeLow + RangeSize * (MMLevel4);
def MML3 = RangeLow + RangeSize * (MMLevel3);
def MML2 = RangeLow + RangeSize * (MMLevel2);
def MML1 = RangeLow + RangeSize * (MMLevel1);
def MML0 = RangeLow;

plot Level8;
plot Level7;
plot Level6;
plot Level5;
plot Level4;
plot Level3;
plot Level2;
plot Level1;
plot Level0;

if  showOnlyToday and !IsNaN(close(period = agg)[-1])
then {
Level8 = Double.NaN;
Level7 = Double.NaN;
Level6 = Double.NaN;
Level5 = Double.NaN;
Level4 = Double.NaN;
Level3 = Double.NaN;
Level2 = Double.NaN;
Level1 = Double.NaN;
Level0 = Double.NaN;
} else {
Level8 = RangeHigh;
Level7 = MML7;
Level6 = MML6;
Level5 = MML5;
Level4 = MML4;
Level3 = MML3;
Level2 = MML2;
Level1 = MML1;
Level0 = MML0;
}
def TimeCondition = IsNaN(Close[-1]) and !IsNaN(close[0]);

Level8.SetDefaultColor(color.RED);
Level8.SetStyle(curve.Short_Dash);
Level8.setLineWeight (4) ;
AddChartBubble(showbubble and TimeCondition ,RangeHigh, "8/8", color.red, yes);

Level7.SetDefaultColor(color.YELLOW);
Level7.SetStyle(curve.Short_Dash);
AddChartBubble(showbubble and TimeCondition , MML7, "7/8ths Fast Reversal line: weak",color.yellow, yes);

Level6.SetDefaultColor(color.YELLOW);
Level6.SetStyle(curve.Short_Dash);
AddChartBubble(showbubble and TimeCondition , MML6, "6/8", color.pink,yes);

Level5.SetDefaultColor(color.CYAN);
Level5.SetStyle(curve.Short_Dash);
AddChartBubble(showbubble and TimeCondition , MML5, "5/8ths Upper Trading Range: ",color.green, yes);

Level4.SetDefaultColor(color.BLUE);
Level4.SetStyle(curve.Short_Dash);
Level4.setLineWeight (4) ;
AddChartBubble(showbubble and TimeCondition ,MML4, "4/8", color.cyan, yes);

Level3.SetDefaultColor(color.CYAN);
Level3.SetStyle(curve.Short_Dash);
AddChartBubble(showbubble and TimeCondition ,MML3, "3/8ths Lower Trading Range: ", color.green, yes);

Level2.SetDefaultColor(color.YELLOW);
Level2.SetStyle(curve.Short_Dash);
AddChartBubble(showbubble and TimeCondition ,MML2, "2/8", color.pink, yes);

Level1.SetDefaultColor(color.YELLOW);
Level1.SetStyle(curve.Short_Dash);
AddChartBubble(showbubble and TimeCondition ,MML1, "1/8ths Fast Reversal line: weak", color.yellow, yes);

Level0.SetDefaultColor(color.GREEN);
Level0.SetStyle(curve.Short_Dash);
Level0.setLineWeight (4) ;
AddChartBubble(showbubble and TimeCondition ,MML0, "0/8", color.green, yes);
 
I've noticed in other codes that whenever Highest(price,length) and Lowest(price,length) are used, they're usually done like Highest(price,length)[1] and Lowest(price,length)[1]. Will keeping it as is without the brackets at the end cause it to repaint? Just want to make sure it doesn't repaint.
 
Yet another version of Murrey Math
Ruby:
# Murrey Math Lines
# Mobius
# V01.11.01.2017
# Chat Room Request

def h = high(period = aggregationPeriod.Day)[1];
def l = low(period = aggregationPeriod.Day)[1];
def sqH = sqr(sqrt(Round(h/10, 0) * 10));
def sqL = sqr(sqrt(Round(l/10, 0) * 10));
def Adj_sqL = if sqL >= l
              then sqr(sqrt(sqL))
              else if Adj_sqL[1] == sqH
              then fold i = 1 to 50
              while Adj_sqL[1] != sqH
              do sqr(Round(sqrt(AdJ_sqL[1]-1), 0))
              else if sqL != sqH
                   then sqL
          else Adj_sqL[1];
plot HIGH4 =  sqH; # (ultimate resistance)  = 8/8
plot HIGH3 = HIGH4 - ((sqH - sqL)/8); #(Strength test) = 7/8
plot HIGH2 = HIGH3 - ((sqH - sqL) / 8); #(Pivot / reverse) = 6/8
plot HIGH1 = HIGH2 - ((sqH - sqL) / 8); #(Inner range top) = 5/8
plot MIDPOINT = HIGH1 - ((sqH - sqL) / 8); #(Pivot point) = 4/8
plot LOW1 = MIDPOINT - ((sqH - sqL) / 8); #(Inner range bottom) = 3/8
plot LOW2 = LOW1 - ((sqH - sqL) / 8); #(Pivot  / reverse) = 2/8
plot LOW3 = LOW2 - ((sqH - sqL) / 8); #(Weakness test) = 1/8
plot LOW4 = sqL; #(Ultimate support)  = 0/8
# End Code Murrey Math Lines
 
Last edited:
It is raining Murrey Math, here is another:
Ruby:
#    Murrey Math Indicator with Adjustable Bubbles
#    Sept 16
#    some of the basics from the here and Yahoo user group,
#    SJ_MurrayMathFullRange / original on Yahoo -TOS
#    original notes potentially look like from StockJock,

#    Sept 18/11
#    Thanks to Eric, Kumobob, Richard Houser, and a whole bunch of guys @ thinkscripter.com
#    You guys really fly the TOS colors,
#    This is one of my first code postings to your site,
#    bring it back here as this is where some great users are,

#    I saw a Murray Math variation on a buddies system who uses AmiBroker,
#    did some quick checking on thinkscripter and yahoo, this is an update,
#    I'm not 100% sure of all the math, but it seems to match the Amibroker math,
#    and it seems to have a lot more functionality than they deliver,

#    R1V2
#    changed labels to make them smaller less intrusive,
#    added add//remove labels to take them away entirely,
#    added additional upper and lower dynamic ranges,
#    added today only Yes / No - try keep this screen clean,
#    added range to monitor (dynamic for the day as highs and lows are hit)
#    added timeframe, works in combinatin with monitor range,
#    added the Equity function for non - equity traders, (decimals),



#Hint Murray_Labels: will show all the lables,
#Hint Murray_OnlyToday: will display only today,
#Hint Murray_Autohide_Upper_Lower: will display the upper and lower potential support and resistance areas based on the current close reaching either the upper or lower pivot,
#Hint Murray_Range: specific time ranges to view,
#Hint Murray_timeFrame: this is important in combination with the range,
#Hint Murray_DataType: default is Equity so will be rounded to 2 decimal places, otherwise can use Forex, This is only used for S & R labels and easier screen presentation,
input Murray_Labels = Yes;
input Murray_OnlyToday = No;
input Murray_Range = {default "Regular Hours", "Today Opening", "Today HiLo", "Previous Range", "Screen HiLo"};
input Murray_timeFrame = {default Day, Week, Month, Year};
input Murray_DataType = {default "Equity", "Other"};

def Market_Open_Time = 0930;
def Market_Close_Time = 1615;

def day = GetDay();
def lastDay = GetLastDay();
def isToday = If(day == lastDay, 1, 0);
def shouldPlot = If(Murray_OnlyToday and isToday, 1, If(!Murray_OnlyToday, 1, 0));
def pastOpen = If((SecondsTillTime(Market_Open_Time) > 0), 0, 1);
def pastClose = If((SecondsTillTime(Market_Close_Time) > 0), 0, 1);
def marketOpen = If(pastOpen and !pastClose, 1, 0);
def firstBar = If (day[1] != day, day - 1, 0);


rec regHoursHigh = If(high > regHoursHigh[1] and marketOpen, high, If(marketOpen and !firstBar, regHoursHigh[1], high));

rec regHoursLow = If(low < regHoursLow[1] and marketOpen, low, If(marketOpen and regHoursLow[1] > 0 and !firstBar, regHoursLow[1], low));

def rangehigh;
def rangelow;
def type;

switch (Murray_Range) {
case "Previous Range":
    rangehigh = high(period = Murray_timeFrame)[1];
    rangelow  = low(period = Murray_timeFrame)[1];
    type = 1;
case "Today Opening":
    rangehigh = high(period = Murray_timeFrame);
    rangelow  = low(period = Murray_timeFrame);
    type = 2;
case "Regular Hours":
    rangehigh = regHoursHigh;
    rangelow = regHoursLow;
    type = 3;
case "Today HiLo":
    rangehigh = high(period = "day");
    rangelow = low(period = "day");
    type = 4;
case "Screen HiLo":
    rangehigh = HighestAll(high);
    rangelow = LowestAll(low);
    type = 5;
}


def RangeSize = AbsValue(rangehigh - rangelow);

def MMLevel8 = 8 / 8;
def MMLevel7 = 7 / 8;
def MMLevel6 = 6 / 8;
def MMLevel5 = 5 / 8;
def MMLevel4 = 4 / 8;
def MMLevel3 = 3 / 8;
def MMLevel2 = 2 / 8;
def MMLevel1 = 1 / 8;
def MMLevel0 = 0 / 8;

### if using Forex - remove the round function to get full decimal places,
# roundit(variable, 2) # number of decimels,

def MML8;
def MML7;
def MML6;
def MML5;
def MML4;
def MML3;
def MML2;
def MML1;
def MML0;
def UpperL2;
def UpperL1;
def LowerL1;
def LowerL2;

switch (Murray_DataType){
case "Equity":
    MML8 = rangehigh;
    MML7 = Round(rangelow + RangeSize * (MMLevel7), 1);
    MML6 = Round(rangelow + RangeSize * (MMLevel6), 1);
    MML5 = Round(rangelow + RangeSize * (MMLevel5), 1);
    MML4 = Round(rangelow + RangeSize * (MMLevel4), 1);
    MML3 = Round(rangelow + RangeSize * (MMLevel3), 1);
    MML2 = Round(rangelow + RangeSize * (MMLevel2), 1);
    MML1 = Round(rangelow + RangeSize * (MMLevel1), 1);
    MML0 = Round(rangelow, 2);
# added 2 upper and lower potential Murray S & R levels,
   UpperL2 = rangehigh + (RangeSize * 2 /8);
    UpperL1 = rangehigh + RangeSize / 8;
    LowerL1 = rangelow - RangeSize / 8;
    LowerL2 = rangelow - (RangeSize * 2 / 8);
case "Other":
    MML8 = rangehigh;
    MML7 = rangelow + RangeSize * (MMLevel7);
    MML6 = rangelow + RangeSize * (MMLevel6);
    MML5 = rangelow + RangeSize * (MMLevel5);
    MML4 = rangelow + RangeSize * (MMLevel4);
    MML3 = rangelow + RangeSize * (MMLevel3);
    MML2 = rangelow + RangeSize * (MMLevel2);
    MML1 = rangelow + RangeSize * (MMLevel1);
    MML0 = rangelow;
# added 2 upper and lower potential Murray S & R levels,
    UpperL2 = rangehigh + (RangeSize * 2 /8);
    UpperL1 = rangehigh + RangeSize / 8;
    LowerL1 = rangelow - RangeSize / 8;
    LowerL2 = rangelow - (RangeSize * 2 / 8);
}


plot Top;
plot Level7;
plot PivotUp;
plot Level5;
plot Mid;
plot Level3;
plot PivotDn;
plot Level1;
plot Base;


if Murray_OnlyToday
then {

    Top = Double.NaN;
    Level7 = Double.NaN;
    PivotUp = Double.NaN;
    Level5 = Double.NaN;
    Mid = Double.NaN;
    Level3 = Double.NaN;
    PivotDn = Double.NaN;
    Level1 = Double.NaN;
    Base = Double.NaN;

} else {

    Top = MML8;
    Level7 = MML7;
    PivotUp = MML6;
    Level5 = MML5;
    Mid = MML4;
    Level3 = MML3;
    PivotDn = MML2;
    Level1 = MML1;
    Base = MML0;
}

#plot UpperR2 = if type==1 then UpperL2 else Double.NaN;
#plot UpperR1 = if type==1 then UpperL1 else Double.NaN;
#plot LowerS1 = if type==1 then LowerL1 else Double.NaN;
#plot LowerS2 = if type==1 then LowerL2 else Double.NaN;

plot UpperR2 = UpperL2;
plot UpperR1 = UpperL1;
plot LowerS1 = LowerL1;
plot LowerS2 = LowerL2;

input n = 4;#Hint n: Move Chart Bubbles to right by "n" bars
def n1 = n - 1;
def TimeCondition = IsNaN(close[n1]) and !IsNaN(close[n]);

UpperR2.SetDefaultColor(Color.MAGENTA);
UpperR2.SetStyle(Curve.SHORT_DASH);
UpperR2.HideBubble();
AddChartBubble(Murray_Labels && TimeCondition , UpperL2[n], Concat("M-R2:", UpperL2[n]), Color.MAGENTA, yes);


UpperR1.SetDefaultColor(Color.GRAY);
UpperR1.SetStyle(Curve.SHORT_DASH);
UpperR1.HideBubble();
AddChartBubble(Murray_Labels && TimeCondition , UpperL1[n], Concat("M-R1:", UpperL1[n]), Color.GRAY, yes);

#8/8
Top.SetDefaultColor(Color.GRAY);
Top.SetStyle(Curve.LONG_DASH);
Top.HideBubble();
#AddChartBubble(Murray_Labels && TimeCondition , MML8[n], Concat("Top:", MML8[n]), Color.CYAN, yes);
AddChartBubble(Murray_Labels && TimeCondition , MML8[n], "8/8:" + astext(MML8[n]), Color.CYAN, yes);

#7/8
Level7.SetDefaultColor(Color.LIGHT_ORANGE);
Level7.SetStyle(Curve.SHORT_DASH);
Level7.HideBubble();
#AddChartBubble(Murray_Labels && TimeCondition , MML7[n], Concat("R:", MML7[n]), Color.LIGHT_ORANGE, yes);
AddChartBubble(Murray_Labels && TimeCondition , MML7[n], "7/8:" + astext(MML7[n]), Color.LIGHT_ORANGE, yes);

#6/8
PivotUp.SetDefaultColor(Color.PINK);
PivotUp.SetStyle(Curve.SHORT_DASH);
PivotUp.HideBubble();
#AddChartBubble(Murray_Labels && TimeCondition , MML6[n], Concat("P:", PivotUp), Color.PINK, yes);
AddChartBubble(Murray_Labels && TimeCondition , MML6[n], "6/8:" + astext(PivotUp), Color.PINK, yes);

#5/8
Level5.SetDefaultColor(Color.DARK_GREEN);
Level5.SetStyle(Curve.SHORT_DASH);
Level5.HideBubble();
#AddChartBubble(Murray_Labels && TimeCondition , MML5[n], Concat("R:", MML5[n]), Color.DARK_GREEN, yes);
AddChartBubble(Murray_Labels && TimeCondition , MML5[n], "5/8:" + astext(MML5[n]), Color.DARK_GREEN, yes);

#4/8
Mid.SetDefaultColor(Color.WHITE);
Mid.SetStyle(Curve.LONG_DASH);
Mid.HideBubble();
#AddChartBubble(Murray_Labels && TimeCondition , MML4[n], Concat("Mid:", MML4[n]), Color.WHITE, yes);
AddChartBubble(Murray_Labels && TimeCondition , MML4[n], "4/8:" + astext(MML4[n]), Color.WHITE, yes);

#3/8
Level3.SetDefaultColor(Color.DARK_GREEN);
Level3.SetStyle(Curve.SHORT_DASH);
Level3.HideBubble();
#AddChartBubble(Murray_Labels && TimeCondition , MML3[n], Concat("R:", MML3[n]), Color.DARK_GREEN, yes);
AddChartBubble(Murray_Labels && TimeCondition , MML3[n], "3/8:" + astext(MML3[n]), Color.DARK_GREEN, yes);

#2/8
PivotDn.SetDefaultColor(Color.PINK);
PivotDn.SetStyle(Curve.SHORT_DASH);
PivotDn.HideBubble();
#AddChartBubble(Murray_Labels && TimeCondition , MML2[n], Concat("P:", PivotDn[n]), Color.PINK, yes);
AddChartBubble(Murray_Labels && TimeCondition , MML2[n], "2/8:" + astext(PivotDn[n]), Color.PINK, yes);

#1/8
Level1.SetDefaultColor(Color.LIGHT_ORANGE);
Level1.SetStyle(Curve.SHORT_DASH);
Level1.HideBubble();
#AddChartBubble(Murray_Labels && TimeCondition , MML1[n], Concat("R:", MML1[n]), Color.LIGHT_ORANGE, yes);
AddChartBubble(Murray_Labels && TimeCondition , MML1[n], "1/8:" + astext(MML1[n]), Color.LIGHT_ORANGE, yes);

#0/8
Base.SetDefaultColor(Color.GRAY);
Base.SetStyle(Curve.SHORT_DASH);
Base.HideBubble();
#AddChartBubble(Murray_Labels && TimeCondition , MML0[n], Concat("Base:", MML0[n]), Color.CYAN, yes);
AddChartBubble(Murray_Labels && TimeCondition , MML0[n], "0/8:" + Astext(MML0[n]), Color.CYAN, yes);

LowerS1.SetDefaultColor(Color.GRAY);
LowerS1.SetStyle(Curve.SHORT_DASH);
LowerS1.HideBubble();
AddChartBubble(Murray_Labels && TimeCondition , LowerL1[n], Concat("M-S1:", LowerL1[n]), Color.GRAY, yes);


LowerS2.SetDefaultColor(Color.MAGENTA);
LowerS2.SetStyle(Curve.LONG_DASH);
LowerS2.HideBubble();
AddChartBubble(Murray_Labels && TimeCondition , LowerL2[n], Concat("M-S2:", LowerL2[n]), Color.MAGENTA, yes);


AddLabel(yes, Concat("*Murray- ", Concat(Murray_Range, Concat(" - ", Murray_timeFrame))),
if close > Level5 then Color.GREEN else
if close < Level3 then Color.RED else Color.GRAY );

#==============================================
 
Last edited:
After scouring the web, I have been unable to find a working Murray Math Lines for ThinkOrSwim for all time frames. Anyone know how to script this possibly?
Shorter-time-frime.jpg
 
Hello Wayne

Here is the Edgerater Script for the Murrey Math Osc:

Code:
hi:=HHV(High,length);
lo:=LLV(Low,length);
range:= hi - lo;
multiplier:= (range) * mult;
midline:= lo + multiplier * 4;
MMO : close - midline) / (range / 2),width2,ColorBlue;
MMOA: MA(MMO,Length2),Width2,ColorRed;
MX:=Max(MMO,MMOA);
MN:=Min(MMO,MMOA);
uZ1 : mult*6,Width2,ColorBlack;
uZ2 : mult*8,Width2,ColorBlack;
lZ1 : -mult*6,Width2,ColorBlack;
lZ2 : -mult*8,Width2,ColorBlack;
FillRgn(1,UZ1,UZ2),Brush#50FFA500;
FillRgn(1,LZ1,LZ2),Brush#50FFA500;
FillRgn(MMO>MMOA,MMO,MMOA),Brush#800000FF;
FillRgn(MMO<MMOA,MMO,MMOA),Brush#80FF0000;
FillRgn(MN>0,MN,0),Brush#200000FF;
FillRgn(MX<0,MX,0),Brush#20FF0000;

And here is the Edgerater code for HK Slow Stochastics:

Code:
K:=(Close-LLV(Low,LB))/(HHV(H,LB)-LLV(Low,LB))*100,Width2,ColorBlue;
D:Ma(K,N1),Width2,ColorGreen;
DS:MA(D,N2),Width2,ColorBlack;

WK:=(Close-LLV(Low,WLB))/(HHV(H,WLB)-LLV(Low,WLB))*100,Width2,ColorBlue;
WD:Ma(WK,N1),Width2,ColorBlue;
WDS:MA(WD,N2),Width2,ColorRed;

EightyLine:80,Width2,ColorRed;
FiftyLine:50,ColorBlack;
twentyLine:20,Width2,ColorGreen;

@SETHLINE(20,50,80);
FillRgn(D>DS,D,DS),Brush#300000FF;
FillRgn(D<DS,D,DS),Brush#30FF0000;

FillRgn(Min(D,DS)>80,Min(D,DS),80),Brush#50FFA500;
FillRgn(Max(D,DS)<20,Max(D,DS),20),Brush#7000FF00;

FillRgn(WD>WDS,WD,WDS),Brush#800000FF;
FillRgn(WD<WDS,WD,WDS),Brush#80FF0000;

FillRgn(Min(WD,WDS)>80,Min(WD,WDS),80),Brush#50FFA500;
FillRgn(Max(WD,WDS)<20,MAX(WD,WDS),20),Brush#7000FF00;

I cannot vouch for how TOS plots these indicators? But using Edgerater, the indicators line up very close to each other! just saying.
could not get code to work any suggestions
 
EKg9G3X.png

* I used confirmed candles in the code calculation to avoid repainting and added signals and bar color.
Author Message:
The Murray Math lines levels are determined within some principles of Gann levels and candlesticks formations. The Murray Math levels act pretty much like pivot and support/resistance areas.

1. Line 8/8 - 0/8 (Ultimate Support and Ultimate Resistance).
Those lines are the most strong concerning Support and resistance .

2. Line 7/8 (Weak, Place to Stop and Reverse).
This line is weak. If suddenly the price was going too fast and too far and stops around this line it means the price will reverse down very soon. If the price did not stop near this line this price will continue the movement to the line 8/8.
3. Line 1/8 (Weak, Place to Stop and Reverse).
This line is weak. If suddenly the price was going too fast and too far and stops around this line it means the price will reverse up very soon. If the price did not stop near this line this price will continue the movement down to the line 0/8.

4. Line 2/8 and 6/8 ( Pivot , Reverse)
Those two lines yield the line 4/8 only to the strength to reverse the price movement.

5. Line 5/8 (Top of Trading Range)
The price is spending the about 40% of the time on the movement between the lines 5/8 and 3/8. If the price is moving near line 5/8 and stopping near the line during the 10 - 12 days so it means that it is necessary to sell in this "bonus zone" (some people are doing like this) but if the price is keeping the tendency to stay above 5/8 line, so it means that the price will be above. But if the price is droping below 5/8 line it means that the price will continue falling to the next level of resistance.

6. Line 3/8 (Bottom of Trading Range).
If the price is below this line and in uptrend it means that it will be very difficult for the price to break this level. If the price broke this line during the uptrend and staying above during the 10- 12 days it means that the price will be above this line during the 40% of its time moving between this line and 5/8 line.

7. Line 4/8 (Major Support/Resistance Line).
It is the major line concerning support and resistance . This level is the better for the new sell or buy. It is the strong level of support of the price is above 4/8. It is the fine resistance line if the price is below this 4/8 line.

CODE:

CSS:
#//@Shizaru
#study("Murray Math Levels",shorttitle="MML_SH",overlay=true)
# Converted and mod by Sam4Cok#Samer800 - 12/2022

input Length = 64;#(64,title="Length")
input ColorBar = yes;
input ShowSignals = yes;
input showLines = no;
input ShowCloud = yes;
input ShowBand = yes;
def na = Double.NaN;
############## theme 1########################################
DefineGlobalColor("Sky1" , CreateColor(0, 221, 255));  # >=90
DefineGlobalColor("Sky2" , CreateColor(4, 188, 217));  # >=80
DefineGlobalColor("Sky3" , CreateColor(4, 156, 179));  # >=70
DefineGlobalColor("Sky4" , CreateColor(4, 127, 145));  # >=60
DefineGlobalColor("Sky5" , CreateColor(4, 103, 117));  # >=50
DefineGlobalColor("Magenta1" , CreateColor(216, 0, 255));  # >=40
DefineGlobalColor("Magenta2" , CreateColor(187, 4, 219));  # >=30
DefineGlobalColor("Magenta3" , CreateColor(155, 5, 181));  # >=20
DefineGlobalColor("Magenta4" , CreateColor(123, 3, 143));  # >=10
DefineGlobalColor("Magenta5" , CreateColor(100, 2, 117));  # >=0
############## theme 2########################################
DefineGlobalColor("Green1" , CreateColor(1,255,0)); # >=90
DefineGlobalColor("Green2" , CreateColor(5,217,4)); # >=80
DefineGlobalColor("Green4" , CreateColor(3,145,3)); # >=60
DefineGlobalColor("Green5" , CreateColor(2,117,2)); # >=50
DefineGlobalColor("Red1" , CreateColor(255,5,5));   # >=40
DefineGlobalColor("Red2" , CreateColor(214,6,6));   # >=30
DefineGlobalColor("Red4" , CreateColor(145,3,3));   # >=10
DefineGlobalColor("Red5" , CreateColor(117,2,2));   # >=0
def h = high[1]; def l = low[1]; def c = close[1]; def o = open[1];

def srcHi = (h+c+c) / 3;
def srcLo = (l+c+c) / 3;
def HiHi = Highest(srcHi, Length);
def LoLo = Lowest(srcLo, Length);

def h44 = HiHi + (HiHi - LoLo) / 8;
def h55 = h44 + (HiHi - LoLo) / 8;
def h33 = HiHi - (HiHi - LoLo) / 8;
def h22 = h33 - (HiHi - LoLo) / 8;
def h11 = h22 - (HiHi - LoLo) / 8;
def Mid = h11 - (HiHi - LoLo) / 8;
def L11 = Mid - (HiHi - LoLo) / 8;
def L22 = L11 - (HiHi - LoLo) / 8;
def L33 = L22 - (HiHi - LoLo) / 8;

def L44 = LoLo - (HiHi - LoLo) / 8;
def L55 = L44 - (HiHi - LoLo) / 8;

plot L5 = if !showLines then na else L55;
L5.SetDefaultColor(GlobalColor("Magenta1"));
plot L4 = if !showLines then na else L44;
L4.SetDefaultColor(GlobalColor("Magenta2"));
plot LL = if !ShowBand then na else LoLo;
LL.SetDefaultColor(Color.RED);
plot L3 = if !showLines then na else L33;
L3.SetDefaultColor(GlobalColor("Magenta3"));
plot L2 = if !showLines then na else L22;
L2.SetDefaultColor(GlobalColor("Magenta4"));
plot L1 = L11;
L1.SetDefaultColor(GlobalColor("Magenta5"));
L1.SetStyle(Curve.LONG_DASH);

def Trend = Average(Mid,Length) ;
plot MidLine = Average(Mid,2);
MidLine.AssignValueColor(if Mid>Trend then Color.CYAN else Color.MAGENTA);

plot H1 = h11;
H1.SetDefaultColor(GlobalColor("Sky5"));
H1.SetStyle(Curve.LONG_DASH);
plot H2 = if !showLines then na else h22;
H2.SetDefaultColor(GlobalColor("Sky4"));
plot H3 = if !showLines then na else h33;
H3.SetDefaultColor(GlobalColor("Sky3"));
plot HH = if !ShowBand then na else HiHi;
HH.SetDefaultColor(Color.GREEN);
plot H4 = if !showLines then na else h44;
H4.SetDefaultColor(GlobalColor("Sky2"));
plot H5 = if !showLines then na else h55;
H5.SetDefaultColor(GlobalColor("Sky1"));
#---- Signals
def SigUp = if (srcHi>Mid and Mid>Trend) then SigUp[1]+1 else 0;
def SigDn = if (srcLo<Mid and Mid<Trend) then SigDn[1]+1 else 0;
plot ArrUp = if !ShowSignals then na else if (SigUp==1 and highest(SigUp[1],9)<1 and highest(SigDn[1],2)<1) then low else na;
plot ArrDn = if !ShowSignals then na else if (SigDn==1 and highest(SigUp[1],2)<1 and highest(SigDn[1],9)<1) then high else na;
ArrUp.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
ArrDn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
ArrUp.SetDefaultColor(Color.WHITE);
ArrDn.SetDefaultColor(Color.DARK_ORANGE);
ArrUp.SetLineWeight(2);
ArrDn.SetLineWeight(2);
#--- Clouds
AddCloud(H1, L1, Color.DARK_GRAY);
AddCloud(If(!ShowCloud, na, H22),  H11,  GlobalColor("Sky5"), GlobalColor("Sky5"));
AddCloud(If(!ShowCloud, na, H33),  H22,  GlobalColor("Sky4"), GlobalColor("Sky4"));
AddCloud(If(!ShowCloud, na, H44),  H33,  GlobalColor("Sky3"), GlobalColor("Sky3"));
AddCloud(If(!ShowCloud, na, H55),  H44,  GlobalColor("Sky2"), GlobalColor("Sky2"));
AddCloud(If(!ShowCloud, na, L11),  L22,  GlobalColor("Magenta5"), GlobalColor("Magenta5"));
AddCloud(If(!ShowCloud, na, L22),  L33,  GlobalColor("Magenta4"), GlobalColor("Magenta4"));
AddCloud(If(!ShowCloud, na, L33),  L44,  GlobalColor("Magenta3"), GlobalColor("Magenta3"));
AddCloud(If(!ShowCloud, na, L44),  L55,  GlobalColor("Magenta2"), GlobalColor("Magenta2"));
#-- Bar Color
AssignPriceColor(if !ColorBar then Color.CURRENT else
                 if srcHi>H44 then GlobalColor("Green1")  else
                 if srcHi>H33 then GlobalColor("Green2")  else
                 if srcHi>H22 then GlobalColor("Green4")  else
                 if srcHi>H11 then GlobalColor("Green5")  else
                 if srcLo<L44 then GlobalColor("red1")  else
                 if srcLo<L33 then GlobalColor("red2")  else
                 if srcLo<L22 then GlobalColor("red4")  else
                 if srcLo<L11 then GlobalColor("red5") else Color.GRAY);

#---- END CODE
 
Last edited by a moderator:
After thoroughly scrutinizing each Murrey Math Line indicator individually before submitting the conversion request. They are entirely distinct from one from Tradingview.com.
 
After thoroughly scrutinizing each Murrey Math Line indicator individually before submitting the conversion request. They are entirely distinct from one from Tradingview.com.
check the below

CSS:
#// 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", shorttitle="MML", overlay=true)
# Converted by Sam4Cok@Samer800    - 05/2023
#//-- get inputs
input ShowLines = yes;
input useChartTimeframe = {default "Yes", "No"};
input ManualTimeframe   = AggregationPeriod.FIFTEEN_MIN;   # "Resolution"
input frameSize = 64;                                      # "Frame Size"
input FrameMultiplier = 1.5;                               # "Frame Multiplier"
input IgnoreWicks = yes;                                   # "Ignore Wicks?"

def na = Double.NaN;
#//-- defines
def logTen = Log(10);
def log8 = Log(8);
def log2 = Log(2);
def lookback = Round(frameSize * FrameMultiplier, 0);

def o;
def c;
def h;
def l;
switch (useChartTimeframe) {
case "Yes":
    o = open;
    c = close;
    h = high;
    l = low;
case "No":
    o = open(Period = ManualTimeframe);
    c = close(Period = ManualTimeframe);
    h = high(Period = ManualTimeframe);
    l = low(Period = ManualTimeframe);
}

def uPrice = if IgnoreWicks then Max(o, c) else h;
def lPrice = if IgnoreWicks then Min(o, c) else l;

#//-- find highest/lowest price over specified lookback
def vLow1 = Lowest(lPrice, lookback);
def vHigh1 = Highest(uPrice, lookback);
def vLow = vLow1;#security(ss, res, vLow1)
def vHigh = vHigh1;#security(ss, res, vHigh1)
def vDist = vHigh - vLow;
#//-- if low price is < 0 then adjust accordingly
def tmpHigh = if vLow < 0 then 0 - vLow else vHigh;
def tmpLow  = if vLow < 0 then 0 - vLow - vDist else vLow;

#//-- determine if price shift is in place
def shift = vLow < 0;

#//-- calculate scale frame
def sfVar = Log(0.4 * tmpHigh) / logTen - Floor(Log(0.4 * tmpHigh) / logTen);
def SR = if tmpHigh > 25 then
   if sfVar > 0 then Exp(logTen * (Floor(Log(0.4 * tmpHigh) / logTen) + 1)) else
   Exp(logTen * Floor(Log(0.4 * tmpHigh) / logTen)) else
   100 * Exp(log8 * Floor(Log(0.005 * tmpHigh) / log8));
def nVar1 = Log(SR / (tmpHigh - tmpLow)) / log8;
def nVar2 = nVar1 - Floor(nVar1);
def N = if nVar1 <= 0 then 0 else if nVar2 == 0 then Floor(nVar1) else Floor(nVar1) + 1;

#//-- calculate scale interval and temporary frame top and bottom
def SI = SR * Exp(-N * log8);
def M = Floor(1.0 / log2 * Log((tmpHigh - tmpLow) / SI) + 0.0000001);
def I = Round((tmpHigh + tmpLow) * 0.5 / (SI * Exp((M - 1) * log2)), 0);

def Bot = (I - 1) * SI * Exp((M - 1) * log2);
def Top = (I + 1) * SI * Exp((M - 1) * log2);

#//-- determine if frame shift is required
def doShift = tmpHigh - Top > 0.25 * (Top - Bot) or Bot - tmpLow > 0.25 * (Top - Bot);

def ER = if doShift then 1 else 0;

def MM = if ER == 0 then M else if ER == 1 and M < 2 then M + 1 else 0;
def NN = if ER == 0 then N else if ER == 1 and M < 2 then N else N - 1;

#//-- recalculate scale interval and top and bottom of frame, if necessary
def finalSI = if ER == 1 then SR * Exp(-NN * log8) else SI;
def finalI = if ER == 1 then Round((tmpHigh + tmpLow) * 0.5 / (finalSI * Exp((MM - 1) * log2)), 0) else I;
def finalBot = if ER == 1 then (finalI - 1) * finalSI * Exp((MM - 1) * log2) else Bot;
def finalTop = if ER == 1 then (finalI + 1) * finalSI * Exp((MM - 1) * log2) else Top;

#//-- determine the increment
def Increment = (finalTop - finalBot) / 8;

#//-- determine the absolute top
def absTop = if shift then -(finalBot - 3 * Increment) else finalTop + 3 * Increment;

#//-- create our Murrey line variables based on absolute top and the increment
def Plus38 = absTop;
def Plus28 = absTop - Increment;
def Plus18 = absTop - 2 * Increment;
def EightEight = absTop - 3 * Increment;
def SevenEight = absTop - 4 * Increment;
def SixEight = absTop - 5 * Increment;
def FiveEight = absTop - 6 * Increment;
def FourEight = absTop - 7 * Increment;
def ThreeEight = absTop - 8 * Increment;
def TwoEight = absTop - 9 * Increment;
def OneEight = absTop - 10 * Increment;
def ZeroEight = absTop - 11 * Increment;
def Minus18 = absTop - 12 * Increment;
def Minus28 = absTop - 13 * Increment;
def Minus38 = absTop - 14 * Increment;

#//-- plot the lines and we are done
plot P83 = if !ShowLines then na else Plus38;    # "+3/8 Imminent Bearish reversal"
plot P82 = if !ShowLines then na else Plus28;    # "+2/8 Extreme Overshoot conditions, can reverse anytime"
plot P81 = Plus18;                               # "+1/8 Overshoot conditions"
plot N88 = EightEight;                           # "8/8 Ultimate resistance, extremely overbought conditions"
plot N87 = SevenEight;                           # "7/8 Weak level, place to stop and reverse"
plot N86 = if !ShowLines then na else SixEight;  # "6/8 Strong pivot reverse"
plot N85 = FiveEight;                            # "5/8 Top of trading range"
plot N84 = FourEight;                            # "4/8 Major support/resistance pivot point"
plot N83 = ThreeEight;                           # "3/8 Bottom of trading range"
plot N82 = if !ShowLines then na else TwoEight;  # "2/8 Strong, Pivot, reverse"
plot N81 = OneEight;                             # "1/8 Weak, place to stop and reverse"
plot N80 = ZeroEight;                            # "0/8 Hardest line to fall below, oversold conditions"
plot M81 = Minus18;                              # "-1/8 Oversold conditions"
plot M82 = if !ShowLines then na else Minus28;   # "-2/8 Extreme oversold conditions, can reverse anytime"
plot M83 = if !ShowLines then na else Minus38;   # "-3/8 Imminent bullish reversal"

P81.SetDefaultColor(Color.DARK_RED);
P82.SetDefaultColor(Color.DARK_RED);
P83.SetDefaultColor(Color.DARK_RED);
M81.SetDefaultColor(Color.DARK_GREEN);
M82.SetDefaultColor(Color.DARK_GREEN);
M83.SetDefaultColor(Color.DARK_GREEN);

N80.SetDefaultColor(Color.GREEN);
N81.SetDefaultColor(Color.DARK_GREEN);
N82.SetDefaultColor(Color.DARK_GRAY);
N83.SetDefaultColor(Color.DARK_GRAY);
N84.SetDefaultColor(Color.GRAY);
N85.SetDefaultColor(Color.DARK_GRAY);
N86.SetDefaultColor(Color.DARK_GRAY);
N87.SetDefaultColor(Color.DARK_RED);
N88.SetDefaultColor(Color.RED);

P81.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
P82.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
P83.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
M81.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
M82.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
M83.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
N80.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
N81.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
N82.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
N83.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
N84.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
N85.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
N86.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
N87.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
N88.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

AddCloud(OneEight, Minus18, Color.DARK_GREEN);     # "Oversold Zone"
AddCloud(FiveEight, ThreeEight, Color.DARK_GRAY);  # "Balance Zone"
AddCloud(Plus18, SevenEight, Color.DARK_RED);      # "Overbought Zone"



#--- END of CODE
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
471 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top