<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ThinkScripter &#187; moving average</title>
	<atom:link href="http://www.thinkscripter.com/tag/moving-average/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thinkscripter.com</link>
	<description>thinkScript Indicators for thinkorswim</description>
	<lastBuildDate>Sun, 29 Jan 2012 16:11:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Daily Moving Average &#8211; Intraday Chart</title>
		<link>http://www.thinkscripter.com/indicator/daily-moving-average-intraday-chart/</link>
		<comments>http://www.thinkscripter.com/indicator/daily-moving-average-intraday-chart/#comments</comments>
		<pubDate>Sun, 20 Feb 2011 15:59:03 +0000</pubDate>
		<dc:creator>ThinkScripter</dc:creator>
				<category><![CDATA[Indicator]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[daily]]></category>
		<category><![CDATA[moving average]]></category>
		<category><![CDATA[thinkscript]]></category>

		<guid isPermaLink="false">http://www.thinkscripter.com/?p=3235</guid>
		<description><![CDATA[Plots a daily moving average of a specified period on any intraday chart.  <a href="http://www.thinkscripter.com/indicator/daily-moving-average-intraday-chart/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Extending the basic structure of the <a href="http://www.thinkscripter.com/indicator/pivot-point-moving-average/">Pivot Point Moving Average</a>, this study plots a daily moving average of a specified period on any intraday chart. The image shows the 50, 100, and 200 period daily moving averages on a four hour chart as well as <a href="http://www.thinkscripter.com/indicator/thinkscripter-multi-stops/">ThinkScripter MultiStops</a> using a chandelier stop. </p>
<div id="attachment_3234" class="wp-caption aligncenter" style="width: 640px"><a href="http://www.thinkscripter.com/wp-content/uploads/2011/02/DailyMA.png"><img src="http://www.thinkscripter.com/wp-content/uploads/2011/02/DailyMA.png" alt="" title="DailyMA" class="size-full wp-image-3234" /></a><p class="wp-caption-text">Daily MA on Intraday Chart</p></div>
<pre class="brush: thinkscript; title: ; notranslate">
# TS_DailyMA
# By Eric Purdy, ThinkScripter LLC
# http://www.thinkscripter.com
# thinkscripter@gmail.com
# Last Update 20 Feb 2011

input period = 50;
input displace = 0;
input display = {default linear, stairStep};

def MA = (fold i = 1 + displace to period + 1 + displace
with sum = 0 do sum + getValue(close(period=&quot;Day&quot;),i,period+1))/period;
def newDay = if getDay() != getDay()[1] then 1 else 0;

plot DailyMovingAverage = if display==display.linear then if newDay then MA else double.nan else MA;
DailyMovingAverage.setDefaultColor(color.yellow);
DailyMovingAverage.setLineWeight(2);
DailyMovingAverage.enableApproximation();
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.thinkscripter.com/indicator/daily-moving-average-intraday-chart/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Pivot Point Moving Average</title>
		<link>http://www.thinkscripter.com/indicator/pivot-point-moving-average/</link>
		<comments>http://www.thinkscripter.com/indicator/pivot-point-moving-average/#comments</comments>
		<pubDate>Sun, 30 Jan 2011 23:28:13 +0000</pubDate>
		<dc:creator>ThinkScripter</dc:creator>
				<category><![CDATA[Indicator]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[moving average]]></category>
		<category><![CDATA[pivot]]></category>
		<category><![CDATA[pivot point moving average]]></category>
		<category><![CDATA[thinkscript]]></category>

		<guid isPermaLink="false">http://www.thinkscripter.com/?p=3215</guid>
		<description><![CDATA[Calculates the moving average of the daily pivot point. <a href="http://www.thinkscripter.com/indicator/pivot-point-moving-average/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Reader Len asked for a moving average of the daily pivot point (H+L+C/3). This provided a great opportunity to demonstrate using the <code>fold</code> command to calculate a moving average from a higher timeframe. This method is extensible and you can let your scripting imaginations run wild with other possibilities. Good luck out there.<br />
-Eric</p>
<div id="attachment_3218" class="wp-caption aligncenter" style="width: 640px"><a href="http://www.thinkscripter.com/wp-content/uploads/2011/01/PPMA.png"><img src="http://www.thinkscripter.com/wp-content/uploads/2011/01/PPMA.png" alt="" title="PPMA" class="size-full wp-image-3218" /></a><p class="wp-caption-text">Pivot Point Moving Average</p></div>
<pre class="brush: thinkscript; title: ; notranslate">
# TS_PivotPointMovingAverage
# By Eric Purdy, ThinkScripter LLC
# http://www.thinkscripter.com
# thinkscripter@gmail.com
# Last Update 30 Jan 2011

input period = 3;
input displace = 0;

plot PivotPointMovingAverage = (fold i = 1 + displace
to period + 1 + displace
with sum = 0 do sum
+ getValue(hlc3(period=&quot;Day&quot;),i,period+1))/period;

PivotPointMovingAverage.setDefaultColor(color.magenta);
PivotPointMovingAverage.setLineWeight(2);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.thinkscripter.com/indicator/pivot-point-moving-average/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>SMA Spread</title>
		<link>http://www.thinkscripter.com/indicator/sma-spread/</link>
		<comments>http://www.thinkscripter.com/indicator/sma-spread/#comments</comments>
		<pubDate>Thu, 07 Oct 2010 14:02:22 +0000</pubDate>
		<dc:creator>ThinkScripter</dc:creator>
				<category><![CDATA[Indicator]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[mean reversion]]></category>
		<category><![CDATA[moving average]]></category>
		<category><![CDATA[thinkscript]]></category>

		<guid isPermaLink="false">http://www.thinkscripter.com/?p=3018</guid>
		<description><![CDATA[A mean reversion indicator that plots the percentage spread of the current close from a given simple moving average. <a href="http://www.thinkscripter.com/indicator/sma-spread/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A few weeks back I was asked to code a mean reversion indicator that plotted the percentage spread of the current close from a given simple moving average. This study is the result. On the lower subgraph you see the blue line representing the current close&#8217;s difference from the SMA as a percentage of the price. This gives some insight into how far this &#8220;rubber band&#8221; typically stretches before a price reversion to the mean occurs. The red horizontal lines depict one standard deviation of the spread percentage for all the chart data.<br />
<div id="attachment_3022" class="wp-caption aligncenter" style="width: 640px"><a href="http://www.thinkscripter.com/wp-content/uploads/2010/10/SMASPread.png"><img src="http://www.thinkscripter.com/wp-content/uploads/2010/10/SMASPread.png" alt="" title="SMASPread" class="size-full wp-image-3022" /></a><p class="wp-caption-text">SMA Spread</p></div></p>
<pre class="brush: thinkscript; title: ; notranslate">
# TS_SMA_SPREAD
# http://www.thinkscripter.com
# thinkscripter@gmail.com
# Last Update 07 OCT 2010

declare lower;

input sma_length = 50;

plot SMA_Spread = (Close - Average(close, sma_length)) / Average(close,sma_length) * 100;
SMA_Spread.setDefaultColor(color.blue);

plot zero = 0;
zero.setDefaultColor(color.white);
zero.hideTitle();

plot overbought = absValue(stdevAll(SMA_Spread));
overbought.setDefaultColor(color.red);
overbought.setLineWeight(2);

plot oversold = -absValue(stdevAll(SMA_Spread));
oversold.setDefaultColor(color.red);
oversold.setLineWeight(2);

def spreadHigh = highestAll(AbsValue(SMA_Spread));

plot A = spreadHigh/5;
A.setDefaultColor(color.dark_gray);
A.setStyle(curve.SHORT_DASH);
A.hideTitle();

plot B = -spreadHigh/5;
B.setDefaultColor(color.dark_gray);
B.setStyle(curve.SHORT_DASH);
B.hideTitle();

plot C = spreadHigh*2/5;
C.setDefaultColor(color.dark_gray);
C.setStyle(curve.SHORT_DASH);
C.hideTitle();

plot D = -spreadHigh*2/5;
D.setDefaultColor(color.dark_gray);
D.setStyle(curve.SHORT_DASH);
D.hideTitle();

plot E = spreadHigh*3/5;
E.setDefaultColor(color.dark_gray);
E.setStyle(curve.SHORT_DASH);
E.hideTitle();

plot F = -spreadHigh*3/5;
F.setDefaultColor(color.dark_gray);
F.setStyle(curve.SHORT_DASH);
F.hideTitle();

plot G = spreadHigh*4/5;
G.setDefaultColor(color.dark_gray);
G.setStyle(curve.SHORT_DASH);
G.hideTitle();

plot H =  -spreadHigh*4/5;
H.setDefaultColor(color.dark_gray);
H.setStyle(curve.SHORT_DASH);
H.hideTitle();

plot I = spreadHigh;
I.setDefaultColor(color.dark_gray);
I.setStyle(curve.SHORT_DASH);
I.hideTitle();

plot J = -spreadHigh;
J.setDefaultColor(color.dark_gray);
J.setStyle(curve.SHORT_DASH);
J.hideTitle();
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.thinkscripter.com/indicator/sma-spread/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Cycle Point Moving Average</title>
		<link>http://www.thinkscripter.com/indicator/cycle-point-moving-average/</link>
		<comments>http://www.thinkscripter.com/indicator/cycle-point-moving-average/#comments</comments>
		<pubDate>Wed, 20 May 2009 04:37:15 +0000</pubDate>
		<dc:creator>ThinkScripter</dc:creator>
				<category><![CDATA[Indicator]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[cycle]]></category>
		<category><![CDATA[cycle moving average]]></category>
		<category><![CDATA[moving average]]></category>
		<category><![CDATA[thinkscript]]></category>

		<guid isPermaLink="false">http://www.thinkscripter.com/?p=1315</guid>
		<description><![CDATA[Plots a close approximation of the cycle point moving average. <a href="http://www.thinkscripter.com/indicator/cycle-point-moving-average/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><span style="color: #ff0000;"> <strong>UPDATE : This script has been rendered inoperable as of 12 Dec 09 due to changes in the TOS ZigZag function. I will leave it posted as a reference for coders to examine the script methodology.</strong></span></p>
<p>This very basic script plots a close approximation of the cycle point moving average. You enter in the required price reversal for a cycle turn, a moving average period, and it does the rest courtesy of the TOS zigZag function. I had coded this script some time ago and found nothing particularly compelling about it but decided to use it to illustrate the only new thinkScript feature I saw in the last build; namely the <span style="color: #0000ff;">defineColor()</span><span style="color: #0000ff;"> </span>command. In the past, when ever I needed to control the color of some study plot dynamically, I had to hard code in the colors in the associated <span style="color: #0000ff;">assignValueColor()</span> statement. As such, the custom coloring was only modifiable by altering the thinkScript itself. Using the new <span style="color: #0000ff;">defineColor()</span> command allows the scripter to code in value assignable colors but also allow an end user to change those colors should they desire. I expect to retrofit my earlier studies with this capability as time allows.</p>
<p>Break&#8230;.Break&#8230;.</p>
<p>Thanks to all for bearing with me this week. I know my response to your emails has been a bit slower than usual but I think I&#8217;ve gotten back to just about everyone at this point. It&#8217;s been a pretty busy week for myself and the family as we move back into our house after a four year absence in Annapolis. As such I haven&#8217;t really had as much time to devote to developmental stuff as I would like. I expect to be full steam ahead by early next week. </p>
<div id="attachment_1314" class="wp-caption aligncenter" style="width: 640px"><a href="http://www.thinkscripter.com/wp-content/uploads/2009/05/cpma.png"><img class="size-full wp-image-1314" title="cpma" src="http://www.thinkscripter.com/wp-content/uploads/2009/05/cpma.png" alt="Cycle Point Moving Average"  /></a><p class="wp-caption-text">Cycle Point Moving Average</p></div>
<pre class="brush: thinkscript; title: ; notranslate">
# TS_CyclePointMovingAverage
# (c) 2009 http://www.thinkscripter.com
# thinkscripter@gmail.com
# Last Update 19 May 2009

declare fullrange;

input RequiredPointsForCycleReversal = 10;
input CycleMovingAveragePeriod = 7;

def ZZData = ZigZagSign(&quot;reversal amount&quot; = RequiredPointsForCycleReversal);
def isHigh = if ZZData[1] &lt; ZZData and ZZData &gt; ZZData[-1] then 1 else 0;
def isLow = if ZZData[1] &gt; ZZData and ZZData &lt; ZZData[-1] then 1 else 0;
plot cyclePoint = if isHigh then high else if isLow then low else double.nan;
plot CPMA = Average(ZZData, CycleMovingAveragePeriod);

CPMA.DefineColor(&quot;Positive Slope&quot;, color.cyan);
CPMA.DefineColor(&quot;Negative Slope&quot;, color.magenta);
CPMA.AssignValueColor(if CPMA - CPMA[1] &gt;= 0 then CPMA.color(&quot;Positive Slope&quot;) else CPMA.color(&quot;Negative Slope&quot;));
CPMA.setLineWeight(3);

cyclePoint.SetStyle(curve.POINTS);
cyclePoint.SetDefaultColor(color.white);
cyclePoint.SetLineWeight(5);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.thinkscripter.com/indicator/cycle-point-moving-average/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Vervoort Crossover</title>
		<link>http://www.thinkscripter.com/indicator/vervoort-crossover/</link>
		<comments>http://www.thinkscripter.com/indicator/vervoort-crossover/#comments</comments>
		<pubDate>Tue, 31 Mar 2009 02:53:52 +0000</pubDate>
		<dc:creator>ThinkScripter</dc:creator>
				<category><![CDATA[Indicator]]></category>
		<category><![CDATA[crossover]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[moving average]]></category>
		<category><![CDATA[thinkscript]]></category>
		<category><![CDATA[vervoort]]></category>

		<guid isPermaLink="false">http://thinkscripter.wordpress.com/?p=892</guid>
		<description><![CDATA[Sylvain Vervoort's trading method using the crosses of two unique moving averages: a zero-lag triple exponential moving average of 1) the typical price (h+l+c)/3 and 2) the Heikin-Ashi close. <a href="http://www.thinkscripter.com/indicator/vervoort-crossover/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><span style="color:#ff0000;">(Update 29 Dec 2009: There is a bug in the current build of TOS which makes the Vervoort Crossover lines go ape at the beginning of the chart. Commenting out the line <strong>signal.assignValueColor(if buySignal then color.green else color.red);</strong> appears to fix the problem&#8230;.for now. &#8211; Eric</span></p>
<p>Thanks to Reader Randy H. for suggesting this one. In his article &#8220;The Quest For Reliable Crossovers&#8221; (Stocks &amp; Commodities Magazine, May 2008) author Sylvain Vervoort sets forth a trading method using the crosses of two unique moving averages. Specifically, he used a zero-lag triple exponential moving average of 1) the typical price (h+l+c)/3 and 2) the Heikin-Ashi close. He successfully backtested his method on 211 stocks and found using a 55 period average on daily charts was optimal.</p>
<div id="attachment_894" class="wp-caption aligncenter" style="width: 640px"><a href="http://www.thinkscripter.com/wp-content/uploads/2009/03/vervoortcrossover.png"><img class="size-full wp-image-894" title="vervoortcrossover" src="http://www.thinkscripter.com/wp-content/uploads/2009/03/vervoortcrossover.png" alt="Vervoort Crossover"  /></a><p class="wp-caption-text">Vervoort Crossover</p></div>
<pre class="brush: thinkscript; title: ; notranslate">
# VervoortCrossover
# (c) 2009 http://www.thinkscripter.com
# thinkscripter@gmail.com
# Last Update 30 MAR 2009

input period = 55;
def price = (high+low+close)/3;

#-----Typical Price ZeroLag Triple Exponential Moving Average

def TMA1 = 3*expAverage(price,period)
-3*expAverage(expAverage(price,period),period)
+expAverage(expAverage(expAverage(price,period)
,period),period);

def TMA2 = 3*expAverage(TMA1,period)
-3*expAverage(expAverage(TMA1,period),period)
+expAverage(expAverage(expAverage(TMA1,period)
,period),period);

def difference = TMA1-TMA2;
plot TypicalPriceZeroLagTEMA = TMA1+difference;
TypicalPriceZeroLagTEMA.setDefaultColor(color.green);

#------Heikin-Ashi Close ZeroLag Triple Exponential Moving Average

rec haopen = CompoundValue(1,((open[1]+high[1]
+low[1]+close[1])/4 + haopen[1])/2, hl2);
def haclose = ((open+high+low+close)/4+haopen
+max(high,haopen)+min(low,haopen))/4;

def HATMA1 = 3*expAverage(haclose,period)
-3*expAverage(expAverage(haclose,period),period)
+expAverage(expAverage(expAverage(haclose,period)
,period),period);

def HATMA2 = 3 * ExpAverage(HATMA1, period)
- 3 * ExpAverage(ExpAverage(HATMA1, period), period)
+ ExpAverage(ExpAverage(ExpAverage(HATMA1, period)
, period), period);

def HAdifference = HATMA1 - HATMA2;

plot HeikinAshiZeroLagTEMA = HATMA1 + HAdifference;
HeikinAshiZeroLagTEMA.setDefaultColor(color.red);

def buySignal = if TypicalPriceZeroLagTEMA &gt; HeikinAshiZeroLagTEMA and TypicalPriceZeroLagTEMA[1] &lt;= HeikinAshiZeroLagTEMA[1] then 1 else 0;

def sellSignal = if TypicalPriceZeroLagTEMA &lt; HeikinAshiZeroLagTEMA and TypicalPriceZeroLagTEMA[1] &gt;= HeikinAshiZeroLagTEMA[1] then 1 else 0;

plot signal = if buySignal or sellSignal then TypicalPriceZeroLagTEMA else double.nan;
#signal.assignValueColor(if buySignal then color.green else color.red);
signal.setLineWeight(5);
signal.SetStyle(curve.points);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.thinkscripter.com/indicator/vervoort-crossover/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Variable Index Dynamic Average (VIDYA)</title>
		<link>http://www.thinkscripter.com/indicator/variable-index-dynamic-average-vidya/</link>
		<comments>http://www.thinkscripter.com/indicator/variable-index-dynamic-average-vidya/#comments</comments>
		<pubDate>Sun, 15 Mar 2009 18:28:54 +0000</pubDate>
		<dc:creator>ThinkScripter</dc:creator>
				<category><![CDATA[Indicator]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[moving average]]></category>
		<category><![CDATA[thinkscript]]></category>
		<category><![CDATA[VIDYA]]></category>

		<guid isPermaLink="false">http://thinkscripter.wordpress.com/?p=634</guid>
		<description><![CDATA[A variable moving average, the VIDYA, as described in The New Technical Trader by Tushar Chande and Stanley Kroll. <a href="http://www.thinkscripter.com/indicator/variable-index-dynamic-average-vidya/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a variable moving average, the VIDYA, as described in <a href="http://www.amazon.com/gp/product/0471597805?ie=UTF8&amp;tag=thinks-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0471597805">The New Technical Trader</a><img src="http://www.assoc-amazon.com/e/ir?t=thinks-20&amp;l=as2&amp;o=1&amp;a=0471597805" width="1" height="1" border="0" alt="" style="border:none!important;margin:0!important;" /> by Tushar Chande and Stanley Kroll.<br />
<div id="attachment_636" class="wp-caption aligncenter" style="width: 640px"><a href="http://www.thinkscripter.com/wp-content/uploads/2009/03/vidya.png"><img src="http://www.thinkscripter.com/wp-content/uploads/2009/03/vidya.png" alt="Variable Index Dynamic Moving Average" title="vidya"  class="size-full wp-image-636" /></a><p class="wp-caption-text">Variable Index Dynamic Moving Average</p></div></p>
<pre class="brush: thinkscript; title: ; notranslate">
# VIDYA
# http://www.thinkscripter.com
# thinkscripter@gmail.com
# Last Update 15 MAR 2009

input sigmaperiod = 10;
input length = 20;

def sigmaConstant = 2/(sigmaperiod+1);
def absCMO = absValue(ChandeMomentumOscillator(length))/100;
rec cV = compoundValue(1, (sigmaConstant*absCMO*close)+(1-(sigmaConstant*absCMO))*cV[1],close);

plot VIDYA =cV;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.thinkscripter.com/indicator/variable-index-dynamic-average-vidya/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Moving Average with Slope Based Color</title>
		<link>http://www.thinkscripter.com/indicator/moving-average-with-slope-based-color/</link>
		<comments>http://www.thinkscripter.com/indicator/moving-average-with-slope-based-color/#comments</comments>
		<pubDate>Sun, 15 Mar 2009 18:17:39 +0000</pubDate>
		<dc:creator>ThinkScripter</dc:creator>
				<category><![CDATA[Indicator]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[moving average]]></category>
		<category><![CDATA[thinkscript]]></category>

		<guid isPermaLink="false">http://thinkscripter.wordpress.com/?p=628</guid>
		<description><![CDATA[The moving average of your choice with the color of the line based on the slope of the line. <a href="http://www.thinkscripter.com/indicator/moving-average-with-slope-based-color/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a real simple script that will plot the moving average of your choice with the color of the line based on the slope of the line. If you want different colors, just change the two color constants in the line of code:<br />
<code>ave.AssignValueColor(if ave > ave[1] then color.cyan else color.dark_red);</code><br />
to your preference.</p>
<div id="attachment_630" class="wp-caption aligncenter" style="width: 640px"><a href="http://www.thinkscripter.com/wp-content/uploads/2009/03/tsma.png"><img src="http://www.thinkscripter.com/wp-content/uploads/2009/03/tsma.png" alt="Moving Average with Slope Based Color" title="tsma" class="size-full wp-image-630" /></a><p class="wp-caption-text">Moving Average with Slope Based Color</p></div>
<pre class="brush: thinkscript; title: ; notranslate">
# TS_MOVINGAVERAGE
# http://www.thinkscripter.com
# thinkscripter@gmail.com
# Last Update 15 MAR 2009

input displace = 0;
input length = 9;
input price = close;
input movingAverageType = {default Simple, Exponential, Weighted, Hull, Variable};

rec data;

switch (movingAverageType) {
case Simple:
    data = compoundValue(1, Average(price[-displace], length), price);
case Exponential:
    data = compoundValue(1, ExpAverage(price[-displace], length), price);
case Weighted:
    data = compoundValue(1, wma(price[-displace], length), price);
Case Hull:
    data = compoundValue(1, hullMovingAvg(price[-displace], length), price);
case variable:
    data = VariableMA(price=price, length=length);
}

plot ave = data;
ave.SetLineWeight(2);
ave.AssignValueColor(if ave &gt; ave[1] then color.cyan else color.dark_red);
ave.HideBubble();</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.thinkscripter.com/indicator/moving-average-with-slope-based-color/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

