Discuss plot normalization code

 

I'm talking about oscillator based indicators, and by normalization I mean that the plot is in a stable range and the 0.00 level remains directly in the center of the window.

My knowledge is limited on this, but I figured out that if you have a plot ranging from a negative value to a positive value, this will work:


double buffer_max = 0.0;

if(buffer_max < MathAbs(vzo[0])){
      
   buffer_max = MathAbs(vzo[0]);
}  

double buffer_current = vzo[0];

// negative value area normalization
IndicatorSetDouble(INDICATOR_MINIMUM, MathMin(buffer_current, -buffer_max)  -  (MathAbs(MathMin(buffer_current, -1)/(MathMax(buffer_current, 1) - MathMin(buffer_current, -1)))

// positive value area normalization
IndicatorSetDouble(INDICATOR_MAXIMUM, MathMax((buffer_current, buffer_max) +  (MathAbs(MathMin(buffer_current, 1)/(MathMax(buffer_current, 1) - MathMin(buffer_current, -1)))


It was figured out through a lot of trial and error. I didn't take knowledge from any source, I wonder if my way is common or if there are better approaches?

I have another indicator which plots very miniscule numbers for example 55.004923 at the top of the window and 55.00129 at the bottom of the window, and I could not manage to normalize this without the plot modulations becoming very flattened out. 

 
Hi
Try to limit the height of your window

 #property indicator_minimum - 4
 #property indicator_maximum 4

0 will be in the center....
Reason: