2010-12-24 15:30:49:926 ERROR: The indicator 'a1RolloverVolume' has called the Add() method with an invalid instrument. Either 'GC 03-11' does not exist in the Instrument Manager or the specified exchange has not been configured.
2010-12-24 15:30:49:928 in OnUnhandledThreadException
2010-12-24 15:30:49:933 ********* exception trapped *********
2010-12-24 15:30:49:933 Index was outside the bounds of the array.
2010-12-24 15:30:49:933 at NinjaTrader.Indicator.IndicatorBase.set_BarsArray( Bars[] value)
at NinjaTrader.Gui.Chart.ChartIndicators.Apply()
at NinjaTrader.Gui.Chart.ChartIndicators.OnOkButtonCl ick(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
------- The Indicator Code is below ------
using System.Globalization; //### TryParse
using System.Text.RegularExpressions; //### Regex
#region Variables
string str="", symbols = "6E, GC, CL, XXX", report="";
Match m;
int month=0, year=0;
int i=0;
#endregion
protected override void Initialize() {
Overlay = true;
CalculateOnBarClose = true;
try {
//### Get all symbols to monitor
Regex spaces = new Regex("\\s+"); symbols = spaces.Replace(symbols, " ");
symbols = symbols.Trim();
string[] split = symbols.Split(new char[] {','});
i = 0;
//### Default Expiry
m = Regex.Match(Instrument.FullName, "(\\d+)-(\\d+)");
if (m.Success) {
Int32.TryParse(m.Groups[1].Value, out month);
Int32.TryParse(m.Groups[2].Value, out year);
}
if ( String.IsNullOrEmpty(symbols) ) {
report = "No symbols specified.";
}
else {
foreach (string s in split) {
if ( !String.IsNullOrEmpty(s) ) {
str = s.Trim();
//### Symbol
string symbol="";
m = Regex.Match(str, "^(.*?)(\\s|,|$)");
if (m.Success) {
symbol = m.Groups[1].Value +" " +month.ToString("00") + "-" +year.ToString("00");
Print (" Adding: " +symbol);
Add(symbol, PeriodType.Day, 1);
}
}
}
}
} //try
catch (Exception ex){
Print("Exception: " + ex.Message);
} //catch
}
protected override void OnBarUpdate(){
}
Comment