I'm doing something incredibly dumb, but I can't figure it out. It seems like a simple solution.
I added a 5 period EMA to my script in the following manner (simplified for the sake of example):
--------
public class TrackingAandB : Strategy
{ double ema_5; }
protected override void OnBarUpdate()
{ ema_5 = EMA(5)[1]; }
-------
The code compiles, but the following comes up in the Output field:
"Strategy 'TrackingAandB': Error on calling 'OnBarUpdate' method on bar 0: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart."
I've tried using CurrentBar > 5 before allowing the script to read that code bit, but it still produces the above.
I'm also attempting to test this script using a recorded session via Market Replay, using a 20 tick chart.
Thanks in advance for any guidance you can give me.
Comment