OCEAN -- Natural Market Mirror and Adam Studies For ThinkOrSwim

mashume

Expert
VIP
Lifetime
Having spent a weekend reading Jim Sloman's Introduction to Ocean Theory, I wrote up a few indicators... I'm not convinced there's a lot of value in this as a technical indicator, but it has been talked about a lot recently and presented an interesting challenge (especially the Adam indicator).

The code for the Natural Market River is somewhere in the first one as well... I didn't find it useful enough to do anything with beyond commenting it out.

Code:
####################################################
#
#     OCEAN -- Natural Market Mirror Study
#
#        after Ocean Theory an Introduction
#                   by Jim Sloman
#                    (chapter 5)
#
#     by mashume for the UseThinkScript community
#                version 1.0 - 2022.12
#
#####################################################

declare lower;

input lookback = 40;
input label_against_nmm = yes;
# if this is yes, then the labels for o1, o2, etc... will be blue when above the NMM value and orange when below it.
# if this is no, then the labels for o1, o2, etc... will be blue when above 0 (zero) and orange when below.

script o {
    input n = 1;
    plot o = (((Log(close) - Log(GetValue(close, n))) / Sqrt(n)) * 1000);
}
;

def o1 = o(1) * 1000;
def o2 = o(2) * 1000;
def o3 = o(3) * 1000;
def o5 = o(5) * 1000;
def o8 = o(8) * 1000;
def o13 = o(13) * 1000;
def o21 = o(21) * 1000;
def o34 = o(34) * 1000;
def o55 = o(55) * 1000;

def nmm = (fold n = 1 to lookback with s = 0 do s + ((Log(close) - Log(GetValue(close, n))) / Sqrt(n)) * 1000000) / lookback;

plot NaturalMarketMirror = nmm;
NaturalMarketMirror.SetDefaultColor(Color.BLACK);
NaturalMarketMirror.SetLineWeight(2);

plot zero = 0;
zero.SetDefaultColor(Color.BLUE);

# def nmr = fold i = 1 to lookback with r do r + (Log(GetValue(close, i - 1)) - Log(GetValue(close, i))) * (Sqrt(i) - Sqrt(i - 1)) * 1000;

plot NaturalMarketMirrorSmoothed = ExpAverage(nmm, Floor(Sqrt(lookback)));
NaturalMarketMirrorSmoothed.SetDefaultColor(Color.gray);
NaturalMarketMirrorSmoothed.SetLineWeight(1);

def nmrk = if label_against_nmm == yes then nmm else 0;

AddLabel(yes, "  Mirror: " + Round(nmm, 0) + "  ", Color.BLACK);

AddLabel(yes, "  o1: " + Round(o1 * 1, 0) + "  ", if o1 > nmrk then Color.BLUE else if o1 < nmrk then Color.DARK_ORANGE else Color.DARK_GRAY);
AddLabel(yes, "  o2: " + Round(o2 * 1, 0) + "  ", if o2 > nmrk then Color.BLUE else if o2 < nmrk then Color.DARK_ORANGE else Color.DARK_GRAY);
AddLabel(yes, "  o3: " + Round(o3 * 1, 0) + "  ", if o3 > nmrk then Color.BLUE else if o3 < nmrk then Color.DARK_ORANGE else Color.DARK_GRAY);
AddLabel(yes, "  o5: " + Round(o5 * 1, 0) + "  ", if o5 > nmrk then Color.BLUE else if o5 < nmrk then Color.DARK_ORANGE else Color.DARK_GRAY);
AddLabel(yes, "  o8: " + Round(o8 * 1, 0) + "  ", if o8 > nmrk then Color.BLUE else if o8 < nmrk then Color.DARK_ORANGE else Color.DARK_GRAY);
AddLabel(yes, "  o13: " + Round(o13 * 1, 0) + "  ", if o13 > nmrk then Color.BLUE else if o13 < nmrk then Color.DARK_ORANGE else Color.DARK_GRAY);
AddLabel(yes, "  o21: " + Round(o21 * 1, 0) + "  ", if o21 > nmrk then Color.BLUE else if o21 < nmrk then Color.DARK_ORANGE else Color.DARK_GRAY);
AddLabel(yes, "  o34: " + Round(o34 * 1, 0) + "  ", if o34 > nmrk then Color.BLUE else if o34 < nmrk then Color.DARK_ORANGE else Color.DARK_GRAY);
AddLabel(yes, "  o55: " + Round(o55 * 1, 0) + "  ", if o55 > nmrk then Color.BLUE else if o55 < nmrk then Color.DARK_ORANGE else Color.DARK_GRAY);

