I'm trying to create an Exponential ATR indicator based on a Daily chart which I will be referencing from within my strategy running against an Hourly chart. Here's what I've achieved so far which, given that I'm posting here, isn't working.
protected override void Initialize()
{
Add(PeriodType.Day,1); //BarsArray[1]
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if (BarsInProgress == 1)
return; // Ignore change to Daily Bar
if (CurrentBar == 0)
Value.Set(Highs[1][0] - Lows[1][0]);
else
{
double trueRange = Highs[1][0] - Lows[1][0];
trueRange = Math.Max(Highs[1][0],Closes[1][1]) - Math.Min(Lows[1][0],Closes[1][1]);
Value.Set((trueRange - Value[1]) * ( 2/(1 + Period)) + Value[1]);
}
}
I modeled this after the standard ATR indicator. What I have read in the manual suggests that this is the way to access a different chart's data, but NT7 really doesn't seem to want to do it. I don't care about seeing a plot, I just need to resulting double value.
When I try to reference this from within my strategy using double thisATR = myATR[0] I'm getting the error message "Cannot apply indexing with [] to an expression of type 'method group'" when I attempt to compile. Google doesn't know anything about that error, and neither do I.
Any thoughts?
Thanks in advance for your assistance.
Comment