Murrey Math Harmonics for ThinkorSwim

horserider

horserider

Well-known member
VIP
Support/resistance lines computed by Murray math. Similiar to other S/R studies so try it out then choose whatever study works best for you.

Code:
# SJ_Murray'sMathHarmonics

#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 showOnlyToday = yes;

input timeFrame = {default DAY, "2 DAYS", "3 DAYS", "4 DAYS", WEEK, MONTH, "OPTEXP"};
def RangeHigh = high(period = "DAY")[0];
def RangeLow = low(period = "DAY")[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 TimeCondition = IsNaN(Close[-1]) and !IsNaN(close[0]);

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 = "DAY")[-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;
}

Level8.SetDefaultColor(color.RED);
Level8.SetStyle(curve.Short_Dash);
Level8.setLineWeight (4) ;
Level8.HideBubble();

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

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

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

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

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

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

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

Level0.SetDefaultColor(color.GREEN);
Level0.SetStyle(curve.Short_Dash);
Level0.setLineWeight (4) ;
Level0.HideBubble();
#AddChartBubble(TimeCondition ,MML0, "0/8", color.cyan, yes);
 
L

Lambert58

New member
Warehouse
Thank you for posting, Very appreciated and a big help.
 
J007RMC

J007RMC

Active member
2019 Donor
Warehouse
VIP
Interesting Ill give this a try I think 5min for me is best.
 
S

San

Member
2019 Donor
@horserider, I really appreciate you are posting valuable information. Is it possible to use this Support /Resistance for MTF ( Multi Time Frame analysis ) Example Monthly, Weekly, Hourly ,15mts, 5mts and 1 mts. I have tried to change time frame setting but its not work out for me.
 
A

Antares66

New member
I also noticed that changing the time frame to daily, weekly, monthly has no effects. The indicator stays unchanged.
Does someone know why? It would be nice to use it on a higher timeframe.
Thanks
 
T

tomsk

Well-known member
VIP
The study as written is based on a daily aggregation. Hence any chart you load most have aggregation periods of daily or less.
I have previously written on secondary aggregations, here is the link to read more about it

 
A

Antares66

New member
Would it be possible to include the premarket in the calculation?
 
R

Rhatten

New member
Thats not MMLs... MML its calculated based on bar count (on time based bars.. ie 64bars, 128, 256, 512bars and on a 15min, 1hour, 4hour, Daily ,weekly etc) and is user defined... Plus there are additional levels (+1/8, +2/8, -1/8, -2/8) and is calculated relative to swing pivots (not just today's or yesterdays range)... This is not even close...
 
horserider

horserider

Well-known member
VIP
@Rhatten I believe you are correct. It was done by somebody named SJ so not sure why he coded it that way. I find it difficult to see how someone could use it. It is finding the high and low and filling the range with the levels.
 
securedabag23

securedabag23

New member
2019 Donor
Warehouse
VIP
Hello,

I enjoyed using this indicator. Would any be able to create scan if a bar crosses below the 1/8 spot and above the 7/8 spot? I like to take a trade and exit around these areas. I attempted to do it myself, but no results came back. TIA
 
B

bobomatic

New member
Found this on the internets.. might be a true model of the indicator but not sure. I'm playing with it for now. Trying to figure out how to get the S/R labels to the left side of the chart. If you developer guru's can take it to another level, have at it.... Muchas Gracias.


Code:

Code:
# SJ_Murray'sMathHarmonics
def showOnlyToday = yes;
def RangeHigh = high(period = "DAY")[0];
def RangeLow = low(period = "DAY")[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 TimeCondition = IsNaN(Close[-1]) and !IsNaN(close[0]);
def MML8 = RangeHigh;
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 = "DAY")[-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 = MML8;
Level7 = MML7;
Level6 = MML6;
Level5 = MML5;
Level4 = MML4;
Level3 = MML3;
Level2 = MML2;
Level1 = MML1;
Level0 = MML0;
}
Level8.SetDefaultColor(color.cyan);
Level8.SetStyle(curve.Short_Dash);
Level8.HideBubble();
AddChartBubble(TimeCondition , Level8, "Top of Octave = 8/8ths: Hardest line to rise above (overbought)", color.cyan, yes);
Level7.SetDefaultColor(color.cyan);
Level7.SetStyle(curve.Short_Dash);
Level7.HideBubble();
AddChartBubble(TimeCondition , MML7, "7/8ths Fast Reversal line: weak",
color.yellow, yes);
Level6.SetDefaultColor(color.cyan);
Level6.SetStyle(curve.Short_Dash);
Level6.HideBubble();
AddChartBubble(TimeCondition , MML6, "6/8ths Pivot Reversal line: ", color.pink,
yes);
Level5.SetDefaultColor(color.cyan);
Level5.SetStyle(curve.Short_Dash);
Level5.HideBubble();
AddChartBubble(TimeCondition , MML5, "5/8ths Upper Trading Range: ",
color.green, yes);
Level4.SetDefaultColor(color.cyan);
Level4.SetStyle(curve.Short_Dash);
Level4.HideBubble();
AddChartBubble(TimeCondition ,MML4, "4/8ths Major Reversal line", color.cyan, yes);
Level3.SetDefaultColor(color.cyan);
Level3.SetStyle(curve.Short_Dash);
Level3.HideBubble();
AddChartBubble(TimeCondition ,MML3, "3/8ths Lower Trading Range: ", color.green, yes);
Level2.SetDefaultColor(color.cyan);
Level2.SetStyle(curve.Short_Dash);
Level2.HideBubble();
AddChartBubble(TimeCondition ,MML2, "2/8ths Pivot Reversal line:", color.pink, yes);
Level1.SetDefaultColor(color.cyan);
Level1.SetStyle(curve.Short_Dash);
Level1.HideBubble();
AddChartBubble(TimeCondition ,MML1, "1/8ths Fast Reversal line: weak", color.yellow, yes);
Level0.SetDefaultColor(color.cyan);
Level0.SetStyle(curve.Short_Dash);
Level0.HideBubble();
AddChartBubble(TimeCondition ,MML0, "0/8ths Baseline: Hardest line to fall below (oversold)", color.cyan, yes);
 
B

bobomatic

New member
@horserider Thanks, bummer, but I'm gonna work with it for tad to get a feel for it. BTW, is getting those labels on the left side of the chart a big deal?

Edit: I have the mq4 file I found for free but have no clue how to convert it. If anyone who knows how to do that and is interested, let me know.
 
Last edited:
horserider

horserider

Well-known member
VIP
Use the " n " input to move the bubbles to right or input a negative number to move left. You can get them off the chart plot if move right and use expansion. Well should work, try it to get what you want.
 
Thread starter Similar threads Forum Replies Date
R Questions 0
S Questions 8
C Questions 0

Top