PineJSStd
An interface representing the standard library functions for PineJS.
Indexable
▪ [key: string
]: (...params
: any
[]) => any
Methods
abs
Absolute value of x is x if x >= 0, or -x otherwise.
Signature
abs(x: number) => number
Parameters
Name | Type |
---|---|
x | number |
Returns
The absolute value of x
number
accdist
Accumulation/distribution index.
Signature
accdist(context: IContext) => number
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
Accumulation/distribution index.
number
acos
The acos function returns the arccosine (in radians) of number such that cos(acos(y)) = y
for y
in range [-1, 1]
.
Signature
acos(x: number) => number
Parameters
Name | Type | Description |
---|---|---|
x | number | Angle, in radians. |
Returns
The arc cosine of a value; the returned angle is in the range [0, Pi]
, or na if y is outside of range [-1, 1]
.
number
add_days_considering_dst
Get time in daysCount
number of days while taking Daylight savings time into account.
Signature
add_days_considering_dst(timezone: string, utcTime: Date, daysCount: number) => Date
Parameters
Name | Type | Description |
---|---|---|
timezone | string | Timezone |
utcTime | Date | Date (JS built-in) |
daysCount | number | Number of days |
Returns
The time is daysCount
number of days, taking into account Daylight savings time.
Date
alma
Arnaud Legoux Moving Average. It uses Gaussian distribution as weights for moving average.
Signature
alma(series: IPineSeries, length: number, offset: number, sigma: number) => number
Parameters
Name | Type | Description |
---|---|---|
series | IPineSeries | Series of values to process. |
length | number | Number of bars (length). |
offset | number | Controls tradeoff between smoothness (closer to 1) and responsiveness (closer to 0). |
sigma | number | Changes the smoothness of ALMA. The larger sigma the smoother ALMA. |
Returns
number
and
Logical AND. Applicable to boolean expressions.
Signature
and(expr1: boolean, expr2: boolean) => boolean
Parameters
Name | Type |
---|---|
expr1 | boolean |
expr2 | boolean |
Returns
Boolean value
boolean
asin
The asin function returns the arcsine (in radians) of number such that sin(asin(y)) = y
for y
in range [-1, 1]
.
Signature
asin(x: number) => number
Parameters
Name | Type | Description |
---|---|---|
x | number | Angle, in radians. |
Returns
The arcsine of a value; the returned angle is in the range [-Pi/2, Pi/2]
, or na if y is outside of range [-1, 1]
.
number
atan
The atan function returns the arctangent (in radians) of number such that tan(atan(y)) = y
for any y
.
Signature
atan(x: number) => number
Parameters
Name | Type | Description |
---|---|---|
x | number | Angle, in radians. |
Returns
The arc tangent of a value; the returned angle is in the range [-Pi/2, Pi/2]
.
number
atr
Function atr (average true range) returns the RMA of true range. True range is max(high - low, abs(high - close[1]), abs(low - close[1]))
Signature
atr(length: number, context: IContext) => number
Parameters
Name | Type | Description |
---|---|---|
length | number | Length (number of bars back). |
context | IContext | PineJS execution context. |
Returns
Average true range.
number
avg
Calculates average of all given series (elementwise).
Signature
avg<T>(...values: T[]) => T
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
...values | T[] |
Returns
the average of the values
T
ceil
The ceil function returns the smallest (closest to negative infinity) integer that is greater than or equal to the argument.
Signature
ceil(x: number) => number
Parameters
Name | Type |
---|---|
x | number |
Returns
The smallest integer greater than or equal to the given number.
number
change
Difference between current value and previous, x - x[1]
.
Signature
change(source: IPineSeries) => number
Parameters
Name | Type | Description |
---|---|---|
source | IPineSeries | Series to process. |
Returns
The result of subtraction.
number
close
Close Price
Signature
close(context: IContext) => number
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
Current close price.
number
compare
Compare the values of n1
and n2
Signature
compare(n1: number, n2: number, eps?: number) => 0 | 1 | -1
Parameters
Name | Type | Description |
---|---|---|
n1 | number | |
n2 | number | |
eps? | number | Epsilon (Optional). |
Returns
0
if values are equal. 1
if x1 is greater than x2. -1
if x1 is less than x2
0 | 1 | -1
correlation
Correlation coefficient. Describes the degree to which two series tend to deviate from their sma
values.
Signature
correlation(sourceA: IPineSeries, sourceB: IPineSeries, length: number, context: IContext) => number
Parameters
Name | Type | Description |
---|---|---|
sourceA | IPineSeries | Source series. |
sourceB | IPineSeries | Target series. |
length | number | Length (number of bars back). |
context | IContext | PineJS execution context. |
Returns
Correlation coefficient.
number
cos
The cos function returns the trigonometric cosine of an angle.
Signature
cos(x: number) => number
Parameters
Name | Type | Description |
---|---|---|
x | number | Angle, in radians. |
Returns
The trigonometric cosine of an angle.
number
createNewSessionCheck
checks whether a new session can be created
Signature
createNewSessionCheck(context: IContext) => (time: number) => boolean
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
checks whether a new session can be created
fn
checks whether a new session can be created
Parameters
Name | Type |
---|---|
time | number |
Returns
checks whether a new session can be created
boolean
cross
Crossing of series
Signature
cross(x: IPineSeries, y: IPineSeries, context: IContext) => boolean
Parameters
Name | Type | Description |
---|---|---|
x | IPineSeries | First series. |
y | IPineSeries | Second series. |
context | IContext | PineJS execution context. |
Returns
true
if two series have crossed each other, otherwise false
.
boolean
cum
Cumulative (total) sum of x
. In other words it's a sum of all elements of x
.
Signature
cum(x: IPineSeries, context: IContext) => number
Parameters
Name | Type | Description |
---|---|---|
x | IPineSeries | Series of values to process. |
context | IContext | PineJS execution context. |
Returns
Total sum series.
number
dayofmonth
Day of month for current bar time in exchange timezone.
Signature
dayofmonth(context: IContext) => number
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
Day of month for current bar time in exchange timezone.
number
dayofweek
Day of week for current bar time in exchange timezone.
Signature
dayofweek(context: IContext) => number
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
Day of week for current bar time in exchange timezone.
number
dev
Measure of difference between the series and its sma.
Signature
dev(source: IPineSeries, length: number, context: IContext) => number
Parameters
Name | Type | Description |
---|---|---|
source | IPineSeries | Series of values to process. |
length | number | Number of bars (length). |
context | IContext | PineJS execution context. |
Returns
Deviation of source for length bars back.
number
dmi
Calculates the directional movement values +DI, -DI, DX, ADX, and ADXR.
Signature
dmi(diLength: number, adxSmoothingLength: number, context: IContext) => [number, number, number, number, number]
Parameters
Name | Type | Description |
---|---|---|
diLength | number | Number of bars (length) used when calculating the +DI and -DI values. |
adxSmoothingLength | number | Number of bars (length) used when calculating the ADX value. |
context | IContext | PineJS execution context. |
Returns
An array of the +DI, -DI, DX, ADX, and ADXR values with diLength smoothing for the (+/-)DI values and adxSmoothingLength for the ADX value.
[number, number, number, number, number]
ema
The ema function returns the exponentially weighted moving average. In ema weighting factors decrease exponentially. It calculates by using a formula: EMA = alpha * x + (1 - alpha) * EMA[1]
, where alpha = 2 / (y + 1)
Signature
ema(source: IPineSeries, length: number, context: IContext) => number
Parameters
Name | Type | Description |
---|---|---|
source | IPineSeries | Series of values to process. |
length | number | Number of bars (length). |
context | IContext | PineJS execution context. |
Returns
Exponential moving average of x
with alpha = 2 / (y + 1)
number
eps
Epsilon (machine precision)
Signature
eps() => number
Returns
Epsilon (machine precision). Upper bound on the relative approximation error due to rounding in floating point arithmetic.
number
eq
Checks if n1
is equal to n2
.
Signature
eq(n1: number, n2: number) => boolean
Parameters
Name | Type |
---|---|
n1 | number |
n2 | number |
Returns
True if n1
is equal to n2
.
boolean
equal
Checks if n1
is equal to n2
(within the accuracy of epsilon).
Signature
equal(n1: number, n2: number, eps?: number) => boolean
Parameters
Name | Type | Description |
---|---|---|
n1 | number | |
n2 | number | |
eps? | number | Epsilon (Optional). |
Returns
True if n1
is equal to n2
.
boolean
error
Display an error message.
Signature
error(message: string) => never
Parameters
Name | Type | Description |
---|---|---|
message | string | message to display for error |
Returns
never
exp
The exp function of x
is e^x
, where x
is the argument and e
is Euler's number.
Signature
exp(x: number) => number
Parameters
Name | Type |
---|---|
x | number |
Returns
A number representing e^x
.
number
falling
Test if the series is now falling for length bars long.
Signature
falling(series: IPineSeries, length: number) => boolean
Parameters
Name | Type | Description |
---|---|---|
series | IPineSeries | Series of values to process. |
length | number | Number of bars (length). |
Returns
true
if current x
is less than any previous x
for length bars back, false
otherwise.
boolean
fixnan
For a given series replaces NaN values with previous nearest non-NaN value.
Signature
fixnan(current: IPineSeries, context: IContext) => IPineSeries
Parameters
Name | Type | Description |
---|---|---|
current | IPineSeries | Series of values to process. |
context | IContext | PineJS execution context. |
Returns
Series without na gaps.
floor
Round the number down to the closest integer
Signature
floor(x: number) => number
Parameters
Name | Type |
---|---|
x | number |
Returns
The largest integer less than or equal to the given number.
number
ge
Checks if n1
is greater than or equal to n2
Signature
ge(n1: number, n2: number) => boolean
Parameters
Name | Type |
---|---|
n1 | number |
n2 | number |
Returns
True if n1
is greater than or equal to n2
.
boolean
greater
Checks if n1
is greater than n2
Signature
greater(n1: number, n2: number, eps?: number) => boolean
Parameters
Name | Type | Description |
---|---|---|
n1 | number | |
n2 | number | |
eps? | number | Epsilon (Optional). |
Returns
True if n1
is greater than n2
.
boolean
greaterOrEqual
Checks if n1
is greater than or equal to n2
Signature
greaterOrEqual(n1: number, n2: number, eps?: number) => boolean
Parameters
Name | Type | Description |
---|---|---|
n1 | number | |
n2 | number | |
eps? | number | Epsilon (Optional). |
Returns
True if n1
is greater than or equal to n2
.
boolean
gt
Checks if n1
is greater than n2
Signature
gt(n1: number, n2: number) => boolean
Parameters
Name | Type |
---|---|
n1 | number |
n2 | number |
Returns
True if n1
is greater than n2
.
boolean
high
High Price
Signature
high(context: IContext) => number
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
Current high price.
number
highest
Highest value for a given number of bars back.
Signature
highest(source: IPineSeries, length: number, context: IContext) => number
Parameters
Name | Type | Description |
---|---|---|
source | IPineSeries | Series of values to process. |
length | number | Number of bars (length). |
context | IContext | PineJS execution context. |
Returns
Highest value.
number
highestbars
Highest value offset for a given number of bars back.
Signature
highestbars(source: IPineSeries, length: number, context: IContext) => number
Parameters
Name | Type | Description |
---|---|---|
source | IPineSeries | Series of values to process. |
length | number | Number of bars (length). |
context | IContext | PineJS execution context. |
Returns
Offset to the highest bar.
number
hl2
Is a shortcut for (high + low)/2
Signature
hl2(context: IContext) => number
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
Calculated average of the current HL values
number
hlc3
Is a shortcut for (high + low + close)/3
Signature
hlc3(context: IContext) => number
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
Calculated average of the current HLC values
number
hour
Current bar hour in exchange timezone.
Signature
hour(context: IContext) => number
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
Current bar hour in exchange timezone.
number
iff
If ... then ... else ...
iff
does exactly the same thing as ternary conditional operator ?:
but in a functional style. Also iff
is slightly less efficient than operator ?:
Signature
iff<T, V>(condition: boolean, thenValue: T, elseValue: V) => T | V
Type parameters
Name |
---|
T |
V |
Parameters
Name | Type | Description |
---|---|---|
condition | boolean | condition to check |
thenValue | T | value to use if condition is true |
elseValue | V | value to use if condition is false |
Returns
either thenValue or elseValue
T | V
interval
Current interval for the symbol
Signature
interval(context: IContext) => string
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
interval string
string
isdaily
Determines whether the current resolution is a daily resolution.
Signature
isdaily(context: IContext) => boolean
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
true if current resolution is a daily resolution
boolean
isdwm
Determines whether the current resolution is a daily, weekly, or monthly resolution.
Signature
isdwm(context: IContext) => boolean
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
true if current resolution is a daily or weekly or monthly resolution
boolean
isintraday
Determines whether the current resolution is an intraday (minutes or seconds) resolution.
Signature
isintraday(context: IContext) => boolean
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
true if current resolution is an intraday (minutes or seconds) resolution
boolean
ismonthly
Determines whether the current resolution is a monthly resolution.
Signature
ismonthly(context: IContext) => boolean
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
true if current resolution is a monthly resolution
boolean
isweekly
Determines whether the current resolution is a weekly resolution.
Signature
isweekly(context: IContext) => boolean
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
true if current resolution is a weekly resolution
boolean
le
Checks if n1
is less than or equal to n2
Signature
le(n1: number, n2: number) => boolean
Parameters
Name | Type |
---|---|
n1 | number |
n2 | number |
Returns
True if n1
is greater than or equal to n2
.
boolean
less
Checks if n1
is less than n2
Signature
less(n1: number, n2: number, eps?: number) => boolean
Parameters
Name | Type | Description |
---|---|---|
n1 | number | |
n2 | number | |
eps? | number | Epsilon (Optional). |
Returns
True if n1
is less than n2
.
boolean
lessOrEqual
Checks if n1
is less than or equal to n2
Signature
lessOrEqual(n1: number, n2: number, eps?: number) => boolean
Parameters
Name | Type | Description |
---|---|---|
n1 | number | |
n2 | number | |
eps? | number | Epsilon (Optional). |
Returns
True if n1
is less than or equal to n2
.
boolean
linreg
Linear regression curve. A line that best fits the prices specified over a user-defined time period.
It is calculated using the least squares method. The result of this function is calculated using the formula:
linreg = intercept + slope * (length - 1 - offset)
, where intercept and slope are the values calculated with
the least squares method on source series (x argument).
Signature
linreg(source: IPineSeries, length: number, offset: number) => number
Parameters
Name | Type | Description |
---|---|---|
source | IPineSeries | Source series. |
length | number | Length (number of bars back). |
offset | number | Offset (number of bars) |
Returns
Linear regression curve point.
number
log
Natural logarithm of any x > 0
is the unique y
such that e^y = x
Signature
log(x: number) => number
Parameters
Name | Type |
---|---|
x | number |
Returns
The natural logarithm of x
.
number
log10
Base 10 logarithm of any x > 0
is the unique y
such that 10^y = x
Signature
log10(x: number) => number
Parameters
Name | Type |
---|---|
x | number |
Returns
The base 10 logarithm of x
.
number
low
Low Price
Signature
low(context: IContext) => number
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
Current low price.
number
lowest
Lowest value for a given number of bars back.
Signature
lowest(source: IPineSeries, length: number, context: IContext) => number
Parameters
Name | Type | Description |
---|---|---|
source | IPineSeries | Series of values to process. |
length | number | Number of bars (length). |
context | IContext | PineJS execution context. |
Returns
Lowest value.
number
lowestbars
Lowest value offset for a given number of bars back.
Signature
lowestbars(source: IPineSeries, length: number, context: IContext) => number
Parameters
Name | Type | Description |
---|---|---|
source | IPineSeries | Series of values to process. |
length | number | Number of bars (length). |
context | IContext | PineJS execution context. |
Returns
Offset to the lowest bar.
number
lt
Checks if n1
is less than n2
Signature
lt(n1: number, n2: number) => boolean
Parameters
Name | Type |
---|---|
n1 | number |
n2 | number |
Returns
True if n1
is less than n2
.
boolean
max
Maximum number in the array
Signature
max<T>(...values: T[]) => T
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
...values | T[] |
Returns
The greatest of multiple given values
T
min
Minimum number in the array
Signature
min<T>(...values: T[]) => T
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
...values | T[] |
Returns
The smallest of multiple given values
T
minute
Current bar minute in exchange timezone.
Signature
minute(context: IContext) => number
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
Current bar minute in exchange timezone.
number
month
Current month year in exchange timezone.
Signature
month(context: IContext) => number
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
Current month year in exchange timezone.
number
n
Current bar index
Signature
n(context: IContext) => number
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
Current bar index. Numbering is zero-based, index of the first historical bar is 0.
number
na
Test value if it's a NaN.
Signature
na(n: number) => boolean
Parameters
Name | Type | Description |
---|---|---|
n | number | value to test |
Returns
true
if x
is not a valid number ( x
is NaN
), otherwise false
.
boolean
neq
Checks if n1
is not equal to n2
.
Signature
neq(n1: number, n2: number) => boolean
Parameters
Name | Type |
---|---|
n1 | number |
n2 | number |
Returns
True if n1
is not equal to n2
.
boolean
not
Logical negation (NOT). Applicable to boolean expressions.
Signature
not(expr1: boolean) => boolean
Parameters
Name | Type |
---|---|
expr1 | boolean |
Returns
Boolean value
boolean
nz
Replaces NaN values with zeros (or given value) in a series.
Signature
nz(x: number, y: number) => number
Parameters
Name | Type | Description |
---|---|---|
x | number | value to test (and potentially replace) |
y | number | fallback value |
Returns
x
if it's a valid (not NaN) number, otherwise y
number
ohlc4
Is a shortcut for (open + high + low + close)/4
Signature
ohlc4(context: IContext) => number
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
Calculated average of the current OHLC values
number
open
Open Price
Signature
open(context: IContext) => number
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
Current open price.
number
or
Logical OR. Applicable to boolean expressions.
Signature
or(expr1: boolean, expr2: boolean) => boolean
Parameters
Name | Type |
---|---|
expr1 | boolean |
expr2 | boolean |
Returns
Boolean value
boolean
percentrank
Percent rank is the percentage of how many previous values were less than or equal to the current value of given series.
Signature
percentrank(source: IPineSeries, length: number) => number
Parameters
Name | Type | Description |
---|---|---|
source | IPineSeries | Series of values to process. |
length | number | Number of bars (length). |
Returns
Percent rank of source
for length
bars back.
number
period
Resolution string, e.g. 60 - 60 minutes, D - daily, W - weekly, M - monthly, 5D - 5 days, 12M - one year, 3M - one quarter
Signature
period(context: IContext) => string
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
The resolution string for the current context
string
pow
Mathematical power function.
Signature
pow<T>(base: T, exponent: number) => T
Type parameters
Name | Type |
---|---|
T | extends number | IPineSeries |
Parameters
Name | Type | Description |
---|---|---|
base | T | Specify the base to use. |
exponent | number | Specifies the exponent. |
Returns
x
raised to the power of y
. If x
is a series, it is calculated elementwise.
T
rising
Test if the series is now rising for length bars long.
Signature
rising(series: IPineSeries, length: number) => boolean
Parameters
Name | Type | Description |
---|---|---|
series | IPineSeries | Series of values to process. |
length | number | Number of bars (length). |
Returns
true
if current x
is greater than any previous x
for length bars back, false
otherwise.
boolean
rma
Moving average used in RSI. It is the exponentially weighted moving average with alpha = 1 / length
.
Signature
rma(source: IPineSeries, length: number, context: IContext) => number
Parameters
Name | Type | Description |
---|---|---|
source | IPineSeries | Series of values to process. |
length | number | Number of bars (length). |
context | IContext | PineJS execution context. |
Returns
Exponential moving average of x
with alpha = 1 / y
.
number
roc
Rate of Change.
Function roc (rate of change) showing the difference between current value of source
and the value of source
that was length
days ago. It is calculated by the formula: 100 * change(src, length) / src[length]
.
Signature
roc(source: IPineSeries, length: number) => number
Parameters
Name | Type | Description |
---|---|---|
source | IPineSeries | Series of values to process. |
length | number | Number of bars (length). |
Returns
The rate of change of source
for length
bars back.
number
round
Round the number to the nearest integer
Signature
round(x: number) => number
Parameters
Name | Type |
---|---|
x | number |
Returns
The value of x
rounded to the nearest integer, with ties rounding up. If the precision parameter is used, returns a float value rounded to that number of decimal places.
number
rsi
Relative strength index. It is calculated based on rma's of upward and downward change of x.
Signature
rsi(upper: number, lower: number) => number
Parameters
Name | Type | Description |
---|---|---|
upper | number | upward change |
lower | number | downward change |
Returns
Relative strength index.
number
sar
Parabolic SAR (parabolic stop and reverse) is a method devised by J. Welles Wilder, Jr., to find potential reversals in the market price direction of traded goods.
Signature
sar(start: IPineSeries, inc: number, max: number, context: IContext) => number
Parameters
Name | Type | Description |
---|---|---|
start | IPineSeries | Start. |
inc | number | Increment |
max | number | Maximum |
context | IContext | PineJS execution context. |
Returns
Parabolic SAR.
number
second
Current bar second in exchange timezone.
Signature
second(context: IContext) => number
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
Current bar second in exchange timezone.
number
selectSessionBreaks
select session breaks for intraday resolutions only
Signature
selectSessionBreaks(context: IContext, times: number[]) => number[]
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
times | number[] | An array of numbers representing the times to select session breaks from. |
Returns
session breaks for intraday resolutions only.
number[]
sign
Sign (signum) of x
is 0
if the x is zero, 1.0
if the x
is greater than zero, -1.0
if the x
is less than zero.
Signature
sign(x: number) => number
Parameters
Name | Type |
---|---|
x | number |
Returns
The sign of x
number
sin
The sin function returns the trigonometric sine of an angle.
Signature
sin(x: number) => number
Parameters
Name | Type | Description |
---|---|---|
x | number | Angle, in radians. |
Returns
The trigonometric sine of an angle.
number
sma
The sma function returns the moving average, that is the sum of last length
values of source
, divided by length
.
Signature
sma(source: IPineSeries, length: number, context: IContext) => number
Parameters
Name | Type | Description |
---|---|---|
source | IPineSeries | Series of values to process. |
length | number | Number of bars (length). |
context | IContext | PineJS execution context. |
Returns
Simple moving average of x for y bars back.
number
sqrt
Square root of any x >= 0
is the unique y >= 0
such that y^2 = x
Signature
sqrt(x: number) => number
Parameters
Name | Type |
---|---|
x | number |
Returns
The square root of x
number
stdev
Standard deviation. Note: This is a biased estimation of standard deviation.
Signature
stdev(source: IPineSeries, length: number, context: IContext) => number
Parameters
Name | Type | Description |
---|---|---|
source | IPineSeries | Series of values to process. |
length | number | Number of bars (length). |
context | IContext | PineJS execution context. |
Returns
Standard deviation.
number
stoch
Stochastic. It is calculated by a formula: 100 * (close - lowest(low, length)) / (highest(high, length) - lowest(low, length))
Signature
stoch(source: IPineSeries, high: IPineSeries, low: IPineSeries, length: number, context: IContext) => number
Parameters
Name | Type | Description |
---|---|---|
source | IPineSeries | Source series. |
high | IPineSeries | Series of high. |
low | IPineSeries | Series of low. |
length | number | Length (number of bars back). |
context | IContext | PineJS execution context. |
Returns
Stochastic value.
number
sum
The sum function returns the sliding sum of last y values of x.
Signature
sum(source: IPineSeries, length: number, context: IContext) => number
Parameters
Name | Type | Description |
---|---|---|
source | IPineSeries | Series of values to process. |
length | number | Number of bars (length). |
context | IContext | PineJS execution context. |
Returns
Sum of x for y bars back.
number
swma
Symmetrically weighted moving average with fixed length: 4. Weights: [1/6, 2/6, 2/6, 1/6]
.
Signature
swma(source: IPineSeries, context: IContext) => number
Parameters
Name | Type | Description |
---|---|---|
source | IPineSeries | Series of values to process. |
context | IContext | PineJS execution context. |
Returns
Symmetrically weighted moving average
number
tan
The tan function returns the trigonometric tangent of an angle.
Signature
tan(x: number) => number
Parameters
Name | Type | Description |
---|---|---|
x | number | Angle, in radians. |
Returns
The trigonometric tangent of an angle.
number
ticker
Ticker ID for the current symbol
Signature
ticker(context: IContext) => string
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
Ticker ID for the current symbol
string
tickerid
Ticker ID
Signature
tickerid(context: IContext) => string
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
Ticker ID for the current symbol
string
time
Current bar time
Signature
time(context: IContext) => number
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
UNIX time of current bar
number
Current bar time
Signature
time(context: IContext, period: string, spec: unknown) => number
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
period | string | Period |
spec | unknown |
Returns
UNIX time of current bar
number
tr
True Range
Signature
tr(handleNan: boolean, context: IContext) => number
Parameters
Name | Type | Description |
---|---|---|
handleNan | boolean | How NaN values are handled. If true , and previous day's close is NaN then tr would be calculated as current day high-low . Otherwise (if false ) tr would return NaN in such cases. Also note, that atr uses tr(true) . |
context | IContext | PineJS execution context. |
Returns
True range. It is max(high - low, abs(high - close[1]), abs(low - close[1]))
number
tsi
True strength index. It uses moving averages of the underlying momentum of a financial instrument.
Signature
tsi(source: IPineSeries, shortLength: number, longLength: number, context: IContext) => number
Parameters
Name | Type | Description |
---|---|---|
source | IPineSeries | Source series. |
shortLength | number | Length (number of bars back). |
longLength | number | Length (number of bars back). |
context | IContext | PineJS execution context. |
Returns
True strength index. A value in range [-1, 1]
number
updatetime
Time of the current update
Signature
updatetime(context: IContext) => string
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
symbol update time
string
variance
Variance is the expectation of the squared deviation of a series from its mean sma
, and it informally measures how far a set of numbers are spread out from their mean. Note: This is a biased estimation of sample variance.
Signature
variance(source: IPineSeries, length: number, context: IContext) => number
Parameters
Name | Type | Description |
---|---|---|
source | IPineSeries | Series of values to process. |
length | number | Number of bars (length). |
context | IContext | PineJS execution context. |
Returns
Variance of source
for length
bars back.
number
volume
Current bar volume
Signature
volume(context: IContext) => number
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
Current bar volume
number
vwma
The vwma function returns volume-weighted moving average of source
for length
bars back. It is the same as: sma(x * volume, y) / sma(volume, y)
Signature
vwma(source: IPineSeries, length: number, context: IContext) => number
Parameters
Name | Type | Description |
---|---|---|
source | IPineSeries | Series of values to process. |
length | number | Number of bars (length). |
context | IContext | PineJS execution context. |
Returns
Volume-weighted moving average of source
for length
bars back.
number
weekofyear
Week number of current bar in exchange timezone.
Signature
weekofyear(context: IContext) => number
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
Week number of current bar in exchange timezone.
number
wma
The wma function returns weighted moving average of source
for length
bars back. In wma weighting factors decrease in arithmetical progression.
Signature
wma(source: IPineSeries, length: number, context: IContext) => number
Parameters
Name | Type | Description |
---|---|---|
source | IPineSeries | Series of values to process. |
length | number | Number of bars (length). |
context | IContext | PineJS execution context. |
Returns
Weighted moving average of series
for length
bars back.
number
year
Current bar year in exchange timezone.
Signature
year(context: IContext) => number
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
Current bar year in exchange timezone.
number
zigzag
Zig-zag pivot points
Signature
zigzag(deviation: number, depth: number, context: IContext) => number[]
Parameters
Name | Type | Description |
---|---|---|
deviation | number | deviation |
depth | number | depth (integer) |
context | IContext | PineJS execution context. |
Returns
the zig-zag pivot points
number[]
zigzagbars
Zig-zag pivot points
Signature
zigzagbars(deviation: number, depth: number, context: IContext) => number[]
Parameters
Name | Type | Description |
---|---|---|
deviation | number | deviation |
depth | number | depth (integer) |
context | IContext | PineJS execution context. |
Returns
the zig-zag pivot points (for bars)
number[]