SLIM Ribbon Indicator for ThinkorSwim

def UP = HL2 + (atrMult * ATR);

def DN = HL2 + (-atrMult * ATR);



def ST = if close < ST[1] then UP else DN;

plot SuperTrend = ST;
SuperTrend.AssignValueColor(if close < ST then Color.RED else Color.GREEN);
SuperTrend.SetHiding(hideSuperTrendAtr);

def SuperTrendUP = if ST crosses below close[-1] then 1 else 0;
def isSuperTrendUP = SuperTrend > close;
def SuperTrendDN = if ST crosses above close[-1] then 1 else 0;
def isSuperTrendDN = SuperTrend < close;


So what is the value of ST when close < ST[1] ?
So what is the value of ST when close> ST[1] ?

Do you see what ST is plotting now?
 
def UP = HL2 + (atrMult * ATR);

def DN = HL2 + (-atrMult * ATR);



def ST = if close < ST[1] then UP else DN;

plot SuperTrend = ST;
SuperTrend.AssignValueColor(if close < ST then Color.RED else Color.GREEN);
SuperTrend.SetHiding(hideSuperTrendAtr);

def SuperTrendUP = if ST crosses below close[-1] then 1 else 0;
def isSuperTrendUP = SuperTrend > close;
def SuperTrendDN = if ST crosses above close[-1] then 1 else 0;
def isSuperTrendDN = SuperTrend < close;


So what is the value of ST when close < ST[1] ?
So what is the value of ST when close> ST[1] ?

Do you see what ST is plotting now?

THANK YOU!!! I think you just helped me learn Recursive structures.
 
Would you please post it again, that link says "not found." Thank you.
Here's another goodie,........the GraB chart and the codes can be adjusted to display different items.....you can remove other things I use...https://tos.mx/9waVowA
 
My understanding is that this is a recursive statement, so you need to define what ST is. But the next line plots ST, and calls it "SuperTrend". I expected that ST or SuperTrend would be calculated somewhere in the code.
As you've already figured out, the ST declaration is a recursive variable. The reason why it's then referenced as Supertrend, is because you can't declare a plot recursively. Hence plot Supertrend = ST

Edit: Your assumption on the logic of the ST variable is correct, but I thought I'd add a bit more context for you. Recursion is simply when a function/variable applies some type of logic to itself (effectively breaking a larger problem down into smaller ones). So what this is checking is whether to define ST as being in an uptrend (UP) or downtrend (DN). In order to do that, it checks whether the close of the current candle is less than the UP or DN value of the previous candle. So if the logic defines ST as UP in the previous candle, we check whether the close of the current candle is less or greater than that value in order to determine the ST value of the current candle.

Thanks for taking the time to backtest as well. I'm currently on mobile, so didn't have a chance to dig into the screenshots you posted in detail, but will look at them more closely in the AM.
Out of curiosity what params were you running the backtests under? Aggregation periods? What was the underlying ticker? I'd also be curious to look a bit closer at those 2018 conditions you described to see what some of the factors were that contributed to the weaker performance.
 
Last edited:
Sorry that I am just now seeing this. Thank you for the extra detail on the recursion logic. I think I am starting to understand that, and it is something I have struggled with for a long time.

The original backtest I did on the strategy was on an hourly chart, using the code from the original post, with no adjustments to the parameters. I ran the test on the /ES (E-mini).

I didn't save all of the results, but it would be easy to recreate if you would like some other parameters looked at. Using an hourly chart, I can test back a few years in a fairly short amount of time. Thanks again for the help.
 
@markos Hi all,

Do you have a scanner for this, I tried but I am unable to succeed and want to create a watch-list columns as well
 
@markos @BenTen could I use this as buy and sell signals for scalping ES futures on 1 min chart?
I would have no Idea, I get motion sick on less than daily charts... Slim Miller has a video of it on his site called askslim dot com. He showed me how to use it on a Daily when I was in a different chat room.
 
