I have just written this very simple strategy, which is just supposed to print the state of bid-ask prices for input instruments. Unfortunately I am getting the following error, that I do not understand at all.
namespace NinjaTrader.Strategy
{
[Description("...")]
public class MyCustomStrategy : Strategy
{
#region Variables
private string instruments = "";
private string[] instruemntsArray;
private Dictionary<string, double> bidDict = new Dictionary<string, double>();
private Dictionary<string, double> askDict = new Dictionary<string, double>();
private List<string> barDesc = new List<string>();
private DateTime currentTime = new DateTime();
#endregion
protected override void Initialize()
{
CalculateOnBarClose = true;
instruemntsArray = instruments.Split(',');
foreach (string instr in instruemntsArray)
{
Add(instr, BarsPeriod.Id, 1, MarketDataType.Bid);
Add(instr, BarsPeriod.Id, 1, MarketDataType.Ask);
bidDict.Add(instr, 0);
askDict.Add(instr, 0);
barDesc.Add("Bid");
barDesc.Add("Ask");
}
}
protected override void OnBarUpdate()
{
if (Historical) { return; }
#region print out data if new timestamp
if (currentTime != Time[0])
{
string thisPrint = currentTime.ToString();
foreach (string instr in instruemntsArray)
{
thisPrint += "#" + bidDict[instr] + "#" + askDict[instr];
}
Print(thisPrint);
currentTime = Time[0];
}
#endregion
#region assign new price
switch (barDesc[BarsInProgress])
{
case "Bid":
bidDict[Instrument.FullName] = Close[0];
break;
case "Ask":
askDict[Instrument.FullName] = Close[0];
break;
default:
break;
}
#endregion
}
#region Properties
[Description("")]
[GridCategory("Parameters")]
public string Instruments
{
get { return instruments; }
set { instruments =value; }
}
#endregion
}
}

Comment