Summary: This indicator script is a range oscillator which provides clear, timely turning points. Calculation: Complex, see script. Developer: John Ehlers Interpretation: 1. Overbought: When the underlying indicator is moving upwards, but the indicator script is approaching its upper bound, the underlying indicator is likely to reverse direction and move downwards. 2. Oversold: When the underlying indicator is moving downwards, but the indicator script is approaching its lower bound, the underlying indicator is likely to reverse direction and move upwards.
' Assign the parameters to script variables. _symbolIndex = symbolIndex _periods = periods _firstPeriods = firstPeriods
' Get the highest prices of the symbol, indexed by bar index. Define high() As Number = BarHigh(_symbolIndex, barIndex, length + 8 + _periods + 2 * _firstPeriods) ' Get the lowest prices of the symbol, indexed by bar index. Define low() As Number = BarLow(_symbolIndex, barIndex, length + 8 + _periods + 2 * _firstPeriods) ' Get the closing prices of the symbol, indexed by bar index. Define close() As Number = BarClose(_symbolIndex, barIndex, length + 8 + _periods + 2 * _firstPeriods) ' Use for holding the highest and lowest number so far. Define highest,lowest As Number ' Use for the calculated raw values, indexed by bar index. Define raw(length + 8 - 1 + 2 * _firstPeriods) As Number ' Use for the 5 period exponential moving average of the raw values, indexed by bar index. Define smoothed(length + 3 - 1 + _firstPeriods) As Number ' Use for the calculated Fisher Transform values, indexed by bar index. Define results(length - 1) As Number ' Calculate the raw values for the specified bar range. For i As Integer = length + 8 - 1 + 2 * _firstPeriods To 0 Step -1 highest = 0 lowest = 10000000 ' Calculate the raw value for the current bar. For j As Integer = i + _periods - 1 To i Step -1 If (highest < high(j)) Then highest = high(j) End If If (lowest > low(j) And low(j) <> 0) Then lowest = low(j) End If Next raw(i) = 2 * (close(i) - lowest) / (highest - lowest) - 1 Next ' Use for the 5-periods exponential moving average smoothing factor. Define smoothFactor As Number = 2 / (5 + 1) ' Use for the exponential moving average sum. Define sum As Number For i As Integer = length + 3 - 1 + _firstPeriods To 0 Step -1 sum = 0 For j As Integer = i + 5 - 1 + _firstPeriods To i Step -1 If (sum <> 0) Then sum = smoothFactor * raw(j) + (1 - smoothFactor) * sum Else sum = raw(j) End If Next smoothed(i) = sum Next Define fishValue As Number ' Use for the 3-periods exponential moving average smoothing factor. smoothFactor = 2 / (3 + 1) For i As Integer = length - 1 To 0 Step -1 sum = 0 ' Calculate the Fisher Transform value for the current bar. For j As Integer = i + 3 - 1 + _firstPeriods To i Step -1 fishValue = MathLn((1 + smoothed(j)) / (1 - smoothed(j))) If (sum <> 0) Then sum = smoothFactor * fishValue + (1 - smoothFactor) * sum Else sum = fishValue End If Next results(i) = sum Next Return results