#### Shinthus

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

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.

https://tos.mx/pJRRxG

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

Code:

```
plot Data = close;
#########################
# 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: smalldoginvestor.blogspot.com
# 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)
else
movAvgExponential(price, length)
;
rec maUpBars =
if ma > ma[1] then
maUpBars[1] + 1
else if ma == ma[1] then
maUpBars[1]
else
0
;
#plot up = maUpBars ; # diagnostics
rec maDnBars =
if ma < ma[1] then
maDnBars [1] + 1
else if ma == ma[1] then
maDnBars[1]
else
0
;
#plot dn = maDnBars ; # diagnostics
plot steep =
if AbsValue(100 * ((ma / ma[compLength]) - 1)) >= flatPct then
ma
else if maUpBars >= compLength then
ma
else if maDnBars >= compLength then
ma
else
double.NaN
;
steep.SetDefaultColor( color.RED);
steep.SetLineWeight(2) ;
plot flat =
if AbsValue(100 * ((ma / ma[compLength]) - 1)) < flatPct then
ma
else if maUpBars < compLength then
ma
else if maDnBars < compLength then
ma
else
double.NaN
;
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
ma
else
double.NaN
;
hot.setDefaultColor( color.MAGENTA);
hot.setPaintingStrategy(paintingStrategy.LINE_VS_TRIANGLES);
rec slope =
if isnaN(close) and !isnaN(close[1]) then
ma[1]-ma[2]
else if isnaN(close) and isnaN(close[1]) then
slope[1]
else
double.NaN
;
rec extrec =
if !isnaN(slope) and isnaN(slope[1]) then
ma[1]+slope
else if !isnaN(slope) then
extrec[1]+ slope
else
double.NaN
;
plot ext = extrec ;
ext.setDefaultColor(color.RED);
ext.setStyle( curve.SHORT_DASH);
#end
```

https://tos.mx/pJRRxG

Last edited: