| Kevin_in_GA 4,599 posts
 msg #95579
 - Ignore Kevin_in_GA
 | 8/11/2010 3:44:08 PM 
 Is there a way to tell the filter to show stocks only when S&P 500 is above its MA(X) and MA(X) is above MA(Y)? Here is what I tried among other things.
 
 and set{sp12,^spx MA12}
 and set{sp26,^spx MA26}
 and sp12>sp26
 and ^spx>sp12
 ++++++++++++++++++++++++
 
 1.  Create a user-defined variable of the ^SPX:
 
 set{SPX, ind(^SPX, close)}
 
 2.  Use the custom moving average (CMA) function to create 2 moving averages of the SPX:
 
 set{SPXMA12, cma(SPX, 12)}
 set{SPXMA26, cma(SPX, 26)}
 
 3.  Now simply use the following lines of code to get the relationships you are looking for:
 
 SPX above SPXMA12
 SPXMA12 above SPXMA26
 
 So all you need to do is to add the following line to your filter:
 
 set{SPX, ind(^SPX, close)}
 set{SPXMA12, cma(SPX, 12)}
 set{SPXMA26, cma(SPX, 26)}
 
 SPX above SPXMA12
 SPXMA12 above SPXMA26
 
 Now the filter will only return results if the above criteria are met.
 
 
 |