Returns the second parameter value if the first parameter value is true. Returns the third parameter value if the first parameter value is false. This function is analogous to the Microsoft Excel IF function.

Syntax:

value = IfThenElse( condition, trueValue, falseValue )

 

Parameter:

Description:

condition

Condition, or statement that evaluates to TRUE or FALSE

trueValue

Value returned if condition is TRUE

falseValue

Value returned if condition is FALSE

 

Example:

'   This function is useful in calculated indicators,
'   where you can only enter an expression.
'   Example of calculated indicator which will return the true
'   low of the day. This could be part of a true range calculation:
IfThenElse( instrument.close[1] < instrument.low, _

           instrument.close[1], instrument.low )

 
value = IfThenElse( 1 = 2, 3, 4 ) ' Returns 4
value = IfThenElse( 2 = 2, 3, 4 ) ' Returns 3

Returns:

True-Value, if condition is TRUE, otherwise False-Value.

 

Links:

 

See Also:

Mathematical Functions

 


Edit Time: 9/25/2017 09:09:58 AM


Topic ID#: 377

 

Created with Help & Manual 7 and styled with Premium Pack Version 2.80 © by EC Software