Sign

Sign ( double number );

Description

Returns the algebraic sign of a number: 1 if the number is positive, 0 if zero and -1 if negative.

Input parameters

Parameter Default value Description
number - Defines the number whose sign is found.

Example 1

declare lower;
plot Trend = Sign( ExpAverage(close, 15) - ExpAverage(close, 30) );

The example draws a plot showing the current trend as 1(bullish), 0(neutral), or -1(bearish) values depending on the difference between two EMAs.

Example 2

declare lower;
plot Data = Average(Sign(close - close[1]) * (high - low), 15);

The example draws the average range for 15 bars considering the closing price change as compared to the previous bar.