I am applying the selection algorithm in the snippet below, but I am getting a compilation error on the line that is supposed to take the price-filtered list and apply EMA filtering to it (the line that begins with var EMALong, towards the end).

I've tried understanding what's wrong and suspect it's some kind of a type mismatch issue, though i can't put my finger on it. Can anyone take a look and give a poor C# noob a help?


public class UniverseSelectionADX : QCAlgorithm {
private const int NumberOfSymbols = 10;
private const decimal AllocationProportion= 0.1m;
private readonly ConcurrentDictionary<Symbol, EMASelection> EMASelectionData = new ConcurrentDictionary<Symbol, EMASelection>(); //defines a dictionary: EMASelectionData

private class EMASelection{ //function to handle selection by EMA
public readonly ExponentialMovingAverage Fast;
public readonly ExponentialMovingAverage Slow;

public EMASelection(){
Fast = new ExponentialMovingAverage(9);
Slow = new ExponentialMovingAverage(21);

public decimal ScaledDelta{ //calculates the proportion of ema delta
get { return (Fast - Slow)/((Fast + Slow)/2m); }

public bool Update(DateTime time, decimal value){ // updates the EMA indicators, returning true when they're both ready
return Fast.Update(time, value) && Slow.Update(time, value);

SecurityChanges _changes = SecurityChanges.None; // initialize our changes to nothing

public override void Initialize() {
UniverseSettings.Leverage = 2.0m;
UniverseSettings.Resolution = Resolution.Daily;

SetStartDate(2014, 01, 01);
SetEndDate(2015, 01, 01);

AddUniverse(CoarseSelectionFunction); // this add universe method accepts a single parameter that is a function that accepts an IEnumerable<CoarseFundamental> and returns IEnumerable<Symbol>

public static IEnumerable<Symbol> CoarseSelectionFunction(IEnumerable<CoarseFundamental> coarse) { // sort the data by daily dollar volume and take the top 'NumberOfSymbols'
var filteredByPrice = coarse.Where(x => (x.Price > 15m) && (x.Price < 150m)); //filter out stocks by price
var EMALong = EMASelectionData.GetOrAdd(filteredByPrice(x => x.Symbol), selectionF => new EMASelection());
// var EMAFiltered = filteredByPrice;
var sortedByDollarVolume = filteredByPrice.OrderByDescending(x => x.DollarVolume); // sort descending by daily dollar volume
var topEntries = sortedByDollarVolume.Take(NumberOfSymbols); // take the top entries from our sorted collection
return topEntries.Select(x => x.Symbol); // return only the symbol objects