I'm trying to draw a diamond on the clicked candle but I get the following error message: Unhandled exception: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
My code :
protected void MouseClicked(object sender, MouseButtonEventArgs e) { clickPoint.X = ChartingExtensions.ConvertToHorizontalPixels(e.GetPosition(ChartControl as IInputElement).X, ChartControl.PresentationSource); clickPoint.Y = ChartingExtensions.ConvertToVerticalPixels(e.GetPosition(ChartControl as IInputElement).Y, ChartControl.PresentationSource); convertedPrice = Instrument.MasterInstrument.RoundToTickSize(chartScale.GetValueByY((float)clickPoint.Y)); convertedTime = ChartControl.GetTimeBySlotIndex((int)ChartControl.GetSlotIndexByX((int)clickPoint.X)); int iTemp = ChartBars.GetBarIdxByTime(ChartControl, convertedTime); Print(iTemp+" "+convertedTime.ToString()); Draw.Diamond(this, "tag1", true, iTemp, Low[iTemp] - TickSize, Brushes.Red); ForceRefresh(); }
Thanks for your explanations.
Edit : I'd like to point out that whatever the index, if it's different from 0 and doesn't come from iTemp but is hard-coded, I get this error.
Comment