RSI Laguerre with Fractal Energy for ThinkorSwim

@HighBredCloud If you like that colored version then use it. Over time learn how it reacts to the market. Time spent doing that is better than looking for what someone else may consider the best version. It is just a momentum indicator with its own way of displaying the data. I posted a comparison in a different topic but will show it here in case you did not see. I bet other studies would compare similarly.

2019-11-22-TOS-CHARTS2.png
 

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

Is there a version of the RSI Laguerre that allows for different aggregation periods? For example, add a 1 hour aggregation RSI Laguerre to a 15 minute chart.
 
@flyer01 Yes, @tomsk recently shared it here.

BenTen, thank you. I am beyond appreciative of information shared on this forum.

@BenTen @flyer01 There's been a lot of interest in MTF type of studies discussed on the site recently.
Many people here are already familiar with John Carter's Squeeze MTF, 10X MTF and even DMI MTF studies
However note that the sort of MTF being implemented in the RSI in Laguerre Time MTF I posted is different
The only way to find out those differences is to examine the underlying code.

I have summarized those findings here, please do have a read through.

https://usethinkscript.com/threads/rsi-in-laguerre-time-mtf-for-thinkorswim.1134/#post-10078
 
I'm slightly confused with the use of the scanner. I am trading on the 4hr (thus will be comparing the scanner output to 4hr charts) . . . so I assume that I need to update the default settings in the scanner from Study, 'Custom' row to read (on the far right), '4HR'? This would then show me stocks that have crossed above 0.2 sometime in the prior 2 bars?

Also, chart settings to include after-hours will confuse this output, correct? Thanks!
 
If you are looking at the 4 HR on the study, your scanner MUST reflect the same aggregation or you'll see very different results.
 
I apologize if this is a bit redundant. I think this script is amazing however I’m using white backgrounds on my charts and the red at the top and green at the bottom of the RSI Laguerre Script are in a pinkish and very lite green color. I’m no coder what so ever but I tried to adjust what I could but the only options to change colors are for the RSI and Fractual lines. Anyone know how I can get this resolved?
 
@jg6021jg Most of the studies posted here are for traders with dark background. If you're running white background, all is not lost. Just change the colors of the study to something that resonates with you. My assumption is that you're using the study that @markos shared entitled RSILg_FE_Gssn. Look for the color related statements in the study and change it accordingly

Code:
RSI.SetDefaultColor(Color.Cyan);
OS.SetDefaultColor(Color.RED);
OB.SetDefaultColor(Color.GREEN);
M.SetDefaultColor(Color.Gray);
FEh.SetDefaultColor(Color.GRAY);
FEl.SetDefaultColor(Color.GRAY);

AddCloud(0, OS, Color.RED, Color.RED);
AddCloud(OB, 1, Color.Green, Color.Green);
 
@tomsk

5KPEho2.png


Thank you for responding. I attempted to adjust the coloring of the OVERBOUGHT/OVERSOLD however thinkorswim doesn't name the colors or a darker or more dynamic color to replace the red or green in the code. I can still use it as it does show as a very pale green and red but it doesn't mesh as well with my overall charting.
 
I guess I am stupid or something but I can't for the life of me figure out how to make this scan for shorts and not just buys. Can someone point me the right direction, please.
 
I guess I am stupid or something but I can't for the life of me figure out how to make this scan for shorts and not just buys. Can someone point me the right direction, please.
Add this ## to the part of the code that you don’t want to use if your only looking for shorts only add ## to the buy and the scan will ignore that part of the code
 
Laguerre upper study with lines...buy/sell targets. This a favorite I've been using for two weeks one of the best studies I've come across. I added the advanced markets moves to it but little else.
Code:
#StudyName:     RSI_Laguerre_Lines_wTargets
#Version/Date:  v1 5/30/17                                           
#TOS.mx Link:
#Type:          [Study]                                               
#Description:   RSI in Laguerre Time MTF plotted on Upper chart
#Author:        jcseattle
#Copyright:     Copyright jcseattle/amalia 2016. All rights reserved.
#Copyleft:      This program is free software: you can redistribute it and/or modify
#               it under the terms of the GNU General Public License as published by
#               the Free Software Foundation, either version 3 of the License, or
#               (at your option) any later version. See <http://www.gnu.org/licenses/>
#Requested By:   ""
#History:       Ver  Date        Auth  Change
#First draft    v1   5/30/17     jcseattle - No changes
# Notes           :Based off original script in 
#                  RSI in Laguerre Time MTF Option_v3
#                  Mobius
#                  V02.07.2014
#                  translation of J Elher's code
# Annotation      : ""
# Trading Notes   : ""

