I’ve been messing with the TRIN as of late and crafted this polarized oscillator using the average value of the TRIN and TRINQ. The oscillator has been inverted so that a rising oscillator line is indicative of rising prices vice the way the actual TRIN works. I’d have to classify this one as experimental so feel free to hack away and post your modified version in the comments. I’ll be creating a user submissions page over the weekend and look forward to posting some of your best scripts!
# POLARIZEDTRINOSCILLATOR
# (c) 2009 http://www.thinkscripter.com
# thinkscripter@gmail.com
# Last Update 26 MAR 2009
declare lower;
input length = 9;
input EMA_period = 5;
def trin = close("$TRIN");
def trinq = close("$TRIN/Q");
def aveTrin = (trin+trinq)/2;
def fractal = sqrt(power(aveTrin-aveTrin[length],2)+100);
def incremental = sqrt(power(aveTrin-aveTrin[1],2)+1);
def sum = sum(incremental,length);
def resultant = if aveTrin-aveTrin[length] > 0 then round((fractal/sum)*100) else round(-(fractal/sum)*100);
def polarizedTrin = if resultant == 0 then 1 else resultant;
plot PTO = expAverage(-polarizedTrin, EMA_period);
PTO.setDefaultColor(color.yellow);
plot zeroline = 0.0;
zeroline.setDefaultColor(color.white);
plot plusLine =75;
plusLine.setDefaultColor(color.cyan);
plot minusLine = -75;
minusLine.setDefaultColor(color.cyan);






I had a question about another indicator. On StockCharts.com there is something called the “Summation Index (ratio adjusted)”, which you can get to with the symbol $NYSI. Supposedly it is a chart of advances-declines, but it’s very different from the chart on TOS of $ADVN-$DECN. Do you know if there is a way to duplicate this chart on TOS?
Thanks,
Bill
Bill,
You’ve peaked my curiosity and I’m investigating if it is possible.
Eric
I found this link with the formula, so I think you could make an indicator, but I was trying to figure out how to get it in the price chart area so an indicator (like MACD) could be applied to it. Not sure if that is possible.
http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:introduction_to_mark#mcclellan_summation_
Thanks Bill. The indicator was easy enough to build but I’m seeing some inconsistency issues with the ToS data for $ADVN and $DECN. I’m not sure what is causing it but there are holes in the data which make the chart incorrect. I will troubleshoot and contact ToS for their opinion.
Eric
Thanks for this script! Check my blog for my own version TICK indicator.
Here is a modification that I made that plots a DOT on the zero line for any time the TRIN is ABOVE 0 “bullish” and no dot when not plotted. The way this is to be used is NOT as a trade system but as a way of saying OKAY should I be more or less bullish. You have to wait until next bar is plotted for confirmation. So basically you want to look for shorts when no dots and buys when dots.
plot zeroCross = if PTO >= 0 then 0 else double.nan;
zeroCross.SetPaintingStrategy(paintingStrategy.points);
Put this on base study (behind graph) and hide everything else except zero line.
Here are my complete modifications. This adds a histogram fill and plots a dot when TRIN >= 0 as explained above.
plot histogramFill = PTO;
histoGramFill.SetPaintingStrategy(paintingStrategy.Histogram);
histoGramFill.SetDefaultColor(color.green);
histoGramFill.SetLineWeight(3);
plot zeroCross = if PTO >= 0 then 0 else double.nan;
zeroCross.SetPaintingStrategy(paintingStrategy.points);
I’m looking for a Fractal Indicator study for the TOS charts. I believe it’s a built-in study in MT4 but I don’t use that package so it would be nice to have a similar indicator for TOS. Have you seen one?
Mark,
The PolarizedFractalEfficiency study already exists in TOS. IS this close to what you want?
Eric
I was wondering if there was a Fractals indicator for TOS Thinkdesktop? This is the fractal indicator that Mark Stevenson was asking for. It is a standard indicator for the Metatrader 4 program. It is one of the main indicators for Bill Williams Alligator system. The way the indicator displays its results is with arrows above or below price bars.
# Bill Williams fractal indicator
# written by Mike Lapping
#
# Make sure that you change the settings for this indicator so that it plots arrows
# up for upfractal plots
# down for downfractal plots
#
# can be used and modified by anyone for any reason. do not sell.
def isupfractal;
def isdownfractal;
# Looking for high and low series of equalities
# checking for possible fractal formation
rec hicount = if (high == high[1], hicount[1] + 1, 0);
# if the last bar high is the same as this bar’s high, increment
# otherwise set false(0)
rec hivalid = if ((hicount[1] == 0 and hicount == 1 and high > high[2] and high > high[3]) or (hicount[1] and hicount and hivalid[1] ), 1, 0) ;
# set hivalid to true(1)
# if we are entering an equality series, check if the 2 bars preceding the first equal bar # are lower than the current bar
# or if the last bar was an equal bar and this bar is an equal bar and the current equal
# series is valid
# otherwise it is false
rec locount = if (low == low[1], locount[1] + 1, 0);
rec lovalid = if ((locount[1] == 0 and locount == 1 and low < low[2] and low high[1] and high > high[2])) and high > high[-1] and high > high[-2], high, 0);
# Ok this is complicated, basically its checking if there were a series of equal bars and
# if the two bars before the first equal bar were lower
# or if the last 2 bars were lower than the current bar
# and if the two following 2 bars are lower than the current bar
# Checking for a traditional or non-standard down fractal
isdownfractal = if(((locount and lovalid) or (low < low[1] and low < low[2])) and low < low[-1] and low < low[-2], low, 0);
plot upfractal = if( isupfractal, isupfractal + (15 * tickSize()), double.nan);
plot downfractal = if( isdownfractal, isdownfractal – (15 * tickSize()), double.nan);
# This business with the tickSize() function is basically putting the arrow further away
# from the bar so that the fractal is easier to read
Mike,
I think the “User Contributions: Studies” section in the forum would be a better place to post this but thanks for sharing regardless.
-Eric