Please confirm if there is a better way to initialize a generic list with three dimensions than the code below:
#region Using declarations using System.Collections.Generic; #endregion namespace NinjaTrader.Indicator { public class TEST : Indicator { #region Variables private string sOutput; private List<List<List<double>>> MDList = new List<List<List<double>>>(); private List<List<double>> SubList = new List<List<double>>(); #endregion protected override void Initialize() { for (int i = 1; i < 4; i++) { SubList.Add (new List<double>(new double[]{(i*10+1),(i*10+2),(i*10+3)})); } for (int i = 0; i < 3; i++) { MDList.Add (SubList); } } protected override void OnBarUpdate() { sOutput = ""; for (int i=0; i < 3; i++) { sOutput = sOutput + i.ToString() + Environment.NewLine; for (int j=0; j < 3; j++) { for (int k=0; k < 3; k++) { sOutput = sOutput + MDList[i][j][k] + "\t"; } sOutput = sOutput + Environment.NewLine; } } Print (""); Print (sOutput); } } }
Shannon
Comment