Interface: PineJSStd
Charting Library.PineJSStd
PineJS standard library functions.
Properties
isZero
• isZero: (v
: number
) => number
Check if a value is zero.
Type declaration
▸ (v
): number
Parameters
Name | Type | Description |
---|---|---|
v | number | the value to test. |
Returns
number
max_series_default_size
• max_series_default_size: 10001
Default maximum size of a pine series.
Methods
abs
▸ abs(x
): number
Absolute value of x is x if x >= 0, or -x otherwise.
Parameters
Name | Type |
---|---|
x | number |
Returns
number
The absolute value of x
accdist
▸ accdist(context
): number
Accumulation/distribution index.
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
number
Accumulation/distribution index.
acos
▸ acos(x
): number
The acos function returns the arccosine (in radians) of number such that cos(acos(y)) = y
for y
in range [-1, 1]
.
Parameters
Name | Type | Description |
---|---|---|
x | number | Angle, in radians. |
Returns
number
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]
.
add_days_considering_dst
▸ add_days_considering_dst(timezone
, utcTime
, daysCount
): Date
Get time in daysCount
number of days while taking Daylight savings time into account.
Parameters
Name | Type | Description |
---|---|---|
timezone | string | Timezone |
utcTime | Date | Date (JS built-in) |
daysCount | number | Number of days |
Returns
Date
The time is daysCount
number of days, taking into account Daylight savings time.
add_years_considering_dst
▸ add_years_considering_dst(timezone
, utcTime
, yearsCount
): Date
Get time in yearsCount
number of years while taking Daylight savings time into account.
Parameters
Name | Type | Description |
---|---|---|
timezone | string | Timezone |
utcTime | Date | Date (JS built-in) |
yearsCount | number | Number of years |
Returns
Date
The time is yearsCount
number of years, taking into account Daylight savings time.
alma
▸ alma(series
, length
, offset
, sigma
): number
Arnaud Legoux Moving Average. It uses Gaussian distribution as weights for moving average.
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
▸ and(n_0
, n_1
): number
Logical AND.
Parameters
Name | Type |
---|---|
n_0 | number |
n_1 | number |
Returns
number
1
if both values are truthy, 0
otherwise.
asin
▸ asin(x
): number
The asin function returns the arcsine (in radians) of number such that sin(asin(y)) = y
for y
in range [-1, 1]
.
Parameters
Name | Type | Description |
---|---|---|
x | number | Angle, in radians. |
Returns
number
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]
.
atan
▸ atan(x
): number
The atan function returns the arctangent (in radians) of number such that tan(atan(y)) = y
for any y
.
Parameters
Name | Type | Description |
---|---|---|
x | number | Angle, in radians. |
Returns
number
The arc tangent of a value; the returned angle is in the range [-Pi/2, Pi/2]
.
atr
▸ atr(length
, context
): number
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]))
Parameters
Name | Type | Description |
---|---|---|
length | number | Length (number of bars back). |
context | IContext | PineJS execution context. |
Returns
number
Average true range.
avg
▸ avg(...values
): number
Calculates average of all given series (elementwise).
Parameters
Name | Type |
---|---|
...values | number [] |
Returns
number
the average of the values
ceil
▸ ceil(x
): number
The ceil function returns the smallest (closest to negative infinity) integer that is greater than or equal to the argument.
Parameters
Name | Type |
---|---|
x | number |
Returns
number
The smallest integer greater than or equal to the given number.
change
▸ change(source
): number
Difference between current value and previous, x - x[1]
.
Parameters
Name | Type | Description |
---|---|---|
source | IPineSeries | Series to process. |
Returns
number
The result of subtraction.
close
▸ close(context
): number
Close Price
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
number
Current close price.
compare
▸ compare(n1
, n2
, eps?
): -1
| 0
| 1
Compare the values of n1
and n2
Parameters
Name | Type | Description |
---|---|---|
n1 | number | |
n2 | number | |
eps? | number | Epsilon (Optional). |
Returns
-1
| 0
| 1
0
if values are equal. 1
if x1 is greater than x2. -1
if x1 is less than x2
correlation
▸ correlation(sourceA
, sourceB
, length
, context
): number
Correlation coefficient. Describes the degree to which two series tend to deviate from their sma
values.
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
number
Correlation coefficient.
cos
▸ cos(x
): number
The cos function returns the trigonometric cosine of an angle.
Parameters
Name | Type | Description |
---|---|---|
x | number | Angle, in radians. |
Returns
number
The trigonometric cosine of an angle.
createNewSessionCheck
▸ createNewSessionCheck(context
): (time
: number
) => boolean
checks whether a new session can be created
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
fn
checks whether a new session can be created
▸ (time
): boolean
Parameters
Name | Type |
---|---|
time | number |
Returns
boolean
cross
▸ cross(n_0
, n_1
, context
): boolean
Crossing of series.
Parameters
Name | Type | Description |
---|---|---|
n_0 | number | First value. |
n_1 | number | Second value. |
context | IContext | PineJS execution context. |
Returns
boolean
true
if two series have crossed each other, otherwise false
.
cum
▸ cum(n_value
, context
): number
Cumulative (total) sum. The function tracks the previous values internally.
Parameters
Name | Type | Description |
---|---|---|
n_value | number | Value to add to the sum. |
context | IContext | PineJS execution context. |
Returns
number
The sum.
currencyCode
▸ currencyCode(ctx
): string
Get the symbol currency code.
Parameters
Name | Type | Description |
---|---|---|
ctx | IContext | PineJS execution context. |
Returns
string
Symbol currency code.
dayofmonth
▸ dayofmonth(context
, time?
): number
Day of month for current bar time in exchange timezone.
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
time? | number | optional time. Current bar time will be used by default. |
Returns
number
Day of month for current bar time in exchange timezone.
dayofweek
▸ dayofweek(context
, time?
): number
Day of week for current bar time in exchange timezone.
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
time? | number | optional time. Current bar time will be used by default. |
Returns
number
Day of week for current bar time in exchange timezone.
dev
▸ dev(source
, length
, context
): number
Measure of difference between the series and its sma.
Parameters
Name | Type | Description |
---|---|---|
source | IPineSeries | Series of values to process. |
length | number | Number of bars (length). |
context | IContext | PineJS execution context. |
Returns
number
Deviation of source for length bars back.
dmi
▸ dmi(diLength
, adxSmoothingLength
, context
): [number
, number
, number
, number
, number
]
Calculates the directional movement values +DI, -DI, DX, ADX, and ADXR.
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
[number
, number
, number
, number
, number
]
An array of the +DI, -DI, DX, ADX, and ADXR values with diLength smoothing for the (+/-)DI values and adxSmoothingLength for the ADX value.
ema
▸ ema(source
, length
, context
): number
Exponential 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)
.
Parameters
Name | Type | Description |
---|---|---|
source | IPineSeries | Series of values to process. |
length | number | Number of bars (length). |
context | IContext | PineJS execution context. |
Returns
number
Exponential moving average of x
with alpha = 2 / (y + 1)
eps
▸ eps(): number
Epsilon (machine precision)
Returns
number
Epsilon (machine precision). Upper bound on the relative approximation error due to rounding in floating point arithmetic.
eq
▸ eq(n1
, n2
): number
Checks if n1
is equal to n2
.
Parameters
Name | Type |
---|---|
n1 | number |
n2 | number |
Returns
number
1
if n1
is equal to n2
, 0
otherwise.
equal
▸ equal(n1
, n2
, eps?
): boolean
Checks if n1
is equal to n2
(within the accuracy of epsilon).
Parameters
Name | Type | Description |
---|---|---|
n1 | number | |
n2 | number | |
eps? | number | Epsilon (Optional). |
Returns
boolean
True if n1
is equal to n2
.
error
▸ error(message
): never
Display an error message.
Parameters
Name | Type | Description |
---|---|---|
message | string | message to display for error |
Returns
never
exp
▸ exp(x
): number
The exp function of x
is e^x
, where x
is the argument and e
is Euler's number.
Parameters
Name | Type |
---|---|
x | number |
Returns
number
A number representing e^x
.
falling
▸ falling(series
, length
): number
Test if the series is now falling for length bars long.
Parameters
Name | Type | Description |
---|---|---|
series | IPineSeries | Series of values to process. |
length | number | Number of bars (length). |
Returns
number
true
if current x
is less than any previous x
for length bars back, false
otherwise.
fixnan
▸ fixnan(n_current
, context
): number
For a given series replaces NaN values with previous nearest non-NaN value.
Parameters
Name | Type | Description |
---|---|---|
n_current | number | Series of values to process. |
context | IContext | PineJS execution context. |
Returns
number
Series without na gaps.
floor
▸ floor(x
): number
Round the number down to the closest integer
Parameters
Name | Type |
---|---|
x | number |
Returns
number
The largest integer less than or equal to the given number.
ge
▸ ge(n1
, n2
): number
Checks if n1
is greater than or equal to n2
Parameters
Name | Type |
---|---|
n1 | number |
n2 | number |
Returns
number
1
if n1
is greater than or equal to n2
, 0
otherwise.
greater
▸ greater(n1
, n2
, eps?
): boolean
Checks if n1
is greater than n2
Parameters
Name | Type | Description |
---|---|---|
n1 | number | |
n2 | number | |
eps? | number | Epsilon (Optional). |
Returns
boolean
True if n1
is greater than n2
.
greaterOrEqual
▸ greaterOrEqual(n1
, n2
, eps?
): boolean
Checks if n1
is greater than or equal to n2
Parameters
Name | Type | Description |
---|---|---|
n1 | number | |
n2 | number | |
eps? | number | Epsilon (Optional). |
Returns
boolean
True if n1
is greater than or equal to n2
.
gt
▸ gt(n1
, n2
): number
Checks if n1
is greater than n2
Parameters
Name | Type |
---|---|
n1 | number |
n2 | number |
Returns
number
1
if n1
is greater than n2
, 0
otherwise.
high
▸ high(context
): number
High Price
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
number
Current high price.
highest
▸ highest(source
, length
, context
): number
Highest value for a given number of bars back.
Parameters
Name | Type | Description |
---|---|---|
source | IPineSeries | Series of values to process. |
length | number | Number of bars (length). |
context | IContext | PineJS execution context. |
Returns
number
Highest value.
highestbars
▸ highestbars(source
, length
, context
): number
Highest value offset for a given number of bars back.
Parameters
Name | Type | Description |
---|---|---|
source | IPineSeries | Series of values to process. |
length | number | Number of bars (length). |
context | IContext | PineJS execution context. |
Returns
number
Offset to the highest bar.
hl2
▸ hl2(context
): number
Is a shortcut for (high + low)/2
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
number
Calculated average of the current HL values
hlc3
▸ hlc3(context
): number
Is a shortcut for (high + low + close)/3
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
number
Calculated average of the current HLC values
hour
▸ hour(context
, time?
): number
Hour of current bar time in exchange timezone.
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
time? | number | optional time. Current bar time will be used by default. |
Returns
number
Current bar hour in exchange timezone.
iff
▸ iff(condition
, thenValue
, elseValue
): number
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 ?:
Parameters
Name | Type | Description |
---|---|---|
condition | number | condition to check |
thenValue | number | value to use if condition is true |
elseValue | number | value to use if condition is false |
Returns
number
either thenValue or elseValue
interval
▸ interval(ctx
): number
Get the symbol interval. For example: if the symbol has a resolution of 1D
then this function would return 1
.
Parameters
Name | Type | Description |
---|---|---|
ctx | IContext | PineJS execution context. |
Returns
number
Symbol interval.
isdaily
▸ isdaily(context
): boolean
Determines whether the current resolution is a daily resolution.
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
boolean
true if current resolution is a daily resolution
isdwm
▸ isdwm(context
): boolean
Determines whether the current resolution is a daily, weekly, or monthly resolution.
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
boolean
true if current resolution is a daily or weekly or monthly resolution
isintraday
▸ isintraday(context
): boolean
Determines whether the current resolution is an intraday (minutes or seconds) resolution.
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
boolean
true if current resolution is an intraday (minutes or seconds) resolution
ismonthly
▸ ismonthly(context
): boolean
Determines whether the current resolution is a monthly resolution.
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
boolean
true if current resolution is a monthly resolution
isweekly
▸ isweekly(context
): boolean
Determines whether the current resolution is a weekly resolution.
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
boolean
true if current resolution is a weekly resolution
le
▸ le(n1
, n2
): number
Checks if n1
is less than or equal to n2
Parameters
Name | Type |
---|---|
n1 | number |
n2 | number |
Returns
number
1
if n1
is greater than or equal to n2
, 0
otherwise.
less
▸ less(n1
, n2
, eps?
): boolean
Checks if n1
is less than n2
Parameters
Name | Type | Description |
---|---|---|
n1 | number | |
n2 | number | |
eps? | number | Epsilon (Optional). |
Returns
boolean
True if n1
is less than n2
.
lessOrEqual
▸ lessOrEqual(n1
, n2
, eps?
): boolean
Checks if n1
is less than or equal to n2
Parameters
Name | Type | Description |
---|---|---|
n1 | number | |
n2 | number | |
eps? | number | Epsilon (Optional). |
Returns
boolean
True if n1
is less than or equal to n2
.
linreg
▸ linreg(source
, length
, offset
): number
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).
Parameters
Name | Type | Description |
---|---|---|
source | IPineSeries | Source series. |
length | number | Length (number of bars back). |
offset | number | Offset (number of bars) |
Returns
number
Linear regression curve point.
log
▸ log(x
): number
Natural logarithm of any x > 0
is the unique y
such that e^y = x
Parameters
Name | Type |
---|---|
x | number |
Returns
number
The natural logarithm of x
.
log10
▸ log10(x
): number
Base 10 logarithm of any x > 0
is the unique y
such that 10^y = x
Parameters
Name | Type |
---|---|
x | number |
Returns
number
The base 10 logarithm of x
.
low
▸ low(context
): number
Low Price
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
number
Current low price.
lowest
▸ lowest(source
, length
, context
): number
Lowest value for a given number of bars back.
Parameters
Name | Type | Description |
---|---|---|
source | IPineSeries | Series of values to process. |
length | number | Number of bars (length). |
context | IContext | PineJS execution context. |
Returns
number
Lowest value.
lowestbars
▸ lowestbars(source
, length
, context
): number
Lowest value offset for a given number of bars back.
Parameters
Name | Type | Description |
---|---|---|
source | IPineSeries | Series of values to process. |
length | number | Number of bars (length). |
context | IContext | PineJS execution context. |
Returns
number
Offset to the lowest bar.
lt
▸ lt(n1
, n2
): number
Checks if n1
is less than n2
Parameters
Name | Type |
---|---|
n1 | number |
n2 | number |
Returns
number
1
if n1
is less than n2
, 0
otherwise.
max
▸ max(...values
): number
Maximum number in the array
Parameters
Name | Type |
---|---|
...values | number [] |
Returns
number
The greatest of multiple given values
min
▸ min(...values
): number
Minimum number in the array
Parameters
Name | Type |
---|---|
...values | number [] |
Returns
number
The smallest of multiple given values
minute
▸ minute(context
, time?
): number
Minute of current bar time in exchange timezone.
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
time? | number | optional time. Current bar time will be used by default. |
Returns
number
Current bar minute in exchange timezone.
month
▸ month(context
, time?
): number
Month of current bar time in exchange timezone.
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
time? | number | optional time. Current bar time will be used by default. |
Returns
number
Current bar month in exchange timezone.
n
▸ n(context
): number
Current bar index
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
number
Current bar index. Numbering is zero-based, index of the first historical bar is 0.
na
▸ na(n?
): number
Test value if it's a NaN.
Parameters
Name | Type | Description |
---|---|---|
n? | number | value to test |
Returns
number
1
if n
is not a valid number (n
is NaN
), otherwise 0
. Returns NaN
if n
is undefined.
neq
▸ neq(n1
, n2
): number
Checks if n1
is not equal to n2
.
Parameters
Name | Type |
---|---|
n1 | number |
n2 | number |
Returns
number
1
if n1
is not equal to n2
, 0
otherwise.
not
▸ not(n_0
): number
Logical negation (NOT).
Parameters
Name | Type |
---|---|
n_0 | number |
Returns
number
1
if value is falsy, 0
if value is truthy.
nz
▸ nz(x
, y?
): number
Replaces NaN values with zeros (or given value) in a series.
Parameters
Name | Type | Description |
---|---|---|
x | number | value to test (and potentially replace) |
y? | number | fallback value. 0 by default. |
Returns
number
x
if it's a valid (not NaN) number, otherwise y
ohlc4
▸ ohlc4(context
): number
Is a shortcut for (open + high + low + close)/4
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
number
Calculated average of the current OHLC values
open
▸ open(context
): number
Open Price
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
number
Current open price.
or
▸ or(n_0
, n_1
): number
Logical OR.
Parameters
Name | Type |
---|---|
n_0 | number |
n_1 | number |
Returns
number
1
if either value is truthy, 0
otherwise.
percentrank
▸ percentrank(source
, length
): number
Percent rank is the percentage of how many previous values were less than or equal to the current value of given series.
Parameters
Name | Type | Description |
---|---|---|
source | IPineSeries | Series of values to process. |
length | number | Number of bars (length). |
Returns
number
Percent rank of source
for length
bars back.
period
▸ period(context
): string
Resolution string, e.g. 60 - 60 minutes, D - daily, W - weekly, M - monthly, 5D - 5 days, 12M - one year, 3M - one quarter
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
string
The resolution string for the current context
pow
▸ pow(base
, exponent
): number
Mathematical power function.
Parameters
Name | Type | Description |
---|---|---|
base | number | Specify the base to use. |
exponent | number | Specifies the exponent. |
Returns
number
x
raised to the power of y
.
rising
▸ rising(series
, length
): number
Test if the series is now rising for length bars long.
Parameters
Name | Type | Description |
---|---|---|
series | IPineSeries | Series of values to process. |
length | number | Number of bars (length). |
Returns
number
true
if current x
is greater than any previous x
for length bars back, false
otherwise.
rma
▸ rma(source
, length
, context
): number
Moving average used in RSI. It is the exponentially weighted moving average with alpha = 1 / length
.
Parameters
Name | Type | Description |
---|---|---|
source | IPineSeries | Series of values to process. |
length | number | Number of bars (length). |
context | IContext | PineJS execution context. |
Returns
number
Exponential moving average of x
with alpha = 1 / y
.
roc
▸ roc(source
, length
): number
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]
.
Parameters
Name | Type | Description |
---|---|---|
source | IPineSeries | Series of values to process. |
length | number | Number of bars (length). |
Returns
number
The rate of change of source
for length
bars back.
round
▸ round(x
): number
Round the number to the nearest integer
Parameters
Name | Type |
---|---|
x | number |
Returns
number
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.
rsi
▸ rsi(upper
, lower
): number
Relative strength index. It is calculated based on rma's of upward and downward change of x.
Parameters
Name | Type | Description |
---|---|---|
upper | number | upward change |
lower | number | downward change |
Returns
number
Relative strength index.
sar
▸ sar(start
, inc
, max
, context
): number
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.
Parameters
Name | Type | Description |
---|---|---|
start | number | Start. |
inc | number | Increment. |
max | number | Maximum. |
context | IContext | PineJS execution context. |
Returns
number
Parabolic SAR value.
second
▸ second(context
, time?
): number
Second of current bar time in exchange timezone.
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
time? | number | optional time. Current bar time will be used by default. |
Returns
number
Current bar second in exchange timezone.
selectSessionBreaks
▸ selectSessionBreaks(context
, times
): number
[]
select session breaks for intraday resolutions only
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
times | number [] | An array of numbers representing the times to select session breaks from. |
Returns
number
[]
session breaks for intraday resolutions only.
sign
▸ sign(x
): number
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.
Parameters
Name | Type |
---|---|
x | number |
Returns
number
The sign of x
sin
▸ sin(x
): number
The sin function returns the trigonometric sine of an angle.
Parameters
Name | Type | Description |
---|---|---|
x | number | Angle, in radians. |
Returns
number
The trigonometric sine of an angle.
sma
▸ sma(source
, length
, context
): number
Simple Moving Average. The sum of last length
values of source
, divided by length
.
Parameters
Name | Type | Description |
---|---|---|
source | IPineSeries | Series of values to process. |
length | number | Number of bars (length). |
context | IContext | PineJS execution context. |
Returns
number
Simple moving average of x for y bars back.
smma
▸ smma(n_value
, n_length
, ctx
): number
Smoothed Moving Average.
Parameters
Name | Type | Description |
---|---|---|
n_value | number | Next value in the series to calculate. |
n_length | number | Smoothing length. |
ctx | IContext | PineJS execution context. |
Returns
number
The smoothed moving average value.
sqrt
▸ sqrt(x
): number
Square root of any x >= 0
is the unique y >= 0
such that y^2 = x
Parameters
Name | Type |
---|---|
x | number |
Returns
number
The square root of x
stdev
▸ stdev(source
, length
, context
): number
Standard deviation. Note: This is a biased estimation of standard deviation.
Parameters
Name | Type | Description |
---|---|---|
source | IPineSeries | Series of values to process. |
length | number | Number of bars (length). |
context | IContext | PineJS execution context. |
Returns
number
Standard deviation.
stoch
▸ stoch(source
, high
, low
, length
, context
): number
Stochastic. It is calculated by a formula: 100 * (close - lowest(low, length)) / (highest(high, length) - lowest(low, length))
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
number
Stochastic value.
sum
▸ sum(source
, length
, context
): number
The sum function returns the sliding sum of last y values of x.
Parameters
Name | Type | Description |
---|---|---|
source | IPineSeries | Series of values to process. |
length | number | Number of bars (length). |
context | IContext | PineJS execution context. |
Returns
number
Sum of x for y bars back.
swma
▸ swma(source
, context
): number
Symmetrically weighted moving average with fixed length: 4. Weights: [1/6, 2/6, 2/6, 1/6]
.
Parameters
Name | Type | Description |
---|---|---|
source | IPineSeries | Series of values to process. |
context | IContext | PineJS execution context. |
Returns
number
Symmetrically weighted moving average
tan
▸ tan(x
): number
The tan function returns the trigonometric tangent of an angle.
Parameters
Name | Type | Description |
---|---|---|
x | number | Angle, in radians. |
Returns
number
The trigonometric tangent of an angle.
ticker
▸ ticker(context
): string
Ticker ID for the current symbol
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
string
Ticker ID for the current symbol
tickerid
▸ tickerid(context
): string
Ticker ID
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
string
Ticker ID for the current symbol
time
▸ time(context
): number
Current bar time
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
number
UNIX time of current bar according to the symbol timezone and not UTC.
▸ time(context
, period
): number
Current bar time
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
period | string | Period |
Returns
number
UNIX time of current bar according to the symbol timezone and not UTC.
toBool
▸ toBool(v
): boolean
Convert a number to a boolean.
Parameters
Name | Type | Description |
---|---|---|
v | number | the value to convert. |
Returns
boolean
true
if the number is finite and non-zero, false
otherwise.
tr
▸ tr(n_handleNaN
, ctx
): number
True Range
Parameters
Name | Type | Description |
---|---|---|
n_handleNaN | number | How NaN values are handled. If truthy, and previous bar's close is NaN then tr would be calculated as current bar high-low . Otherwise tr would return NaN in such cases. Also note, that atr uses tr(true) . |
ctx | IContext | PineJS execution context. |
Returns
number
True range. It is max(high - low, abs(high - close[1]), abs(low - close[1]))
tsi
▸ tsi(source
, shortLength
, longLength
, context
): number
True strength index. It uses moving averages of the underlying momentum of a financial instrument.
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
number
True strength index. A value in range [-1, 1]
unitId
▸ unitId(ctx
): string
Get the symbol unit ID.
Parameters
Name | Type | Description |
---|---|---|
ctx | IContext | PineJS execution context. |
Returns
string
Symbol unit ID.
updatetime
▸ updatetime(context
): number
Time of the current update
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
number
symbol update time
variance
▸ variance(source
, length
, context
): number
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.
Parameters
Name | Type | Description |
---|---|---|
source | IPineSeries | Series of values to process. |
length | number | Number of bars (length). |
context | IContext | PineJS execution context. |
Returns
number
Variance of source
for length
bars back.
volume
▸ volume(context
): number
Current bar volume
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
Returns
number
Current bar volume
vwma
▸ vwma(source
, length
, context
): number
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)
Parameters
Name | Type | Description |
---|---|---|
source | IPineSeries | Series of values to process. |
length | number | Number of bars (length). |
context | IContext | PineJS execution context. |
Returns
number
Volume-weighted moving average of source
for length
bars back.
weekofyear
▸ weekofyear(context
, time?
): number
Week number of current bar time in exchange timezone.
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
time? | number | optional time. Current bar time will be used by default. |
Returns
number
Week number of current bar in exchange timezone.
wma
▸ wma(source
, length
, context
): number
The wma function returns weighted moving average of source
for length
bars back. In wma weighting factors decrease in arithmetical progression.
Parameters
Name | Type | Description |
---|---|---|
source | IPineSeries | Series of values to process. |
length | number | Number of bars (length). |
context | IContext | PineJS execution context. |
Returns
number
Weighted moving average of series
for length
bars back.
year
▸ year(context
, time?
): number
Year of current bar time in exchange timezone.
Parameters
Name | Type | Description |
---|---|---|
context | IContext | PineJS execution context. |
time? | number | optional time. Current bar time will be used by default. |
Returns
number
Current bar year in exchange timezone.
zigzag
▸ zigzag(n_deviation
, n_depth
, context
): number
Zig-zag pivot points
Parameters
Name | Type | Description |
---|---|---|
n_deviation | number | Deviation |
n_depth | number | Depth (integer) |
context | IContext | PineJS execution context. |
Returns
number
the zig-zag pivot points
zigzagbars
▸ zigzagbars(n_deviation
, n_depth
, context
): number
Zig-zag pivot points
Parameters
Name | Type | Description |
---|---|---|
n_deviation | number | Deviation |
n_depth | number | Depth (integer) |
context | IContext | PineJS execution context. |
Returns
number
the zig-zag pivot points (for bars)