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.
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
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:
Happy Trading, Happy New Year,
-mashume
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);
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
Last edited: