/* TRI.AFL v 1.00 17/10/2001
/* TRI - The Range Indicator
/* Developed by Jack L. Weinberg
/* From Technical Analysis of Stocks and Commodities, V13:6 (238-242)
/* Coded by Marek Chlopek, October 2001
/* Support from Tomasz Janeczko and Amibroker Mailing List members - THANKS!!!
*/
/* **************************************************************************
*/
/* StochRange - first step in constructing the TRI
/* StochRange - an oscillator of the ratio of the daily true range with the intraday range
/* Value1 - Today's True Range divided by today's close minus yesterday's close unless C-Ref(C,-1) < 0 then Value1 = True Range
/* Value2 - the lowest value of Value1, over the last q days
/* Value3 - the highest value of Value1, over the last q days */
q = 10; /* stochastic period */
Value1 = IIf(Close > Ref(Close, -1), ATR(1) / (Close - Ref(Close, -1)), ATR(1));
Value2 = LLV(Value1, q);
Value3 = HHV(Value1, q);
StochRange = IIf((Value3 - Value2) > 0, 100 * (Value1 - Value2) / (Value3 - Value2), 100 * (Value1 - Value2));
/* The Range Indicator - TRI by J.L Weinberg
/* The Range Indicator - smooth StochRange using an exponential moving average
of m periods */
m = 3; /* exponential smoothing period */
TRI = EMA(StochRange, m);
/* **************************************************************************
*/
/* Graphic presentation in Amibroker */
MaxGraph = 1;
Graph0 = TRI;
Title = Name() + " - TRI = " + WriteVal(Graph0, 1.2) + " %";
/* **************************************************************************
*/
/* Exploration in Amibroker */
Filter = 1;
NumColumns = 2;
Column0 = StochRange; Column0Name = "StochRange"; Column0Format = 1.2;
Column1 = TRI; Column1Name = "TRI"; Column1Format = 1.2;
/* **************************************************************************
*/
/* END TRI Indicator Formula */