Only show smallest variable

 

Hi,

I have three variables (values of this variables are for example: 68, 25, 93). Now I will only show the smallest one of them in the indicator window.

How can I check this three variables so I get back the smallest one?

Thanks

 

for example: 3 variables are var1,var2 and var3 and additional variable called smallest.

if(var1<var2) smallest=var1;

else smallest=var2;

if (var3<smallest) smallest=var3;

 

Ok, thought there is a small functionn out there for that....

Say it are five variables... how to it then?

Thanks

 

I think that is something that is missing from MT4's math routines.

You can use the MathMin(Var1, Var2) in a loop to do this. It sucks to do something complicated for something that simple. I with MT people provide us with a built in Highest and Lowest routine for any number. Currently, it can only do that for the OHLC type of values.

 
Jagg:
Ok, thought there is a small functionn out there for that....

Say it are five variables... how to it then?

Thanks

The following snippet can be used for any fixed number of variables:

double values[] = { var1, var2, .., varN };

double min = ArrayMinimum( values );

 
ralph.ronnquist:
double values[] = { var1, var2, .., varN };

double min = ArrayMinimum( values );

[/PHP]

Ok, I have PDiff, S1Diff, ... variables (double). Now I tried:

[PHP]double values[] = { PDiff, S1Diff, S2Diff, R1Diff, R2Diff };

double min = ArrayMinimum( values );

but get

'}' - comma or semicolon expected

Reason: