Polarity Digital Docs
  • Workbench Reference
Powered by GitBook
On this page

Workbench Reference

Explore the array of features offered within the Polarity Digital Workbench analysis tool.

Input of Formulas

In the chart workbench, each data set or function that is added to the chart is assigned a unique identifier. These identifiers are in the format of m# for metrics and f# for formulas, where "#" is a number that increments with each new addition. For instance, the first metric added to the chart is labeled m1, the second is m2, and so on. Similarly, the first formula is f1, the second is f2, and so forth.

To illustrate, let’s assume you have loaded the price of Bitcoin: Price onto the chart. By default, this data set is assigned the identifier m1. If you subsequently load a formula, it will be assigned the identifier f1.

Now, let’s explore how you can utilize these identifiers to perform calculations on the chart. The workbench is powerful and supports a wide array of functions and computations.

For a simple example, if you want to calculate and plot the 100-day moving average of the Bitcoin price (which you loaded earlier as m1), you can use the following command: sma(m1, 100). Here, sma stands for Simple Moving Average, m1 represents the Bitcoin price data, and "100" specifies the number of days over which the average is calculated.

Let’s now delve into a more intricate example. Say, you want to calculate the 100-day moving average of the 30-day percentage change in Bitcoin price. This is still achievable in a single command: sma(percentage_change(m1, 30), 100). In this command, the term percentage_change(m1, 30) calculates the 30-day percentage change in Bitcoin price. It replaces the m1 in the initial example. The outer sma function then takes this result and computes its 100-day moving average.

By employing these identifiers (m# for metrics, f# for formulas) and integrating functions, the workbench enables users to conduct both simple and complex calculations efficiently.

n is a float value. A float value is used to store decimal numbers (numbers with fractional parts, i.e. 7.5 or 13.01). i is an integer value. An integer is any whole number, positive or negative, including zero.

period is an integer value, that represents the number of days to be applied to the specified function (i.e. in the formula percent_change(m1, 7) will calculate the percentage change of a data set (m1), over the prior 7 day period. Currently, all time resolutions are given in one day increments. Closing values are based on UTC.

Workbench Function
Syntax Options
Function Description

Simple Moving Average

sma(m1, period)

Returns the simple moving average of m1 over the specified period.

Exponential Moving Average

ema(m1, period)

Returns the exponentially weighted moving average of m1 over the specified period. EMA weighting factors decrease exponentially. It calculates by using a formula: EMA = α* m1+ (1 - α) * EMA[1], where α = 2 / (period+ 1).

Median

median(m1, period) med(m1, period)

Returns the median of m1 over the specified period.

Sum

sum(m1, period)

Returns the sum of m1over the specified period.

Cumulative Mean

cummean(m1) cm(m1)

Returns the running mean using all values from the start of the data, until each closing period.

Cumalative Standard Deviation

cumstd(m1) cs(m1)

Returns the running standard deviation using all values from the start of the data, until each closing period.

Cumulative Sum

cumsum(m1)

Returns a cumulative sum by adding all the data from the first day to the closing data point of each respective period.

Standard Deviation

std(m1, period)

Returns the standard deviation of m1 over the specified period.

Percentage Change

percent_change(m1, period) pc(m1, period)

Returns the percentage change of m1 over the specified period.

Difference

diff(m1, period)

Returns the difference of m1 and m2 over the specified period.

Logarithm

log(m1)

Returns the logarithm (base 10) of m1.

Power

pow(m1, i)

Returns m1 raised to the power of n.

Absolute Value

abs(m1)

Returns the absolute value of m1.

Range

range(m1)

Returns a line from day y = 0 to y = current day for m1, increasing in increments of 1.

Relative Strength Index

rsi(m1, period)

Returns the relative strength index of m1 over the specified period.

Min

min(m1, period)

Returns the minimum value of m1 over the specified period.

Max

max(m1, period)

Returns the maximum value of m1 over the specified period.

Shift

shift(m1, period)

Shifts the data of m1 by the specified period.

Correlation

corr(m1, m2, period)

Returns the correlation between m1 and m2 over the specified period.

Square Root

sqrt(m1)

Returns the square root of m1.

If

if(m1, "cond", m2, true, false)

Establishes an if-then condition comparing the trace of m1 to m2 at each data point, returning the result true or false. The "cond" may be set equal to any of the following: "=" equal to "!=" not equal to ">" greater than ">=" greater than or equal to "<" less than "<=" less than or equal to

Last updated 1 year ago