@markos Hi all,

Do you have a scanner for this, I tried but I am unable to succeed and want to create a watch-list columns as well
@dougn Could you post your watch list scan for the slim ribbons here please? And a scan if you have one. Of course, if you have some proprietary items in there then I understand. @URA please give a bit of time, like 2 weeks, for @dougn to get back. Thank you.

@URA please also check the community OneNote that is in the Tutorial Section.
 
Hi @markos, here is a scanner for Slim. This can easily be adopted to a watchlist or scans. Let me know if you have any questions.

Ruby:
#Slim's Ribbon (askSLIM dot com)
#
#Optimized Scanner @diazlaz 2020.04.28
#Initial Release
#

#INPUTS
input sSuperFast = 8;
input sFast = 13;
input sSlow = 21;
input displace = 0;

def SCANNER_SUPERFAST = ExpAverage(close[-DISPLACE], SSUPERFAST);
def SCANNER_FAST = ExpAverage(close[-DISPLACE], SFAST);
def SCANNER_SLOW = ExpAverage(close[-DISPLACE], SSLOW);
def SCANNER_BUY = SCANNER_SUPERFAST > SCANNER_FAST and SCANNER_FAST > SCANNER_SLOW and low > SCANNER_SUPERFAST;
def SCANNER_STOPBUY = SCANNER_SUPERFAST <= SCANNER_FAST;
def SCANNER_BUYNOW = !SCANNER_BUY[1] and SCANNER_BUY;
def SCANNER_BUYSIGNAL = CompoundValue(1, if SCANNER_BUYNOW and !SCANNER_STOPBUY then 1
else if SCANNER_BUYSIGNAL[1] == 1 and SCANNER_STOPBUY then 0 else SCANNER_BUYSIGNAL[1], 0);
def SCANNER_BUY_SIGNAL = SCANNER_BUYSIGNAL[1] == 0 and SCANNER_BUYSIGNAL == 1;
def SCANNER_MOMENTUM_DOWN = SCANNER_BUYSIGNAL[1] == 1 and SCANNER_BUYSIGNAL == 0;
def SCANNER_SELL = SCANNER_SUPERFAST < SCANNER_FAST and SCANNER_FAST < SCANNER_SLOW and high < SCANNER_SUPERFAST;
def SCANNER_STOPSELL = SCANNER_SUPERFAST >= SCANNER_FAST;
def SCANNER_SELLNOW = !SCANNER_SELL[1] and SCANNER_SELL;
def SCANNER_SELLSIGNAL = CompoundValue(1, if SCANNER_SELLNOW and !SCANNER_STOPSELL then 1
else if SCANNER_SELLSIGNAL[1] == 1 and SCANNER_STOPSELL then 0 else SCANNER_SELLSIGNAL[1], 0);
def SCANNER_SELL_SIGNAL = SCANNER_SELLSIGNAL[1] == 0 and SCANNER_SELLSIGNAL;
def SCANNER_MOMENTUM_UP = SCANNER_SELLSIGNAL[1] == 1 and SCANNER_SELLSIGNAL == 0;
def SCANNER_SSTATE = if SCANNER_BUY_SIGNAL then 100 else if SCANNER_MOMENTUM_UP then 10 else if SCANNER_SELL_SIGNAL then -100 else if SCANNER_MOMENTUM_DOWN then -10 else SCANNER_SSTATE[1];

#SCANNER
def bullish = SCANNER_sState == 100;
def bearish = SCANNER_sState == -100;
def neutral = SCANNER_sState == -10 or SCANNER_sState == 10;

plot results = bullish;

Modify plot for the type of condition you which to scan for.
 
@markos @BenTen could someone please help me do a strategy report of buy and sell signals? I am curious to see how this strategy would do. What would I put into the code? I want to buy at a green arrow and sell at a red arrow. And vice versa.
 

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