Foreach Loop Issue



I'm having an issue with usnig a foreach loop inside my array declaration for my manual universe selection.  This little issue is tripping me up quite a bit in moving forward, so any help would be really great!!!

string[] arrayofTickers = new string[] {

public override void Initialize()
//General housekeeping and setup
SetStartDate(2018, 1, 15); //Set Start Date
SetEndDate(2018, 7, 15); //Set End Date
SetCash(100000); //Set Strategy Cash

UniverseSettings.Resolution = Resolution.Minute;
maxMinCount = maxDayCount*1440;

//Save number of tickers to a global int for later loop purposes in onData
numTickers = arrayofTickers.Length;

var symbols = new[] //Building list of all tickers for the universe
//foreach loop here? for QuantConnect.Symbol.Create(arrayofTickers[i], SecurityType.Equity, Market.USA)


//Set universe mode selection to manual
SetUniverseSelection(new ManualUniverseSelectionModel(symbols));

//Set all other modules to null
SetAlpha(new NullAlphaModel());
SetPortfolioConstruction(new NullPortfolioConstructionModel());
SetExecution(new NullExecutionModel());
SetRiskManagement(new NullRiskManagementModel());

Update Backtest

New to QC, but this is typically what that would look like for me (unless you are into LINQ).

// At top of file, to support List<>
using System.Collections.Generic;

// Create a list of Symbols
List<Symbol> symbols = new List<Symbol>();
foreach (var ticker in arrayofTickers) {
var symbol = QuantConnect.Symbol.Create(ticker, SecurityType.Equity, Market.USA);


I actually suspect I'm telling you to do things sorta outside the norm of QC :)  It would not surprise me if 1 or both of us over complicated things, in that I don't know the difference (yet) between a Symbol and a Security.  I could imagine this would be fine... 

foreach (var ticker in arrayofTickers) {
    AddEquity(ticker, Resolution.Daily);

And just use the Securities dictionary to retrieve them as necessary.  But I don't know things :)


Update Backtest


The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


This discussion is closed