Hello All,

I want to find 400 stocks for my trend following strategy. The stocks should have less noise and more trends.

According to Perry Kaufman Author. The Kaufman efficency ratio helps to find out if the stock trends or not.

 

I am creating  sample algorithm to calculate kaufmanefficiencyratio for 20-day period and use endofalgorithm to print average kaufman efficiency ratio of last one year. The algorithm should only run once per month  and calculate average kaufman efficiency ratio for each 20-day period

 

The code is not working. Please help