#                                        Start Code 

def na = Double.NaN;
script R {
    input gamma              = .2;
    input usecandletype      = {candle_hybrid, default candle};
    input usehigheraggperiod = {default "Current", "Higher"};
    input outputformat       = {default Rounded, "Not Rounded"};
    ;#Hint outputformat: 'Not Rounded' is used for notes, bonds (eg: 109'110), forex, etc type format. 
    input atrlength          = 21;
    input agg                = AggregationPeriod.TWO_MIN;
    input overbought         = .8;
    input oversold           = .2;
    def o;
    def h;
    def l;
    def c;
    def CU1;
    def CU2;
    def CU;
    def CD1;
    def CD2;
    def CD;
    def L0;
    def L1;
    def L2;
    def L3;
    plot RSI;
    plot OS;
    plot OB;
    def error = usehigheraggperiod == usehigheraggperiod."Higher" and GetAggregationPeriod() > agg;
    switch (usehigheraggperiod) {
    case Current:
        if usecandletype == usecandletype.candle_hybrid {
            o = (open + close[1]) / 2;
            h = Max(high, close[1]);
            l = Min(low, close[1]);
            c = (o + h + l + close) / 4;
        } else {
            o = open;
            h = high;
            l = low;
            c = close;
        }
    case Higher:
        if error {
            o = Double.NaN;
            h = Double.NaN;
            l = Double.NaN;
            c = Double.NaN;
        } else {
            if usecandletype == usecandletype.candle_hybrid {
                o = (open(period = agg)     + close(period = agg)[1]) / 2;
                h = Max(high(period = agg)  , close(period = agg)[1]);
                l = Min(low(period = agg)   , close(period = agg)[1]);
                c = ((open(period = agg)    + close(period = agg)[1]) / 2 
            + Max(high(period = agg), close(period = agg)[1]) 
            + Min(low(period = agg) , close(period = agg)[1]) 
            + close(period = agg)) / 4;
            } else {
                o = open(period = agg);
                h = high(period = agg);
                l = low(period = agg);
                c = close(period = agg);
            }
        }
}
    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 IsNaN(close) then Double.NaN
      else if CU + CD <> 0
      then    CU / (CU + CD) else 0;
    OS  = if IsNaN(close)
      then Double.NaN else oversold;
    OB  = if IsNaN(close)
      then Double.NaN
      else overbought;
    def mid = if IsNaN(close) then Double.NaN else 0.5;
    def lineh = 1.2;
    def linel = -.2;
    
# End Code Basic RSI Laguerre - Author: Mobius

}

def Up = if R() crosses above R().OS then 1 else 0;
def u = if R() crosses above R().OB then 1 else 0;

def Dn = if R() crosses below R().OB then 1 else 0;
def d = if R() crosses below R().OS then 1 else 0;

def Green = if Up 
#or u 
then low else 0;
def Red = if Dn 
#or d 
then high else 0;

def showLines = 1;


def trendchange = if Green then low else if Red then high else trendchange[1];

def PL = if !IsNaN(trendchange) 
             then trendchange 
             else PL[1];

plot pivotLine = if PL > 0
                       then PL
                       else Double.NaN;
pivotLine.SetPaintingStrategy(PaintingStrategy.LINE);
pivotLine.SetHiding(!showLines);

input showArrows = yes;
plot ArrUp = if showArrows and Green then low else 0;
ArrUp.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
ArrUp.SetDefaultColor(Color.GREEN);

plot ArrDn = if showArrows and Red then high else 0;
ArrDn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
ArrDn.SetDefaultColor(Color.RED);

pivotLine.AssignValueColor(if R() < R().OB then Color.RED else if R() > R().OS then Color.GREEN else Color.BLACK);

input ShowLabels = yes;
#Multipliers for ATR targets
input firsttgt = 1.618;
input secondtgt = 3.447;
input thirdtgt = 4.25;
input ATRLength = 8;#default is 14

