Chart.FindAllObjects() Crashes when there is a Fibonacci Timezones on the Chart.
Chart.FindAllObjects() Crashes when there is a Fibonacci Timezones on the Chart.
12 Apr 2023, 10:02
I'm trying to get all the Fibonacci Timezones on the chart with Chart.FindAllObjects(), but the indicator crashes when there is a Fibonacci Timezones on the chart. This crash only happens with Fibonacci Timezones as far as I know. I tried creating a new indicator and placing one single line of code on the Initialize method to test this.
The line of code I used is:
var myFibTimezonesChartObjects = Chart.FindAllObjects(ChartObjectType.FibonacciTimezones);
Here is the error:
Crashed in Initialize with ArgumentOutOfRangeException: Exception of type 'System.ArgumentOutOfRangeException' was thrown. (Parameter 'chartObjectType') Actual value was FibonacciTimezones.
Then I tried another way, but it still crashes.
List<ChartFibonacciTimezones> myFibTimeZonesList = new List<ChartFibonacciTimezones>();
foreach (ChartObject obj in Chart.Objects)
{
if (obj.ObjectType == ChartObjectType.FibonacciTimezones)
{
Print(" TEST !!!!!!!!!!!!!"); //<<<<<<---------------- This never prints
ChartFibonacciTimezones fibTimeZones = (ChartFibonacciTimezones)obj;
myFibTimeZonesList.Add(fibTimeZones);
}
}
ChartFibonacciTimezones[] myFibTimeZonesArray = myFibTimeZonesList.ToArray();
The only way it doesn't crash is if i find the object by name, but that doesn't help me.
pick
13 Apr 2023, 13:24
This issue also appears on my end when calling to obj.ObjectType on a FibonacciTimezone. Below I will include a crude workaround, but don't rely on this to work going forward - hopefully an official change can be made in the near future.
@pick