Mobius Chart Reader For ThinkOrSwim
https://usethinkscript.com/threads/trending-chart-setup-for-thinkorswim.10833/
https://usethinkscript.com/threads/trending-chart-setup-for-thinkorswim.10833/
Ruby:
# Chart Reader
# Mobius
# V01.06.2021
#Hint: Chart Reader gives an overall view of where price is in the current cycle.
# Combine this study with Trend Pivots, Pivot Array or Wolfe Pivots. Best signals are those there this indicator and a Pivot indicator both agree.
# Label added by ZupDog
# PaintBars option added by ZupDog
input paintBars = no;
input Label = yes;
input n1 = 21;
input n2 = 13;
input n3 = 200;
def h = high;
def l = low;
def c = close;
def x = barNumber();
def nan = double.nan;
def x0 = if isNaN(c[-1]) and !isNaN(c) then x else x0[1];
def sR = Max(h, c[1]) - Min(l, c[1]);
def lR = highest(h, 21) - lowest(l, 21);
def energy = Round(Log(sum( sR, 21) / lR) / log(21), 1);
def K = inertia(c - ((Highest(h, n1) + Lowest(l, n1)) /
2 + ExpAverage(c, n1)) /2, n1);
def D = ExpAverage(K, n2);
def sT = InertiaAll(c);
def diff = (K - D);
def compress = if Average(c, 20) + (2 * stDev(c, 20)) <
Average(c, 20) + (1.5 * Average(TrueRange(h, c, l), 20))
then 0
else nan;
def zero = 0;
def he = if energy >= .6 then highestAll(K) else nan;
def le = if energy <= .35 then lowestAll(K) else nan;
def countup = if Diff crosses above Zero then 1 else countup[1] + 1;
def countdn = if Diff crosses below Zero then -1 else countdn[1] - 1;
AddLabel(label, Concat("Chart_Reader ", if Diff > 0 then countup else countdn), if Diff > 0 then Color.CYAN else if Diff < 0 then Color.YELLOW else Color.WHITE );
# Changes color of bars
DefineGlobalColor("Positive", Color.BLUE);
DefineGlobalColor("Negative", Color.DARK_RED);
AssignPriceColor(if !paintBars
then Color.CURRENT
else if Diff >= 0
then GlobalColor("Positive")
else GlobalColor("Negative"));
# End Code
Last edited by a moderator: