Small Dog Moving Average Indicator for ThinkorSwim


Active member
2019 Donor
I found this in the almighty ThinkScript_Cloud under 03. Technical Analysis > Trend. This was written by a gentleman named Allen Everhart. No idea who he is but he made this and I put it on my chart to test it out. I tested this using a swing trading mindset.

Steep sloping MA is red, flat or close to flat is orange. "Hot" price movement in either direction is given purple triangles as seen below. I have more testing to do, but it seems scarily accurate to the point where I'm personally going to throw money in the direction of the trend in the form of an OTM cheapo call/put once I'm alerted to purple triangles appearing. This does repaint; since it can repaint, I recommend entering your position after a set amount of time (maybe 1H) or price action after the MA changes colors or purple triangles show up. It might even be best to enter 1min before market close to confirm it won't repaint and fake you out. This does not do well for intraday strategies, as there are very few signals. But if you're busy like me, this could be a great thing to swing with.

The purple triangles can appear any time during the day so it allows us to buy in, set stop loss, and "forget." The only thing we need to do is monitor our position for a profit exit. I'm going to be pressed for time for the next few days so please test it and see if it's great or just ok. I will bring updates to this thread as I test it.

Please manage your risk accordingly.

thinkScript Code

# sdi_ma: Small Dog Investor Moving Average
#hint: Displays a moving average with some additional signals. In the default configuration, when the MA is trending, as defined by 30 consecutive up/down moves, OR the MA is more than 5% away from the MA 30 bars prior then the MA appears in red. When the moving average is nontrending and within 5% of the value 30 bars prior then the MA appears in orange. When price is more than 10% away from the MA, the MA line is decorated with hot pink triangles. In the right extension we show a straight line projection taken from the last two bars. Version: 1.1
# source:
# author: allen everhart 8/4/2011
# revised: 8/21/2011 added price data series selection.
# copylefts reserved. This is free software. That means you are free
# to use or modify it for your own usage but not for resale.
# Help me get the word out about my blog by keeping this header
# in place.
#hint price: Choose data series to average over.
input price = close;
#def price = close;
#hint type: Choose between Simple and Exponential Moving Average.
input type = { default EXP, SMP } ;
#hint length: Number of bars in moving average.
input length = 30 ;
#hint flatPct: Main criteria for color-coded trend changes.
input flatPct = 5.0 ;
#hint compLength: Number of consecutive up/down bars to use as the secondary criteria for color-coded trend changes.
input compLength = 30 ;
#hint hotPct: Criteria for the hot decoration.
input hotPct = 10.0 ;
def ma =
  if type == type.SMP then
    simpleMovingAvg(price, length)
    movAvgExponential(price, length);

rec maUpBars =
  if ma > ma[1] then
    maUpBars[1] + 1
  else if ma == ma[1] then

#plot up = maUpBars ; # diagnostics
rec maDnBars =
  if ma < ma[1] then
    maDnBars [1] + 1
  else if ma == ma[1] then

#plot dn = maDnBars ; # diagnostics
plot steep =
if AbsValue(100 * ((ma / ma[compLength]) - 1)) >= flatPct then
else if maUpBars >= compLength then
else if maDnBars >= compLength then
steep.SetDefaultColor( color.RED);
steep.SetLineWeight(2) ;

plot flat =
if AbsValue(100 * ((ma / ma[compLength]) - 1)) < flatPct then
else if maUpBars < compLength then
else if maDnBars < compLength then

flat.SetDefaultColor( color.ORANGE);
flat.SetLineWeight(2) ;

#plot pct =100 * ((ma / ma[compLength]) - 1);
#plot bkma =  ma[compLength] ;
plot hot =
if AbsValue( 100 * ((price / ma) - 1) ) > hotPct then

hot.setDefaultColor( color.MAGENTA);

rec slope =
  if isnaN(close) and !isnaN(close[1]) then
  else if isnaN(close) and isnaN(close[1]) then

rec extrec =
  if !isnaN(slope) and isnaN(slope[1]) then
  else if !isnaN(slope) then
    extrec[1]+ slope

plot ext = extrec ;

ext.setStyle( curve.SHORT_DASH);
Last edited by a moderator:

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

@Shinthus I am happy to see that you are finding your way all around our Universe of Thinkscript, located in the Tutorial Section of this site. (y)
Mr. Everhart is known as the "small dog investor", his study codes will most likely have SDI in the header.
Very nice find, Let the testing begin!
Update: It doesn't seem to work well with stop losses. I'm thinking about just buying cheap 2 week exp, OTM options and YOLOing each trade to see if there are more gains than losses. Also ****s for intraday. There are barely any signals for 5m, 15m, and 30 minute charts.

If it's possible to set up an automatic paper trading strat with this, please let me know.

Will report back.
Last edited:
Update: Ok I realized it can also be used as a confirmation when you are already in a position. Depending on the situation, it may warrant an additional position on top of the one you have. For example, if you used other indicators to get into a position and you are already winning, you may be able to add to your position if the purple triangles show up.
I just got a seemingly brilliant idea. Have one chart open with daily timeframe. Have the other chart 5m or some intraday interval. When the purple triangle shows up on the daily chart in the middle of a trend, check the intraday chart for a pullback in the opposite direction of the trend. Using help of RSI L and Market Mover or the Zigzag reversal (or whatever you like), wait until the pullback seems over and take a weekly ATM option in the direction of the trend!

Let me know it this was clear or not. It sounds like an awesome strategy. Basically, days that have a purple triangle on them are really really good day trading days. Say the daily trend is violently DOWN. The triangle appears on the daily, and you wait until a small uptrend happens on the 5m chart and possibly look for oversold signal on RSI or TMO/stochastics. Then buy puts as soon as you start to see a decline!
Just letting you know that it sounded clear to me. Very interesting thought, checking multiple time frames. Obviously, you would consult at least a full year daily chart to be sure of trend. Good trading & let us know what you've found!
Had this indicator on one of my charts for some time. I have found no use for it other than as a 30 EMA which is useful for checking if price breaks or respects the line. It needs a highly volatile stock to show triangles.
So I know this is an old thread, but I wanted to ask you if you have ever thought about using this indicator on a Renko chart and modifying the settings, especially the hot percent setting? If you happen to try this, please let me know what you think.
So I know this is an old thread, but I wanted to ask you if you have ever thought about using this indicator on a Renko chart and modifying the settings, especially the hot percent setting? If you happen to try this, please let me know what you think.
I've been tinkering with adding this indicator to my rep on RENKO. Haven't messed with changing the hot setting yet but the average itself changing from orange to red looks pretty great at identifying those obnoxious trending days where you keep expecting a reversal and it never happens. It kind of just slaps you in the face, as if to say- "stop fighting it and just join the trend, stupid":LOL: Pairing it with ADX/DMI to confirm entries/exits when switching to red seems promising...

It may also help when trading on Fed-speaking days, when action happens fast, range widens, and you feel like as soon as you jump in its gonna reverse on you. This past Tuesday, for instance, on SPY it signaled red 3 times for a $3, $4, and $2 continuation move that I might've caught a piece of.

I wonder if anybody could create an alarm for when the ma changes from orange to red?

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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