Custom Study Constructor is able to use utility functions from PineJS object (an argument of custom_indicators_getter function).
Test value if it's a NaN.
true
if x
is not a valid number (x
is NaN), otherwise false
.
Replaces NaN values with zeros (or given value) in a series.
x
if it's a valid (not NaN) number, otherwise y
Logical AND. Applicable to boolean expressions.
Boolean value, or series of boolean values.
Logical OR. Applicable to boolean expressions.
Boolean value, or series of boolean values.
Logical negation (NOT). Applicable to boolean expressions.
Boolean value, or series of boolean values.
The greatest of multiple values
The smallest of multiple given values.
Mathematical power function.
x
raised to the power of y
. If x
is a series, it is calculated elementwise.
base
(series[float]) Specify the base to use.exponent
(float) Specifies the exponent.
Absolute value of x
is x
if x >= 0
, or -x
otherwise.
The absolute value of x
Natural logarithm of any x > 0
is the unique y
such that e^y = x
The natural logarithm of x.
Base 10 logarithm of any x > 0
is the unique y
such that 10^y = x
The base 10 logarithm of x.
Square root of any x >= 0
is the unique y >= 0
such that y^2 = x
The square root of x.
Sign (signum) of x
is zero if the x
is zero, 1.0
if the x
is greater than zero, -1.0
if the x
is less than zero.
The sign of the argument.
The exp function of x
is e^x
, where x
is the argument and e
is Euler's number.
A number representing e^x.
The sin
function returns the trigonometric sine of an angle.
The trigonometric sine of an angle.
x
(series[float]) Angle, in radians.
The cos function returns the trigonometric cosine of an angle.
The trigonometric cosine of an angle.
x
(series[float]) Angle, in radians.
The tan function returns the trigonometric tangent of an angle.
The trigonometric tangent of an angle.
x
(series[float]) Angle, in radians.
The asin function returns the arcsine (in radians) of number such that sin(asin(y)) = y
for y
in range [-1, 1]
.
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]
.
The acos function returns the arccosine (in radians) of number such that cos(acos(y)) = y
for y
in range [-1, 1]
.
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]
.
The atan function returns the arctangent (in radians) of number such that tan(atan(y)) = y
for any y
.
The arc tangent of a value; the returned angle is in the range [-Pi/2, Pi/2]
.
The largest integer less than or equal to the given number.
The ceil function returns the smallest (closest to negative infinity) integer that is greater than or equal to the argument.
The smallest integer greater than or equal to the given 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.
Calculates average of all given series (elementwise).
Average.
Current open price.
context
PineJS execution context.
Current high price.
context
PineJS execution context.
Current low price.
context
PineJS execution context.
Close price of the current bar when it has closed, or last traded price of a yet incomplete, realtime bar.
context
PineJS execution context.
Is a shortcut for (high + low)/2
context
PineJS execution context.
Is a shortcut for (high + low + close)/3
context
PineJS execution context.
Is a shortcut for (open + high + low + close)/4
context
PineJS execution context.
Current bar volume.
context
PineJS execution context.
Resolution string, e.g. 60
- 60 minutes, D
- daily, W
- weekly, M
- monthly, 5D
- 5 days, 12M
- one year, 3M
- one quarter
context
PineJS execution context.
context
PineJS execution context.
Current bar year in exchange timezone.
context
PineJS execution context.
Current bar month in exchange timezone.
context
PineJS execution context.
Week number of current bar time in exchange timezone.
context
PineJS execution context.
Date of current bar time in exchange timezone.
context
PineJS execution context.
Day of week for current bar time in exchange timezone.
context
PineJS execution context.
Current bar hour in exchange timezone.
context
PineJS execution context.
Current bar minute in exchange timezone.
context
PineJS execution context.
Current bar second in exchange timezone.
context
PineJS execution context.
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 ?:
Test if the series
is now rising for length
bars long.
true
if current x
is greater than any previous x
for length
bars back, false
otherwise.
series
(series[float]) Series of values to process.length
(integer) Number of bars (length).
Test if the series
is now falling for length
bars long.
true
if current x
is less than any previous x
for length
bars back, false
otherwise.
series
(series[float]) Series of values to process.length
(integer) Number of bars (length).
Relative strength index. It is calculated based on rma's of upward and downward change of x.
Relative strength index.
upper
(float) Series of values to process.lower
(float) Number of bars (length).
The sum function returns the sliding sum of last y values of x.
Sum of x for y bars back.
source
(series[float]) Series of values to process.length
(integer) Number of bars (length).context
PineJS execution context.
The sma function returns the moving average, that is the sum of last length
values of source
, divided by length
.
Simple moving average of x for y bars back.
source
(series[float]) Series of values to process.length
(integer) Number of bars (length).context
PineJS execution context.
Moving average used in RSI. It is the exponentially weighted moving average with alpha = 1 / length.
Exponential moving average of x with alpha = 1 / y.
source
(series[float]) Series of values to process.length
(integer) Number of bars (length).context
PineJS execution context.
For a given series replaces NaN values with previous nearest non-NaN value.
Series without na
gaps.
current
(series[float]) Series of values to process.context
PineJS execution context.
True range. It is max(high - low, abs(high - close[1]), abs(low - close[1]))
handle_nan
(bool) How NaN values are handled. iftrue
, and previous day's close is NaN thentr
would be calculated as current day high-low. Otherwise (iffalse
)tr
would return NaN in such cases. Also note, that atr usestr(true)
.context
PineJS execution context.
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]))
Average true range.
length
(integer) Length (number of bars back).context
PineJS execution context.
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)
Exponential moving average of x with alpha = 2 / (y + 1)
source
(series[float]) Series of values to process.length
(integer) Number of bars (length).context
PineJS execution context.
The wma function returns weighted moving average of source
for length
bars back. In wma weighting factors decrease in arithmetical progression.
Weighted moving average of series
for length
bars back.
source
(series[float]) Series of values to process.length
(integer) Number of bars (length).context
PineJS execution context.
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)
Volume-weighted moving average of source
for length
bars back.
source
(series[float]) Series of values to process.length
(integer) Number of bars (length).context
PineJS execution context.
Symmetrically weighted moving average with fixed length: 4. Weights: [1/6, 2/6, 2/6, 1/6]
.
Symmetrically weighted moving average
source
(series[float]) Source series.context
PineJS execution context.
Lowest value offset for a given number of bars back.
Offset to the lowest bar.
source
(series[float]) Series of values to process.length
(integer) Number of bars (length).context
PineJS execution context.
Lowest value for a given number of bars back.
Lowest value.
source
(series[float]) Series of values to process.length
(integer) Number of bars (length).context
PineJS execution context.
Highest value offset for a given number of bars back.
Offset to the highest bar.
source
(series[float]) Series of values to process.length
(integer) Number of bars (length).context
PineJS execution context.
Highest value for a given number of bars back.
Highest value.
source
(series[float]) Series of values to process.length
(integer) Number of bars (length).context
PineJS execution context.
Cumulative (total) sum of x
. In other words it's a sum of all elements of x
.
Total sum series.
x
(series[float]) Series of values to process.context
PineJS execution context.
Accumulation/distribution index.
context
PineJS execution context.
Correlation coefficient. Describes the degree to which two series tend to deviate from their sma
values.
Correlation coefficient.
source_a
(series[float]) Source series.source_b
(series[float]) Target series.length
(integer) Length (number of bars back).context
PineJS execution context.
Stochastic. It is calculated by a formula: 100 * (close - lowest(low, length)) / (highest(high, length) - lowest(low, length))
Stochastic.
source
(series[float]) Source series.high
(series[float]) Series of high.low
(series[float]) Series of low.length
(integer) Length (number of bars back).context
PineJS execution context.
True strength index. It uses moving averages of the underlying momentum of a financial instrument.
True strength index. A value in range [-1, 1]
source
(series[float]) Source series.short_length
(integer) Short length.long_length
(integer) Long length.context
PineJS execution context.
true
if two series have crossed each other, otherwise false
.
x
(series[float]) First series.y
(series[float]) Second series.context
PineJS execution context.
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).
Linear regression curve.
source
(series[float]) Source series.length
(integer)offset
(integer) Offset.
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.
Parabolic SAR.
start
(series[float]) Start.inc
(integer) Increment.max
(integer) Maximum.context
PineJS execution context.
Arnaud Legoux Moving Average. It uses Gaussian distribution as weights for moving average.
Arnaud Legoux Moving Average.
series
(series[float]) Series of values to process.length
(integer) Number of bars (length).offset
(float) Controls tradeoff between smoothness (closer to 1) and responsiveness (closer to 0).sigma
(float) Changes the smoothness of ALMA. The larger sigma the smoother ALMA.
Difference between current value and previous, x - x[1]
.
The result of subtraction.
source
(series[float])
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]
.
The rate of change of source
for length
bars back.
source
(series[float]) Series of values to process.length
(integer) Number of bars (length).
Measure of difference between the series and it's sma
.
Deviation of source
for length
bars back.
source
(series[float]) Series of values to process.length
(integer) Number of bars (length).context
PineJS execution context.
Standard deviation.
source
(series[float]) Series of values to process.length
(integer) Number of bars (length).context
PineJS execution context.
This is a biased estimation of standard deviation.
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.
Variance of source
for length
bars back.
source
(series[float]) Series of values to process.length
(integer) Number of bars (length).context
PineJS execution context.
This is a biased estimation of sample variance.
Percent rank is the percents of how many previous values was less than or equal to the current value of given series.
Percent rank of source
for length
bars back.
source
(series[float]) Series of values to process.length
(integer) Number of bars (length).
isZero(number)
- boolean, shows whether thenumber
equals zero or almost zerotoBool(number)
- boolean,true
if a number is finite and not equals zeroeq(arg1, arg2)
- boolean,true
if argument numbers are equalneq(arg1, arg2)
- boolean,true
if argument numbers are not equalge(arg1, arg2)
- boolean,true
if first argument number is greater or equal to secondgt(arg1, arg2)
- boolean,true
if first argument number is greater than secondle(arg1, arg2)
- boolean,true
if first argument number is lesser or equal to secondlt(arg1, arg2)
- boolean,true
if first argument is lesser than secondupdatetime(context)
- string, symbol update timeticker(context)
- string, symbol name without exchange prefix, e.g. 'MSFT'interval(context)
- returns symbol interval stringisdwm(context)
- boolean, returnstrue
if current resolution is a daily or weekly or monthly resolutionisintraday(context)
- boolean, returns true if current resolution is an intraday (minutes or seconds) resolutionisdaily(context)
- boolean, returnstrue
if current resolution is a daily resolutionisweekly(context)
- boolean, returnstrue
if current resolution is a weekly resolutionismonthly(context)
- boolean, returnstrue
if current resolution is a monthly resolutionadd_days_considering_dst(timezone, utcTime, daysCount)
selectSessionBreaks(context, times)
- select session breaks for intraday resolutions onlytimepart(symbol, field, time)
wvap(source, context)
createNewSessionCheck(context)
error(message)
- returns study error withmessage
specifiedtime(context, period, spec)
- returns UNIX time of current bar