def agg = if GetAggregationPeriod() > AggregationPeriod.FIFTEEN_MIN then GetAggregationPeriod() else AggregationPeriod.FIFTEEN_MIN;#You can edit this to just (GetAggregationPeriod())
def ATR = Average(TrueRange(High(period = agg),Close(period = agg),Low(period = agg)),ATRLength);
addlabel(ShowLabels, "ATR = " + Round((ATR) / TickSize(),0)*TickSize(), Color.GRAY);

input showStrategy = yes;
def co = if PL[1] and R()[1] > R().OS[1] then 1 else 0;
def firstlongtarget = if co then (PivotLine + ATR*firsttgt) else 0;
def secondlongtarget = if co then (PivotLine + ATR*secondtgt) else 0;
def thirdlongtarget = if co then (PivotLine + ATR*thirdtgt) else 0;

def sto = if PL and R() < R().OB then 1 else 0;
def firstshorttarget = if sto then (PivotLine - ATR*firsttgt) else 0;
def secondshorttarget = if sto then (PivotLine - ATR*secondtgt) else 0;
def thirdshorttarget = if sto then (PivotLine - ATR*thirdtgt) else 0;


#    Internal Script Reference
#    Author: Mobius

    def LineLimit = 30;
    def Detrend = 0;
    def OnExpansion = yes;
    def data = firstlongtarget;
    def bar = 0;
    def ShowAllPlots = 0;
    def ThisBar = HighestAll(bar) - Detrend;
    def cLine   = if ShowAllPlots == 0 
            then if bar == ThisBar 
                 then data
                 else Double.NaN
            else data;
    def cond1 = CompoundValue(1, if IsNaN(data)
                                then cond1[1] 
                                else data, data);
    def P = if ShowAllPlots == 0 
            then if ThisBar - LineLimit <= bar
            then HighestAll(cLine)
            else Double.NaN
            else cLine;
    plot firstLTarget = if OnExpansion and 
                     IsNaN(data[-1]) 
                  then cond1 
                  else Double.NaN;
firstLTarget.SetDefaultColor(Color.GREEN);
addlabel(ShowLabels, if R() > R().OS then "Long Target = " + Round((firstLTarget) / TickSize(),0)*TickSize() else "", Color.GREEN);
AddChartBubble(IsNaN(close) and !isNaN(close[1]), 
               firstLTarget, 
              "First Target = " + Round((firstLTarget) / TickSize(),0)*TickSize(), 
               Color.GREEN, 
               yes);

def difflongtarget = if close < firstlongtarget then (firstlongtarget - close) else (close - firstlongtarget);
addLabel(ShowLabels, if R() > R().OS then "Diff 1st L tgt = " + (Round((difflongtarget) / TickSize(),0)*TickSize()) else "", Color.LIGHT_GREEN);


    def LineLimit3 = 30;
    def Detrend3 = 0;
    def OnExpansion3 = yes;
    def data3 = secondlongtarget;
    def bar3 = 0;
    def ShowAllPlots3 = 0;
    def ThisBar3 = HighestAll(bar) - Detrend;
    def cLine3   = if ShowAllPlots3 == 0 
            then if bar3 == ThisBar3 
                 then data3
                 else Double.NaN
            else data3;
    def cond3 = CompoundValue(1, if IsNaN(data3)
                                then cond3[1] 
                                else data3, data3);
    def P3 = if ShowAllPlots3 == 0 
            then if ThisBar3 - LineLimit3 <= bar3
            then HighestAll(cLine3)
            else Double.NaN
            else cLine3;
    plot secondLTarget = if OnExpansion3 and 
                     IsNaN(data3[-1]) 
                  then cond3 
                  else Double.NaN;
secondLTarget.SetDefaultColor(Color.GREEN);
addlabel(ShowLabels, if R() > R().OS then "2nd Long Target = " + Round((secondLTarget) / TickSize(),0)*TickSize() else "", Color.GREEN);
AddChartBubble(IsNaN(close) and !isNaN(close[1]), 
               secondLTarget, 
              "2nd Long Target = " + Round((secondLTarget) / TickSize(),0)*TickSize(), 
               Color.GREEN, 
               yes);