plot ob = 1000;
ob.SetStyle(curve.SHORT_DASH);
ob.SetDefaultColor(color.blue);

plot os = -1000;
os.SetStyle(curve.SHORT_DASH);
os.SetDefaultColor(color.blue);

And this one from chapter 2
N.B You must set your expansion bars to the same number as you set the projection fior this one to work properly
Code:
####################################################
#
#                OCEAN -- Adam Study
#
#        after Ocean Theory an Introduction
#                   by Jim Sloman
#                    (chapter 2)
#
#     by mashume for the UseThinkScript community
#                version 1.0 - 2022.12
#
#####################################################

declare upper;

input projection = 25;

def barnum = barnumber();
def current_bar = highestAll(barnum);
def bars_from_current = current_bar - barnum;

def c = if bars_from_current[0] ==  projection then close else c[1];

def steady_close = c[- 2 * projection];

def future_bar_count = if !isNan(CLOSE) then 0 else future_bar_count[1] + 1;

def reversed_closes = if future_bar_count > 1 then getValue(close,(2* future_bar_count -1)) else double.nan;

def reversed_highs = if future_bar_count > 1 then getValue(high,(2* future_bar_count -1)) else double.nan;

def reversed_lows = if future_bar_count > 1 then getValue(low,(2* future_bar_count -1)) else double.nan;

def reversed_opens = if future_bar_count > 1 then getValue(open,(2* future_bar_count -1)) else double.nan;


def o = - (reversed_opens[-1] - steady_close) + steady_close;
def h = - (reversed_lows[-1] - steady_close) + steady_close;
def l = - (reversed_highs[-1] - steady_close) + steady_close;
def cl = - (reversed_closes[-1] - steady_close) + steady_close;

AddChart(high = h, low = l, open = cl, close = o, type=ChartType.BAR, growColor = Color.light_GRAY, fallColor = Color.light_GRAY, neutralColor = Color.light_GRAY);
I saw something like this for about $600 on the 'net while researching it. I decided I could do better.
if you prefer a line to candles, simply put this line of code somewhere near the end of the study:
Code:
plot ADAM = - (reversed_closes[-1] - steady_close) + steady_close;

Happy Trading, Happy New Year,
-mashume

Eye Candy

VQFHUP0.png
 
Last edited:
a big thank you for sharing with us. There is nothing plotted on the chart by the UPPER indicator. I must be making a mistake. Could you maybe provide more information regarding your comment "N.B You must set your expansion bars to the same number as you set the projection fior this one to work properly"

Thank you
 
a big thank you for sharing with us. There is nothing plotted on the chart by the UPPER indicator. I must be making a mistake. Could you maybe provide more information regarding your comment "N.B You must set your expansion bars to the same number as you set the projection fior this one to work properly"

Thank you
The first indicator is a lower (Natural Market Mirror), you're quite correct.

The second indicator above (ADAM) plots the light gray candles out into the future on the upper chart. These are the double-reflected candles for the proceeding n bars (as set by the projection input). They plot on the expansion area. Use them with a big grain of salt, as they aren't real prices... just a reflection. The need for setting the expansion bars to be the same as the projection variable is so that the correct (current) close price is marked by the script. There is a better way to do this, but I haven't implemented it...

