Mobius Supertrend and Fractal Energy Adjusted RSI For ThinkOrSwim

amalia

Member
Mobius Supertrend and Fractal Energy Adjusted RSI For ThinkOrSwim
From BLT back in the day:
http://tos.mx/AzRX1J

Ruby:
#blt base multicolored candles exanded to for more colors
#Mobius Supertrend and Fractal Energy Adjusted RSI in Laguerre Time included
#Top half of candles color determined by Supertrend, bottom half determined by the Mobius Self-Adjusting RSI in Laguerre Time
#Dot in center of candle if FLE is above .618
#If you want to change colors, Grow Color is the effective color - look for GetColor within Addchart
#Hint: Set your candles in appearance tab to be all the same color

addlabel(yes, "Hollow Red/Green: Candle " , color.white);
addlabel(yes, "Dark Red/Green: RSI Laguerre ", color.yellow);
addlabel(yes, "Solid Red/Green: Supertrend", color.white);
addlabel(yes, "Dot: Fractal Energy", color.yellow);

input Up_Candle_type = ChartType.CANDLE;
input Down_Candle_Type = ChartType.CANDLE;
def o = open;
def h = high;
def l = low;
def c = close;

# Mobius
# SuperTrend
input AtrMult = 1.0;
input nATR = 4;
input AvgType = AverageType.HULL;

def ATR = MovingAverage(AvgType, TrueRange(high, close, low), nATR);
def UP = HL2 + (AtrMult * ATR);
def DN = HL2 + (-AtrMult * ATR);
def ST = if close < ST[1] then UP else DN;
def STUP = close < ST[1];


# RSI in Laguerre Time Self Adjusting With Fractal Energy
# Mobius
# V02.07.2014
# V03.06.15.2016
# Both Fractal Energy and RSI are defined

#Inputs:
input nFE = 13;#hint nFE: length for Fractal Energy calculation.
input RSI_Above = 0.80;
Assert(RSI_Above > 0, "'RSI' must be positive: " + RSI_Above);
# Variables:
def orsi;
def hrsi;
def lrsi;
def crsi;
def CU1;
def CU2;
def CU;
def CD1;
def CD2;
def CD;
def L0;
def L1;
def L2;
def L3;
def RSI;

# Calculations
orsi = (open + close[1]) / 2;
hrsi = Max(high, close[1]);
lrsi = Min(low, close[1]);
crsi = (o + h + l + close) / 4;
def gamma = Log(Sum((Max(high, close[1]) - Min(low, close[1])), nFE) / (Highest(high, nFE) - Lowest(low, nFE))) / Log(nFE);

L0 = (1 – gamma) * c + gamma * L0[1];
L1 = -gamma * L0 + L0[1] + gamma * L1[1];
L2 = -gamma * L1 + L1[1] + gamma * L2[1];
L3 = -gamma * L2 + L2[1] + gamma * L3[1];
if L0 >= L1
then {
    CU1 = L0 - L1;
    CD1 = 0;
} else {
    CD1 = L1 - L0;
    CU1 = 0;
}
if L1 >= L2
then {
    CU2 = CU1 + L1 - L2;
    CD2 = CD1;
} else {
    CD2 = CD1 + L2 - L1;
    CU2 = CU1;
}
if L2 >= L3
then {
    CU = CU2 + L2 - L3;
    CD = CD2;
} else {
    CU = CU2;
    CD = CD2 + L3 - L2;
}

RSI = if CU + CD <> 0 then CU / (CU + CD) else 0;

input charttype = ChartType.CANDLE;

def oo1;
def ll1;
def cc1;
def hh1;

if RSI > RSI_Above {
    oo1 =  if o <= c
           then c
           else if o >= c
           then o
           else Double.NaN;
    hh1 =  if o <= c
           then h
           else if o >= c
           then h
           else Double.NaN;
    ll1 =  if o <= c
           then c
           else if o > c
           then o
           else Double.NaN;
    cc1 =  if o <= c
           then o - (o - c) / 2.5
           else if o > c
           then o - (o - c) / 2.5
           else Double.NaN;
} else {
    oo1 = Double.NaN;
    hh1 = Double.NaN;
    ll1 = Double.NaN;
    cc1 = Double.NaN;
}
#createColor(0,204,51)
AddChart(growColor = Color.DARK_GREEN, fallColor = Color.GREEN, neutralColor = Color.GRAY, high = hh1, low = ll1, open = oo1, close = cc1, type = charttype);

def o1;
def l1_;
def c1;
def h1_;

if RSI < RSI_Above {
    o1  =  if o > c
           then c - (c - o) / 2
           else if o < c
           then c - (c - o) / 2
           else Double.NaN;
    h1_ =  if o > c
           then c
           else if o < c    
           then o
           else Double.NaN;
    l1_ =  if o > c
           then l
           else if o < c
           then l
           else Double.NaN;
    c1  =  if o > c
           then c
           else if o < c
           then o
           else Double.NaN;
} else {
    o1  = Double.NaN;
    h1_ = Double.NaN;
    l1_ = Double.NaN;
    c1  = Double.NaN;
}
#createcolor(255,0,51)
AddChart(growColor = Color.DARK_RED , fallColor = Color.GREEN, neutralColor = Color.GRAY, high = h1_, low = l1_, open = o1, close = c1, type = charttype);
def oo1a;
def ll1a;
def cc1a;
def hh1a;

if close > ST[1] {
    oo1a =  if o <= c
            then c
            else if o >= c
            then o
            else Double.NaN;
    hh1a =  if o <= c
            then h
            else if o >= c
            then h
            else Double.NaN;
    ll1a =  if o <= c
            then c
            else if o >= c
            then o
            else Double.NaN;
    cc1a =  if o <= c
            then o - (o - c) / 1.5
            else if o > c
            then o - (o - c) / 1.5
            else Double.NaN;
} else {
    oo1a = Double.NaN;
    hh1a = Double.NaN;
    ll1a = Double.NaN;
    cc1a = Double.NaN;
}
#createColor(0,204,51)
AddChart(growColor = Color.GREEN, fallColor = Color.GREEN, neutralColor = Color.GRAY, high = hh1a, low = ll1a, open = oo1a, close = cc1a, type = charttype);

def o1b;
def l1_b;
def c1b;
def h1_b;

if close < ST[1] {
    o1b  =  if o > c
            then c - (c - o) / 4
            else if o < c
            then c - (c - o) / 4
            else Double.NaN;
    h1_b =  if o > c
            then c
            else if o < c    
            then o
            else Double.NaN;
    l1_b =  if o > c
            then l
            else if o < c
            then l
            else Double.NaN;
    c1b  =  if o > c
            then c
            else if o < c
            then o
            else Double.NaN;
} else {
    o1b  = Double.NaN;
    h1_b = Double.NaN;
    l1_b = Double.NaN;
    c1b  = Double.NaN;
}
#createcolor(255,0,51)
AddChart(growColor = Color.RED , fallColor = Color.GREEN, neutralColor = Color.GRAY, high = h1_b, low = l1_b, open = o1b, close = c1b, type = charttype);

#Places Dot on cande when Fractal Energy > .618
plot GammaSignal = if gamma > .618 then HL2 else Double.NaN;
GammaSignal.SetDefaultColor(Color.WHITE);
GammaSignal.SetPaintingStrategy(PaintingStrategy.POINTS);
 
Last edited:

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
296 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