Here the code:
namespace NinjaTrader.NinjaScript.Strategies { public class Trendline { public int Position; public double Price; public Trendline() { Position=0; Price=0.00; } } public class R : Strategy { Trendline[] Uptrend; // Array of uptrends Trendline[] Downtrend; // Array of uptrends private int ARRAY_SIZE; // Array size private int Uptrendcount; // Number of active uptrends private int Downtrendcount; // Number of active Downtrends protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @""; Name = "R"; Calculate = Calculate.OnPriceChange; MaximumBarsLookBack = MaximumBarsLookBack.Infinite; } else if (State == State.Configure) { ARRAY_SIZE = 100000; Uptrendcount = 0; Downtrendcount = 0; Uptrend = new Trendline[ARRAY_SIZE]; Downtrend = new Trendline[ARRAY_SIZE]; } } protected override void OnBarUpdate() { if ( CurrentBar < 1 ) { Uptrendcount=0; Downtrendcount=0; for (int i = 0; i <ARRAY_SIZE; i++) { Uptrend[i]= new Trendline(); Downtrend[i]= new Trendline(); } for (int i = 0; i <ARRAY_SIZE; i++) // just in case this initialization was necessary to solve the issue { Uptrend[i].Position=0; Uptrend[i].Price=0.00; Downtrend[i].Position=0; Downtrend[i].Price=0.00; } return; } if (IsFirstTickOfBar) { if ( Uptrendcount==0 && Downtrendcount==0 ) { Ps=0; } else { // certain code } Uptrendcount+=1; Downtrendcount+=1; } ...the continues relying on that at least are Uptrendcount=1 and Downtrendcount=1, but they're just 0....logically I got an array error outside of bounds
Thanks in advance
Comment