  | 
		John Faig 
      2012-01-17 21:14:38
	  	   	
	   
	  
	  
	  	   
	  	  
	  	  
	   	  	  
 | 	  
	  
 | 
    
 
	 
  I am trying to recreate an indicator I used in a different trading platform.  It takes three moving averages and creates an indicator of the strength of an uptrend (U1, U2, or U3) or a downtrend (D3, D2, D1).  The function has lots of errors.  I will eventually figure it out, but would appreciate some hlep to move up the learning curve faster. 
 
var score : int; 
var sma20_one_day : double; 
var sma65_one_day : double; 
var sma130_one_day : double; 
//VectorD pj = cFunctions.CreateNumericVector(); 
 
 
VectorD sma20 = cFunctions.CompileFormula("a = SMA(20);").GetVectorDouble("a") 
VectorD sma65 = cFunctions.CompileFormula("b = SMA(65);").GetVectorDouble("b") 
VectorD sma130 = cFunctions.CompileFormula("c = SMA(130);").GetVectorDouble("c") 
 
VectorD close = cFunctions.Close; 
for(int i = 130;i<close.Length;i++) 
{ 
sma20_one_day = sma20.GetValue(i);  
sma65_one_day = sma65.GetValue(i);  
sma130_one_day = sma130.GetValue(i);  
 
//assume D3 
score = 3; 
//U1 
if (sma130_one_day > sma20_one_day) and (sma20_one_day > sma65_one_day) then score = 1; 
//U2 
if (sma20_one_day > sma130_one_day) and (sma130_one_day > sma65_one_day) then score = 2; 
//U3 
if (sma20_one_day > sma65_one_day) and (sma65_one_day > sma130_one_day) then score = 3; 
//D1 
if (sma65_one_day > sma20_one_day) and (sma20_one_day > sma130_one_day) then score = 1; 
// D2 
if (sma65_one_day > sma130_one_day) and (sma130_one_day > sma20_one_day) then score = 2; 
 
//pj[i] = score;  
result.SetValue(i, score); 
 
} 
 
       
       
 
 
 | 
 |