def difflongtarget2 = if close < secondlongtarget then (secondlongtarget - close) else (close - secondlongtarget);
addLabel(ShowLabels, if R() > R().OS then "Diff 2nd L tgt = " + Round((difflongtarget2) / TickSize(),0)*TickSize() else "", Color.LIGHT_GREEN);


    def LineLimit9 = 30;
    def Detrend9 = 0;
    def OnExpansion9 = yes;
    def data9 = thirdlongtarget;
    def bar9 = 0;
    def ShowAllPlots9 = 0;
    def ThisBar9 = HighestAll(bar9) - Detrend9;
    def cLine9   = if ShowAllPlots9 == 0 
            then if bar9 == ThisBar9 
                 then data9
                 else Double.NaN
            else data9;
    def cond9 = CompoundValue(1, if IsNaN(data9)
                                then cond9[1] 
                                else data9, data9);
    def P9 = if ShowAllPlots9 == 0 
            then if ThisBar9 - LineLimit9 <= bar9
            then HighestAll(cLine9)
            else Double.NaN
            else cLine9;
    plot thirdLTarget = if OnExpansion9 and 
                     IsNaN(data9[-1]) 
                  then cond9 
                  else Double.NaN;
thirdLTarget.SetDefaultColor(Color.GREEN);
addlabel(ShowLabels, if R() > R().OS then "3rd Long Target = " + Round((thirdLTarget) / TickSize(),0)*TickSize() else "", Color.GREEN);
AddChartBubble(IsNaN(close) and !isNaN(close[1]), 
              thirdLTarget, 
            "3rd Long Target = " + Round((thirdLTarget) / TickSize(),0)*TickSize(), 
               Color.GREEN, 
               yes);

def difflongtarget9 = if close < thirdlongtarget then (thirdlongtarget - close) else (close - thirdlongtarget);
addLabel(ShowLabels, if R() > R().OS then "Diff 3rd L tgt = " + Round((difflongtarget9) / TickSize(),0)*TickSize() else "", Color.LIGHT_GREEN);


    def LineLimit2 = 30;
    def Detrend2 = 0;
    def OnExpansion2 = yes;
    def data2 = firstshorttarget;
    def bar2 = 0;
    def ShowAllPlots2 = 0;
    def ThisBar2 = HighestAll(bar2) - Detrend2;
    def cLine2   = if ShowAllPlots2 == 0 
            then if bar2 == ThisBar2 
                 then data2
                 else Double.NaN
           else data2;
    def cond2 = CompoundValue(1, if IsNaN(data2)
                                then cond2[1] 
                                else data2, data2);
    def P2 = if ShowAllPlots2 == 0 
            then if ThisBar2 - LineLimit2 <= bar2
            then HighestAll(cLine2)
            else Double.NaN
            else cLine2;
    plot firstSTarget = if OnExpansion2 and 
                     IsNaN(data2[-1]) 
                  then cond2 
                  else Double.NaN;
firstSTarget.SetDefaultColor(Color.RED);
addlabel(ShowLabels, if R() < R().OB then "1st Short Target = " + Round((firstSTarget) / TickSize(),0)*TickSize() else "", Color.RED);
AddChartBubble(IsNaN(close) and !IsNaN(Close[1]),
                firstSTarget,
                "Short Target = " + Round((firstSTarget) / TickSize(),0)*TickSize(),
                Color.RED,
                no);

def diffshorttarget = if close < data2 then (data2 - close) else (close - data2);
addLabel(ShowLabels, if R() < R().OB then "Diff 1st S tgt = " + Round((diffshorttarget) / TickSize(),0)*TickSize() else "", Color.LIGHT_RED);
#

    def LineLimit4 = 30;
    def Detrend4 = 0;
    def OnExpansion4 = yes;
    def data4 = secondshorttarget;
    def bar4 = 0;
    def ShowAllPlots4 = 0;
    def ThisBar4 = HighestAll(bar4) - Detrend4;
    def cLine4   = if ShowAllPlots4 == 0 
            then if bar4 == ThisBar4 
                 then data4
                 else Double.NaN
           else data4;
    def cond4 = CompoundValue(1, if IsNaN(data4)
                                then cond4[1] 
                                else data4, data4);
    def P4 = if ShowAllPlots4 == 0 
            then if ThisBar4 - LineLimit4 <= bar4
            then HighestAll(cLine4)
            else Double.NaN
            else cLine4;
    plot secondSTarget = if OnExpansion4 and 
                  IsNaN(data4[-1]) 
                  then cond4 #
                  else Double.NaN;