-mashume
 
Having spent a weekend reading Jim Sloman's Introduction to Ocean Theory, I wrote up a few indicators... I'm not convinced there's a lot of value in this as a technical indicator, but it has been talked about a lot recently and presented an interesting challenge (especially the Adam indicator).

The code for the Natural Market River is somewhere in the first one as well... I didn't find it useful enough to do anything with beyond commenting it out.

Code:
####################################################
#
#     OCEAN -- Natural Market Mirror Study
#
#        after Ocean Theory an Introduction
#                   by Jim Sloman
#                    (chapter 5)
#
#     by mashume for the UseThinkScript community
#                version 1.0 - 2022.12
#
#####################################################

declare lower;

input lookback = 40;
input label_against_nmm = yes;
# if this is yes, then the labels for o1, o2, etc... will be blue when above the NMM value and orange when below it.
# if this is no, then the labels for o1, o2, etc... will be blue when above 0 (zero) and orange when below.

script o {
    input n = 1;
    plot o = (((Log(close) - Log(GetValue(close, n))) / Sqrt(n)) * 1000);
}
;

def o1 = o(1) * 1000;
def o2 = o(2) * 1000;
def o3 = o(3) * 1000;
def o5 = o(5) * 1000;
def o8 = o(8) * 1000;
def o13 = o(13) * 1000;
def o21 = o(21) * 1000;
def o34 = o(34) * 1000;
def o55 = o(55) * 1000;

def nmm = (fold n = 1 to lookback with s = 0 do s + ((Log(close) - Log(GetValue(close, n))) / Sqrt(n)) * 1000000) / lookback;

plot NaturalMarketMirror = nmm;
NaturalMarketMirror.SetDefaultColor(Color.BLACK);
NaturalMarketMirror.SetLineWeight(2);

plot zero = 0;
zero.SetDefaultColor(Color.BLUE);

# def nmr = fold i = 1 to lookback with r do r + (Log(GetValue(close, i - 1)) - Log(GetValue(close, i))) * (Sqrt(i) - Sqrt(i - 1)) * 1000;

plot NaturalMarketMirrorSmoothed = ExpAverage(nmm, Floor(Sqrt(lookback)));
NaturalMarketMirrorSmoothed.SetDefaultColor(Color.gray);
NaturalMarketMirrorSmoothed.SetLineWeight(1);

def nmrk = if label_against_nmm == yes then nmm else 0;

AddLabel(yes, "  Mirror: " + Round(nmm, 0) + "  ", Color.BLACK);

AddLabel(yes, "  o1: " + Round(o1 * 1, 0) + "  ", if o1 > nmrk then Color.BLUE else if o1 < nmrk then Color.DARK_ORANGE else Color.DARK_GRAY);
AddLabel(yes, "  o2: " + Round(o2 * 1, 0) + "  ", if o2 > nmrk then Color.BLUE else if o2 < nmrk then Color.DARK_ORANGE else Color.DARK_GRAY);
AddLabel(yes, "  o3: " + Round(o3 * 1, 0) + "  ", if o3 > nmrk then Color.BLUE else if o3 < nmrk then Color.DARK_ORANGE else Color.DARK_GRAY);
AddLabel(yes, "  o5: " + Round(o5 * 1, 0) + "  ", if o5 > nmrk then Color.BLUE else if o5 < nmrk then Color.DARK_ORANGE else Color.DARK_GRAY);
AddLabel(yes, "  o8: " + Round(o8 * 1, 0) + "  ", if o8 > nmrk then Color.BLUE else if o8 < nmrk then Color.DARK_ORANGE else Color.DARK_GRAY);
AddLabel(yes, "  o13: " + Round(o13 * 1, 0) + "  ", if o13 > nmrk then Color.BLUE else if o13 < nmrk then Color.DARK_ORANGE else Color.DARK_GRAY);
AddLabel(yes, "  o21: " + Round(o21 * 1, 0) + "  ", if o21 > nmrk then Color.BLUE else if o21 < nmrk then Color.DARK_ORANGE else Color.DARK_GRAY);
AddLabel(yes, "  o34: " + Round(o34 * 1, 0) + "  ", if o34 > nmrk then Color.BLUE else if o34 < nmrk then Color.DARK_ORANGE else Color.DARK_GRAY);
AddLabel(yes, "  o55: " + Round(o55 * 1, 0) + "  ", if o55 > nmrk then Color.BLUE else if o55 < nmrk then Color.DARK_ORANGE else Color.DARK_GRAY);

