Indicator keeps the same INDICATOR_MAXIMUM/MINIMUM set values after reloading

 

Hi!

I'm developing an indicator of the "separate window" kind that has an input variable where the user can choose between different visualization algorithms. In one of those, I need the maximum and minimum value to be set fixed (3.0 and -3.0 specifically), while in any other algorithm it's not supposed to have fixed max/min values with the Y axis "running free" in accordance with the data to be visualized.

In order for that to happen, I added an if clause in the OnInit function only setting max/min in case the especific algorithm was selected while doing nothing for the others:

if (Algorithm == AlgoWithMaxMinLimited)
   {
      if (!IndicatorSetDouble(INDICATOR_MAXIMUM,3.0))
      {
      
      }
      
      if (!IndicatorSetDouble(INDICATOR_MINIMUM,-3.0))
      {
      
      }
   }

What is happening, though, is that, as soon as I load the indicator with the input variable set to the algorithm with limited max/min value and then later change to another, different algorithm, the previously set max/min values are kept in the chart, thus cropping the visualization, instead of being reset. In other words, it's like OnInit wasn't being fully reloaded when the indicator has an input variable changed.

Is that how it is supposed to work? It surely looks like a bug to me. That being said, if it is supposed to be so, then how can I change the y axis to behave as previously, without a set maximum/min value and updating its values in accordance with the data? (I tried putting 0.0, but it didn't work).

Here is a video with the reported behavior:


 
   if(Algorithm == AlgoWithMaxMinLimited)
   {
      IndicatorSetDouble(INDICATOR_MAXIMUM, 3.0);
      IndicatorSetDouble(INDICATOR_MINIMUM,-3.0);
   }
   else
   {   
      IndicatorSetInteger(INDICATOR_FIXED_MAXIMUM,false);
      IndicatorSetInteger(INDICATOR_FIXED_MINIMUM,false);
   }