Start reading about if statements and Operators
if (apples > oranges) // if apples is greater than oranges eatFruit() // run some function
This form is a great place to learn and develop your programming skills. Welcome.
Thank you.
I know for 2 values, but I want to compare the values of a list 8,10,...values, and to keep the highest.
Off the top of my head.... Not tested and will not compile. But those are some options. Or something like that.
double highest_value( double value_Ray[] ){
arraysort( double value_Ray[] ); //sort in highest first
return( value_Ray[0] );
}
double highest_value( double value_Ray[] ){ double highest_value;
for(int i=arraysize( value_Ray )-1; i>=0; i--){
if( value_Ray[i]>highest_value || highest_value==0 ){ highest_value= value_Ray[i] ;}
}
return( highest_value );
}
If you don't have the values in arrays then ... you could
if( value1>=value2 && value1>=value3 ){double highest=value1;}else
if( value2>=value1 && value2>=value3 ){ highest=value2;}else
if( value3>=value1 && value3>=value2 ){ highest=value3;}else
etc........ but very crude indeed.
Off the top of my head.... Not tested and will not compile. But those are some options. Or something like that.
double highest_value( double value_Ray[] ){
arraysort( double value_Ray[] ); //sort in highest first
return( value_Ray[0] );
}
double highest_value( double value_Ray[] ){ double highest_value;
for(int i=arraysize( value_Ray )-1; i>=0; i--){
if( value_Ray[i]>highest_value || highest_value==0 ){ highest_value= value_Ray[i] ;}
}
return( highest_value );
}
If you don't have the values in arrays then ... you could
if( value1>=value2 && value1>=value3 ){double highest=value1;}else
if( value2>=value1 && value2>=value3 ){ highest=value2;}else
if( value3>=value1 && value3>=value2 ){ highest=value3;}else
etc........ but very crude indeed.
Do you see this crystal7 3 different ways given by ubzen to compare values ....
Thank you
I'm not familiar with array, but I will learn and test that.
If i have some problems I come back to you.
how is ArrayMaximum() sounds
Nice function. Learn something new every-day. :)
That's also what I do Thank you qjol
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
I want to compare differentes values and to keep the highest or the lowest in an ea.
How I can code that. Is there a fonction to compare the value of variables?
Thank you