plot ob = 1000;
ob.SetStyle(curve.SHORT_DASH);
ob.SetDefaultColor(color.blue);

plot os = -1000;
os.SetStyle(curve.SHORT_DASH);
os.SetDefaultColor(color.blue);

And this one from chapter 2
N.B You must set your expansion bars to the same number as you set the projection fior this one to work properly
Code:
####################################################
#
#                OCEAN -- Adam Study
#
#        after Ocean Theory an Introduction
#                   by Jim Sloman
#                    (chapter 2)
#
#     by mashume for the UseThinkScript community
#                version 1.0 - 2022.12
#
#####################################################

declare upper;

input projection = 25;

def barnum = barnumber();
def current_bar = highestAll(barnum);
def bars_from_current = current_bar - barnum;

def c = if bars_from_current[0] ==  projection then close else c[1];

def steady_close = c[- 2 * projection];

def future_bar_count = if !isNan(CLOSE) then 0 else future_bar_count[1] + 1;

def reversed_closes = if future_bar_count > 1 then getValue(close,(2* future_bar_count -1)) else double.nan;

def reversed_highs = if future_bar_count > 1 then getValue(high,(2* future_bar_count -1)) else double.nan;

def reversed_lows = if future_bar_count > 1 then getValue(low,(2* future_bar_count -1)) else double.nan;

def reversed_opens = if future_bar_count > 1 then getValue(open,(2* future_bar_count -1)) else double.nan;


def o = - (reversed_opens[-1] - steady_close) + steady_close;
def h = - (reversed_lows[-1] - steady_close) + steady_close;
def l = - (reversed_highs[-1] - steady_close) + steady_close;
def cl = - (reversed_closes[-1] - steady_close) + steady_close;

AddChart(high = h, low = l, open = cl, close = o, type=ChartType.BAR, growColor = Color.light_GRAY, fallColor = Color.light_GRAY, neutralColor = Color.light_GRAY);
I saw something like this for about $600 on the 'net while researching it. I decided I could do better.
if you prefer a line to candles, simply put this line of code somewhere near the end of the study:
Code:
plot ADAM = - (reversed_closes[-1] - steady_close) + steady_close;

Happy Trading, Happy New Year,
-mashume

