I have daily data for SP500 stocks, but not minute or tick data.
I wrote a simple multi-timeframe indicator that compare weekly and daily volume to their previous bar.
The code is here:
namespace NinjaTrader.Indicator
{
[Description("Enter the description of your new custom indicator here")]
public class aatest : Indicator
{
protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Dot, "Plot0"));
CalculateOnBarClose = true;
Overlay = false;
Add(PeriodType.Day, 1);
}
protected override void OnBarUpdate()
{
if (BarsInProgress != 0 )
return;
if(BarsInProgress==0)
{ if(Volume[0]>Volume[1]&&Volumes[1][0]>Volumes[1][1])
{DrawArrowUp("My up arrow" + CurrentBar, false, 0, Low[0] + -5 * TickSize, Color.Blue);
base.Values[0].Set(1); }
if(Volume[0]<Volume[1]&&Volumes[1][0]<Volumes[1][1])
{DrawArrowDown("My up arrow1" + CurrentBar, false, 0, High[0] + 5 * TickSize, Color.Yellow);
base.Values[0].Set(-1);}
}
}
#region Properties
[Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public DataSeries Plot0
{
get { return Values[0]; }
}
#endregion
}
}
Then I loaded the list of SP500 stock into the Market Analyzer, and in the "aatest" indicator column it all show "#check log#" message, and in the log it says:
" Failed to call 'OnBarUpdate' method for market analyzer column "aatest": index out of range exception"
Could you tell me what's the cause of this problem?
Thanks.

Comment