| 
	If it is any help, here is another version. 
	// Universal Oscillator 
	// (c) 2014 John F. Ehlers 
	// TASC January 2015 
	// mapped to C# for WhenToTrade platform by LvT 
	  
	using System; 
	  
	namespace WTTScripting 
	{ 
	public partial class Indicator 
	{ 
	///<scriptname> 
	///Ehlers Universal Oscillator 
	///</scriptname> 
	///<param> 
	///Length(20) 
	///</param> 
	///<plotfuture> 
	///false 
	///</plotfuture> 
	///<summary> 
	///Plots universal oscillator 
	///as shown in TASC January 2015 
	///</summary> 
	public static double[] UNIOSC(double[] source, string stringParam) 
	{ 
	//---- Define general script parameters 
	int currentbar = 1;  // barcounter  
	int Bars = source.Length; // length of source dataset (bars) 
	double[] returnvalues = new double[source.Length]; // init of return dataset 
	  
	//---- Define individual script parameters 
	double WhiteNoise, a1, b1, c1, c2, c3, Filt, Peak, Universal; 
	double prevWhiteNoise1, prevFilt1, prevFilt2, prevPeak1; //used to store previous values 
	  
	//----  Parse script input parameters "xxx,xxx,xxx,xxx" 
	int BandEdge; // individual parameter from individual settings 
	string[] param = stringParam.Split(','); 
	int.TryParse(param[0], out BandEdge); 
	  
	//---- set initial values 
	WhiteNoise = Filt = Peak = prevFilt1 = Universal = 0; 
	if (BandEdge == 0) BandEdge = 20; 
	// initialize first indicator values for return dataset with zero 
	for (int z = 1; z <= BandEdge + 2; z++) returnvalues[Bars - z] = 0.0; 
	  
	//---- Loop over dataset and do script calculation 
	int i = Bars-3; 
	while (i >= 0) 
	{ 
	//save previous values 
	prevWhiteNoise1 = WhiteNoise; 
	prevFilt2 = prevFilt1; 
	prevFilt1 = Filt; 
	prevPeak1 = Peak; 
	  
	//start calculation 
	WhiteNoise = (source[i] - source[i+2]) / 2; 
	  
	// SuperSmoother Filter 
	a1 = ExpValue(-1.414 * 3.14159 / BandEdge); 
	b1 = 2 * a1 * Cosine(1.414 * 180 / BandEdge); 
	c2 = b1; 
	c3 = -a1 * a1; 
	c1 = 1 - c2 - c3; 
	Filt = c1 * (WhiteNoise + prevWhiteNoise1) / 2 + c2 * prevFilt1 + c3 * prevFilt2; 
	if (currentbar == 1) Filt = 0; 
	if (currentbar == 2) Filt = c1 * 0 * (source[i] + source[i+1]) / 2 + c2 * prevFilt1; 
	if (currentbar == 3) Filt = c1 * 0 * (source[i] + source[i+1]) / 2 + c2 * prevFilt1 + c3 * prevFilt2; 
	  
	// Automatic Gain Control (AGC) 
	Peak = .991 * prevPeak1; 
	if (currentbar == 1) Peak = .0000001; 
	if (AbsValue(Filt) > Peak) Peak = AbsValue(Filt); 
	if (Peak!= 0) Universal = Filt / Peak; 
	  
	//Write back final return value 
	returnvalues[i] = Universal; 
	  
	currentbar++; 
	i--; 
	} 
	  
	return returnvalues; 
	} 
	// end individual script indicator function 
	} 
	// end of indicator class 
	} 
	// end of namespace WTTScripting 
	  |