secondSTarget.SetDefaultColor(Color.RED);
#Round((close + (atr)) / TickSize(), 0) * TickSize()
addlabel(ShowLabels, if R() < R().OB then "2nd Short Target = " + Round((secondSTarget) / TickSize(),0)*TickSize() else "", Color.RED);
AddChartBubble(IsNaN(close) and !IsNaN(Close[1]),
                secondSTarget,
                "2nd Short Target = " + Round((secondSTarget) / TickSize(),0)*TickSize(),
                Color.RED,
                no);

def diffshorttgt2 = if close < secondshorttarget then (secondshorttarget - close) else (close - secondshorttarget);
addLabel(ShowLabels, if R() < R().OB then "Diff 2nd S tgt = " + Round((diffshorttgt2) / TickSize(),0)*TickSize() else "", Color.LIGHT_RED);

    def LineLimit8 = 30;
    def Detrend8 = 0;
    def OnExpansion8 = yes;
    def data8 = thirdshorttarget;
    def bar8 = 0;
    def ShowAllPlots8 = 0;
    def ThisBar8 = HighestAll(bar8) - Detrend8;
    def cLine8  = if ShowAllPlots8 == 0 
            then if bar8 == ThisBar8 
                 then data8
                 else Double.NaN
            else data8;
    def cond8 = CompoundValue(1, if IsNaN(data8)
                                then cond8[1] 
                                else data8, data8);
    def P8 = if ShowAllPlots8 == 0 
            then if ThisBar8 - LineLimit8 <= bar8
            then HighestAll(cLine8)
            else Double.NaN
            else cLine8;
    plot thirdSTarget = if OnExpansion8 and 
                     IsNaN(data8[-1]) 
                  then cond8 
                  else Double.NaN;
thirdSTarget.SetDefaultColor(Color.RED);
addlabel(ShowLabels, if R() < R().OB then "3rd Short Target = " + Round((thirdSTarget) / TickSize(),0)*TickSize() else "", Color.RED);
AddChartBubble(IsNaN(close) and !isNaN(close[1]), 
               thirdSTarget, 
              "3rd Short Target = " + Round((thirdSTarget) / TickSize(),0)*TickSize(), 
               Color.RED, 
               no);

def diffshorttarget3 = if close < thirdshorttarget then (thirdshorttarget - close) else (close - thirdshorttarget);
addLabel(ShowLabels, if R() < R().OB then "Diff 3rd S tgt = " + Round((diffshorttarget3) / TickSize(),0)*TickSize() else "", Color.LIGHT_RED);

#Inputs: 
input nFE = 34;#hint nFE: length for Fractal Energy calculation.
input PriceColor = yes;
plot gamma1 = Log(Sum((Max(high, close[1]) - Min(low, close[1])), nFE) / 
        (Highest(high, nFE) - Lowest(low, nFE))) / Log(nFE);
gamma1.AssignNormGradientColor(nFE, Color.GREEN, Color.RED);
gamma1.SetLineWeight(2);

addLabel(showlabels, if showlabels and gamma1 < 0.382 then "Trending =" + gamma1 else if gamma1 > 0.618 then "Non-Trending =" + gamma1 else "FE = " + gamma1, if gamma1 < 0.382 then Color.WHITE else if gamma1 > 0.618 then Color.CYAN else Color.GRAY);

AssignPriceColor(if PriceColor and gamma1 
#crosses below 
<
.382 then Color.WHITE else if PriceColor and  gamma1 
#crosses above 
>
.618 then Color.CYAN else Color.CURRENT);

#                                        End Code
 
Last edited by a moderator:
Hmmm, something is making it all mash into one :( for me , even with the shared link. Sorry to bug you but can you share your grid with it. Might be setting I have on that is affecting this and not you. @J007RMC
Try this grid,......https://tos.mx/SSu1m68
 
@J007RMC a little background info. jcseattle spends most of his days and evenings trading /YM. What I don't know is if he used this study for that.
anywho, thought you might like to know that the indicator was probably built with short term trading in mind. Hopefully it's helpful, otherwise useless trivia...
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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