Eye Candy[/h


Having spent a weekend reading Jim Sloman's Introduction to Ocean Theory, I wrote up a few indicators... I'm not convinced there's a lot of value in this as a technical indicator, but it has been talked about a lot recently and presented an interesting challenge (especially the Adam indicator).

The code for the Natural Market River is somewhere in the first one as well... I didn't find it useful enough to do anything with beyond commenting it out.

Code:
####################################################
#
#     OCEAN -- Natural Market Mirror Study
#
#        after Ocean Theory an Introduction
#                   by Jim Sloman
#                    (chapter 5)
#
#     by mashume for the UseThinkScript community
#                version 1.0 - 2022.12
#
#####################################################

declare lower;

input lookback = 40;
input label_against_nmm = yes;
# if this is yes, then the labels for o1, o2, etc... will be blue when above the NMM value and orange when below it.
# if this is no, then the labels for o1, o2, etc... will be blue when above 0 (zero) and orange when below.

script o {
    input n = 1;
    plot o = (((Log(close) - Log(GetValue(close, n))) / Sqrt(n)) * 1000);
}
;

def o1 = o(1) * 1000;
def o2 = o(2) * 1000;
def o3 = o(3) * 1000;
def o5 = o(5) * 1000;
def o8 = o(8) * 1000;
def o13 = o(13) * 1000;
def o21 = o(21) * 1000;
def o34 = o(34) * 1000;
def o55 = o(55) * 1000;

def nmm = (fold n = 1 to lookback with s = 0 do s + ((Log(close) - Log(GetValue(close, n))) / Sqrt(n)) * 1000000) / lookback;

plot NaturalMarketMirror = nmm;
NaturalMarketMirror.SetDefaultColor(Color.BLACK);
NaturalMarketMirror.SetLineWeight(2);

plot zero = 0;
zero.SetDefaultColor(Color.BLUE);

# def nmr = fold i = 1 to lookback with r do r + (Log(GetValue(close, i - 1)) - Log(GetValue(close, i))) * (Sqrt(i) - Sqrt(i - 1)) * 1000;

plot NaturalMarketMirrorSmoothed = ExpAverage(nmm, Floor(Sqrt(lookback)));
NaturalMarketMirrorSmoothed.SetDefaultColor(Color.gray);
NaturalMarketMirrorSmoothed.SetLineWeight(1);

def nmrk = if label_against_nmm == yes then nmm else 0;

AddLabel(yes, "  Mirror: " + Round(nmm, 0) + "  ", Color.BLACK);

AddLabel(yes, "  o1: " + Round(o1 * 1, 0) + "  ", if o1 > nmrk then Color.BLUE else if o1 < nmrk then Color.DARK_ORANGE else Color.DARK_GRAY);
AddLabel(yes, "  o2: " + Round(o2 * 1, 0) + "  ", if o2 > nmrk then Color.BLUE else if o2 < nmrk then Color.DARK_ORANGE else Color.DARK_GRAY);
AddLabel(yes, "  o3: " + Round(o3 * 1, 0) + "  ", if o3 > nmrk then Color.BLUE else if o3 < nmrk then Color.DARK_ORANGE else Color.DARK_GRAY);
AddLabel(yes, "  o5: " + Round(o5 * 1, 0) + "  ", if o5 > nmrk then Color.BLUE else if o5 < nmrk then Color.DARK_ORANGE else Color.DARK_GRAY);
AddLabel(yes, "  o8: " + Round(o8 * 1, 0) + "  ", if o8 > nmrk then Color.BLUE else if o8 < nmrk then Color.DARK_ORANGE else Color.DARK_GRAY);
AddLabel(yes, "  o13: " + Round(o13 * 1, 0) + "  ", if o13 > nmrk then Color.BLUE else if o13 < nmrk then Color.DARK_ORANGE else Color.DARK_GRAY);
AddLabel(yes, "  o21: " + Round(o21 * 1, 0) + "  ", if o21 > nmrk then Color.BLUE else if o21 < nmrk then Color.DARK_ORANGE else Color.DARK_GRAY);
AddLabel(yes, "  o34: " + Round(o34 * 1, 0) + "  ", if o34 > nmrk then Color.BLUE else if o34 < nmrk then Color.DARK_ORANGE else Color.DARK_GRAY);
AddLabel(yes, "  o55: " + Round(o55 * 1, 0) + "  ", if o55 > nmrk then Color.BLUE else if o55 < nmrk then Color.DARK_ORANGE else Color.DARK_GRAY);

plot ob = 1000;
ob.SetStyle(curve.SHORT_DASH);
ob.SetDefaultColor(color.blue);

plot os = -1000;
os.SetStyle(curve.SHORT_DASH);
os.SetDefaultColor(color.blue);

And this one from chapter 2
N.B You must set your expansion bars to the same number as you set the projection fior this one to work properly
Code:
####################################################
#
#                OCEAN -- Adam Study
#
#        after Ocean Theory an Introduction
#                   by Jim Sloman
#                    (chapter 2)
#
#     by mashume for the UseThinkScript community
#                version 1.0 - 2022.12
#
#####################################################

declare upper;

input projection = 25;

def barnum = barnumber();
def current_bar = highestAll(barnum);
def bars_from_current = current_bar - barnum;

def c = if bars_from_current[0] ==  projection then close else c[1];

def steady_close = c[- 2 * projection];

def future_bar_count = if !isNan(CLOSE) then 0 else future_bar_count[1] + 1;

def reversed_closes = if future_bar_count > 1 then getValue(close,(2* future_bar_count -1)) else double.nan;

def reversed_highs = if future_bar_count > 1 then getValue(high,(2* future_bar_count -1)) else double.nan;

def reversed_lows = if future_bar_count > 1 then getValue(low,(2* future_bar_count -1)) else double.nan;

def reversed_opens = if future_bar_count > 1 then getValue(open,(2* future_bar_count -1)) else double.nan;


def o = - (reversed_opens[-1] - steady_close) + steady_close;
def h = - (reversed_lows[-1] - steady_close) + steady_close;
def l = - (reversed_highs[-1] - steady_close) + steady_close;
def cl = - (reversed_closes[-1] - steady_close) + steady_close;

AddChart(high = h, low = l, open = cl, close = o, type=ChartType.BAR, growColor = Color.light_GRAY, fallColor = Color.light_GRAY, neutralColor = Color.light_GRAY);
I saw something like this for about $600 on the 'net while researching it. I decided I could do better.
if you prefer a line to candles, simply put this line of code somewhere near the end of the study:
Code:
plot ADAM = - (reversed_closes[-1] - steady_close) + steady_close;

Happy Trading, Happy New Year,
-mashume

Eye Candy

View attachment 16913
Thank you so much for sharing the Adam Theory Study. I've been using a modified version of Adam Theory for a while now that seems to work for me. I use a drawing tool to copy price movement and I rotate the price movement 180 degrees to create the Adam projection. However, I don't always start with the current price as taught in the book. Sometimes, I move it back in time and locate at least two turning points. I have attached a few photos of what I mean.
So my question to you is, is it possible to move (displace) the projection back instead of forward - much like the photos below?





 


Thank you so much for sharing the Adam Theory Study. I've been using a modified version of Adam Theory for a while now that seems to work for me. I use a drawing tool to copy price movement and I rotate the price movement 180 degrees to create the Adam projection. However, I don't always start with the current price as taught in the book. Sometimes, I move it back in time and locate at least two turning points. I have attached a few photos of what I mean.
So my question to you is, is it possible to move (displace) the projection back instead of forward - much like the photos below?
Interesting idea... I'll think about it and what can be done... Thanks for writing back that you find this one useful.

Would it be enough to have the point in time back where it starts be something manually set? I'm not sure about working from an automatically defined turning point... that might require a lot more thought.

-mashume
 
Interesting idea... I'll think about it and what can be done... Thanks for writing back that you find this one useful.

Would it be enough to have the point in time back where it starts be something manually set? I'm not sure about working from an automatically defined turning point... that might require a lot more thought.

-mashume
Manually setting the point back in time would work just fine since that's what I've been doing for years. I keep the same projection as long as it's following the market. When the market changes course, I make a new projection.
 
Last edited:
Comparing o1 thru o55 vs the nmrk is a complete waste of time if set label against Nmm == yes

Comparing Nmm vs the 0 line shows promise
 
Interesting idea... I'll think about it and what can be done... Thanks for writing back that you find this one useful.

Would it be enough to have the point in time back where it starts be something manually set? I'm not sure about working from an automatically defined turning point... that might require a lot more thought.

-mashume
I made a simple change to the script to reflect the correct projection per the Adam Theory book. I switched the open and close of the projected prices.

See images below.



 
mashume, I've been looking for the second one. Thanks.
But something seem to be off. I I'm not mistaken, this is for trading continuation patterns, and all I see is just a mirror of previous bars. Meaning: after a rise in price, instead of showing a continuation, you get the price stand "at the top" following a projected decline. And that also happens in the opposite situation. after a drop, you're always standing at the bottom (instead of the middle of the move), following a projected rise.

Here are the books:
https://forex-station.com/download/file.php?id=3233072
https://libgen.is/book/index.php?md5=A9EB67F7102CD704755ABF496DFE3CD5

In other words, its mirrored but not flipped.

You can check it in any chart in tradingview like this:
Use the "Bars Pattern" to copy a period of bars (could be all stock history) then right click on it and check "Mirrored" (that's what the current indicator is doing). Now if you also check "Flipped" you get what it should be like. A continuation pattern.

What do you think?
 
Last edited:
Having spent a weekend reading Jim Sloman's Introduction to Ocean Theory, I wrote up a few indicators... I'm not convinced there's a lot of value in this as a technical indicator, but it has been talked about a lot recently and presented an interesting challenge (especially the Adam indicator).

The code for the Natural Market River is somewhere in the first one as well... I didn't find it useful enough to do anything with beyond commenting it out.

Code:
####################################################
#
#     OCEAN -- Natural Market Mirror Study
#
#        after Ocean Theory an Introduction
#                   by Jim Sloman
#                    (chapter 5)
#
#     by mashume for the UseThinkScript community
#                version 1.0 - 2022.12
#
#####################################################

declare lower;

input lookback = 40;
input label_against_nmm = yes;
# if this is yes, then the labels for o1, o2, etc... will be blue when above the NMM value and orange when below it.
# if this is no, then the labels for o1, o2, etc... will be blue when above 0 (zero) and orange when below.

script o {
    input n = 1;
    plot o = (((Log(close) - Log(GetValue(close, n))) / Sqrt(n)) * 1000);
}
;

def o1 = o(1) * 1000;
def o2 = o(2) * 1000;
def o3 = o(3) * 1000;
def o5 = o(5) * 1000;
def o8 = o(8) * 1000;
def o13 = o(13) * 1000;
def o21 = o(21) * 1000;
def o34 = o(34) * 1000;
def o55 = o(55) * 1000;

def nmm = (fold n = 1 to lookback with s = 0 do s + ((Log(close) - Log(GetValue(close, n))) / Sqrt(n)) * 1000000) / lookback;

plot NaturalMarketMirror = nmm;
NaturalMarketMirror.SetDefaultColor(Color.BLACK);
NaturalMarketMirror.SetLineWeight(2);

plot zero = 0;
zero.SetDefaultColor(Color.BLUE);

# def nmr = fold i = 1 to lookback with r do r + (Log(GetValue(close, i - 1)) - Log(GetValue(close, i))) * (Sqrt(i) - Sqrt(i - 1)) * 1000;

plot NaturalMarketMirrorSmoothed = ExpAverage(nmm, Floor(Sqrt(lookback)));
NaturalMarketMirrorSmoothed.SetDefaultColor(Color.gray);
NaturalMarketMirrorSmoothed.SetLineWeight(1);

def nmrk = if label_against_nmm == yes then nmm else 0;

AddLabel(yes, "  Mirror: " + Round(nmm, 0) + "  ", Color.BLACK);

AddLabel(yes, "  o1: " + Round(o1 * 1, 0) + "  ", if o1 > nmrk then Color.BLUE else if o1 < nmrk then Color.DARK_ORANGE else Color.DARK_GRAY);
AddLabel(yes, "  o2: " + Round(o2 * 1, 0) + "  ", if o2 > nmrk then Color.BLUE else if o2 < nmrk then Color.DARK_ORANGE else Color.DARK_GRAY);
AddLabel(yes, "  o3: " + Round(o3 * 1, 0) + "  ", if o3 > nmrk then Color.BLUE else if o3 < nmrk then Color.DARK_ORANGE else Color.DARK_GRAY);
AddLabel(yes, "  o5: " + Round(o5 * 1, 0) + "  ", if o5 > nmrk then Color.BLUE else if o5 < nmrk then Color.DARK_ORANGE else Color.DARK_GRAY);
AddLabel(yes, "  o8: " + Round(o8 * 1, 0) + "  ", if o8 > nmrk then Color.BLUE else if o8 < nmrk then Color.DARK_ORANGE else Color.DARK_GRAY);
AddLabel(yes, "  o13: " + Round(o13 * 1, 0) + "  ", if o13 > nmrk then Color.BLUE else if o13 < nmrk then Color.DARK_ORANGE else Color.DARK_GRAY);
AddLabel(yes, "  o21: " + Round(o21 * 1, 0) + "  ", if o21 > nmrk then Color.BLUE else if o21 < nmrk then Color.DARK_ORANGE else Color.DARK_GRAY);
AddLabel(yes, "  o34: " + Round(o34 * 1, 0) + "  ", if o34 > nmrk then Color.BLUE else if o34 < nmrk then Color.DARK_ORANGE else Color.DARK_GRAY);
AddLabel(yes, "  o55: " + Round(o55 * 1, 0) + "  ", if o55 > nmrk then Color.BLUE else if o55 < nmrk then Color.DARK_ORANGE else Color.DARK_GRAY);

plot ob = 1000;
ob.SetStyle(curve.SHORT_DASH);
ob.SetDefaultColor(color.blue);

plot os = -1000;
os.SetStyle(curve.SHORT_DASH);
os.SetDefaultColor(color.blue);

And this one from chapter 2
N.B You must set your expansion bars to the same number as you set the projection fior this one to work properly
Code:
####################################################
#
#                OCEAN -- Adam Study
#
#        after Ocean Theory an Introduction
#                   by Jim Sloman
#                    (chapter 2)
#
#     by mashume for the UseThinkScript community
#                version 1.0 - 2022.12
#
#####################################################

declare upper;

input projection = 25;

def barnum = barnumber();
def current_bar = highestAll(barnum);
def bars_from_current = current_bar - barnum;

def c = if bars_from_current[0] ==  projection then close else c[1];

def steady_close = c[- 2 * projection];

def future_bar_count = if !isNan(CLOSE) then 0 else future_bar_count[1] + 1;

def reversed_closes = if future_bar_count > 1 then getValue(close,(2* future_bar_count -1)) else double.nan;

def reversed_highs = if future_bar_count > 1 then getValue(high,(2* future_bar_count -1)) else double.nan;

def reversed_lows = if future_bar_count > 1 then getValue(low,(2* future_bar_count -1)) else double.nan;

def reversed_opens = if future_bar_count > 1 then getValue(open,(2* future_bar_count -1)) else double.nan;


def o = - (reversed_opens[-1] - steady_close) + steady_close;
def h = - (reversed_lows[-1] - steady_close) + steady_close;
def l = - (reversed_highs[-1] - steady_close) + steady_close;
def cl = - (reversed_closes[-1] - steady_close) + steady_close;

AddChart(high = h, low = l, open = cl, close = o, type=ChartType.BAR, growColor = Color.light_GRAY, fallColor = Color.light_GRAY, neutralColor = Color.light_GRAY);
I saw something like this for about $600 on the 'net while researching it. I decided I could do better.
if you prefer a line to candles, simply put this line of code somewhere near the end of the study:
Code:
plot ADAM = - (reversed_closes[-1] - steady_close) + steady_close;

Happy Trading, Happy New Year,
-mashume

Eye Candy

View attachment 16913
I've been using the Natural Market Mirror to help with entries and exits when the two lines cross. I was wondering if you can add a breakout signal that I can turn off and on. Thanks
 
Last edited by a moderator:

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
294 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