<?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 - Custom ThinkScript Indicators for thinkorswim &#187; Add new tag</title>
	<atom:link href="http://www.thinkscripter.com/tag/add-new-tag/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thinkscripter.com</link>
	<description>Custom ThinkScript Indicator Scripts for thinkorswim</description>
	<lastBuildDate>Mon, 28 Jun 2010 02:18:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>ThinkScripter AutoFibLines Explained &#8211; Conclusion</title>
		<link>http://www.thinkscripter.com/2009/06/07/thinkscripter-autofiblines-explained-conclusion/</link>
		<comments>http://www.thinkscripter.com/2009/06/07/thinkscripter-autofiblines-explained-conclusion/#comments</comments>
		<pubDate>Mon, 08 Jun 2009 02:45:32 +0000</pubDate>
		<dc:creator>ThinkScripter</dc:creator>
				<category><![CDATA[Educational]]></category>
		<category><![CDATA[Add new tag]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[Fibonacci]]></category>
		<category><![CDATA[Indicator]]></category>
		<category><![CDATA[thinkscript]]></category>

		<guid isPermaLink="false">http://www.thinkscripter.com/?p=1381</guid>
		<description><![CDATA[In part one I discussed the use of the ZigZag function as the engine behind ThinkScripter AutoFibLines.* In part two, the methodology for saving the resulting swing highs and lows using the rec variable was added. At this point, every bar now &#8220;knows&#8221; the most recent swing high and low and can do the simple [...]]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://www.thinkscripter.com/2009/05/29/thinkscripter-autofiblines-code-explained-part-1/">part one</a> I discussed the use of the ZigZag function as the engine behind <a href="http://www.thinkscripter.com/2009/03/29/thinkscripter-autofibs/">ThinkScripter AutoFibLines.</a>*  In <a href="http://www.thinkscripter.com/2009/06/02/thinkscripter-autofiblines-code-explained-part-2/">part two</a>, the methodology for saving the resulting swing highs and lows using the rec variable was added. At this point, every bar now &#8220;knows&#8221; the most recent swing high and low and can do the simple math required to calculate Fibonacci ratios:<code><br />
def deltaHL = prevHigh - prevLow;<br />
def ret1 = deltaHL * fib1;<br />
def ret2 = deltaHL * fib2;<br />
...<br />
</code></p>
<p>First we find the difference between the swing high and low and then calculate the various user-defined fib levels between them or extended beyond for ratios greater than one or less than zero.</p>
<p>Now the tricky part&#8230;There is only so much stuff you can put on a chart and have it be useful. I prefer a minimalist approach to studies and my charts and so I chose to plot the Fibonacci ratios in the &#8220;white space&#8221; to the right of the last bar. (If you don&#8217;t have any expansion bars to the right on your chart it is a simple change in the TOS styles panel). </p>
<p>First, before we plot anything, we need to know if we are on a reversal up or down:<br />
<code>rec direction = if(isLow, 1, if(isHigh, -1, direction[1]));</code><br />
Here I&#8217;ve used <code>rec</code> again to remember if the last swing was a low or a high. We can use this so that the plotted fib lines are oriented in the proper direction.</p>
<p>With all our ducks in a row we can now plot a Fibonacci ratio line:<br />
<code>1) def f1c = if(direction > 0 , prevLow + ret1, prevHigh - ret1);<br />
2) rec f1e = if(!isNan(close[-1]), f1c, f1e[1]);<br />
3) plot f1 = if isNan(close[-1]) then f1e else double.nan;</code></p>
<p>Translation:<br />
1) fib line #1 calculated = either the previous low + the ratio*(high-low) or the previous high &#8211; the ratio*(high-low)<br />
2) fib line #1 extension = if the next bar is not empty (i.e. in the future or right expansion space) then the calculated fib line #1 otherwise carry forward the last value of fib line#1 extension<br />
3) plot fib line #1 only if the next bar is empty (i.e. all bars forward without data &#8211; the right extension)</p>
<p>Phew! Sometimes I think it is much easier writing/debugging code than explaining it in a somewhat comprehensible manner. That&#8217;s all for now. I hope you learned a few of the nuanced techniques that can make thinkScript do out of the ordinary stuff. Until next time, thank you all for your support and good luck in your trading.</p>
<p>*The <a href="http://www.thinkscripter.com/forum">AutoFibLines code is available in the forum</a> if you&#8217;d like it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thinkscripter.com/2009/06/07/thinkscripter-autofiblines-explained-conclusion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ThinkScripter AutoFibLines Code Explained &#8211; Part 2</title>
		<link>http://www.thinkscripter.com/2009/06/02/thinkscripter-autofiblines-code-explained-part-2/</link>
		<comments>http://www.thinkscripter.com/2009/06/02/thinkscripter-autofiblines-code-explained-part-2/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 01:13:57 +0000</pubDate>
		<dc:creator>ThinkScripter</dc:creator>
				<category><![CDATA[Educational]]></category>
		<category><![CDATA[Indicator]]></category>
		<category><![CDATA[Add new tag]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[Fibonacci]]></category>
		<category><![CDATA[retracement]]></category>
		<category><![CDATA[thinkscript]]></category>

		<guid isPermaLink="false">http://www.thinkscripter.com/?p=1367</guid>
		<description><![CDATA[Recall from part one that the core engine driving the ThinkScripter AutoFibLines script is TOS&#8217; built in ZigZagSign() function. I chose to harness the power of this function rather than re-invent the wheel to capture the swing highs and lows needed to draw Fibonacci lines. With this piece of the code complete, the script enables [...]]]></description>
			<content:encoded><![CDATA[<p>Recall from <a href="http://www.thinkscripter.com/2009/05/29/thinkscripter-autofiblines-code-explained-part-1/">part one</a> that the core engine driving the <a href="http://www.thinkscripter.com/2009/03/29/thinkscripter-autofibs/">ThinkScripter AutoFibLines</a> script is TOS&#8217; built in ZigZagSign() function. I chose to harness the power of this function rather than re-invent the wheel to capture the swing highs and lows needed to draw Fibonacci lines. With this piece of the code complete, the script enables any bar to determine if it is a swing high or swing low and set an appropriate flag if so. </p>
<p>At this point I should explain an important nuance here. If you have ever watched the TOS ZigZag in action you will have noticed that it often &#8220;Changes its mind&#8221; about whether to draw an inflection point or not. This is just the nature of the way the ZigZag works on any platform. So, as a result, a bar may get its swing high/low flag set only to have the ZigZag change a bar or two later. We don&#8217;t want false high/lows flagged so we force our entire chart to redraw each bar with the <code>declare fullrange</code> statement up front. Therefore, if a flag is set and then nullified a bar later, the redraw of the chart will remove the false flag.</p>
<p>Onward&#8230;.In order to draw the Fibonacci levels at the final bar, that bar needs to know the previously recorded values of the swing high and swing low. Enter the <code>rec</code> statement. Many folks get the <code>def</code> and <code>rec</code> statements confused. In this case, we need to carry along a value in a variable using <code>rec</code> (short for recursion). Any variable definition that refers to a previous value of itself requires the use of this command. To properly seed the <code>rec</code> variable, you need to use the <code>compoundValue()</code> statement. The compoundValue() statement sets the value of the variable to one value if less than a certain number of bars have passed and to another value when they have. We&#8217;ll dive deeper into this one in another segment. For now, just push the &#8220;I believe&#8221; button. Here&#8217;s the resulting code to hold the swing high/low values and carry them forward from bar to bar:</p>
<p><code>rec prevLow = compoundValue(1, if(isLow[1], min(lowest(low,3),low[-1]), prevLow[1]));<br />
rec prevHigh = compoundValue(1, if(isHigh[1], max(highest(high,3),high[-1]), prevHigh[1]));</code></p>
<p>Since the ZigZag function does not always grab the absolute high/low, I&#8217;ve added a little code to search the identified high/low bar for larger extreme values on adjacent bars. </p>
<p>Again, in plain english: set the value of prevLow to be the lowest low from this bar or the previous/following bars if and only if this bar has been identified as a swing low and if it is not then carry the value of the swing low from the previous bar forward. Similar for the prevHigh variable.</p>
<p>Tune in next time and we&#8217;ll dive deeper into the methodology for drawing in the blank space to the right of the last bar. Again, the <a href="http://www.thinkscripter.com/forum">AutoFibLines code is available in the forum</a> if you&#8217;d like it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thinkscripter.com/2009/06/02/thinkscripter-autofiblines-code-explained-part-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Four Volume</title>
		<link>http://www.thinkscripter.com/2009/05/13/four-volume/</link>
		<comments>http://www.thinkscripter.com/2009/05/13/four-volume/#comments</comments>
		<pubDate>Thu, 14 May 2009 04:27:37 +0000</pubDate>
		<dc:creator>ThinkScripter</dc:creator>
				<category><![CDATA[Indicator]]></category>
		<category><![CDATA[Add new tag]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[thinkscript]]></category>
		<category><![CDATA[up/down volume ratio]]></category>
		<category><![CDATA[volume]]></category>

		<guid isPermaLink="false">http://www.thinkscripter.com/?p=1243</guid>
		<description><![CDATA[Here is a bit of a twist on my earlier Up/Down Volume Ratio study. Rather than plot the ratio of an underlying equity or future contract, this study averages the volume of the /ES, /YM, /NQ, and /TF and performs the same calculations. In essence, I&#8217;m trying to see if more of the volume is [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a bit of a twist on my earlier <a href="http://www.thinkscripter.com/2009/01/20/updown-volume-ratio">Up/Down Volume Ratio</a> study. Rather than plot the ratio of an underlying equity or future contract, this study averages the volume of the /ES, /YM, /NQ, and /TF and performs the same calculations. In essence, I&#8217;m trying to see if more of the volume is going into the bars that close down or to those that close up. You can see from the plot that very high ratios often precede tops and very low ratios often precede bottoms. The indicator can also produce nice divergences as well.  (NOTE: This one is a resource hog! You may not want to run this on a &#8220;challenged&#8221; machine)</p>
<div id="attachment_1242" class="wp-caption aligncenter" style="width: 460px"><a href="http://www.thinkscripter.com/wp-content/uploads/2009/05/fourvolume.png"><img src="http://www.thinkscripter.com/wp-content/uploads/2009/05/fourvolume.png" alt="Four Volume" title="fourvolume" width="450" height="500" class="size-full wp-image-1242" /></a><p class="wp-caption-text">Four Volume</p></div>
<p><code><br />
# TS_FourVolume<br />
# (c) 2009 http://www.thinkscripter.com<br />
# thinkscripter@gmail.com<br />
# Last Update 13 May 2009</p>
<p>declare lower;</p>
<p>input VolumePeriod = 10;<br />
input OscillatorLength = 10;<br />
input priceChangeWeighted = NO;<br />
input overbought = 80.0;<br />
input oversold = 20.0;</p>
<p>input mode = {default UP_DOWN_VOL_RATIO, OSCILLATOR};</p>
<p>def price1 = close(&quot;/ES&quot;);<br />
def price2 = close(&quot;/NQ&quot;);<br />
def price3 = close(&quot;/YM&quot;);<br />
def price4 = close(&quot;/TF&quot;);</p>
<p>def volume1 = volume(&quot;/ES&quot;);<br />
def volume2 = volume(&quot;/NQ&quot;);<br />
def volume3 = volume(&quot;/YM&quot;);<br />
def volume4 = volume(&quot;/TF&quot;);</p>
<p>def avePrice = (price1+price2+price3+price4)/4.0;<br />
def delta = absValue(avePrice-avePrice[1]);<br />
def aveVolume = (volume1+volume2+volume3+volume4)/4.0;<br />
def multiplier = if(priceChangeWeighted, delta,1);</p>
<p>plot maxLine = 80.0;<br />
plot minLine = 20.0;<br />
maxLine.setDefaultColor(color.BLUE);<br />
minLine.setDefaultColor(color.BLUE);<br />
plot midLine = 50.0;<br />
midLine.setDefaultColor(color.WHITE);</p>
<p>def up = if(avePrice&gt;avePrice[1], aveVolume*multiplier, 0);<br />
def down = if(avePrice&lt;avePrice[1], aveVolume*multiplier, 0);<br />
def upvol = sum(up, VolumePeriod);<br />
def downvol = sum(down, VolumePeriod);</p>
<p>def UPDVR= ((upvol/(downvol+upvol)));</p>
<p>def highestVR = Highest(UPDVR, OscillatorLength);<br />
def lowestVR = Lowest(UPDVR, OscillatorLength);</p>
<p>plot FourVolume;</p>
<p>switch (mode) {</p>
<p>case UP_DOWN_VOL_RATIO:<br />
FourVolume = UPDVR*100;<br />
case OSCILLATOR:<br />
FourVolume = (UPDVR - lowestVR) / (highestVR - lowestVR)*100;<br />
}</p>
<p>FourVolume.DefineColor(&quot;OverBought&quot;, Color.DOWNTICK);<br />
FourVolume.DefineColor(&quot;Normal&quot;, color.cyan);<br />
FourVolume.DefineColor(&quot;OverSold&quot;, Color.UPTICK);<br />
FourVolume.AssignValueColor(if FourVolume &lt; oversold then FourVolume.color(&quot;OverSold&quot;)<br />
else if FourVolume &gt; overbought then FourVolume.color(&quot;OverBought&quot;)<br />
else FourVolume.color(&quot;Normal&quot;));</p>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.thinkscripter.com/2009/05/13/four-volume/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Hourly Rolling Pivots Update</title>
		<link>http://www.thinkscripter.com/2009/04/29/hourly-rolling-pivots-update/</link>
		<comments>http://www.thinkscripter.com/2009/04/29/hourly-rolling-pivots-update/#comments</comments>
		<pubDate>Thu, 30 Apr 2009 02:20:29 +0000</pubDate>
		<dc:creator>ThinkScripter</dc:creator>
				<category><![CDATA[Indicator]]></category>
		<category><![CDATA[Add new tag]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[Hourly rolling pivots]]></category>
		<category><![CDATA[pivot]]></category>
		<category><![CDATA[thinkscript]]></category>

		<guid isPermaLink="false">http://www.thinkscripter.com/?p=1183</guid>
		<description><![CDATA[One of our forum members pointed out a problem with the Rolling Pivots study that caused them to fail when plotted on tick charts. After a bit of troubleshooting I found my mistake and got the study up and running again. Good as new. The update is posted in the &#8220;Requests&#8221; forum in the Gold [...]]]></description>
			<content:encoded><![CDATA[<p>One of our forum members pointed out a problem with the <a href="http://www.thinkscripter.com/2009/03/21/hourly-rolling-pivots/">Rolling Pivots</a> study that caused them to fail when plotted on tick charts. After a bit of troubleshooting I found my mistake and got the study up and running again. Good as new. The update is posted in the &#8220;Requests&#8221; forum in the Gold Donor section and will be added to the weekly update this Sunday.</p>
<div id="attachment_1186" class="wp-caption aligncenter" style="width: 460px"><a href="http://www.thinkscripter.com/wp-content/uploads/2009/04/rollingupdate.png"><img src="http://www.thinkscripter.com/wp-content/uploads/2009/04/rollingupdate.png" alt="Rolling Pivots on Tick Charts" title="rollingupdate" width="450" height="500" class="size-full wp-image-1186" /></a><p class="wp-caption-text">Rolling Pivots on Tick Charts</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.thinkscripter.com/2009/04/29/hourly-rolling-pivots-update/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
