// Downloaded From https://www.WiseStockTrader.com // This is an upgraded/fixed and improved version of the code that was originally created by Marek Chlopek /* 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 */ stochper = Param("Stochatic Period", 10, 1, 100); smoothper = Param("Smooth Period", 3, 1, 100); a = ATR(1); Value1 = IIf(Close > Ref(Close, -1), a / ((Close - Ref(Close, -1)) + 0.00001), a); Value2 = LLV(Value1, stochper); Value3 = HHV(Value1, stochper); StochRange = IIf((Value3 - Value2) > 0, 100 * (Value1 - Value2) / ((Value3 - Value2) + 0.00001), 100 * (Value1 - Value2)); TRI = EMA(StochRange, smoothper); Plot(TRI, _DEFAULT_NAME(), colorRed); Filter = 1; AddColumn(StochRange, "Stoch Range"); AddColumn(TRI, "TRI");