Help Debugging Fisher Transform Code (Ehlers)

Discussion in 'Technical Analysis' started by newbie73, Dec 2, 2008.

  1. newbie73

    newbie73

    The attached file is a chart showing a test on the S&P 500 for the past 10 years.

    This looks obviously wrong and I may be having problems with how I scale/normalize the data before passing it to the Fisher Transform function.

    NOTE: I am not using smoothing via Moving Averages or Exp. Moving Averages as I am trying to simplify my code to identify the main error. It may have to do with using a global min and global max for data scaling.

    Pseudo Code:
    Code:
    
    # normalization / scaling to keep data within (-1, 1)
    gMin = min(ts)
    gMax = max(ts)
    gRng = gMax-gMin
    gMid = (gMin + gMax)/2.0
    
    for i in range(0, ts.size-1):           
    	t = 2 * (ts[i]-gMid)/gRng
    	
    	if t < -.9999:
    		t = -.9999
    	elif t > .9999:
    		t = .9999
    	
    	#           t -= .5
    	ndata.append(t)
    
    #fisher transform being applied below
    
    ndata = .5 * ln( (1+ndata)/(1-ndata) )