Array

Backtest

Data

Number

Plot

String

A list of Numbers or Strings.

Backtest

To backtest different types of systems on a specified security, a Backtest object has to be created so it can be properly analyzed.

Data

Historic quotes, volume, ratings and signals data pertaining to a specific symbol are loaded in a Data object.

Number

A number (natural number, integer or decimal).

Plot

To draw an Array or Number on a Chart, it has to be loaded into a Plot object.

String

Any string of characters encapsulated by matching single or double quotes.

E:Number

LN10:Number

LN2:Number

PI:Number

Constant Number value e for the base of natural logarithm.

LN10:Number

Constant Number value for the natural logarithm of 10.

LN2:Number

Constant Number value for the natural logarithm of 2.

PI:Number

Constant Number value pi (ratio of circumference of a circle to its diameter).

Retrieving Data Quotes

data(a="x":String, b="symbol_name":String(optional)):null

Creates a data object x and populates it with quotes data for a specified symbol "symbol_name".

Data Properties

close(x:Data):Array

Returns close quotes Array for a Data object x.

date(x:Data):Array

Returns dates Array for a data object x.

high(x:Data):Array

Returns high quotes Array for a Data object x.

low(x:Data):Array

Returns low quotes Array for a Data object x.

method1(x:Data):Array

Returns Bollinger Method 1 (Volatility Breakout) signals Array for a Data object x.

method2(x:Data):Array

Returns Bollinger Method 2 (Trend Following) signals Array for a Data object x.

method3(x:Data):Array

Returns Bollinger Method 3 (Reversals) signals Array for a Data object x.

method4(x:Data):Array

Returns Bollinger Method 4 (Confirmed Breakout) signals Array for a Data object x.

open(x:Data):Array

Returns open quotes Array for a Data object x.

performance(x:Data):Array

Returns performance ratings Array for a Data object x.

potential(x:Data):Array

Returns potential ratings Array for a Data object x.

signal(x:Data):Array

Returns signals Array for a Data object x.

volume(x:Data):Array

Returns volume Array for a Data object x.

Data Object Functions

adline(x:Data):Array

Returns the Accumulation-Distribution (AD) using parameter period of Data object x in an Array object.

adosc(x:Data, period:Number):Array

Returns the Accumulation-Distribution Oscillator (AD%) using parameter period of Data object x in an Array object.

aroon(x:Data, period:Number, series:String["up","down","oscillator"]):Array

Returns the Aroon Up, Aroon Down or Aroon Oscillator (AR), depending on the string value of the series parameter, using parameter period of Data object x in an Array object.

atr(x:Data, n:Number(optional)):Array or Number

Returns the average true range for a Data object x.

bbaccumulation(x:Data, period:Number, width:Number):Array

Returns the Bollinger Bands Accumulation using parameters period and length of Data object x in an Array object.

bbands(x:Data, period:Number, width:Number, series:String["upper","middle","lower"]):Array

Returns one of the Bollinger Bands^{®} of parameters period and width (upper, middle or lower), depending on the string value of the series parameter, of Data object x in an Array object.

bbimpulse(x:Data, period:Number, width:Number, type:String["bbands","benvelope"]):Array

Returns the Bollinger Bands Impulse (BBImpulse, BBI) of Bollinger Bands or Bollinger Envelopes of parameters period and width (depending on the string value of type) of Data object x in an Array object.

bbindex(x:Data, period:Number):Array

Returns the Bollinger Bands Index (BBIndex, BBX) of Data object x in an Array object.

bbmtm(x:Data, period:Number, width:Number, period2:Number, type:String["bbands","benvelope"]):Array

Returns the Bollinger Bands Momentum (BBMomentum, BBM) of Bollinger Bands or Bollinger Envelopes of parameters period and width (depending on the string value of type) using parameter period2 of Data object x in an Array object.

bbpersist(x:Data, period:Number, width:Number, lookback:Number, type:String["bbands","benvelope"]):Array

Returns the BBPersist of Bollinger Bands or Bollinger Envelopes of parameters period and width (depending on the string value of type) using parameter lookback of Data object x in an Array object.

bbstops(x:Data, entry_date:String["YYYY-MM-DD"], trade_type:Number[1,-1], af_step:Number, af_max:Number, beOffset:Number):Array

Returns an Array object containing the BBStops™ entry and exit signals (1 for buy, -1 for sell) where entry_date is the first trade date string, trade_type is the type of the first trade (1 for long, -1 for short), af_step is the Acceleration Factor (AF) step (usually 0.02) and af_max is the maximum AF. Only one trade is generated.

bbtrend(x:Data, period1:Number, period2:Number):Array

Returns the Bollinger Bands Trend (BBTrend, BBT) using parameters period1 and period2 of Data object x in an Array object.

benvelope(x:Data, period:Number, width:Number, series:String["upper","middle","lower"]):Array

Returns the Bollinger Envelopes of parameters period and width (upper, middle or lower), depending on the string value of the series parameter, of Data object x in an Array object.

bwdelta(x:Data, period:Number, width:Number, period2:Number, type:String["bbands","benvelope"]):Array

Returns the BandWidth Delta of Bollinger Bands or Bollinger Envelopes of parameters period and width (depending on the string value of type) using parameter period2 of Data object x in an Array object.

bwdth(x:Data, period:Number, width:Number, type:String["bbands","benvelope"]):Array

Returns the BandWidth (BW) of the Data object x for Bollinger Bands or Bollinger Envelopes of parameters period and width (depending on the string value of type) in an Array object.

cci(x:Data, period:Number):Array

Returns the Commodity Channel Index (CCI) using parameter period of Data object x in an Array object.

chandelierstops(x:Data, entry_date:String["YYYY-MM-DD" or "YYYY-MM-DD HH:MM"], trade_type:Number[1,-1], m:Number, n:Number, always_in:Number[1,0]):Array

Returns an Array object containing the Chandelier stops entry and exit signals (1 for buy, -1 for sell) where entry_date is the first trade date string, trade_type is the type of the first trade (1 for long, -1 for short), m is the Average True Range (ATR) period and n is the ATR multiplier. Setting always_in to 0 will only generate one trade whereas setting it to 1 will generate a system of trades that keep reversing positions on trade close

chop(x:Data, period:Number):Array

Returns the Choppiness Index (CI) using parameter period of Data object x in an Array object.

cmo(x:Data, period:Number):Array

Returns the Chande Momentum Oscillator (CMO) using parameter period of Data object x in an Array object.

conviction(x:Data, period:Number):Array

Returns the Alphier Conviction using parameter period of Data object x in an Array object.

departure(x:Data, period1:Number, period2:Number):Array

Returns the Departure Chart (DC) using parameters period1 and period2 of Data object x in an Array object.

dfa(x:Data, period:Number):Array

Returns the Deviation from Average using parameter period of Data object x in an Array object.

dmi(x:Data, period:Number, series:String["adx","dmiplus","dmiminus"]):Array

Returns the Average Directional Index (ADX), Plus Directional Movement Index (DMI+) or Minus Directional Movement Index (DMI-), depending on the string value of the series parameter, using parameter period of Data object x in an Array object.

expectation(x:Data, series:String["expect","signal"]):Array

Returns the Alphier Expectation curve or Alphier Expectation Alerts, depending on the string value of the series parameter, of Data object x in an Array object.

ialine(x:Data):Array

Returns the Interday Accumulation (IA) of Data object x in an Array object.

iaosc(x:Data, period:Number):Array

Returns the Interday Accumulation Oscillator (IA%) using parameter period of Data object x in an Array object.

icebreaker(tdata:Data, sdata:Data):Array

Returns John Bollinger's Ice Breaker signals of Data object sdata to trade Data object tdata in an Array object.

iiline(x:Data):Array

Returns the Intraday Intensity (II) of Data object x in an Array object.

iiosc(x:Data, period:Number):Array

Returns the Intraday Intensity Oscillator (II%) using parameter period of Data object x in an Array object.

macd(x:Data, p1:Number, p2:Number, p3:Number, series:String["macd","signal"]):Array

Returns the Moving Average Convergence-Divergence (MACD) or MACD Signal, depending on the string value of the series parameter, using parameters p1, p2 and p3 of Data object x in an Array object.

mfi(x:Data, period:Number):Array

Returns the Money Flow Index (MFI) using parameter period of Data object x in an Array object.

mtm(x:Data, period:Number):Array

Returns the Momentum (MTM) using parameter period of Data object x in an Array object.

normvol(x:Data, period:Number):Array

Returns the Normalized Volume (Vol%) using parameter period of Data object x in an Array object.

nrsi(x:Data, period:Number):Array

Returns the Normalized Relative Strength Index (NRSI) using parameter period of Data object x in an Array object.

obv(x:Data):Array

Returns the On-Balance Volume (OBV) of Data object x in an Array object.

parabolicstops(x:Data, entry_date:String["YYYY-MM-DD"], trade_type:Number[1,-1], af_step:Number, af_max:Number):Array

Returns an Array object containing the Parabolic stop and reversal system entry and exit signals (1 for buy, -1 for sell) where entry_date is the first trade date string, trade_type is the type of the first trade (1 for long, -1 for short), af_step is the Acceleration Factor (AF) step (usually 0.02) and af_max is the maximum AF.

perb(x:Data, period:Number, width:Number, type:String["bbands","benvelope"]):Array

Returns the %b (Percent b) of the Data object x for Bollinger Bands or Bollinger Envelopes of parameters period and width (depending on the string value of type) in an Array object.

perbw(x:Data, period:Number, width:Number, period2:Number, type:String["bbands","benvelope"]):Array

Returns the %BandWidth (Percent BandWidth) of Bollinger Bands or Bollinger Envelopes of parameters period and width (depending on the string value of type) using parameter period2 of Data object x in an Array object.

psychology(x:Data, period:Number):Array

Returns the Alphier Psychology of Data object x in an Array object.

pvt(x:Data):Array

Returns the Price-Volume Trend (PVT) using parameter period of Data object x in an Array object.

qstk(x:Data, period:Number):Array

Returns the Qstick (QSTK) using parameter period of Data object x in an Array object.

range(x:Data, n:Number(optional)):Array,Number

Returns the range of a Data object x.

rmi(x:Data, p1:Number, p2:Number):Array

Returns the Relative Momentum Index (RMI) using parameters p1 and p2 of Data object x in an Array object.

roc(x:Data, period:Number):Array

Returns the Rate of Change (ROC) using parameter period of Data object x in an Array object.

rsi(x:Data, period:Number):Array

Returns the Relative Strength Index (RSI) using parameter period of Data object x in an Array object.

spvol(x:Data):Array

Returns the Sponsored Volume (SV) of Data object x in an Array object.

spvolp(x:Data, period:Number):Array

Returns the Sponsored Volume Oscillator (SV%) using parameter period of Data object x in an Array object.

stochimp(x:Data, period:Number):Array

Returns the Stochastic Impulse using parameter period of Data object x in an Array object.

stochkd(x:Data, p1:Number, p2:Number, type:String["fast","slow"], series:String["k","d"]):Array

Returns the fast or slow (depending on the string value of type) Stochastics %k or %d, depending on the string value of the series parameter, using parameters p1 and p2 of Data object x in an Array object.

stochrsi(x:Data, rsiPeriod:Number, stochPeriod:Number):Array

Returns the Stochastic Relative Strength Index (STOCHRSI) using parameter periods rsiPeriod and stochPeriod of Data object x in an Array object.

tri(x:Data, q:Number, m:Number):Array

Returns the The Range Indicator (TRI) using parameters q and m of Data object x in an Array object.

truerange(x:Data):Array

Returns the true range for a Data object x.

uos(x:Data, p1:Number, p2:Number, p3:Number):Array

Returns the Ultimate Oscillator (UO) using parameters p1, p2 and p3 of Data object x in an Array object.

vhf(x:Data, period:Number):Array

Returns the Vertical Horizontal Filter (VHF) using parameter period of Data object x in an Array object.

vos(x:Data, period1:Number, period2:Number):Array

Returns the Volume Oscillator (VO) using parameters period1 and period2 of Data object x in an Array object.

vpci(x:Data, shortPeriod:Number, longPeriod:Number):Array

Returns the volume price confirmation indicator array using shortPeriod and longPeriod of Data object x in an Array object.

vwma(x:Data, p1:Number):Array

Returns the volume weighted moving average of period p1 of Data object x in an Array object.

vwmacd(x:Data, p1:Number, p2:Number, p3:Number, series:String["vwmacd","signal"]):Array

Returns the Volume-Weighted Moving Average Convergence-Divergence (VWMACD) or the VWMACD Signal, depending on the string value of the series parameter, using parameters p1, p2 and p3 of Data object x in an Array object.

williams(x:Data, period:Number):Array

Returns the Williams %R using parameter period of Data object x in an Array object.

wynia(x:Data, threshold:Number):Array

Returns the Wynia Volume Profile (WVP) using parameter period for the zig zag percentage filter of Data object x in an Array object.

Logical Functions

and(x:Array or Number, y:Array or Number):Array or Number

Evaluates the logical AND of parameters passed and returns the result.

not(x:Array or Number):Array or Number

Returns the logical opposite of x.

or(x:Array or Number, y:Array or Number):Array or Number

Evaluates the logical OR of the parameters passed and returns the result.

Comparison Functions

equal(x:Array or Number or String, y:Array or Number or String):Array or Number

Returns true if x equals to y, otherwise false.

greater(x:Array or Number or String, y:Array or Number or String):Array or Number

Returns true if x greater than y, otherwise false.

greaterorequal(x:Array or Number or String, y:Array or Number or String):Array or Number

Returns true if x greater than or equal to y, otherwise false.

less(x:Array or Number or String, y:Array or Number or String):Array or Number

Returns true if x less than y, otherwise false.

lessorequal(x:Array or Number or String, y:Array or Number or String):Array or Number

Returns true if x less than or equal to y, otherwise false.

notequal(x:Array or Number or String, y:Array or Number or String):Array or Number

Returns true if x is not equal to the y, otherwise false.

signum(x:Array or Number):Array or Number

Returns 1 when the element provided is greater than zero, -1 when less and 0 when 0.

Conditional Functions

if(x:Array or Number, y:Array or Number, z:Array or Number):Array or Number

Conditional statement, checks for x, returns y if true, z if false.

Iteration Functions

else():null

Used in a conditional block within a manual iteration block as a last option after all preceding startif or elseif function are skipped (their conditions were not met). Can only be used after initializing conditional blocks via startif.

elseif(x:Number):null

Used in a conditional block within a manual iteration block after a preceding startif or elseif function is skipped (their conditions were not met). Checks for x and executes next statements if x is true. Can only be used after initializing conditional blocks via startif.

end():null

Closes a manual block of iterations. Must be paired with an iterate function call.

endif():null

Marks the end of a conditional block inside a manual iteration. Must be paired with a startif function.

iterate(n:Number):null

Creates a repeating block of statements according to the specified number of times n passed. Must be paired with an end function call.

startif(x:Number):null

Initializes a conditional block inside a manual iteration block. Checks for x and executes statements if true. Must be paired with an endif function call.

Trigonometric Functions

acos(x:Array or Number):Array or Number

Returns the arc cosine for x, in radians.

asin(x:Array or Number):Array or Number

Returns the arc sine for x, in radians.

atan(x:Array or Number):Array or Number

Returns the value, in radians, of the angle whose tangent is specified in x.

atan2(y:Array or Number, x:Array or Number):Array or Number

Calculates and returns the angle of the point y/x in radians.

ceil(x:Array or Number):Array or Number

Returns the ceiling of the specified parameter x.

cos(x:Array or Number):Array or Number

Returns the cosine of the parameter angle x expressed in radians.

sin(x:Array or Number):Array or Number

Returns the sine of the parameter angle x expressed in radians.

tan(x:Array or Number):Array or Number

Returns the tangent of the parameter angle x expressed in radians.

Rounding Functions

ceil(x:Array or Number):Array or Number

Returns the ceiling of the specified parameter x.

floor(x:Array or Number):Array or Number

Returns the floor of the specified parameter x.

round(x:Array or Number):Array or Number

Rounds x up or down to the nearest integer and returns the value.

Math Functions

abs(x:Array or Number):Array or Number

Returns the absolute value of x.

exp(x:Array or Number):Array or Number

Returns the value of the base of the natural logarithm (e), to the power of x.

max(x:Array or Number, y:Array or Number):Array or Number

Returns the maximum of the parameters passed.

min(x:Array or Number, y:Array or Number):Array or Number

Returns the minimum of the parameters passed.

mod(x:Array or Number, y:Array or Number):Array or Number

Returns the remainder of division between x and y.

pow(x:Array or Number, y:Array or Number):Array or Number

Returns x to the power of y.

random():Array or Number

Returns a pseudo-random Number n, where 0 <= n < 1.

sqrt(x:Array or Number):Array or Number

Returns the square root of x.

Array Functions

array(x:Number):Array

Returns an Array initialized to the value of the parameter passed.

counter(x:Array):Array

Returns an Array of increasing values 0,1,2,3,etc.

length(x:Array):Number

Returns the total number of elements in an Array.

randomarray():Array

Returns a random Array with different pseudo-random Numbers n[i], where 0 <= n[i] < 1.

replacenan(array_with_NaN:Array, replacement_of_NaN:Number or Array):Array

Replaces all NaN occurrences in an input array which are never plotted in a chart with a scalar number or with corresponding values from another array.

reverse(x:Array):Array

Returns the Array passed to it in reverse order.

sort(x:Array):Array

Sorts and returns the Array passed to it by increasing order.

Statistical Functions

absdev(x:Array, p:Number(optional)):Array or Number

Returns the absolute deviation of the Array passed.

ema(x:Array, p:Number(optional)):Array or Number

Returns the exponential moving average of the Array passed.

lwma(x:Array, n:Number):Array

Returns the linear weighted moving average of the Array passed of window length p.

median(x:Array, p:Number(optional)):Array or Number

Returns the moving Median (middle value) of the Array passed to it.

movmax(x:Array, p:Number(optional)):Array or Number

Returns the moving maximum of the Array passed.

movmin(x:Array, p:Number(optional)):Array or Number

Returns the moving minimum of the Array passed.

movsum(x:Array, p:Number(optional)):Array or Number

Returns the moving sum of the Array passed.

since(x:Array, n:Number(optional)):Number

Returns the index of the nth occurrence of a true value starting from the end of array x.

sma(x:Array, p:Number(optional)):Array or Number

Returns the simple moving average of the Array passed.

stdev(x:Array, p:Number(optional)):Array or Number

Returns the standard deviation of the Array passed.

within(x:Array, p:Number(optional)):Array or Number

Returns the Array of number of times Array is true within a moving period.

wma(x:Array, c1:Number, c2:Number, c3:Number(optional), cn:Number(optional)):Array

Returns the weighted moving average of Array passed using the weight coefficient window c1, c2, c3... cn.

xover(x:Array, y:Array):Array

Returns Array of true values when first Array crosses over second Array, false otherwise.

xunder(x:Array, y:Array):Array

Returns Array of true values when first Array crosses under second Array, false otherwise.

Plot and Chart Functions

chart(p1:Plot, p2:Plot(optional), p3:Plot(optional), p4:Plot(optional), p5:Plot(optional), p6:Plot(optional), p7:Plot(optional), p8:Plot(optional), p9:Plot(optional), p10:Plot(optional)):null

Displays all the plot objects passed to it in one indicator chart.

pchart(p1:Plot, p2:Plot(optional), p3:Plot(optional), p4:Plot(optional), p5:Plot(optional), p6:Plot(optional), p7:Plot(optional), p8:Plot(optional), p9:Plot(optional), p10:Plot(optional)):null

Displays all the plot objects passed to it in the main price chart.

plot(x:Array or Number, name:String(optional), type:String(optional), color:String(optional), s:Array or Backtest(optional)):Plot

Creates and returns the plot object of the Array or Number passed.

Backtesting Functions

backtest(x:Data, s:Array, optionalSystemType:Number[0,1,2,3,4,5], optionalStopType:Number[0,1,2], optionalStopParameter1:Number, optionalStopParameter2:Number, optionalStopParameter3:Number):Backtest

Generates a trade report with all the entry and exit signals using the provided signals array for the data object requested.
The trade entry and exit is chosen depending on the system type. In addition there is an optional stop type and stop parameters to be passed when systems with stops are selected.

equitycurve(bt:Backtest, equitycurve_type:Number[0,1]):Array

Returns an array of data used to plot the equity curve. The data represents the historical percent gains using the specified input system, starting with 0%.

tradesig(bt:Backtest):Array

Returns an Array of signals/stops that correspond to the trade report generated by the system defined in the Backtest object passed.

Display Functions

print(x1:Array or Number or String or Plot or Data, x2:Array or Number or String or Plot or Data, x3:Array or Number or String or Plot or Data, ...:Array or Number or String or Plot or Data):null

Appends all the parameters passed and prints their values to the output screen.

Data Types

Array

All indicators are basically Arrays that are computed using other Arrays. All arrays are stored internally to have the same length and aligned so that each point in time in one array is aligned with another. Arrays can be shifted backward or forward. This is used in some cases to calculate current Array values using previous or even future values.

Example

myArray = array(0)

arrayname[-p]

close(x)[-2] references the close value 2 positions before the current one

close(x)[+1] references the close value 1 position after the current one

close(x) or close(x)[0] is the current close value

arrayname[-p]

close(x)[-2] references the close value 2 positions before the current one

close(x)[+1] references the close value 1 position after the current one

close(x) or close(x)[0] is the current close value

Backtest

To backtest different types of systems represented by an array of signals on a security's historical data represented by its data object, a Backtest object has to be created so it can be properly analyzed. An array of signals is specified, a data object to represent the security on which the system will be analyed, the type of system used [0: always in the market without pyramiding, 1: always in the market with pyramiding, 2: Discrete trades without stops and without pyramiding, 3: Discrete trades without stops and with pyramiding, 4: Discrete trades with stops and without pyramiding, 5: Discrete trades with stops and with pyramiding], the type of stops used [0: Chandelier, 1: Parabolic, 2: Bollinger] if relevant to the system and up to 3 additional parameters for customizing these stops. Using the backtest object, information such as all the relevant signals and stops can be obtained as well equity curve data for plotting.

Example

myBacktester = backtest(dataObject, signalArray, optionalSystemType, optionalStopType, optionalStopParameter1, optionalStopParameter2, optionalStopParameter3)

Data

In order to create indicators specific to a chart, the symbol's historic quotes have to be loaded into a Data object. Up to 10 different Data quotes can be loaded at one time.

Example

data('myData','aapl')

Number

Numbers consist of any scalar quantities: natural numbers, integers or decimals. Logical states are also represented in Numbers. FALSE is 0 and TRUE is 1. Any undefined Number has a value NaN. This value will be ignored and skipped on the chart whenever it is encountered.

Example

myNumber = 3.5

Plot

To draw an Array or a Number in a chart, it has to be loaded into a Plot object. This object has optional additional parameters such a label name, type of plot ('line' for linear plot and 'histogram' for histogram plots) and an optional Array of signals which can be bundled with the array to be plotted. Multiple Plot objects can be drawn in one indicator/price chart.

Example

myPlot = plot(myArrayOrNumberToPlot, optionalNameOfPlot, optionalTypeOfPlot, optionalColorString, optionalPlotSignalsArray)

String

Any string of characters encapsulated by matching single or double quotes consist of a String data type. Plot names are String data types. In addition, Plot types can be either one these 2 Strings: 'line' for linear plots and 'histogram' for vertical line plots. Finally, a Plot chart color is a 6 hexadecimal character String or an 8 hexadecimal character String where the first 2 characters are interpreted as alpha channel(ff for opaque, 00 for fully transparent).

Example

myString = 'this is a string'

Constants

Methods

Retrieving Data QuotesData PropertiesData Object FunctionsLogical FunctionsComparison FunctionsConditional FunctionsIteration FunctionsTrigonometric FunctionsRounding FunctionsMath FunctionsArray FunctionsStatistical FunctionsPlot and Chart FunctionsBacktesting FunctionsDisplay Functions

data(a="x":String, b="symbol_name":String(optional)):null

Parameters

a="x":String - Variable String name where the Data object will be stored.

b="symbol_name":String(optional) - The symbol String name whose historic quotes are to be loaded.

b="symbol_name":String(optional) - The symbol String name whose historic quotes are to be loaded.

Returns

null - No returned value.

data("x","symbol_name") creates an object x and populate it with the quotes data for symbol "symbol_name". If symbol name is not specified, the default currently plotted symbol will be selected. A maximum of 10 symbols can be loaded.

Example

data("var","msft")

print(var)

print(var)

close(x:Data):Array

Parameters

x:Data - Data object variable name whose historic quotes are to be accessed.

Returns

Array - Array of close quotes.

Returns the close quotes Array for Data object x.

Example

data("x")

myCloseArray = close(x)

print(myCloseArray)

myCloseArray = close(x)

print(myCloseArray)

date(x:Data):Array

Parameters

x:Data - Data object variable name whose historic quotes are to be accessed.

Returns

Array - Array of date Strings.

Returns the dates Array (Array of strings) of format ("YYYY-MM-DD" or "YYYY-MM-DD HH:MM") for Data object x.

Example

data("x")

myDateArray = date(x)

print(myDateArray)

myDateArray = date(x)

print(myDateArray)

high(x:Data):Array

Parameters

x:Data - Data object variable name whose historic quotes are to be accessed.

Returns

Array - Array of high quotes.

Returns the high quotes Array for Data object x.

Example

data("x")

myHighArray = high(x)

print(myHighArray)

myHighArray = high(x)

print(myHighArray)

low(x:Data):Array

Parameters

x:Data - Data object variable name whose historic quotes are to be accessed.

Returns

Array - Array of low quotes.

Returns the low quotes Array for Data object x.

Example

data("x")

myLowArray = low(x)

print(myLowArray)

myLowArray = low(x)

print(myLowArray)

method1(x:Data):Array

Parameters

x:Data - Data object variable name whose historic Bollinger Method 1 (Volatility Breakout) signals are to be accessed.

Returns

Array - Array of Method 1 signals (Possible Numbers: 0, +1, -1)

Returns the Bollinger Method 1 (Volatility Breakout) signals Array for Data object x(equities/forex data)

0: no signal

-1: Volatility Breakout Sell

+1: Volatility Breakout Buy

0: no signal

-1: Volatility Breakout Sell

+1: Volatility Breakout Buy

Example

data("x")

myMethod1Array = method1(x)

print(myMethod1Array)

myMethod1Array = method1(x)

print(myMethod1Array)

method2(x:Data):Array

Parameters

x:Data - Data object variable name whose historic Bollinger Method 2 (Trend Following) signals are to be accessed.

Returns

Array - Array of Method 2 signals (Possible Numbers: 0, +1, -1)

Returns the Bollinger Method 2 (Trend Following) signals Array for Data object x(equities data only)

0: no signal

-1: Trend Following Sell

+1: Trend Following Buy

0: no signal

-1: Trend Following Sell

+1: Trend Following Buy

Example

data("x")

myMethod2Array = method2(x)

print(myMethod2Array)

myMethod2Array = method2(x)

print(myMethod2Array)

method3(x:Data):Array

Parameters

x:Data - Data object variable name whose historic Bollinger Method 3 (Reversals) signals are to be accessed.

Returns

Array - Array of Method 3 signals (Possible Numbers: 0, +1, -1)

Returns the Bollinger Method 3 (Reversals) signals Array for Data object x(equities data only)

0: no signal

-1: Reversals Sell

+1: Reversals Buy

0: no signal

-1: Reversals Sell

+1: Reversals Buy

Example

data("x")

myMethod3Array = method3(x)

print(myMethod3Array)

myMethod3Array = method3(x)

print(myMethod3Array)

method4(x:Data):Array

Parameters

x:Data - Data object variable name whose historic Bollinger Method 4 (Confirmed Breakout) signals are to be accessed.

Returns

Array - Array of Method 4 signals (Possible Numbers: 0, +1, -1)

Returns the Bollinger Method 4 (Confirmed Breakout) signals Array for Data object x(equities/forex data)

0: no signal

-1: Confirmed Breakout Sell

+1: Confirmed Breakout Buy

0: no signal

-1: Confirmed Breakout Sell

+1: Confirmed Breakout Buy

Example

data("x")

myMethod4Array = method4(x)

print(myMethod4Array)

myMethod4Array = method4(x)

print(myMethod4Array)

open(x:Data):Array

Parameters

x:Data - Data object variable name whose historic quotes are to be accessed.

Returns

Array - Array of open quotes.

Returns the open quotes Array for Data object x.

Example

data("x")

myOpenArray = open(x)

print(myOpenArray)

myOpenArray = open(x)

print(myOpenArray)

performance(x:Data):Array

Parameters

x:Data - Data object variable name whose historic quotes are to be accessed.

Returns

Array - Array of performance ratings (Numbers between 0 and 5).

Returns the performance ratings Array for Data object x(equities data only)

Ratings Details:

[0]-> ------

]0,1] -> ----gg

]1,2] -> ---yg-

]2,3] -> --yy--

]3,4] -> -ry---

]4,+inf] -> rr----

Ratings Details:

[0]-> ------

]0,1] -> ----gg

]1,2] -> ---yg-

]2,3] -> --yy--

]3,4] -> -ry---

]4,+inf] -> rr----

Example

data("x")

myPerformanceRatingsArray = performance(x)

print(myPerformanceRatingsArray)

myPerformanceRatingsArray = performance(x)

print(myPerformanceRatingsArray)

potential(x:Data):Array

Parameters

x:Data - Data object variable name whose historic quotes are to be accessed.

Returns

Array - Array of potential ratings (Numbers between 0 and 5).

Returns the potential ratings Array for Data object x (equities data only)

Ratings Details:

[0]-> ------

]0,1] -> ----gg

]1,2] -> ---yg-

]2,3] -> --yy--

]3,4] -> -ry---

]4,+inf] -> rr----

Ratings Details:

[0]-> ------

]0,1] -> ----gg

]1,2] -> ---yg-

]2,3] -> --yy--

]3,4] -> -ry---

]4,+inf] -> rr----

Example

data("x")

myPotentialRatingsArray = potential(x)

print(myPotentialRatingsArray)

myPotentialRatingsArray = potential(x)

print(myPotentialRatingsArray)

signal(x:Data):Array

Parameters

x:Data - Data object variable name whose historic quotes are to be accessed.

Returns

Array - Array of signals (Possible Numbers: 0, +1, -1, +2, -2)

Returns the signals Array for Data object x(equities data only)

0: no signal

-1: negative powershift

-2: negative pivot

+1: positive powershift

+2: positive pivot

0: no signal

-1: negative powershift

-2: negative pivot

+1: positive powershift

+2: positive pivot

Example

data("x")

mySignalsArray = signal(x)

print(mySignalsArray)

mySignalsArray = signal(x)

print(mySignalsArray)

adline(x:Data):Array

Parameters

x:Data - Data object variable name whose Accumulation-Distribution (AD) is to be calculated.

Returns

Array - Accumulation-Distribution of Data object x.

Accumulation-Distribution (AD) was created by Larry Williams to track buying pressure (accumulation) and selling pressure (distribution). AD compares the range between the open and clsoe relative to the range of the day. It is a concept very closely related to Japanese candlestick charts.

Returns the AD of Data object x.

Returns the AD of Data object x.

Example

data("x") // Use the data from the chart

myAD = adline(x) // Compute Accumulation-Distribution

period = 50 // Period to use with Bollinger Bands

width = 2.1 // Width to use with Bollinger Bands

middleBB = sma(myAD,period) // Compute middle Bollinger Band of myAD

upperBB = middleBB + (width*(stdev(myAD,period))) // Compute upper Bollinger Band of myAD

lowerBB = middleBB - (width*(stdev(myAD,period))) // Compute lower Bollinger Band of myAD

plotAD = plot(myAD,"AD","line","000000") // Plot object for myAD

plotUpperBB = plot(upperBB,"upperBB","line","CC0000") // Plot object for upper Bollinger Band of myAD

plotMiddleBB = plot(middleBB,"middleBB","line","0000FF") // Plot object for middle Bollinger Band of myAD

plotLowerBB = plot(lowerBB,"lowerBB","line","009900") // Plot object for lower Bollinger Band of myAD

chart(plotAD,plotUpperBB,plotMiddleBB,plotLowerBB) // Plot myAD with Bollinger Bands in a clip

myAD = adline(x) // Compute Accumulation-Distribution

period = 50 // Period to use with Bollinger Bands

width = 2.1 // Width to use with Bollinger Bands

middleBB = sma(myAD,period) // Compute middle Bollinger Band of myAD

upperBB = middleBB + (width*(stdev(myAD,period))) // Compute upper Bollinger Band of myAD

lowerBB = middleBB - (width*(stdev(myAD,period))) // Compute lower Bollinger Band of myAD

plotAD = plot(myAD,"AD","line","000000") // Plot object for myAD

plotUpperBB = plot(upperBB,"upperBB","line","CC0000") // Plot object for upper Bollinger Band of myAD

plotMiddleBB = plot(middleBB,"middleBB","line","0000FF") // Plot object for middle Bollinger Band of myAD

plotLowerBB = plot(lowerBB,"lowerBB","line","009900") // Plot object for lower Bollinger Band of myAD

chart(plotAD,plotUpperBB,plotMiddleBB,plotLowerBB) // Plot myAD with Bollinger Bands in a clip

adosc(x:Data, period:Number):Array

Parameters

x:Data - Data object variable name whose Accumulation-Distribution Oscillator (AD%) is to be calculated.

period:Number - Accumulation-Distribution Oscillator (AD%) period value.

period:Number - Accumulation-Distribution Oscillator (AD%) period value.

Returns

Array - Accumulation-Distribution Oscillator (AD%) of Data object x.

Accumulation-Distribution Oscillator (AD%) is the closed form of Accumulation-Distribution (AD). AD% is calculated by taking the *n*-day sum of AD and dividing by the *n*-day sum of volume; the result is a normalized AD that is now comparable from issue to issue. Specify the number of days used in the calculation using Number object period. If a decimal value is entered for period, the function will drop the decimal part and use the integer part as the period in the calculation without warning.

Returns the AD% of Data object x.

Returns the AD% of Data object x.

Example

data("x") // Use the data from the chart

myADOsc = adosc(x,20) // 20-day AD%

plotMyADOsc = plot(myADOsc,"AD%","histogram") // Plot object for myADOsc

ref1 = plot(25,"","line","000000") // Plot object for 25% reference level

ref2 = plot(-25,"","line","000000") // Plot object for -25% reference level

chart(plotMyADOsc,ref1,ref2) // Plot myADOsc in a clip with reference levels

myADOsc = adosc(x,20) // 20-day AD%

plotMyADOsc = plot(myADOsc,"AD%","histogram") // Plot object for myADOsc

ref1 = plot(25,"","line","000000") // Plot object for 25% reference level

ref2 = plot(-25,"","line","000000") // Plot object for -25% reference level

chart(plotMyADOsc,ref1,ref2) // Plot myADOsc in a clip with reference levels

aroon(x:Data, period:Number, series:String["up","down","oscillator"]):Array

Parameters

x:Data - Data object variable name whose Aroon Indicator (AR) is to be calculated.

period:Number - Aroon Indicator (AR) period value.

series:String["up","down","oscillator"] - String to specify what is returned. Must be one of "up", "down", or "oscillator" for Aroon Up, Aroon Down and Aroon Oscillator, respectively.

period:Number - Aroon Indicator (AR) period value.

series:String["up","down","oscillator"] - String to specify what is returned. Must be one of "up", "down", or "oscillator" for Aroon Up, Aroon Down and Aroon Oscillator, respectively.

Returns

Array - If "up" is specified for series, the Aroon Up line of Data object x.

If "down" is specified for series, the Aroon Down line of Data object x.

If "oscillator" is specified for series, the Aroon Oscillator of Data object x.

If "down" is specified for series, the Aroon Down line of Data object x.

If "oscillator" is specified for series, the Aroon Oscillator of Data object x.

Aroon Indicator (AR), developed by Tushar Chande, is designed to identify direction and magnitude of a trend. AR consists of three lines: Aroon Up, Aroon Down, and Aroon Oscillator. Specify the lookback period value using Number object period. If a decimal value is entered for period, the function will drop the decimal part and use the integer part as the period in the calculation without warning.

Aroon Up line above 70 indicates an up trend, Aroon Down line above 70 indicates a down trend and Arooon Oscillator line near zero indicates a consolidation phase (no trend). The idea is to count the number of days since the high of the range (this is the Aroon Up line) and the low of the range (this is the Aroon Down line). it is a simple concept that produces surprisingly deep market insight.

Returns the Aroon Up line of Data object x if String object series is "up", returns the Aroon Down line of Data object x if String object series is "down", and returns the Aroon Oscillator line of Data object x if String object series is set to "oscillator".

Aroon Up line above 70 indicates an up trend, Aroon Down line above 70 indicates a down trend and Arooon Oscillator line near zero indicates a consolidation phase (no trend). The idea is to count the number of days since the high of the range (this is the Aroon Up line) and the low of the range (this is the Aroon Down line). it is a simple concept that produces surprisingly deep market insight.

Returns the Aroon Up line of Data object x if String object series is "up", returns the Aroon Down line of Data object x if String object series is "down", and returns the Aroon Oscillator line of Data object x if String object series is set to "oscillator".

Example

data("x") // Use the data from the chart

myARup = aroon(x,20,"up") // 20-day Aroon Up

myARdown = aroon(x,20,"down") // 20-day Aroon Down

myARosc = aroon(x,20,"oscillator") // 20-day Aroon Oscillator

plotARup = plot(myARup,"20-Day AR Up","line","00CC00") // Plot object for myARup

plotARdown = plot(myARdown,"20-Day AR Down","line","CC0033") // Plot object for myARdown

plotARosc = plot(myARosc,"20-Day AR%","line","000000") // Plot object for myARosc

chart(plotARup,plotARdown,plotARosc) // Plot myARup, myARdown, and myARosc in a clip

myARup = aroon(x,20,"up") // 20-day Aroon Up

myARdown = aroon(x,20,"down") // 20-day Aroon Down

myARosc = aroon(x,20,"oscillator") // 20-day Aroon Oscillator

plotARup = plot(myARup,"20-Day AR Up","line","00CC00") // Plot object for myARup

plotARdown = plot(myARdown,"20-Day AR Down","line","CC0033") // Plot object for myARdown

plotARosc = plot(myARosc,"20-Day AR%","line","000000") // Plot object for myARosc

chart(plotARup,plotARdown,plotARosc) // Plot myARup, myARdown, and myARosc in a clip

atr(x:Data, n:Number(optional)):Array or Number

Parameters

x:Data - Data object variable name whose average true range is to be calculated.

n:Number(optional) - Average true range period value.

n:Number(optional) - Average true range period value.

Returns

Returns the simple moving average Array of the true range of Data object x. if n is not provided, the total average of true range is returned.

Example

data("x")

period = 20

atrArray = atr(x,period)

print(atrArray)

atrTotal = atr(x)

print(atrTotal)

period = 20

atrArray = atr(x,period)

print(atrArray)

atrTotal = atr(x)

print(atrTotal)

bbaccumulation(x:Data, period:Number, width:Number):Array

Parameters

x:Data - Data object variable name whose BBAccumulation is to be calculated.

period:Number - BBAccumulation length (period)

width:Number - BBAccumulation width

period:Number - BBAccumulation length (period)

width:Number - BBAccumulation width

Returns

Array - Bollinger Bands Accumulation of Data object x.

Bollinger Band Trend Accumulation...

Example

data("x") // Use the data from the chart

period = 20 // period

width = 2.0 // length

myBBAccum = bbaccumulation(x,period,width) // Compute BBAccumulation

myBBAccumplot = plot(myBBAccum,"BBAccum","histogram") // Plot object for myBBAccum

chart(myBBAccumplot) // Chart myBBAccum in a clip

period = 20 // period

width = 2.0 // length

myBBAccum = bbaccumulation(x,period,width) // Compute BBAccumulation

myBBAccumplot = plot(myBBAccum,"BBAccum","histogram") // Plot object for myBBAccum

chart(myBBAccumplot) // Chart myBBAccum in a clip

bbands(x:Data, period:Number, width:Number, series:String["upper","middle","lower"]):Array

Parameters

x:Data - Data object variable name whose Bollinger Bands^{®} are to be calculated.

period:Number - Period to compute the Bollinger Bands (default is 20).

width:Number - Width to compute the Bollinger Bands (default is 2.0).

series:String["upper","middle","lower"] - String to specify which Bollinger Band to be returned. Must be one of "upper", "middle", or "lower" for the upper band, middle band, or lower band, respectively.

period:Number - Period to compute the Bollinger Bands (default is 20).

width:Number - Width to compute the Bollinger Bands (default is 2.0).

series:String["upper","middle","lower"] - String to specify which Bollinger Band to be returned. Must be one of "upper", "middle", or "lower" for the upper band, middle band, or lower band, respectively.

Returns

Array - The specified band (upper, middle, or lower) of the Bollinger Bands for Data object x

Bollinger Bands are computed using parameters period and width. Period is the length of the simple moving average and width is the multiplier of standard deviation. An Array object of the specified band, taken as the series parameter, is returned.

If a decimal value is entered for period, the function will drop the decimal part and use the integer part as the period in the calculation without warning.

If a decimal value is entered for period, the function will drop the decimal part and use the integer part as the period in the calculation without warning.

Example

data("x") // Use the data from the chart

period = 20 // Set the length

width = 2.0 // Set the width

upperBB = bbands(x,period,width,"upper") // Get the upper band

middleBB = bbands(x,period,width,"middle") // Get the middle band

lowerBB = bbands(x,period,width,"lower") // Get the lower band

myUpperBBPlot = plot(upperBB,"upperBB","line","00CC33") // Assign a plot function for the upper band

myMiddleBBPlot = plot(middleBB,"middleBB","line","3300CC") // Assign a plot function for the midle band

myLowerBBPlot = plot(lowerBB,"lowerBB","line","CC0033") // Assign a plot function for the lower band

pchart(myUpperBBPlot,myMiddleBBPlot,myLowerBBPlot) // Plot the bands to the price chart

period = 20 // Set the length

width = 2.0 // Set the width

upperBB = bbands(x,period,width,"upper") // Get the upper band

middleBB = bbands(x,period,width,"middle") // Get the middle band

lowerBB = bbands(x,period,width,"lower") // Get the lower band

myUpperBBPlot = plot(upperBB,"upperBB","line","00CC33") // Assign a plot function for the upper band

myMiddleBBPlot = plot(middleBB,"middleBB","line","3300CC") // Assign a plot function for the midle band

myLowerBBPlot = plot(lowerBB,"lowerBB","line","CC0033") // Assign a plot function for the lower band

pchart(myUpperBBPlot,myMiddleBBPlot,myLowerBBPlot) // Plot the bands to the price chart

bbimpulse(x:Data, period:Number, width:Number, type:String["bbands","benvelope"]):Array

Parameters

x:Data - Data object variable name whose BBImpulse is to be calculated.

period:Number - Period to compute the Bollinger Bands or Bollinger Envelopes (default is 20).

width:Number - Width to compute the Bollinger Bands or Bollinger Envelopes (default is 2.0 for Bollinger Bands, 1.5 for Bollinger Envelopes).

type:String["bbands","benvelope"] - String to specify the use of Bollinger Bands or Bollinger Envelopes in the calculation of BBImpulse. Must be one of "bbands" or "benvelope" for Bollinger Bands or Bollinger Envelopes, respectively.

period:Number - Period to compute the Bollinger Bands or Bollinger Envelopes (default is 20).

width:Number - Width to compute the Bollinger Bands or Bollinger Envelopes (default is 2.0 for Bollinger Bands, 1.5 for Bollinger Envelopes).

type:String["bbands","benvelope"] - String to specify the use of Bollinger Bands or Bollinger Envelopes in the calculation of BBImpulse. Must be one of "bbands" or "benvelope" for Bollinger Bands or Bollinger Envelopes, respectively.

Returns

Array - Bollinger Bands Impulse (BBImpulse, BBI) in percent of Data object x.

BBImpulse (BBI) is one of the newest Bollinger Bands indicators; it has also been adapted to Bollinger Envelopes. It is derived from %b (Percent b). Its value is the period change of %b (i.e., momentum of %b).

Returns the BBImpulse in percent of Data object x using period as the simple moving average and width as the standard deviation multiplier to compute Bollinger Bands or Bollinger Envelopes, whichever is specified by String object type. If a decimal value is entered for period, the function will drop the decimal part and use the integer part as the period in the calculation without warning.

Returns the BBImpulse in percent of Data object x using period as the simple moving average and width as the standard deviation multiplier to compute Bollinger Bands or Bollinger Envelopes, whichever is specified by String object type. If a decimal value is entered for period, the function will drop the decimal part and use the integer part as the period in the calculation without warning.

Example

data("x") // Use the data from the chart

period = 10 // Set the length

width = 1.9 // Set the width

type = "benvelope" // Use Bollinger Envelopes

myBBI = bbimpulse(x,period,width,type) // Get the BBImpulse data and assign it to Array object myBBI

plotBBI = plot(myBBI,"BBI","histogram") // Assign a plot object for myBBI

plotRefUU = plot(40,"","line","000000") // Plot object for extreme upper reference level

plotRefU = plot(24,"","line","999999") // Plot object for upper reference level

plotRefL = plot(-24,"","line","999999") // Plot object for lower reference level

plotRefLL = plot(-40,"","line","000000") // Plot object for extreme lower reference level

chart(plotBBI,plotRefUU,plotRefU,plotRefL,plotRefLL) // Plot BBI with reference lines on a clip

period = 10 // Set the length

width = 1.9 // Set the width

type = "benvelope" // Use Bollinger Envelopes

myBBI = bbimpulse(x,period,width,type) // Get the BBImpulse data and assign it to Array object myBBI

plotBBI = plot(myBBI,"BBI","histogram") // Assign a plot object for myBBI

plotRefUU = plot(40,"","line","000000") // Plot object for extreme upper reference level

plotRefU = plot(24,"","line","999999") // Plot object for upper reference level

plotRefL = plot(-24,"","line","999999") // Plot object for lower reference level

plotRefLL = plot(-40,"","line","000000") // Plot object for extreme lower reference level

chart(plotBBI,plotRefUU,plotRefU,plotRefL,plotRefLL) // Plot BBI with reference lines on a clip

bbindex(x:Data, period:Number):Array

Parameters

x:Data - Data object variable name whose BBIndex is to be calculated.

period:Number - BBIndex period value.

period:Number - BBIndex period value.

Returns

Array - Bollinger Bands Index (BBIndex, BBX) of Data object x.

BBIndex (BBX) is the latest in a series of technical indicators derived from Bollinger Bands. BBX is a classic overbought/oversold indicator similar in application to the Commodity Channel Index (CCI). Match the period to the trend you are trading, 20 is the default, and we use plus/minus 2.0 as the basic overbought/oversold reference levesl with plus/minus 3.0 as extreme levels.

Returns the BBIndex of Data object x using the specified period. If a decimal value is entered for the period, the function will drop the decimal part and use the integer part as the period in the calculation without warning.

Returns the BBIndex of Data object x using the specified period. If a decimal value is entered for the period, the function will drop the decimal part and use the integer part as the period in the calculation without warning.

Example

data("x") // Use the data from the chart

period = 20 // Set the length

myBBX = bbindex(x,period) // Get the BBIndex and assign it Array object myBBX

plotBBX = plot(myBBX,"BBX","histogram") // Assign a plot object for myBBX

plotRef3p = plot(3,"","line","000000") // Plot object for extreme overbought reference line

plotRef2p = plot(2,"","line","999999") // Plot object for overbought reference line

plotRef2m = plot(-2,"","line","999999") // Plot object for oversold reference line

plotRef3m = plot(-3,"","line","000000") // Plot object for extremem oversold reference line

chart(plotBBX,plotRef3p,plotRef2p,plotRef2m,plotRef3m) // Plot BBX with reference lines on a clip

period = 20 // Set the length

myBBX = bbindex(x,period) // Get the BBIndex and assign it Array object myBBX

plotBBX = plot(myBBX,"BBX","histogram") // Assign a plot object for myBBX

plotRef3p = plot(3,"","line","000000") // Plot object for extreme overbought reference line

plotRef2p = plot(2,"","line","999999") // Plot object for overbought reference line

plotRef2m = plot(-2,"","line","999999") // Plot object for oversold reference line

plotRef3m = plot(-3,"","line","000000") // Plot object for extremem oversold reference line

chart(plotBBX,plotRef3p,plotRef2p,plotRef2m,plotRef3m) // Plot BBX with reference lines on a clip

bbmtm(x:Data, period:Number, width:Number, period2:Number, type:String["bbands","benvelope"]):Array

Parameters

x:Data - Data object variable name whose BBMomentum is to be calculated.

period:Number - Period to compute the Bollinger Bands or Bollinger Envelopes (default is 20).

width:Number - Width to compute the Bollinger Bands or Bollinger Envelopes (default is 2.0 for Bollinger Bands, 1.5 for Bollinger Envelopes).

period2:Number - BBMomentum period value.

type:String["bbands","benvelope"] - String to specify the use of Bollinger Bands or Bollinger Envelopes in the calculation of BBMomentum. Must be one of "bbands" or "benvelope" for Bollinger Bands or Bollinger Envelopes, respectively.

period:Number - Period to compute the Bollinger Bands or Bollinger Envelopes (default is 20).

width:Number - Width to compute the Bollinger Bands or Bollinger Envelopes (default is 2.0 for Bollinger Bands, 1.5 for Bollinger Envelopes).

period2:Number - BBMomentum period value.

type:String["bbands","benvelope"] - String to specify the use of Bollinger Bands or Bollinger Envelopes in the calculation of BBMomentum. Must be one of "bbands" or "benvelope" for Bollinger Bands or Bollinger Envelopes, respectively.

Returns

Array - Bollinger Bands Momentum (BBMomentum, BBM) of Data object x.

BBMomentum (BBM) is one of the newest Bollinger Bands indicators; it has also been adapted to Bollinger Envelopes. It measures price moves os a function of the width of Bollinger Bands or Bollinger Envelopes. BBM's value is the periodic change divided by the upper band or envelope minus the lower band or envelope. A good starting place is half the length of the Bollinger Bands or Bollinger Envelopes calculation.

BBM normalizes momentum using the width of the Bollinger Bands or Bollinger Envelopes. In volatile times it takes a large change in price to create the same BBM reading that a much smaller change would create in calm times. BBM can be thought of as a form of volatility-normalized momentum and can be used the way any other momentum indicator is used.

Returns the BBM of Data object x using period as the simple moving average and width as the standard deviation multiplier to compute Bollinger Bands or Bollinger Envelopes, whichever is specified by String object type , with period2 as the BBM period value. If a decimal is used for period or period2, the function will drop the decimal part and use the integer part as period or period2 in the calculation without warning.

BBM normalizes momentum using the width of the Bollinger Bands or Bollinger Envelopes. In volatile times it takes a large change in price to create the same BBM reading that a much smaller change would create in calm times. BBM can be thought of as a form of volatility-normalized momentum and can be used the way any other momentum indicator is used.

Returns the BBM of Data object x using period as the simple moving average and width as the standard deviation multiplier to compute Bollinger Bands or Bollinger Envelopes, whichever is specified by String object type , with period2 as the BBM period value. If a decimal is used for period or period2, the function will drop the decimal part and use the integer part as period or period2 in the calculation without warning.

Example

data("x") // Use the data from the chart

period = 20 // Set the length

width = 1.5 // Set the width

period2 = 10 // Set the BBM period

type = "benvelope" // Use Bollinger Envelopes

myBBM = bbmtm(x,period,width,period2,type) // Compute BBM

myBBMplot = plot(myBBM,"BBM","line","000000") // Plot object for myBBM

chart(myBBMplot) // Plot myBBM in a clip

period = 20 // Set the length

width = 1.5 // Set the width

period2 = 10 // Set the BBM period

type = "benvelope" // Use Bollinger Envelopes

myBBM = bbmtm(x,period,width,period2,type) // Compute BBM

myBBMplot = plot(myBBM,"BBM","line","000000") // Plot object for myBBM

chart(myBBMplot) // Plot myBBM in a clip

bbpersist(x:Data, period:Number, width:Number, lookback:Number, type:String["bbands","benvelope"]):Array

Parameters

x:Data - Data object variable name whose BBPersist is to be calculated.

period:Number - Period to compute the Bollinger Bands or Bollinger Envelopes (default is 20).

width:Number - Width to compute the Bollinger Bands or Bollinger Envelopes (default is 2.0 for Bollinger Bands, 1.5 for Bollinger Envelopes).

lookback:Number - BBPersist lookback period.

type:String["bbands","benvelope"] - String to specify the use of Bollinger Bands or Bollinger Envelopes in the calculation of BBPersist. Must be one of "bbands" or "benevelope" for Bollinger Bands or Bollinger Envelopes, respectively.

period:Number - Period to compute the Bollinger Bands or Bollinger Envelopes (default is 20).

width:Number - Width to compute the Bollinger Bands or Bollinger Envelopes (default is 2.0 for Bollinger Bands, 1.5 for Bollinger Envelopes).

lookback:Number - BBPersist lookback period.

type:String["bbands","benvelope"] - String to specify the use of Bollinger Bands or Bollinger Envelopes in the calculation of BBPersist. Must be one of "bbands" or "benevelope" for Bollinger Bands or Bollinger Envelopes, respectively.

Returns

Array - BBPersist of Data object x.

BBPersist...

Example

data("x") // Use the data from the chart

period = 20 // Set the length

width = 2.0 // Set the width

lookback = 125 // Set the lookback period

type = "benvelope" // Use Bollinger Envelopes

myBBPersist = bbpersist(x,period,width,lookback,type) // Get the BBPersist data and assign it to Array object myBBPersist

plotBBPersist = plot(myBBPersist,"BBPersist","histogram") // Assign a plot object for myBBPersist

chart(plotBBPersist) // Plot BBPersist in a clip

period = 20 // Set the length

width = 2.0 // Set the width

lookback = 125 // Set the lookback period

type = "benvelope" // Use Bollinger Envelopes

myBBPersist = bbpersist(x,period,width,lookback,type) // Get the BBPersist data and assign it to Array object myBBPersist

plotBBPersist = plot(myBBPersist,"BBPersist","histogram") // Assign a plot object for myBBPersist

chart(plotBBPersist) // Plot BBPersist in a clip

bbstops(x:Data, entry_date:String["YYYY-MM-DD"], trade_type:Number[1,-1], af_step:Number, af_max:Number, beOffset:Number):Array

Parameters

x:Data - Data object variable name whose BBStop is to be calculated

entry_date:String["YYYY-MM-DD"] - String object variable of the date of trade entry in "YYYY-MM-DD" format

trade_type:Number[1,-1] - Number object variable to specify the type of trade: 1 for long, -1 for short.

af_step:Number - Number object variable name specifying the AF step value (default is 0.02)

af_max:Number - Number object variable name specifying the maximum AF value (default is 0.20)

beOffset:Number - Nnumber that specifies the BE offset( multiplier for the upper or lower Bollinger Envelope).

entry_date:String["YYYY-MM-DD"] - String object variable of the date of trade entry in "YYYY-MM-DD" format

trade_type:Number[1,-1] - Number object variable to specify the type of trade: 1 for long, -1 for short.

af_step:Number - Number object variable name specifying the AF step value (default is 0.02)

af_max:Number - Number object variable name specifying the maximum AF value (default is 0.20)

beOffset:Number - Nnumber that specifies the BE offset( multiplier for the upper or lower Bollinger Envelope).

Returns

Array - BBStops entry and exit signals for Data object x.

BBStops™ are an adaptation of the stops included in Welles Wilder's Parabolic Price Time System. These stops increment both with the passage of time and the progress of the trade. They start at an interval above/below the entry day as a function of Bollinger Envelopes and then progress automatically as time passes and as price changes. If the entry is a buy, BBStops start beneath entry at an interval determined by the lower Bollinger Envelope calculation. For a sell the interval is a value above the entry determined by the upper Bollinger Envelope calculation. You chose the Bollinger Envelope multiplier. The default is 1.5.

Example

data("x") // Use the data from the chart

myCloses = close(x)

BBS = bbstops(x,"2012-01-02",1,0.04,0.44,1.5) // Generate bbstop signals for the data. The trade is long starting on January 2, 2012, using an AF step of 0.04 and a maximum AF of 0.44. The multiplier is 1.5.

plotBBS = plot(myCloses,"BBStop","line","00000000",BBS) // Anchor the bbstop signals to the closes (the line will not be shown but the signals will)

pchart(plotBBS) // Plot the bbstops signals on the price chart

myCloses = close(x)

BBS = bbstops(x,"2012-01-02",1,0.04,0.44,1.5) // Generate bbstop signals for the data. The trade is long starting on January 2, 2012, using an AF step of 0.04 and a maximum AF of 0.44. The multiplier is 1.5.

plotBBS = plot(myCloses,"BBStop","line","00000000",BBS) // Anchor the bbstop signals to the closes (the line will not be shown but the signals will)

pchart(plotBBS) // Plot the bbstops signals on the price chart

bbtrend(x:Data, period1:Number, period2:Number):Array

Parameters

x:Data - Data object variable name whose BBTrend is to be calculated.

period1:Number - BBTrend short period value.

period2:Number - BBTrend long period value.

period1:Number - BBTrend short period value.

period2:Number - BBTrend long period value.

Returns

Array - Bollinger Bands Trend (BBTrend, BBT) of Data object x.

Bollinger Band Trend (BBTrend) takes advantage of the ways in which Bollinger Bands of various lengths interact to determine whether the market is trending or not. Amongst commonly used technical indicators, ADX and Choppiness serve similar purposes.

Two time periods must be specified. The Number object period1 is the "short" period and Number object period2 is the "long" period. 20 and 50 are the defaults, but 10 and 30 or 40 may be more attractive for shorter-term traders.

Unlike the traditional trend indicators, BBTrend combines directional information with the trend information. Readings below zero are indicative of negative trends and readings above sero are indicative of positive trends.

Returns BBT of Data object x using period1 as the short-term BBT period value and period2 as the long-term BBT period value. If a decimal value is entered for period1 or period2, the function will drop the decimal part and use the integer part as period1 or period2 in the calculation without warning.

Two time periods must be specified. The Number object period1 is the "short" period and Number object period2 is the "long" period. 20 and 50 are the defaults, but 10 and 30 or 40 may be more attractive for shorter-term traders.

Unlike the traditional trend indicators, BBTrend combines directional information with the trend information. Readings below zero are indicative of negative trends and readings above sero are indicative of positive trends.

Returns BBT of Data object x using period1 as the short-term BBT period value and period2 as the long-term BBT period value. If a decimal value is entered for period1 or period2, the function will drop the decimal part and use the integer part as period1 or period2 in the calculation without warning.

Example

data("x") // Use the data from the chart

shortPeriod = 10 // Short period

longPeriod = 30 // Long period

myBBT = bbtrend(x,shortPeriod,longPeriod) // Compute BBTrend

myBBTplot = plot(myBBT,"BBT","histogram") // Plot object for myBBT

chart(myBBTplot) // Chart myBBT in a clip

shortPeriod = 10 // Short period

longPeriod = 30 // Long period

myBBT = bbtrend(x,shortPeriod,longPeriod) // Compute BBTrend

myBBTplot = plot(myBBT,"BBT","histogram") // Plot object for myBBT

chart(myBBTplot) // Chart myBBT in a clip

benvelope(x:Data, period:Number, width:Number, series:String["upper","middle","lower"]):Array

Parameters

x:Data - Data object variable name whose Bollinger Envelope is to be calculated.

period:Number - Period to compute the Bollinger Envelope (default is 20)

width:Number - Width to compute the Bollinger Envelopes (default is 1.5).

series:String["upper","middle","lower"] - String to specify which Bollinger Envelope to be returned. Must be one of "upper", "middle", or "lower" for the upper envelope, middle envelope, or lower envelope, respectively.

period:Number - Period to compute the Bollinger Envelope (default is 20)

width:Number - Width to compute the Bollinger Envelopes (default is 1.5).

series:String["upper","middle","lower"] - String to specify which Bollinger Envelope to be returned. Must be one of "upper", "middle", or "lower" for the upper envelope, middle envelope, or lower envelope, respectively.

Returns

Array - The specified envelope (upper, middle, or lower) of the Bollinger Envelopes for Data object x

Bollinger Envelopes are a variation on Bollinger Bands that focus on the extremes of price action. While Bollinger Bands are centered on a moving average, usually of closing prices, Bollinger Envelopes are anchored by the extremes: the highs and the lows.

The upper Bollinger Envelope is constructed from a moving average of the highs and the standard deviation of the highs; the lower Bollinger Envelope is constructed from a moving average of the lows and the standard deviation of the lows. The middle Bollinger Envelope is implied by taking a mean of the upper and lower Bollinger Envelopes.

Returns the specified Bollinger Envelope of Data object x using period as the simple moving average period and width as the multiplier of standard deviation. If a decimal value is entered for period, the function will drop the decimal part and use the integer part as the period in the calculation without warning.

The upper Bollinger Envelope is constructed from a moving average of the highs and the standard deviation of the highs; the lower Bollinger Envelope is constructed from a moving average of the lows and the standard deviation of the lows. The middle Bollinger Envelope is implied by taking a mean of the upper and lower Bollinger Envelopes.

Returns the specified Bollinger Envelope of Data object x using period as the simple moving average period and width as the multiplier of standard deviation. If a decimal value is entered for period, the function will drop the decimal part and use the integer part as the period in the calculation without warning.

Example

data("x") // Use the data from the chart

period = 20 // Set the length

width = 1.5 // Set the width

upperBE = benvelope(x,period,width,"upper") // Get the upper envelope

middleBE = benvelope(x,period,width,"middle") // Get the middle envelope

lowerBE = benvelope(x,period,width,"lower") // Get the lower envelope

myUpperBEPlot = plot(upperBE,"upperBE","line","00CC33") // Assign a plot object for the upper band

myMiddleBEPlot = plot(middleBE,"middleBE","line","3300CC") // Assign a plot object for the middle band

myLowerBEPlot = plot(lowerBE,"lowerBE","line","CC0033") // Assign a plot object for the lower band

pchart(myUpperBEPlot,myMiddleBEPlot,myLowerBEPlot) // Plot the envelopes on the price chart.

period = 20 // Set the length

width = 1.5 // Set the width

upperBE = benvelope(x,period,width,"upper") // Get the upper envelope

middleBE = benvelope(x,period,width,"middle") // Get the middle envelope

lowerBE = benvelope(x,period,width,"lower") // Get the lower envelope

myUpperBEPlot = plot(upperBE,"upperBE","line","00CC33") // Assign a plot object for the upper band

myMiddleBEPlot = plot(middleBE,"middleBE","line","3300CC") // Assign a plot object for the middle band

myLowerBEPlot = plot(lowerBE,"lowerBE","line","CC0033") // Assign a plot object for the lower band

pchart(myUpperBEPlot,myMiddleBEPlot,myLowerBEPlot) // Plot the envelopes on the price chart.

bwdelta(x:Data, period:Number, width:Number, period2:Number, type:String["bbands","benvelope"]):Array

Parameters

x:Data - Data object variable name whose BandWidth Delta is to be calculated.

period:Number - Period to compute the Bollinger Bands or Bollinger Envelopes (default is 20).

width:Number - Width to compute the Bollinger Bands or Bollinger Envelopes (default is 2.0 for Bollinger Bands, 1.5 for Bollinger Envelopes).

period2:Number - BandWidth Delta period value.

type:String["bbands","benvelope"] - String to specify the use of Bollinger Bands or Bollinger Envelopes in the calculation of BandWidth Delta. Must be one of "bbands" or "benvelope" for Bollinger Bands or Bollinger Envelopes, respectively.

period:Number - Period to compute the Bollinger Bands or Bollinger Envelopes (default is 20).

width:Number - Width to compute the Bollinger Bands or Bollinger Envelopes (default is 2.0 for Bollinger Bands, 1.5 for Bollinger Envelopes).

period2:Number - BandWidth Delta period value.

type:String["bbands","benvelope"] - String to specify the use of Bollinger Bands or Bollinger Envelopes in the calculation of BandWidth Delta. Must be one of "bbands" or "benvelope" for Bollinger Bands or Bollinger Envelopes, respectively.

Returns

Array - BandWidth Delta of Data object x.

BandWidth Delta (BWD) depicts the *n*-period momentum in BandWidth (BW) and is useful in diagnosing the peaks and troughs in BW as markers of potnetial trend changes. This indicator is especially useful when trying to analyze the potential for consolidations or reversals after large moves. You can think of BWD as a magnifying glass for BW.

Returns the BWD of Data object x using period as the simple moving average and width as the standard deviation multiplier to compute Bollinger Bands or Bollinger Envelopes, whichever is specified by String object type, with period2 as the BWD period value. If a decimal is entered for period or period2, the function will drop the decimal part and use the integer part as period and period2 in the calculation without warning.

Returns the BWD of Data object x using period as the simple moving average and width as the standard deviation multiplier to compute Bollinger Bands or Bollinger Envelopes, whichever is specified by String object type, with period2 as the BWD period value. If a decimal is entered for period or period2, the function will drop the decimal part and use the integer part as period and period2 in the calculation without warning.

Example

data("x") // Use the data from the chart

periodA1 = 20 // Set the length

widthA = 2.0 // Set the width

periodA2 = 1 // Set the bwdA period

periodB1 = 50 // Set the length

widthB = 2.1 // Set the width

periodB2 = 5 // Set the bwdB period

type = "bbands" // Use Bollinger Bands to compute bwdA and bwdB

bwdA = bwdelta(x,periodA1,widthA,periodA2,type) // Get first BWD

bwdB = bwdelta(x,periodB1,widthB,periodB2,type) // Get second BWD

plotbwdA = plot(bwdA,"bwdA","line","00FF00") // plot object for bwdA

plotbwdB = plot(bwdB,"bwdB","line","FF00FF") // plot object for bwdB

chart(plotbwdA,plotbwdB) // Chart both bwdA and bwdB in the same clip

periodA1 = 20 // Set the length

widthA = 2.0 // Set the width

periodA2 = 1 // Set the bwdA period

periodB1 = 50 // Set the length

widthB = 2.1 // Set the width

periodB2 = 5 // Set the bwdB period

type = "bbands" // Use Bollinger Bands to compute bwdA and bwdB

bwdA = bwdelta(x,periodA1,widthA,periodA2,type) // Get first BWD

bwdB = bwdelta(x,periodB1,widthB,periodB2,type) // Get second BWD

plotbwdA = plot(bwdA,"bwdA","line","00FF00") // plot object for bwdA

plotbwdB = plot(bwdB,"bwdB","line","FF00FF") // plot object for bwdB

chart(plotbwdA,plotbwdB) // Chart both bwdA and bwdB in the same clip

bwdth(x:Data, period:Number, width:Number, type:String["bbands","benvelope"]):Array

Parameters

x:Data - Data object variable name whose BandWidth is to be calculated.

period:Number - Period used to compute Bollinger Bands or Bollinger Envelopes (default is 20).

width:Number - Width to compute Bollinger Bands or Bollinger Envelopes (default is 2.0 for Bollinger Bands, 1.5 for Bollinger Envelopes)

type:String["bbands","benvelope"] - String to specify the use of Bollinger Bands or Bollinger Envelopes in the calculation of BandWidth. Must be one of "bbands" or "benvelope" for Bollinger Bands or Bollinger Envelopes, respectively.

period:Number - Period used to compute Bollinger Bands or Bollinger Envelopes (default is 20).

width:Number - Width to compute Bollinger Bands or Bollinger Envelopes (default is 2.0 for Bollinger Bands, 1.5 for Bollinger Envelopes)

type:String["bbands","benvelope"] - String to specify the use of Bollinger Bands or Bollinger Envelopes in the calculation of BandWidth. Must be one of "bbands" or "benvelope" for Bollinger Bands or Bollinger Envelopes, respectively.

Returns

Array - The width of the Bollinger Bands or Bollinger Envelopes as a function of the middle band or envelope.

This was the first indicator derived from Bollinger Bands; it has also been adapted to Bollinger Envelopes. BandWidth depicts how wide the Bollinger Bands or Bollinger Envelopes are as a function of the middle band or envelope. The most popular use of BandWidth is to identify a Squeeze or a Bulge.

Returns the BandWidth of Data object x using period as the simple moving average period and width as the standard deviation multiplier to compute Bollinger Bands or Bollinger Envelopes, whichever is specified by String object type. If a decimal value is entered for period, the function will drop the decimal part and use the integer part as the period in the calculation without warning.

Returns the BandWidth of Data object x using period as the simple moving average period and width as the standard deviation multiplier to compute Bollinger Bands or Bollinger Envelopes, whichever is specified by String object type. If a decimal value is entered for period, the function will drop the decimal part and use the integer part as the period in the calculation without warning.

Example

data("x") // Use the data from the chart

period = 20 // Set the length

width = 2.0 // Set the width

type = "bbands" // Use Bollinger Bands in the calculation of BandWidth

myBW = bwdth(x,period,width,type) // Get BandWidth and store it in Array object myBW

mySmoothBW = ema(myBW,21) // Get a 21-day exponential moving average of myBW and store it in Array object mySmoothBW

plotBW = plot(myBW,"BandWidth","line","000000") // Assign a plot object for myBW

plotSmoothBW = plot(mySmoothBW,"EMA","line","00FF00") // Assign a plot object for mySmoothBW

chart(plotBW,plotSmoothBW) // Plot myBW and mySmoothBW in the same clip

period = 20 // Set the length

width = 2.0 // Set the width

type = "bbands" // Use Bollinger Bands in the calculation of BandWidth

myBW = bwdth(x,period,width,type) // Get BandWidth and store it in Array object myBW

mySmoothBW = ema(myBW,21) // Get a 21-day exponential moving average of myBW and store it in Array object mySmoothBW

plotBW = plot(myBW,"BandWidth","line","000000") // Assign a plot object for myBW

plotSmoothBW = plot(mySmoothBW,"EMA","line","00FF00") // Assign a plot object for mySmoothBW

chart(plotBW,plotSmoothBW) // Plot myBW and mySmoothBW in the same clip

cci(x:Data, period:Number):Array

Parameters

x:Data - Data object variable name whose Commodity Channel Index (CCI) is to be calculated.

period:Number - Commodity Channel Index (CCI) period value.

period:Number - Commodity Channel Index (CCI) period value.

Returns

Array - Commodity Channel Index (CCI) of Data object x.

Commodity Channel Index (CCI) is a sophisticated overbought/oversold tool that uses volatility as its gauge. It uses an old scaling convention derived from its commodity futures market heritage. Specify the CCI period value using Number object period. If a decimal value is entered for period, the function will drop the decimal part and use the integer part as the period in the calculation without warning.

Returns the CCI of Data object x.

Returns the CCI of Data object x.

Example

data("x") // Use the data from the chart

myCCI = cci(x,14) // 14-period CCI

plotCCI = plot(myCCI,"CCI","line","000000") // Plot object for myCCI

refOB = plot(100,"","line","FF0000") // Overbought reference line (+100)

refOS = plot(-100,"","line","00FF00") // Oversold reference line (-100)

chart(plotCCI,refOB,refOS) // Chart myCCI and reference lines in a clip

myCCI = cci(x,14) // 14-period CCI

plotCCI = plot(myCCI,"CCI","line","000000") // Plot object for myCCI

refOB = plot(100,"","line","FF0000") // Overbought reference line (+100)

refOS = plot(-100,"","line","00FF00") // Oversold reference line (-100)

chart(plotCCI,refOB,refOS) // Chart myCCI and reference lines in a clip

chandelierstops(x:Data, entry_date:String["YYYY-MM-DD" or "YYYY-MM-DD HH:MM"], trade_type:Number[1,-1], m:Number, n:Number, always_in:Number[1,0]):Array

Parameters

x:Data - Data object variable name whose Chandelier stop is to be calculated

entry_date:String["YYYY-MM-DD" or "YYYY-MM-DD HH:MM"] - String object variable of the date of trade entry in "YYYY-MM-DD" or "YYYY-MM-DD HH:MM." The latter is helpful for ForEx data.

trade_type:Number[1,-1] - Number object variable to specify the type of trade: 1 for long, -1 for short.

m:Number - Number object variable specifying the period to compute Average True Range (ATR) (default is 10).

n:Number - Number object variable specifying the multiplication factor of Average True Range (ATR) in the stop calculation (default is 3).

always_in:Number[1,0] - Number object variable name specifying whether the trade is always in the market (1] or not (0).

entry_date:String["YYYY-MM-DD" or "YYYY-MM-DD HH:MM"] - String object variable of the date of trade entry in "YYYY-MM-DD" or "YYYY-MM-DD HH:MM." The latter is helpful for ForEx data.

trade_type:Number[1,-1] - Number object variable to specify the type of trade: 1 for long, -1 for short.

m:Number - Number object variable specifying the period to compute Average True Range (ATR) (default is 10).

n:Number - Number object variable specifying the multiplication factor of Average True Range (ATR) in the stop calculation (default is 3).

always_in:Number[1,0] - Number object variable name specifying whether the trade is always in the market (1] or not (0).

Returns

Array - Chandelier stops entry and exit signals for Data object x.

Chandelier stops were popularized by Chuck LeBeau. They are dynamic, progressive stops that cna be calculated starting with the period after you enter a trade. The formulas are simple and robust. For sell stops when you are long the stop is the highest high since you netered the trade less *n* times the *m*-day Average True Range (ATR). For buy stops when you are short the stop is the lowest low since you entered the trade plus *n* times the *m*-day ATR. The usual defaults are *n* = 3 and *m* = 10, so that means a "normal" Chandelier sell stop is the highest high since entry less three times the 10-period ATR.

Chandelier stops can be computed each period an open position is hed as ATR will change even if a new high (when long) or low (when short) since entry isn't recorded. One question that often comes up is whether to allow the stop to back off? For example, if this period's stop for a short position is 33.35 and next period's is 33.5 due to an expansion in ATR, should we stick with the more conservative stop of 33.35 or allow it to back off a bit to 33.5? Chuck LeBeau's answer is that backing off is a feature of Chandelier stops that should be allowed and that is good enough for us.

This function returns the buy and sell signals. The signals can be computed for a single trade ("always_in=0") or as a trading system always in the market ("always_in=1") from the entry date specified.

Chandelier stops can be computed each period an open position is hed as ATR will change even if a new high (when long) or low (when short) since entry isn't recorded. One question that often comes up is whether to allow the stop to back off? For example, if this period's stop for a short position is 33.35 and next period's is 33.5 due to an expansion in ATR, should we stick with the more conservative stop of 33.35 or allow it to back off a bit to 33.5? Chuck LeBeau's answer is that backing off is a feature of Chandelier stops that should be allowed and that is good enough for us.

This function returns the buy and sell signals. The signals can be computed for a single trade ("always_in=0") or as a trading system always in the market ("always_in=1") from the entry date specified.

Example

data("x") // Use the data from the chart

myCloses = close(x) // An array of closes

myStop = chandelierstops(x,"2012-01-02",-1,15,3.5,0) // Entered a short trade on January 2, 2012; compute the Chandelier stop for this trade only using a 15-day ATR and 3.5 multiplication factor

plotStop = plot(myCloses,"Chandelier stop","line","00000000",myStop) // Anchor the Chandelier stop to the closes (line will not display but signal will)

pchart(plotStop) // Plot the Chandelier stop on the price chart

myCloses = close(x) // An array of closes

myStop = chandelierstops(x,"2012-01-02",-1,15,3.5,0) // Entered a short trade on January 2, 2012; compute the Chandelier stop for this trade only using a 15-day ATR and 3.5 multiplication factor

plotStop = plot(myCloses,"Chandelier stop","line","00000000",myStop) // Anchor the Chandelier stop to the closes (line will not display but signal will)

pchart(plotStop) // Plot the Chandelier stop on the price chart

chop(x:Data, period:Number):Array

Parameters

x:Data - Data object variable name whose Choppiness Index (CI) is to be calculated.

period:Number - Choppiness Index (CI) period value.

period:Number - Choppiness Index (CI) period value.

Returns

Array - Choppiness Index (CI) of Data object x.

Choppiness Index (CI), developed by E.W. Dreiss, uses chaos principles to measure "choppiness" or directionality of the market, whether prices are trending or we are in a period of trendless consolidation. The core idea is to compare the combined length of all the bars in a range (the ink) with the range itself. Low values (below 38) indicate trending markets (up or down) and high values (above 62) indicate significant consolidations. Specify the CI period value using Number object period. If a decimal value is entered for period, the function will drop the decimal part and use the integer part as the period in the calculation without warning.

Returns the CI of Data object x.

Returns the CI of Data object x.

Example

data("x") // Use the data from the chart

period = 14 // Use 14 as the calculation period

myCI = chop(x,period) // 14-period CI

plotCI = plot(myCI,"CI","line","000000") // Plot object for myCI

chart(plotCI) // Chart myCI in a clip

period = 14 // Use 14 as the calculation period

myCI = chop(x,period) // 14-period CI

plotCI = plot(myCI,"CI","line","000000") // Plot object for myCI

chart(plotCI) // Chart myCI in a clip

cmo(x:Data, period:Number):Array

Parameters

x:Data - Data object variable name whose Chande Momentum Oscillator (CMO) is to be calculated.

period:Number - Chande Momentum Oscillator (CMO) period value.

period:Number - Chande Momentum Oscillator (CMO) period value.

Returns

Array - Chande Momentum Oscillator (CMO) of Data object x.

Chande Momentum Oscillator (CMO) is Tushar Chande's attempt to capture Pure Momentum. The idea is to separately sum up and down momentum over a given period and compare them with a normalized ratio. Specify the lookback period using Number object period. If a decimal value is entered for period, the function will drop the decimal part and use the integer part as the period in the calculation without warning.

Returns the CMO of Data object x.

Returns the CMO of Data object x.

Example

data("x") // Use the data from the chart

myCMO = cmo(x,14) // 14-period CMO

plotCMO = plot(myCMO,"CMO","histogram") // Plot object for CMO

chart(plotCMO) // Chart myCMO in a clip

myCMO = cmo(x,14) // 14-period CMO

plotCMO = plot(myCMO,"CMO","histogram") // Plot object for CMO

chart(plotCMO) // Chart myCMO in a clip

conviction(x:Data, period:Number):Array

Parameters

x:Data - Data object variable name whose Alphier Conviction curve is to be calculated.

period:Number - Alphier Conviction period value.

period:Number - Alphier Conviction period value.

Returns

Array - Alphier Conviction curve of Data object x.

Alphier Conviction is a classic divergence indicator, implemented only as Jim Alphier might have, that works by providing a comparison of the counts of plus and minus days versus the actual gains recorded. Classic divergence analysis is at is best here. Specify the period used in the calculation using Number object period. If a decimal value is entered for period, the function will drop the decimal part and use the integer part as the period in the calculation without warning.

Returns the Alphier Conviction curve of Data object x.

Returns the Alphier Conviction curve of Data object x.

Example

data("x") // Use the data from the chart

myConviction = conviction(x,50) // 50-period Alphier Conviction

plotConviction = plot(myConviction,"Alphier Conviction","line","000000") // Plot object for myConviction

chart(plotConviction) // Chart myConviction in a clip

myConviction = conviction(x,50) // 50-period Alphier Conviction

plotConviction = plot(myConviction,"Alphier Conviction","line","000000") // Plot object for myConviction

chart(plotConviction) // Chart myConviction in a clip

departure(x:Data, period1:Number, period2:Number):Array

Parameters

x:Data - Data object variable name whose Departure Chart (DC) is to be calculated.

period1:Number - Departure Chart (DC) short period value.

period2:Number - Departure Chart (DC) long period value.

period1:Number - Departure Chart (DC) short period value.

period2:Number - Departure Chart (DC) long period value.

Returns

Array - Departure Chart (DC) of Data object x.

The Departure Chart (DC) is one of the oldest technical studies. Its primary use is as a trend identification tool, but it is also often employed to identify overbought and oversold conditions. The DC measures the difference between two moving averages of a data series, one short and one long. Specify the DC short period value with Number object period1; specify the DC long period value with Number object period2. If a decimal value is entered for period1 or period2, the function will drop the decimal part and use the integer part as period1 or period2 in the calculation without warning.

Returns the DC of data object x.

Returns the DC of data object x.

Example

data("x") // Use the data from the chart

myDC = departure(x,10,20) // Short period = 10, long period = 20

plotDC = plot(myDC,"Departure Chart","histogram") // Plot object for myDC

chart(plotDC) // Plot myDC in a clip

myDC = departure(x,10,20) // Short period = 10, long period = 20

plotDC = plot(myDC,"Departure Chart","histogram") // Plot object for myDC

chart(plotDC) // Plot myDC in a clip

dfa(x:Data, period:Number):Array

Parameters

x:Data - Data object variable name whose Deviation from Average is to be calculated.

period:Number - Deviation from Average period value.

period:Number - Deviation from Average period value.

Returns

Array - Deviation from Average of Data object x.

The most basic overbought/oversold tool. Deviation from Average expresses how far a data series has deviated from the mean as measured by an *n*-day average. If a decimal value is entered for period, the function will drop the decimal part and use the integer part as the period in the calculation without warning.

Returns the Deviation from Average in percent of Data object x.

Returns the Deviation from Average in percent of Data object x.

Example

data("x") // Use the data from the chart

myDFA = dfa(x,50) // 50-period average

plotDFA = plot(myDFA,"DFA","histogram") // Plot object for myDFA

chart(plotDFA) // Plot myDFA in a clip

myDFA = dfa(x,50) // 50-period average

plotDFA = plot(myDFA,"DFA","histogram") // Plot object for myDFA

chart(plotDFA) // Plot myDFA in a clip

dmi(x:Data, period:Number, series:String["adx","dmiplus","dmiminus"]):Array

Parameters

x:Data - Data object variable name whose Directional Movement Index (DMI) is to be calculated.

period:Number - Directional Movement Index (DMI) period value.

series:String["adx","dmiplus","dmiminus"] - String to specify what is to be returned. Must be one of "adx", "dmiplus", or "dmiminus" for Average Directional Index (ADX), Plus Directional Movement Index (DMI+), or Minus Directional Movement Index (DMI-), respectively.

period:Number - Directional Movement Index (DMI) period value.

series:String["adx","dmiplus","dmiminus"] - String to specify what is to be returned. Must be one of "adx", "dmiplus", or "dmiminus" for Average Directional Index (ADX), Plus Directional Movement Index (DMI+), or Minus Directional Movement Index (DMI-), respectively.

Returns

Array - If "adx" is specified for series, the Average Directional Index (ADX) of Data object x.

If "dmiplus" is specified for series, the Plus Directional Movement Index (DMI+) of Data object x. If "dmiminus" is specified for series, the Minus Directional Movement Index (DMI-) of Data object x.

If "dmiplus" is specified for series, the Plus Directional Movement Index (DMI+) of Data object x. If "dmiminus" is specified for series, the Minus Directional Movement Index (DMI-) of Data object x.

Created by Welles Wilder, these indicators parse the price structure into plus and minus components, Plus Directional Movement Index (DMI+) and Minus Directional Movement Index (DMI-). However, the most interesting feature is a derivative of the DMI indeces called Average Directional Index (ADX). ADX indicates whether the data is trending or not. Values above 18 are considered to indicate trending markets while values below 18 are associated with trading-range markets. Specify the calculation lookback period using Number object period. If a decimal value is entered for period, the function will drop the decimal part and use the integer part as the period in the calculation without warning.

Returns the DMI+ of Data object x if String object series is "dmiplus", returns the DMI- of Data object x if String object series is "dmiminus", and returns the ADX of Data object x if String object series is set to "adx".

Returns the DMI+ of Data object x if String object series is "dmiplus", returns the DMI- of Data object x if String object series is "dmiminus", and returns the ADX of Data object x if String object series is set to "adx".

Example

data("x") // Use the data from the chart

plusDMI = dmi(x,14,"dmiplus") // 14-Day DMI+

minusDMI = dmi(x,14,"dmiminus") // 14-day DMI-

ADX = dmi(x,14,"adx") // 14-day ADX

plusDMIplot = plot(plusDMI,"DMI+","line","000000") // Plot object for plusDMI

minusDMIplot = plot(minusDMI,"DMI-","line","CC0033") // Plot object for minusDMI

ADXplot = plot(ADX,"ADX","histogram") // Plot object for ADX

chart(plusDMIplot,minusDMIplot,ADXplot) // Plot plusDMI, minusDMI, and ADX in a clip

plusDMI = dmi(x,14,"dmiplus") // 14-Day DMI+

minusDMI = dmi(x,14,"dmiminus") // 14-day DMI-

ADX = dmi(x,14,"adx") // 14-day ADX

plusDMIplot = plot(plusDMI,"DMI+","line","000000") // Plot object for plusDMI

minusDMIplot = plot(minusDMI,"DMI-","line","CC0033") // Plot object for minusDMI

ADXplot = plot(ADX,"ADX","histogram") // Plot object for ADX

chart(plusDMIplot,minusDMIplot,ADXplot) // Plot plusDMI, minusDMI, and ADX in a clip

expectation(x:Data, series:String["expect","signal"]):Array

Parameters

x:Data - Data object variable name whose Alphier Expectation is to be calculated.

series:String["expect","signal"] - String to specify what is returned. Must be one of "expect" or "signal" for Alphier Expectation curve or Alphier Expectation Alerts, respectively.

series:String["expect","signal"] - String to specify what is returned. Must be one of "expect" or "signal" for Alphier Expectation curve or Alphier Expectation Alerts, respectively.

Returns

Array - If "exepct" is specified for series, the Alphier Expectation curve of Data object x. If "signal" is specified, the Alphier Expectation Alerts for Data object x.

This function will return the Alphier Expectation curve or signal data. The Alphier Expectation curve is a supply-demand calculation along the lines of Accumulation-Distribution or Intraday Intensity. Use it as you would any other supply-demand tool - volume is not a factor. If "expect" is specified, an Array for Data object x will be returned. The Array will contain the values of the Alphier Expectation line.

If "signal" is specified, an Array for Data object x will be returned. The Array will contain the following:

0: no signal

-5: 200 Sell Rule

-4: Major Shift Sell

-3: Sell from 200

-2: Sell Signal

-1: Sell Alert

5: 0 Buy Rule

4: Major Shift Buy

3: Buy from 0

2: Buy Signal

1: Buy Alert

The above signals are generated based on rules we have implemented.

If "signal" is specified, an Array for Data object x will be returned. The Array will contain the following:

0: no signal

-5: 200 Sell Rule

-4: Major Shift Sell

-3: Sell from 200

-2: Sell Signal

-1: Sell Alert

5: 0 Buy Rule

4: Major Shift Buy

3: Buy from 0

2: Buy Signal

1: Buy Alert

The above signals are generated based on rules we have implemented.

Example

data("x") // Use the data from the chart

myClose = close(x) // An array of closes

myExpectationCurve = expectation(x,"expect") // Get the Expectation curve

myExpectationAlerts = expectation(x,"signal") // Get the Expectation signals

PlotCurve = plot(myExpectationCurve,"myExpectCurve","line","000000") // Plot object to plot the Expectation Curve

PlotAlerts = plot(myClose,"","line","00000000",myExpectationAlerts) // Plot object to anchor the Expectation Alerts to the closes (line will not be shown, but alerts will)

chart(PlotCurve) // Plot the Expectation Curve in a clip

pchart(PlotAlerts) // Plot the Expectation Alerts on the price chart

myClose = close(x) // An array of closes

myExpectationCurve = expectation(x,"expect") // Get the Expectation curve

myExpectationAlerts = expectation(x,"signal") // Get the Expectation signals

PlotCurve = plot(myExpectationCurve,"myExpectCurve","line","000000") // Plot object to plot the Expectation Curve

PlotAlerts = plot(myClose,"","line","00000000",myExpectationAlerts) // Plot object to anchor the Expectation Alerts to the closes (line will not be shown, but alerts will)

chart(PlotCurve) // Plot the Expectation Curve in a clip

pchart(PlotAlerts) // Plot the Expectation Alerts on the price chart

ialine(x:Data):Array

Parameters

x:Data - Data object variable name whose Interday Accumulation (IA) is to be calculated.

Returns

Array - Interday Accumulation (IA) of Data object x.

Interday Accumulation (IA) is a version of Accumulation-Distribution (AD) that uses true highs and true lows instead of period highs and period lows in its calculation. If you trade something that has frequent and/or large gaps, you may want to use this instead of AD.

Returns the IA of Data object x.

Returns the IA of Data object x.

Example

data("x") // Use the data from the chart

myIA = ialine(x) // Compute Interday Accumulation

myIAplot = plot(myIA,"IA","line","000000") // Plot object for myIA

chart(myIAplot) // Plot myIA in a clip

myIA = ialine(x) // Compute Interday Accumulation

myIAplot = plot(myIA,"IA","line","000000") // Plot object for myIA

chart(myIAplot) // Plot myIA in a clip

iaosc(x:Data, period:Number):Array

Parameters

x:Data - Data object variable name whose Interday Accumulation Oscillator (IA%) is to be calculated.

period:Number - Interday Accumulation Oscillator (IA%) period value.

period:Number - Interday Accumulation Oscillator (IA%) period value.

Returns

Array - Interday Accumulation Oscillator (IA%) of data object x.

Interday Accumulation Oscillator (IA%) is the closed form of Interday Accumulation (IA). IA% is created by taking the *n*-day sum of IA and dividing by the *n*-day sum of volume; the result is a normalized IA that is comparable from issue to issue. Specify the IA% period value using Number object period. If a decimal value is entered for period, the function will drop the decimal part and use the integer part as the period in the calculation without warning.

Returns the IA% of Data object x.

Returns the IA% of Data object x.

Example

data("x") // Use the data from the chart

period = 21 // Use 21 for calculation period

myIAOsc = iaosc(x,period) // 21-period IA%

plotIAOsc = plot(myIAOsc,"IA%","histogram") // Plot object for myIAOsc

chart(plotIAOsc) // Chart myIAOsc in a clip

period = 21 // Use 21 for calculation period

myIAOsc = iaosc(x,period) // 21-period IA%

plotIAOsc = plot(myIAOsc,"IA%","histogram") // Plot object for myIAOsc

chart(plotIAOsc) // Chart myIAOsc in a clip

icebreaker(tdata:Data, sdata:Data):Array

Parameters

tdata:Data - Data object variable name that will be traded.

sdata:Data - Data object variable name whose Ice Breaker Signals will be generated for.

sdata:Data - Data object variable name whose Ice Breaker Signals will be generated for.

Returns

Array - John Bollinger's Ice Breaker signals of Data object sdata to trade Data object tdata.

The Ice Breaker signal is generated using Bollinger Envelopes (BEs). A buy alert (1] is generated when the close penetrates the 10-day, 1.5 standard deviation lower BE, a condition considered as oversold. A sell alert (-1] is generated when the close penetrates the 10-day, 1.5 standard deviation upper BE, a condition considered as overbought.

Returns the Ice Breaker signals (an array of 1s, 0s, and -1s) of Data object sdata used to trade Data object tdata. A value of 1 is a buy signal, a value of 0 is no signal, and a value of -1 is a sell signal.

Returns the Ice Breaker signals (an array of 1s, 0s, and -1s) of Data object sdata used to trade Data object tdata. A value of 1 is a buy signal, a value of 0 is no signal, and a value of -1 is a sell signal.

Example

data("x") // Use the data from the chart

data("ref","SPX") // Use SPX data

myIBSig = icebreaker(x,ref) // Trade x using signals generated for ref

myCloses = close(x) // An array of closes

plotIBSig = plot(myCloses,"Ice Breaker Signals","line","00000000",myIBSig) // Anchor the Ice Breaker Signals to the closes (line will not display but signals will)

pchart(plotIBSig) // Plot the Ice Breaker Signals on the price chart

data("ref","SPX") // Use SPX data

myIBSig = icebreaker(x,ref) // Trade x using signals generated for ref

myCloses = close(x) // An array of closes

plotIBSig = plot(myCloses,"Ice Breaker Signals","line","00000000",myIBSig) // Anchor the Ice Breaker Signals to the closes (line will not display but signals will)

pchart(plotIBSig) // Plot the Ice Breaker Signals on the price chart

iiline(x:Data):Array

Parameters

x:Data - Data object variable name whose Intraday Intensity (II) is to be calculated.

Returns

Array - Intraday Intensity (II) of Data object x.

Intraday Intensity (II) was developed by the economist David Bostian. This indicator uses the position of the close in relation to the high and low to parse volume. It is meant to track the activities of institutional traders; large blocks move the market in the direction of their order flow -- increasingly so toward the close.

Returns the II of Data object x.

Returns the II of Data object x.

Example

data("x") // Use the data from the chart

myII = iiline(x) // Compute Intraday Intensity (II)

mtmPeriod = -9 // Period to compute Momentum of myII

myIImtm = myII[0]-myII[mtmPeriod] // Compute Momentum

plotIImtm = plot(myIImtm,"II Momentum","line","000000") // Plot object for myIImtm

chart(plotIImtm) // Plot myIImtm in a clip

myII = iiline(x) // Compute Intraday Intensity (II)

mtmPeriod = -9 // Period to compute Momentum of myII

myIImtm = myII[0]-myII[mtmPeriod] // Compute Momentum

plotIImtm = plot(myIImtm,"II Momentum","line","000000") // Plot object for myIImtm

chart(plotIImtm) // Plot myIImtm in a clip

iiosc(x:Data, period:Number):Array

Parameters

x:Data - Data object variable name whose Intraday Intensity Oscillator (II%) is to be calculated.

period:Number - Intraday Intensity Oscillator (II%) period value.

period:Number - Intraday Intensity Oscillator (II%) period value.

Returns

Array - Intraday Intensity Oscillator (II%) of Data object x.

Intraday Intensity Oscillator (II%) is the closed form of Intraday Intensity (II). II% is calculated by taking the *n*-day sum of II and dividing by the *n*-day sum of volume; the result is a normalized II that is now comparable from issue to issue. Specify the number of days used in the calculation using Number object period. If a decimal value is entered for period, the function will drop the decimal part and use the integer part as the period in the calculation without warning.

Returns the II% of Data object x.

Returns the II% of Data object x.

Example

data("x") // Use the data from the chart

myIIOsc = iiosc(x,21) // 21-day II%

plotMyIIOsc = plot(myIIOsc,"II%","line","000000") // Plot object for myIIOsc

ref1 = plot(25,"","line","CCCCCC") // Plot object for 25% reference level

ref2 = plot(-25,"","line","CCCCCC") // Plot object for -25% reference level

chart(plotMyIIOsc,ref1,ref2) // Plot myIIOsc in a clip with reference levels

myIIOsc = iiosc(x,21) // 21-day II%

plotMyIIOsc = plot(myIIOsc,"II%","line","000000") // Plot object for myIIOsc

ref1 = plot(25,"","line","CCCCCC") // Plot object for 25% reference level

ref2 = plot(-25,"","line","CCCCCC") // Plot object for -25% reference level

chart(plotMyIIOsc,ref1,ref2) // Plot myIIOsc in a clip with reference levels

macd(x:Data, p1:Number, p2:Number, p3:Number, series:String["macd","signal"]):Array

Parameters

x:Data - Data object variable name whose Moving Average Convergence-Divergence (MACD) is to be calculated.

p1:Number - Short period value

p2:Number - Long period value.

p3:Number - Signal period value.

series:String["macd","signal"] - String to specify what is to be returned. Must be one of "macd" or "signal" for Moving Average Convergence-Divergence (MACD) or Signal line, respectively.

p1:Number - Short period value

p2:Number - Long period value.

p3:Number - Signal period value.

series:String["macd","signal"] - String to specify what is to be returned. Must be one of "macd" or "signal" for Moving Average Convergence-Divergence (MACD) or Signal line, respectively.

Returns

Array - If "macd" is specified for series, the Moving Average Convergence-Divergence (MACD) of Data object x.

If "signal" is specified for series, the MACD Signal of Data object x.

If "signal" is specified for series, the MACD Signal of Data object x.

Gerald Appel created Moving Average Convergence-Divergence (MACD), a departure chart with an additional average added that acts as a signal line. The MACD curve is the difference between a short- and long-period exponential moving average. This signal line is an exponential moving average of the MACD curve.

Specify the MACD short period value using Number object p1, specify the MACD long period value using Number object p2, and specify the signal line exponential moving average period value using Number object p3. If a decimal is entered for p1, p2 or p3, the function will drop the decimal part and use the integer part for p1, p2 or p3 in the calculation without warning.

Returns the MACD curve of Data object x if "macd" is specified by String object type, or returns the MACD Signal line of Data object x if "signal" is specified for String object type.

Specify the MACD short period value using Number object p1, specify the MACD long period value using Number object p2, and specify the signal line exponential moving average period value using Number object p3. If a decimal is entered for p1, p2 or p3, the function will drop the decimal part and use the integer part for p1, p2 or p3 in the calculation without warning.

Returns the MACD curve of Data object x if "macd" is specified by String object type, or returns the MACD Signal line of Data object x if "signal" is specified for String object type.

Example

data("x") // Use the data from the chart

myMACDcurve = macd(x,24,50,12,"macd") // MACD curve using 24- and 50-day exponential moving averages and 12-day signal line

myMACDsignal = macd(x,24,50,12,"signal") // Signal line using 24-day and 50-day exponential moving averages and 12-day signal line

MACDdiff = myMACDcurve - myMACDsignal // Difference between MACD curve and MACD Signal line

plotMACDcurve = plot(myMACDcurve,"MACD","line","000000") // Plot object for myMACDcurve

plotMACDsignal = plot(myMACDsignal,"Signal","line","FF0000") // Plot object for myMACDsignal

plotMACDdiff = plot(MACDdiff,"Difference","histogram") // Plot object for MACDdiff

chart(plotMACDcurve,plotMACDsignal,plotMACDdiff) // Plot myMACDcurve, myMACDsignal and MACDdiff in a clip

myMACDcurve = macd(x,24,50,12,"macd") // MACD curve using 24- and 50-day exponential moving averages and 12-day signal line

myMACDsignal = macd(x,24,50,12,"signal") // Signal line using 24-day and 50-day exponential moving averages and 12-day signal line

MACDdiff = myMACDcurve - myMACDsignal // Difference between MACD curve and MACD Signal line

plotMACDcurve = plot(myMACDcurve,"MACD","line","000000") // Plot object for myMACDcurve

plotMACDsignal = plot(myMACDsignal,"Signal","line","FF0000") // Plot object for myMACDsignal

plotMACDdiff = plot(MACDdiff,"Difference","histogram") // Plot object for MACDdiff

chart(plotMACDcurve,plotMACDsignal,plotMACDdiff) // Plot myMACDcurve, myMACDsignal and MACDdiff in a clip

mfi(x:Data, period:Number):Array

Parameters

x:Data - Data object variable name whose Money Flow Index (MFI) is to be calculated.

period:Number - Money Flow Index (MFI) period value.

period:Number - Money Flow Index (MFI) period value.

Returns

Array - Money Flow Index (MFI) of Data object x in an Array object.

Money Flow Index (MFI) compares volume on up days to volume on down days in a manner similar to Relative Strength Index (RSI). The typical price, (high+low+close)/3, is used to separate up periods from down. The periods are averaged and a ratio of up to down is taken. Specify the number of days used in the calculation using Number object period. If a decimal value is entered for period, the function will drop the decimal part and use the integer part as the period in the calculation without warning.

Returns the MFI of Data object x.

Returns the MFI of Data object x.

Example

data("x") // Use the data from the chart

myMFI1 = mfi(x,14) // 14-day MFI

myMFI2 = mfi(x,50) // 50-day MFI

MFIdiff = myMFI1-myMFI2 // Difference between 14-day MFI and 50-day MFI

plotMFI1 = plot(myMFI1,"14-day MFI","line","000000") // Plot object for myMFI1

plotMFI2 = plot(myMFI2,"50-day MFI","line","00CC00") // Plot object for myMFI2

plotMFIdiff = plot(MFIdiff,"Delta","histogram") // Plot object for MFIdiff

chart(plotMFI1,plotMFI2,plotMFIdiff) // Plot myMFI1, myMFI2, MFIdiff in a clip

myMFI1 = mfi(x,14) // 14-day MFI

myMFI2 = mfi(x,50) // 50-day MFI

MFIdiff = myMFI1-myMFI2 // Difference between 14-day MFI and 50-day MFI

plotMFI1 = plot(myMFI1,"14-day MFI","line","000000") // Plot object for myMFI1

plotMFI2 = plot(myMFI2,"50-day MFI","line","00CC00") // Plot object for myMFI2

plotMFIdiff = plot(MFIdiff,"Delta","histogram") // Plot object for MFIdiff

chart(plotMFI1,plotMFI2,plotMFIdiff) // Plot myMFI1, myMFI2, MFIdiff in a clip

mtm(x:Data, period:Number):Array

Parameters

x:Data - Data object variable name whose Momentum is to be calculated.

period:Number - Momentum period value.

period:Number - Momentum period value.

Returns

Array - Momentum (MTM) of Data object x.

Momentum (MTM) is the point change of a data series over a specified time period. This may be the most elemental indicator in the technician's tool chest. Specify the period to compute MTM using Number object period. If a decimal value is entered for period, the function will drop the decimal part and use the integer part as the period in the calculation without warning.

Returns the MTM of Data object x.

Returns the MTM of Data object x.

Example

data("x") // Use the data from the chart

MTM1 = mtm(x,5) // 5-period MTM

MTM2 = mtm(x,20) // 20-period MTM

MTMdiff = MTM1-MTM2 // difference of 5- and 20-day MTM

plotMTM1 = plot(MTM1,"5-period MTM","line","000000") // Plot object for MTM1

plotMTM2 = plot(MTM2,"20-period MTM","line","FFBF00") // Plot object for MTM2

plotMTMdiff = plot(MTMdiff,"Delta","histogram") // Plot object for MTMdiff

chart(plotMTM1,plotMTM2,plotMTMdiff) // Plot MTM1, MTM2 and MTMdiff in a clip

MTM1 = mtm(x,5) // 5-period MTM

MTM2 = mtm(x,20) // 20-period MTM

MTMdiff = MTM1-MTM2 // difference of 5- and 20-day MTM

plotMTM1 = plot(MTM1,"5-period MTM","line","000000") // Plot object for MTM1

plotMTM2 = plot(MTM2,"20-period MTM","line","FFBF00") // Plot object for MTM2

plotMTMdiff = plot(MTMdiff,"Delta","histogram") // Plot object for MTMdiff

chart(plotMTM1,plotMTM2,plotMTMdiff) // Plot MTM1, MTM2 and MTMdiff in a clip

normvol(x:Data, period:Number):Array

Parameters

x:Data - Data object variable name whose Normalized Volume (Vol%) is to be calculated.

period:Number - Normalized Volume (Vol%) period value.

period:Number - Normalized Volume (Vol%) period value.

Returns

Array - Normalized Volume (Vol%) of Data object x.

Normalized volume (Vol%) is volume divided by an average, specified by Number object period.

Returns the Vol% of Data object x. When volume equals its average volume, Vol% is 100. Above average volume is indicated by Vol% greater than 100; below average volume is indicated by Vol% less than 100. If a decimal value is entered for period, the function will drop the decimal part and use the integer part as the period in the calculation without warning.

Returns the Vol% of Data object x. When volume equals its average volume, Vol% is 100. Above average volume is indicated by Vol% greater than 100; below average volume is indicated by Vol% less than 100. If a decimal value is entered for period, the function will drop the decimal part and use the integer part as the period in the calculation without warning.

Example

data("x") // Use the data from the chart

myNV1 = normvol(x,5) // 5 day normalized volume

myNV2 = normvol(x,10) // 10 day normalized volume

myNV3 = normvol(x,25) // 25 day normalized volume

myNV4 = normvol(x,50) // 50 day normalized volume

plotNV1 = plot(myNV1,"5-day Vol%","line","000000") // Plot object for myNV1

plotNV2 = plot(myNV2,"10-day Vol%","line","00CC00") // Plot object for myNV2

plotNV3 = plot(myNV3,"25-day Vol%","line","0000CC") // Plot object for myNV3

plotNV4 = plot(myNV4,"50-day Vol%","line","00CCCC") // Plot object for myNV4

chart(plotNV1,plotNV2,plotNV3,plotNV4) // Plot myNV1, myNV2, myNV3, myNV4 in a clip

myNV1 = normvol(x,5) // 5 day normalized volume

myNV2 = normvol(x,10) // 10 day normalized volume

myNV3 = normvol(x,25) // 25 day normalized volume

myNV4 = normvol(x,50) // 50 day normalized volume

plotNV1 = plot(myNV1,"5-day Vol%","line","000000") // Plot object for myNV1

plotNV2 = plot(myNV2,"10-day Vol%","line","00CC00") // Plot object for myNV2

plotNV3 = plot(myNV3,"25-day Vol%","line","0000CC") // Plot object for myNV3

plotNV4 = plot(myNV4,"50-day Vol%","line","00CCCC") // Plot object for myNV4

chart(plotNV1,plotNV2,plotNV3,plotNV4) // Plot myNV1, myNV2, myNV3, myNV4 in a clip

nrsi(x:Data, period:Number):Array

*See Relative Strength Index (RSI)* Plotting 50-day, 2.1 standard deviation Bollinger Bands on Relative Strength Index (RSI) allows the analyst to dispense with fixed levels and focus on indicator action. The upper band serves the same role as RSI 70 (overbought) and the lower band serves the same role as RSI 30 (oversold).

Here we go one stop further and create a Normalized RSI by plotting %b of RSI and 50-day Bollinger Bands. Specify the RSI period value used in the NRSI calculation using Number object period. If a decimal value is entered for period, the function will drop the decimal part and use the integer part as the period in the calculation without warning.

Returns the NRSI of Data object x.

Parameters

x:Data - Data object variable name whose Normalized Relative Strength Index (NRSI) is to be calculated.

period:Number - Normalized Relative Strength Index (NRSI) period value.

period:Number - Normalized Relative Strength Index (NRSI) period value.

Returns

Array - Normalized Relative Strength Index (NRSI) of Data object x. Normalization is performed using 50-day, 2.1 standard deviation Bollinger Bands.

Here we go one stop further and create a Normalized RSI by plotting %b of RSI and 50-day Bollinger Bands. Specify the RSI period value used in the NRSI calculation using Number object period. If a decimal value is entered for period, the function will drop the decimal part and use the integer part as the period in the calculation without warning.

Returns the NRSI of Data object x.

Example

data("x") // Use the data from the chart

period = 14 // Use 14 as the calculation period

myNRSI = nrsi(x,period) // 14-Period NRSI

plotNRSI = plot(myNRSI,"NRSI","line","000000") // Plot object for myNRSI

ref0 = plot(0,"","line","808080") // Reference line at 0%

ref50 = plot(50,"","line","C0C0C0") // Reference line at 50%

ref100 = plot(100,"","line","808080") // Reference line at 100%

chart(plotNRSI,ref0,ref50,ref100) // Chart myNRSI with reference lines in a clip

period = 14 // Use 14 as the calculation period

myNRSI = nrsi(x,period) // 14-Period NRSI

plotNRSI = plot(myNRSI,"NRSI","line","000000") // Plot object for myNRSI

ref0 = plot(0,"","line","808080") // Reference line at 0%

ref50 = plot(50,"","line","C0C0C0") // Reference line at 50%

ref100 = plot(100,"","line","808080") // Reference line at 100%

chart(plotNRSI,ref0,ref50,ref100) // Chart myNRSI with reference lines in a clip

obv(x:Data):Array

Parameters

x:Data - Data object variable name whose On-Balance Volume (OBV) is to be calculated.

Returns

Array - On-Balance Volume (OBV) of Data object x.

This is one of the oldest and best known of all the volume indicators. On-Balance Volume (OBV) was popularized by Joe Granville and is a good trend indicator. OBV adds volume to a running sum when price advances and subtracts volume from the running sum when price declines. It is meant to model the basic forces of supply and demand.

Returns the OBV of Data object x.

Returns the OBV of Data object x.

Example

data("x") // Use the data from the chart

myOBV = obv(x) // Compute On-Balance Volume

rocPeriod = -5 // Period to compute Rate of Change of myOBV

myOBVroc = ((myOBV[0]-myOBV[rocPeriod])/myOBV[rocPeriod])*100 // Compute Rate of Change

plotOBVroc = plot(myOBVroc,"OBV RoC","histogram") // Plot object for myOBVroc

chart(plotOBVroc) // Plot myOBVroc in a price clip

myOBV = obv(x) // Compute On-Balance Volume

rocPeriod = -5 // Period to compute Rate of Change of myOBV

myOBVroc = ((myOBV[0]-myOBV[rocPeriod])/myOBV[rocPeriod])*100 // Compute Rate of Change

plotOBVroc = plot(myOBVroc,"OBV RoC","histogram") // Plot object for myOBVroc

chart(plotOBVroc) // Plot myOBVroc in a price clip

parabolicstops(x:Data, entry_date:String["YYYY-MM-DD"], trade_type:Number[1,-1], af_step:Number, af_max:Number):Array

Parameters

x:Data - Data object variable name whose Parabolic stop-and-reverse is to be calculated

entry_date:String["YYYY-MM-DD"] - String object variable of the date of trade entry in "YYYY-MM-DD" format

trade_type:Number[1,-1] - Number object variable to specify the type of trade: 1 for long, -1 for short.

af_step:Number - Number object variable name specifying the AF step value (default is 0.02)

af_max:Number - Number object variable name specifying the maximum AF value (default is 0.20)

entry_date:String["YYYY-MM-DD"] - String object variable of the date of trade entry in "YYYY-MM-DD" format

trade_type:Number[1,-1] - Number object variable to specify the type of trade: 1 for long, -1 for short.

af_step:Number - Number object variable name specifying the AF step value (default is 0.02)

af_max:Number - Number object variable name specifying the maximum AF value (default is 0.20)

Returns

Array - Parabolic stop and reversal entry and exit system signals for Data object x.

Welles wilder's Parabolic stop-and-reverse is a price and time trading system. The SAR (stop-and-reverse) indicator trails the price as the trend extends over time. In an uptrend the indicator rises below the price line while in a downtrend the indicator falls above the price line. When the price trend breaks below or above the indicator line, the indicator stops and reverses.

The function computes a sell signal when the price moves below a long stop and a buy signal when the price moves above a short stop.

The signals are computed as a trading system always in the market from the entry date specified.

The function computes a sell signal when the price moves below a long stop and a buy signal when the price moves above a short stop.

The signals are computed as a trading system always in the market from the entry date specified.

Example

data("x") // Use the data from the chart

myCloses = close(x)

SAR = parabolicstops(x,"2012-01-02",1,0.04,0.44) // Generate stop-and-reverse signals for the data. The first trade is long starting on January 2, 2012, using an AF step of 0.04 and a maximum AF of 0.44.

plotSAR = plot(myCloses,"Stop-and-Reverse","line","00000000",SAR) // Anchor the stop-and-reverse signals to the closes (the line will not be shown but the signals will)

pchart(plotSAR) // Plot the stop-and-reverse signals on the price chart

myCloses = close(x)

SAR = parabolicstops(x,"2012-01-02",1,0.04,0.44) // Generate stop-and-reverse signals for the data. The first trade is long starting on January 2, 2012, using an AF step of 0.04 and a maximum AF of 0.44.

plotSAR = plot(myCloses,"Stop-and-Reverse","line","00000000",SAR) // Anchor the stop-and-reverse signals to the closes (the line will not be shown but the signals will)

pchart(plotSAR) // Plot the stop-and-reverse signals on the price chart

perb(x:Data, period:Number, width:Number, type:String["bbands","benvelope"]):Array

Parameters

x:Data - Data object variable name whose %b is to be calculated.

period:Number - Period to used to compute Bollinger Bands or Bollinger Envelopes (default is 20).

width:Number - Width to compute Bollinger Bands or Bollinger Envelopes (default is 2.0 for Bollinger Bands, 1.5 for Bollinger Envelopes)

type:String["bbands","benvelope"] - String to specify the use of Bollinger Bands or Bollinger Envelopes in the calculation of %b. Must be one of "bbands" or "benvelope" for Bollinger Bands or Bollinger Envelopes, respectively.

period:Number - Period to used to compute Bollinger Bands or Bollinger Envelopes (default is 20).

width:Number - Width to compute Bollinger Bands or Bollinger Envelopes (default is 2.0 for Bollinger Bands, 1.5 for Bollinger Envelopes)

type:String["bbands","benvelope"] - String to specify the use of Bollinger Bands or Bollinger Envelopes in the calculation of %b. Must be one of "bbands" or "benvelope" for Bollinger Bands or Bollinger Envelopes, respectively.

Returns

Array - The position of Data object x within Bollinger Bands or Bollinger Envelopes.

%b (Percent b) was the second indicator derived from Bollinger Bands; it has also been adapted to Bollinger Envelopes. It employs a variation of the formula for Stochastics. %b depicts the location of the most recent close within the Bollinger Bands or Bollinger Envelopes. At 1.0, the close is at the upper band or upper envelope, at 0.0 the close is at the lower band or lower envelope, and at 0.5 the close is at the middle band or middle envelope. A %b above 1.0 means that you are above the upper band or upper envelope, and a %b below 0.0 means that you are below the lower band or lower envelope.

%b is a useful tool for identifying divergences, diagnosing tops and bottoms, and pattern recognition. %b is also used extensively in trading system construction.

Returns %b of Data object x using period as the simple moving average period and width as the standard deviation multiplier to compute Bollinger Bands or Bollinger Envelopes, whichever is specified by String object type. If a decimal value is entered for period, the function will drop the decimal part and use the integer part as the period in the calculation without warning.

%b is a useful tool for identifying divergences, diagnosing tops and bottoms, and pattern recognition. %b is also used extensively in trading system construction.

Returns %b of Data object x using period as the simple moving average period and width as the standard deviation multiplier to compute Bollinger Bands or Bollinger Envelopes, whichever is specified by String object type. If a decimal value is entered for period, the function will drop the decimal part and use the integer part as the period in the calculation without warning.

Example

data("x") // Use the data from the chart

period = 50 // Set the length

width = 2.1 // Set the width

type = "bbands" // Use Bollinger Bands in the calculation of %b

myPerb = perb(x,period,width,type) // Get %b and store it in Array object myPerb

myPerb1 = ema(myPerb,5) // Get the 5-day exponential moving average of myPerb and store it in Array object myPerb1

myPerb2 = ema(myPerb1,5) // Get the 5-day exponential moving average of myPerb1 and store it in Array object myPerb2

plotPerb = plot(myPerb,"myPerb","line","000000") // Assign a plot object for myPerb

plotPerb1 = plot(myPerb1,"myPerb1","line","00FF00") // Assign a plot object for myPerb1

plotPerb2 = plot(myPerb2,"myPerb2","line","FF00FF") // Assign a plot object for myPerb2

chart(plotPerb,plotPerb1,plotPerb2) // Plot myPerb,myPerb1,myPerb2 in the same clip

period = 50 // Set the length

width = 2.1 // Set the width

type = "bbands" // Use Bollinger Bands in the calculation of %b

myPerb = perb(x,period,width,type) // Get %b and store it in Array object myPerb

myPerb1 = ema(myPerb,5) // Get the 5-day exponential moving average of myPerb and store it in Array object myPerb1

myPerb2 = ema(myPerb1,5) // Get the 5-day exponential moving average of myPerb1 and store it in Array object myPerb2

plotPerb = plot(myPerb,"myPerb","line","000000") // Assign a plot object for myPerb

plotPerb1 = plot(myPerb1,"myPerb1","line","00FF00") // Assign a plot object for myPerb1

plotPerb2 = plot(myPerb2,"myPerb2","line","FF00FF") // Assign a plot object for myPerb2

chart(plotPerb,plotPerb1,plotPerb2) // Plot myPerb,myPerb1,myPerb2 in the same clip

perbw(x:Data, period:Number, width:Number, period2:Number, type:String["bbands","benvelope"]):Array

Parameters

x:Data - Data object variable name whose %BandWidth is to be calculated.

period:Number - Period to compute the Bollinger Bands or Bollinger Envelopes (default is 20).

width:Number - Width to compute the Bollinger Bands or Bollinger Envelopes (default is 2.0 for Bollinger Bands, 1.5 for Bollinger Envelopes).

period2:Number - %BandWidth lookback period.

type:String["bbands","benvelope"] - String to specify the use of Bollinger Bands or Bollinger Envelopes in the calculation of %BandWidth. Must be one of "bbands" or "benevelope" for Bollinger Bands or Bollinger Envelopes, respectively.

period:Number - Period to compute the Bollinger Bands or Bollinger Envelopes (default is 20).

width:Number - Width to compute the Bollinger Bands or Bollinger Envelopes (default is 2.0 for Bollinger Bands, 1.5 for Bollinger Envelopes).

period2:Number - %BandWidth lookback period.

type:String["bbands","benvelope"] - String to specify the use of Bollinger Bands or Bollinger Envelopes in the calculation of %BandWidth. Must be one of "bbands" or "benevelope" for Bollinger Bands or Bollinger Envelopes, respectively.

Returns

Array - %BandWidth (Percent BandWidth) of Data object x.

%BandWidth (Percent BandWidth) uses the formula for Stochastics to normalize BandWidth (BW) as a function of its *n*-day lookback period. 1.0 equals the highest BW in the past *n* periods, while 0.0 equals the lowest BW in the past *n* periods. If you use 125 as the lookback period, then 0.0 = The Squeeze and 1.0 = The Bulge.

Interpretations are similar to BandWidth, but some find the normalized, or closed presentation more intuitive.

%BandWidth, along with %b, are two primary building blocks for Bollinger Band tranding systems.

Returns the %BandWidth in percent of Data object x using period as the simple moving average and width as the standard deviation multiplier to compute Bollinger Bands or Bollinger Envelopes, whichever is specified by String object type, with period2 as the lookback period value. If a decimal value is entered for period or lookback, the function will drop the decimal part and use the integer part for period and lookback in the calculation without warning.

Interpretations are similar to BandWidth, but some find the normalized, or closed presentation more intuitive.

%BandWidth, along with %b, are two primary building blocks for Bollinger Band tranding systems.

Returns the %BandWidth in percent of Data object x using period as the simple moving average and width as the standard deviation multiplier to compute Bollinger Bands or Bollinger Envelopes, whichever is specified by String object type, with period2 as the lookback period value. If a decimal value is entered for period or lookback, the function will drop the decimal part and use the integer part for period and lookback in the calculation without warning.

Example

data("x") // Use the data from the chart

period = 20 // Set the length

width = 2.0 // Set the width

lookback = 125 // Set the lookback period

type = "benvelope" // Use Bollinger Envelopes

myPBW = perbw(x,period,width,lookback,type) // Get the %BandWidth data and assign it to Array object myPBW

plotPBW = plot(myPBW,"%BandWidth","line","000000") // Assign a plot object for myPBW

chart(plotPBW) // Plot %BandWidth in a clip

period = 20 // Set the length

width = 2.0 // Set the width

lookback = 125 // Set the lookback period

type = "benvelope" // Use Bollinger Envelopes

myPBW = perbw(x,period,width,lookback,type) // Get the %BandWidth data and assign it to Array object myPBW

plotPBW = plot(myPBW,"%BandWidth","line","000000") // Assign a plot object for myPBW

chart(plotPBW) // Plot %BandWidth in a clip

psychology(x:Data, period:Number):Array

Parameters

x:Data - Data object variable name whose Alphier Psychology curve is to be computed.

period:Number - Alphier Psychology period value.

period:Number - Alphier Psychology period value.

Returns

Array - Alphier Psychology curve of Data object x.

This is a short-term component of the Alphier Expectation curve that is more sensitive than Alphier Expectation. It is shorter-term in outlook and can be used on its own or to help anticipate changes in the Alphier Expectation curve. Specify the Alphier Psychology period value using Number object period. If a decimal value is entered for period, the function will drop the decimal part and use the integer part as the period in the calculation without warning.

Returns the Alphier Psychology curve of Data object x.

Returns the Alphier Psychology curve of Data object x.

Example

data("x") // Use the data from the chart

myAP = psychology(x,19) // Compute 19-period Alphier Psychology

plotAP = plot(myAP,"Alphier Psychology","line","000000") // Plot object for myAP

chart(plotAP) // Chart myAP in a clip

myAP = psychology(x,19) // Compute 19-period Alphier Psychology

plotAP = plot(myAP,"Alphier Psychology","line","000000") // Plot object for myAP

chart(plotAP) // Chart myAP in a clip

pvt(x:Data):Array

Parameters

x:Data - Data object variable name whose Price-Volume Trend (PVT) is to be calculated.

Returns

Array - Price-Volume Trend (PVT) of Data object x in an Array object.

Price-Volume Trend (PVT) is David Markstein's variation on On-Balance Volume (OBV) in which the percentage changes from period to period are used to parse volume.

Returns the PVT of Data object x.

Returns the PVT of Data object x.

Example

data("x") // Use the data from the chart

myPVT = pvt(x) // Compute Price-Volume Trend

myPVTs1 = ema(myPVT,3) // 3-day EMA of myPVT

myPVTs2 = ema(myPVTs1,3) // 3-day EMA pf myPVTs1

myPVTplot = plot(myPVT,"PVT","line","000000") // Plot object for myPVT

myPVTs1plot = plot(myPVTs1,"PVT(s1)","line","58FA58") // Plot object for myPVTs1

myPVTs2plot = plot(myPVTs2,"PVT(s2)","line","F781F3") // Plot object for myPVTs2

chart(myPVTplot,myPVTs1plot,myPVTs2plot) // Plot myPVT, myPVTs1, and myPVTs2 in a clip

myPVT = pvt(x) // Compute Price-Volume Trend

myPVTs1 = ema(myPVT,3) // 3-day EMA of myPVT

myPVTs2 = ema(myPVTs1,3) // 3-day EMA pf myPVTs1

myPVTplot = plot(myPVT,"PVT","line","000000") // Plot object for myPVT

myPVTs1plot = plot(myPVTs1,"PVT(s1)","line","58FA58") // Plot object for myPVTs1

myPVTs2plot = plot(myPVTs2,"PVT(s2)","line","F781F3") // Plot object for myPVTs2

chart(myPVTplot,myPVTs1plot,myPVTs2plot) // Plot myPVT, myPVTs1, and myPVTs2 in a clip

qstk(x:Data, period:Number):Array

Parameters

x:Data - Data object variable name whose Qstick (QSTK) is to be calculated.

period:Number - Qstick (QSTK) period value.

period:Number - Qstick (QSTK) period value.

Returns

Array - Qstick (QSTK) of Data object x.

Qstick (QSTK) is a moving average of the bodies of Japanese candlesticks, the relations between the opens and the closes. QSTK is negative when the closes have been less than the opens for a certain period and is positive when the closes have been greater than the opens for the same period. Thus it is a look at the internal trend of the price structure. Specify the the QSTK period value using Number object period. If a decimal value is entered for period, the function will drop the decimal part and use the integer part as the period in the calculation without warning.

Returns the QSTK of Data object x.

Returns the QSTK of Data object x.

Example

data("x") // Use the data from the chart

myQSTK = qstk(x,9) // 9-period QSTK

plotQSTK = plot(myQSTK,"9-period QSTK","line","000000") // Plot object for myQSTK

chart(plotQSTK) // Plot myQSTK in a clip

myQSTK = qstk(x,9) // 9-period QSTK

plotQSTK = plot(myQSTK,"9-period QSTK","line","000000") // Plot object for myQSTK

chart(plotQSTK) // Plot myQSTK in a clip

range(x:Data, n:Number(optional)):Array,Number

Parameters

x:Data - Data object variable name whose range is to be calculated.

n:Number(optional) - Range period value.

n:Number(optional) - Range period value.

Returns

Returns the range Array of a Data object as defined by the equation: max(high(x),n) - min(low(x),n); if n not provided, the maximum high of x minus minimum low of x will be returned.

Example

data("x")

period = 20

rangeArray = range(x,period)

print(rangeArray)

rangeTotal = range(x)

print(rangeTotal)

period = 20

rangeArray = range(x,period)

print(rangeArray)

rangeTotal = range(x)

print(rangeTotal)

rmi(x:Data, p1:Number, p2:Number):Array

Parameters

x:Data - Data object variable name whose Relative Momentum Index (RMI) is to be calculated.

p1:Number - Period to compute Relative Strength Index (RSI).

p2:Number - Relative Momentum Index (RMI) period value.

p1:Number - Period to compute Relative Strength Index (RSI).

p2:Number - Relative Momentum Index (RMI) period value.

Returns

Array - Relative Momentum Index (RMI) of Data object x.

Relative Momentum Index (RMI) is Roger Altman's momentum variation of Welles Wilder's Relative Strength Index (RSI). Instead of accumulation plus and minus price changes, RMI accumulates changes in momentum. Over 70 is considered overbought and under 30 is considered oversold. (NOTE: RMI = RSI when the time frames are the same and RMI momentum period value is set to 1.)

Specify the time frame using Number object p1; specify the momentum period value using Number object p2. If a decimal value is entered for p1 or p2, the function will drop the decimal part and use the integer part as p1 or p2 in the calculation without warning.

Returns the RMI of data object x.

Specify the time frame using Number object p1; specify the momentum period value using Number object p2. If a decimal value is entered for p1 or p2, the function will drop the decimal part and use the integer part as p1 or p2 in the calculation without warning.

Returns the RMI of data object x.

Example

data("x") // Use the data from the chart

myRMI = rmi(x,14,4) // 4-day lookback, 14-day period

plotRMI = plot(myRMI,"RMI","line","000000") // Plot object for myRMI

ref1 = plot(70,"","line","FF0000") // Overbought reference line

ref2 = plot(30,"","line","00CC00") // Oversold reference line

chart(plotRMI,ref1,ref2) // Plot myRMI with reference lines in a clip

myRMI = rmi(x,14,4) // 4-day lookback, 14-day period

plotRMI = plot(myRMI,"RMI","line","000000") // Plot object for myRMI

ref1 = plot(70,"","line","FF0000") // Overbought reference line

ref2 = plot(30,"","line","00CC00") // Oversold reference line

chart(plotRMI,ref1,ref2) // Plot myRMI with reference lines in a clip

roc(x:Data, period:Number):Array

Parameters

x:Data - Data object variable name whose Rate of Change is to be calculated.

period:Number - Rate of Change period value.

period:Number - Rate of Change period value.

Returns

Array - Rate of Change (ROC) of Data object x.

Rate of Change (ROC) is the percent difference of a data series over a specified time period. Specify the period to compute ROC using Number object period. If a decimal value is entered for period, the function will drop the decimal part and use the integer part as the period in the calculation without warning.

Returns the ROC of Data object x.

Returns the ROC of Data object x.

Example

data("x") // Use the data from the chart

ROC1 = roc(x,5) // 5-period ROC

ROC2 = roc(x,20) // 20-period ROC

ROCdiff = ROC1-ROC2 // difference of 5- and 20-day ROC

plotROC1 = plot(ROC1,"5-period ROC","line","000000") // Plot object for ROC1

plotROC2 = plot(ROC2,"20-period ROC","line","00CC00") // Plot object for ROC2

plotROCdiff = plot(ROCdiff,"Delta","histogram") // Plot object for ROCdiff

chart(plotROC1,plotROC2,plotROCdiff) // Plot ROC1, ROC2 and ROCdiff in a clip

ROC1 = roc(x,5) // 5-period ROC

ROC2 = roc(x,20) // 20-period ROC

ROCdiff = ROC1-ROC2 // difference of 5- and 20-day ROC

plotROC1 = plot(ROC1,"5-period ROC","line","000000") // Plot object for ROC1

plotROC2 = plot(ROC2,"20-period ROC","line","00CC00") // Plot object for ROC2

plotROCdiff = plot(ROCdiff,"Delta","histogram") // Plot object for ROCdiff

chart(plotROC1,plotROC2,plotROCdiff) // Plot ROC1, ROC2 and ROCdiff in a clip

rsi(x:Data, period:Number):Array

Parameters

x:Data - Data object variable name whose Relative Strength Index (RSI) is to be calculated.

period:Number - Relative Strength Index (RSI) period value.

period:Number - Relative Strength Index (RSI) period value.

Returns

Array - Relative Strength Index (RSI) of Data object x.

Welles Wilder's Relative Strength Index (RSI) is a classic technical analysis tool that compares strength on up days to weakness on down days. The fixed values of 70 (overbought) and 30 (oversold) are most often used as signal levels. However, in a bullish environment 80 and 40 may be better suited and 60 and 20 are often used in bear markets. Many analysts use the swings of RSI through various levels to define bull and bear markets.

Returns the RSI of Data object x. If a decimal value is entered for period, the function will drop the decimal part and use the integer part as the period in the calculation without warning.

Returns the RSI of Data object x. If a decimal value is entered for period, the function will drop the decimal part and use the integer part as the period in the calculation without warning.

Example

data("x") // Use the data from the chart

myRSI = rsi(x,14) // 14-period RSI

myRSIplot = plot(myRSI,"14-Period RSI","line","000000") // Plot object for myRSI

ref1 = plot(30,"","line","00FF00") // Reference line at 30

ref2 = plot(45,"","line","FFFF00") // Reference line at 45

ref3 = plot(60,"","line","FFBF00") // Reference line at 60

ref4 = plot(75,"","line","FF4000") // Reference line at 75

ref5 = plot(90,"","line","000000") // Reference line at 90

chart(myRSIplot,ref1,ref2,ref3,ref4,ref5) // Chart all Plot objects in a clip

myRSI = rsi(x,14) // 14-period RSI

myRSIplot = plot(myRSI,"14-Period RSI","line","000000") // Plot object for myRSI

ref1 = plot(30,"","line","00FF00") // Reference line at 30

ref2 = plot(45,"","line","FFFF00") // Reference line at 45

ref3 = plot(60,"","line","FFBF00") // Reference line at 60

ref4 = plot(75,"","line","FF4000") // Reference line at 75

ref5 = plot(90,"","line","000000") // Reference line at 90

chart(myRSIplot,ref1,ref2,ref3,ref4,ref5) // Chart all Plot objects in a clip

spvol(x:Data):Array

Parameters

x:Data - Data object variable name whose Sponsored Volume (SV) is to be calculated.

Returns

Array - Sponsored Volume (SV) of Data object x.

Sponsored Volume (SV) is a version of Intraday Intensity (II) from Jim Alphier that uses true highs and true lows instead of periodic highs and periodic lows in its calculation. If you trade something that has frequent and/or large gaps, you may want to use this version of II.

Returns the SV of Data object x.

Returns the SV of Data object x.

Example

data("x") // Use the data from the chart

mySV = spvol(x) // Compute Sponsored Volume

mySVplot = plot(mySV,"SV","line","000000") // Plot object for mySV

chart(mySVplot) // Plot mySV in a clip

mySV = spvol(x) // Compute Sponsored Volume

mySVplot = plot(mySV,"SV","line","000000") // Plot object for mySV

chart(mySVplot) // Plot mySV in a clip

spvolp(x:Data, period:Number):Array

Parameters

x:Data - Data object variable name whose Sponsored Volume Oscillator (SV%) is to be calculated.

period:Number - Sponsored Volume Oscillator (SV%) period value.

period:Number - Sponsored Volume Oscillator (SV%) period value.

Returns

Array - Sponsored Volume Oscillator (SV%) of Data object x.

Sponsored Volume Oscillator (SV%) is the closed form of Sponsored Volume. SV% is created by taking the *n*-day sum of SV and dividing by the *n*-day sum of volume. Specify the SV% period value using Number object period. If a decimal value is entered for period, the function will drop the decimal part and use the integer part as the period in the calculation without warning.

Returns the SV% of Data object x.

Returns the SV% of Data object x.

Example

data("x") // Use the data from the chart

period = 50 // Use 50 for calculation period

mySVOsc = spvolp(x,period) // 50-Period SV%

plotSVOsc = plot(mySVOsc,"SV%","histogram") // Plot object for mySVOsc

chart(plotSVOsc) // Chart mySVOsc in a clip

period = 50 // Use 50 for calculation period

mySVOsc = spvolp(x,period) // 50-Period SV%

plotSVOsc = plot(mySVOsc,"SV%","histogram") // Plot object for mySVOsc

chart(plotSVOsc) // Chart mySVOsc in a clip

stochimp(x:Data, period:Number):Array

Parameters

x:Data - Data object variable name whose Stochastic Impulse is to be calculated.

period:Number - Stochastic Impulse period value.

period:Number - Stochastic Impulse period value.

Returns

Array - Stochastic Impulse of Data object x.

Stochastic Impulse is an another Bollinger Bands exclusive indicator. It is a variation on BBImpulse that depicts the changes in Stochastics rather than the changes in %b. Another way of saying this is that BBImpulse measures impulse strength in relation to the Bollinger Bands and Stochastic Impulse measures impulse strength in relation to range (*See BBImpulse*). Specify the Stochastic Impulse period using Number object period. If a decimal value is entered for period, the function will drop the decimal part and use the integer part as the period in the calculation without warning.

Returns the Stochastic Impulse of Data object x.

Returns the Stochastic Impulse of Data object x.

Example

data("x") // Use the data from the chart

period = 14 // Use a 14 periods in the calculation

mySI = stochimp(x,period) // Calculate 14-Period Stochastic Impulse

plotSI = plot(mySI,"Stochastic Impulse","histogram") // Plot object for mySI

chart(plotSI) // Plot mySI in a clip

period = 14 // Use a 14 periods in the calculation

mySI = stochimp(x,period) // Calculate 14-Period Stochastic Impulse

plotSI = plot(mySI,"Stochastic Impulse","histogram") // Plot object for mySI

chart(plotSI) // Plot mySI in a clip

stochkd(x:Data, p1:Number, p2:Number, type:String["fast","slow"], series:String["k","d"]):Array

Parameters

x:Data - Data object variable name whose Stochastics is to be calculated.

p1:Number - %k lookback period value.

p2:Number - %d lookback period value.

type:String["fast","slow"] - String to specify the type of Stochastic to be calculated. Must be one of "fast" or "slow" for fast Stochastics or slow Stochastics, respectively.

series:String["k","d"] - STring to specify what is to be returned. Must be one of "k" or "d" for %k and %d, respectively.

p1:Number - %k lookback period value.

p2:Number - %d lookback period value.

type:String["fast","slow"] - String to specify the type of Stochastic to be calculated. Must be one of "fast" or "slow" for fast Stochastics or slow Stochastics, respectively.

series:String["k","d"] - STring to specify what is to be returned. Must be one of "k" or "d" for %k and %d, respectively.

Returns

Array - If "k" is specified for series, the fast or slow (specified by type) %k of Data object x. If "d" is specified for series, the fast or slow (specified by type) %d of Data object x.

This is George Lane's Stochastics, an indicator of the position of current price relative to the price range of the past *n* days.

Specify the lookback period value for the lowest low and highest high using Number object p1. Specify the length of the averages using Number object p2. If a decimal value is entered for p1 or p2, the function will drop the decimal part and use the integer part for p1 or p2 as the period in the calculation without warning.

If String object type is "fast", raw %k will be returned if String object series is "k" and an average of %k (%d) will be returned if String object series is "d". If String object type is "slow", %d will be returned if String object series is "k" and an average of %d (a second averaging of raw %k) will be returned if String object series is "d".

Specify the lookback period value for the lowest low and highest high using Number object p1. Specify the length of the averages using Number object p2. If a decimal value is entered for p1 or p2, the function will drop the decimal part and use the integer part for p1 or p2 as the period in the calculation without warning.

If String object type is "fast", raw %k will be returned if String object series is "k" and an average of %k (%d) will be returned if String object series is "d". If String object type is "slow", %d will be returned if String object series is "k" and an average of %d (a second averaging of raw %k) will be returned if String object series is "d".

Example

data("x") // Use the data from the chart

fastk = stochkd(x,14,3,"fast","k") // Fast %k using 14-period calculation and 3-period simple moving average (raw %k)

fastd = stochkd(x,14,3,"fast","d") // Fast %d using 14-period calculation and 3-period simple moving average (3-period sma of fast %k)

slowk = stochkd(x,14,3,"slow","k") // Slow %k using 14-period calculation and 3-period simple moving average

slowd = stochkd(x,14,3,"slow","d") // Slow %d using 14-period calculation and 3-period simple moving average (3-period sma of slow %k)

plotfk = plot(fastk,"Fast %k","line","000000") // Plot object for fast %k

plotfd = plot(fastd,"Fast %d","line","CC0033") // Plot object for fast %d

plotsk = plot(slowk,"Slow %k","line","00CC33") // Plot object for slow %k

plotsd = plot(slowd,"Slow %d","line","3300CC") // Plot object for slow %d

chart(plotfk,plotfd,plotsk,plotsd) // Plot fast %k, fast %d, slow %k, and slow %d in a clip

fastk = stochkd(x,14,3,"fast","k") // Fast %k using 14-period calculation and 3-period simple moving average (raw %k)

fastd = stochkd(x,14,3,"fast","d") // Fast %d using 14-period calculation and 3-period simple moving average (3-period sma of fast %k)

slowk = stochkd(x,14,3,"slow","k") // Slow %k using 14-period calculation and 3-period simple moving average

slowd = stochkd(x,14,3,"slow","d") // Slow %d using 14-period calculation and 3-period simple moving average (3-period sma of slow %k)

plotfk = plot(fastk,"Fast %k","line","000000") // Plot object for fast %k

plotfd = plot(fastd,"Fast %d","line","CC0033") // Plot object for fast %d

plotsk = plot(slowk,"Slow %k","line","00CC33") // Plot object for slow %k

plotsd = plot(slowd,"Slow %d","line","3300CC") // Plot object for slow %d

chart(plotfk,plotfd,plotsk,plotsd) // Plot fast %k, fast %d, slow %k, and slow %d in a clip

stochrsi(x:Data, rsiPeriod:Number, stochPeriod:Number):Array

Parameters

x:Data - Data object variable name whose Stochastic Relative Strength Index (STOCHRSI) is to be calculated.

rsiPeriod:Number - Relative Strength Index period value.

stochPeriod:Number - Stochastic Relative Strength Index period value.

rsiPeriod:Number - Relative Strength Index period value.

stochPeriod:Number - Stochastic Relative Strength Index period value.

Returns

Array - Stochastic Relative Strength Index (STOCHRSI) of Data object x.

Stochastic RSI is the result of a marriage of two indicators, Stochastics and the Relative Strength Index. Interpretation is simpler and clearer than for RSI alone. The general rules are the same as for RSI, Stochastics or any other over-bought / over-sold index. Divergence analysis is particularity useful. Mathematically Stochastic RSI is an n-period Stochastic of an m-period RSI. The defaults for n and m are usually 14. Please see Normalized RSI for our version of this approach in which RSI is normalized with Bollinger Bands. Stochastic RSI was written by Tushar Chande.

Returns the STOCHRSI of Data object x.

Returns the STOCHRSI of Data object x.

Example

data("x") // Use the data from the chart

rsiPer = 14 //rsi period

stochPer = 14 //stochastic rsi period

k = stochrsi(x,rsiPer,stochPer) //stochastic rsi for data object x using periods rsiPer and stochPer

d = ema(k, 3) //ema of stochrsi using period 3

kPlot = plot(k, "stochRSI %k", "line") //stoch rsi line plot object

dPlot = plot(d, "stochRSI %d", "line", "0000FF") //ema line plot object

highRef = plot(80, "overbought", "line", "FF0000") //overbought horizontal reference point

lowRef = plot(20, "oversold", "line", "00FF00") //oversold horizontal reference point

chart(kPlot, dPlot, highRef, lowRef) //chart stochrsi, its ema and the 2 reference lines in a single clip

rsiPer = 14 //rsi period

stochPer = 14 //stochastic rsi period

k = stochrsi(x,rsiPer,stochPer) //stochastic rsi for data object x using periods rsiPer and stochPer

d = ema(k, 3) //ema of stochrsi using period 3

kPlot = plot(k, "stochRSI %k", "line") //stoch rsi line plot object

dPlot = plot(d, "stochRSI %d", "line", "0000FF") //ema line plot object

highRef = plot(80, "overbought", "line", "FF0000") //overbought horizontal reference point

lowRef = plot(20, "oversold", "line", "00FF00") //oversold horizontal reference point

chart(kPlot, dPlot, highRef, lowRef) //chart stochrsi, its ema and the 2 reference lines in a single clip

tri(x:Data, q:Number, m:Number):Array

Parameters

x:Data - Data object variable name whose The Range Indicator (TRI) is to be calculated.

q:Number - Exponential moving average of Stochastic Range.

m:Number - Stochastic Range lookback period.

q:Number - Exponential moving average of Stochastic Range.

m:Number - Stochastic Range lookback period.

Returns

Array - True Range Indicator (TRI) of Data object x.

The Range Indicator (TRI) was published by Jack L. Weinberg in the June 1995 issue of *Technical Analysis of Stocks & Commodities*. The idea here is to compare high minus low (the range) with close versus the close (the change). Look for trends to start from low levels when range and change are in gear and end from high levels of TRI when range and change are out of gear.

Specify the Stochastic Range lookback period value using Number object q; specify the Stochastic Range exponential moving average period value using Number object m. If a decimal value is entered for q or m, the function will drop the decimal part and use the integer part as q or m in the calculation without warning.

Returns the TRI of Data object x.

Specify the Stochastic Range lookback period value using Number object q; specify the Stochastic Range exponential moving average period value using Number object m. If a decimal value is entered for q or m, the function will drop the decimal part and use the integer part as q or m in the calculation without warning.

Returns the TRI of Data object x.

Example

data("x") // Use the data from the chart

myTRI = tri(x,3,10) // Standard TRI values

plotTRI = plot(myTRI,"TRI","line","000000") // Plot object for myTRI

ref1 = plot(20,"","line","00CC00") // Reference line

ref2 = plot(70,"","line","FF0000") // Reference line

chart(plotTRI,ref1,ref2) // Plot myTRI with reference lines in a clip

myTRI = tri(x,3,10) // Standard TRI values

plotTRI = plot(myTRI,"TRI","line","000000") // Plot object for myTRI

ref1 = plot(20,"","line","00CC00") // Reference line

ref2 = plot(70,"","line","FF0000") // Reference line

chart(plotTRI,ref1,ref2) // Plot myTRI with reference lines in a clip

truerange(x:Data):Array

Parameters

x:Data - Data object variable name whose true range is to be calculated.

Returns

Array - True Range of Data object x.

Returns the true range Array of a Data object x as defined by the formula: if(high(x) < close(x)[-1], close(x)[-1], high(x)) - if(low(x) > close(x)[-1], close(x)[-1], low(x)).

Example

data("x")

truerangeArray = truerange(x)

print(truerangeArray)

truerangeArray = truerange(x)

print(truerangeArray)

uos(x:Data, p1:Number, p2:Number, p3:Number):Array

Parameters

x:Data - Data object variable name whose Ultimate Oscillator (UO) is to be calculated.

p1:Number - Ultimate Oscillator (UO) short period value.

p2:Number - Ultimate Oscillator (UO) intermediate period value.

p3:Number - Ultimate Oscillator (UO) long period value.

p1:Number - Ultimate Oscillator (UO) short period value.

p2:Number - Ultimate Oscillator (UO) intermediate period value.

p3:Number - Ultimate Oscillator (UO) long period value.

Returns

Array -

This is Larry Williams' weighted momentum oscillator. The Ultimate Oscillator (UO) is a combination of three different individual oscillators of varying time frames. This is usually one of the smoothest momentum tools. Specify the periods for the three underlying oscillators using Number object p1 (short), Number object p2 (intermediate), and Number object p3 (long). If a decimal value is entered for p1, p2 or p3, the function will drop the decimal part and use the integer part as p1, p2 or p3 in the calculation without warning.

Returns the UO of Data object x.

Returns the UO of Data object x.

Example

data("x") // Use the data from the chart

short_period = 7 // UO short period

intermediate_period = 28 // UO intermediate period

long_period = 91 // UO long period

myUO = uos(x,short_period,intermediate_period,long_period) // Calculate UO with short, intermediate and long periods

plotUO = plot(myUO,"UO (7,28,91)","line","000000") // Plot object for myUO

ref1 = plot(30,"","line","00CC00") // Reference line

ref2 = plot(70,"","line","FF0000") // Reference line

chart(plotUO,ref1,ref2) // Plot myUO with reference lines in a clip

short_period = 7 // UO short period

intermediate_period = 28 // UO intermediate period

long_period = 91 // UO long period

myUO = uos(x,short_period,intermediate_period,long_period) // Calculate UO with short, intermediate and long periods

plotUO = plot(myUO,"UO (7,28,91)","line","000000") // Plot object for myUO

ref1 = plot(30,"","line","00CC00") // Reference line

ref2 = plot(70,"","line","FF0000") // Reference line

chart(plotUO,ref1,ref2) // Plot myUO with reference lines in a clip

vhf(x:Data, period:Number):Array

Parameters

x:Data - Data object variable name whose Vertical Horizontal Filter (VHF) is to be calculated.

period:Number - Vertical Horizontal Filter (VHF) period value.

period:Number - Vertical Horizontal Filter (VHF) period value.

Returns

Array - Vertical Horizontal Filter (VHF) of Data object x.

Vertical Horizontal Filter (VHF), Tushar Chande's trend analysis tool, compares the distance traveled within a range to the range itself. In a perfectly trending market the distance traveled and the range will be the same. The formula is range/distance. As it takes more and more travel to cover the range, the value of VHF falls. Specify the VHF period value using Number object period. If a decimal value is entered for period, the function will drop the decimal part and use the integer part as the period in the calculation without warning.

Returns the VHF of Data object x.

Returns the VHF of Data object x.

Example

data("x") // Use the data from the chart

myVHF1 = vhf(x,14) // 14-period VHF

myVHF2 = vhf(x,50) // 50-period VHF

plotVHF1 = plot(myVHF1,"14-Period VHF","line","000000") // Plot object for myVHF1

plotVHF2 = plot(myVHF2,"50-Period VHF","line","00CC00") // Plot object for myVFH2

chart(plotVHF1,plotVHF2) // Plot myVHF1 and myVHF2 in a clip

myVHF1 = vhf(x,14) // 14-period VHF

myVHF2 = vhf(x,50) // 50-period VHF

plotVHF1 = plot(myVHF1,"14-Period VHF","line","000000") // Plot object for myVHF1

plotVHF2 = plot(myVHF2,"50-Period VHF","line","00CC00") // Plot object for myVFH2

chart(plotVHF1,plotVHF2) // Plot myVHF1 and myVHF2 in a clip

vos(x:Data, period1:Number, period2:Number):Array

Parameters

x:Data - Data object variable name whose Volume Oscillator (VO) is to be calculated.

period1:Number - Volume Oscillator (VO) short period value.

period2:Number - Volume Oscillator (VO) long period value.

period1:Number - Volume Oscillator (VO) short period value.

period2:Number - Volume Oscillator (VO) long period value.

Returns

Array - Volume Oscillator (VO) of Data object x.

The Volume Oscillator (VO) considers nothing but volume. It is the difference between a short moving average of volume and a longer one. It is used to confirm volume patterns in relation to price patterns. Specify the short period value with Number object period1 and the long period value with Number object period2. If a decimal value is entered for period1 or period2, the function will drop the decimal part and use the integer part as period1 or period2 in the calculation without warning.

Returns the VO of Data object x.

Returns the VO of Data object x.

Example

data("x") // Use the data from the chart

myVO = vos(x,20,50) // Compute Volume Oscillator (VO) using 20- and 50-day periods

plotVO = plot(myVO,"VO (20,50)","histogram") // Plot object for myVO

chart(plotVO) // Plot myVO in a clip

myVO = vos(x,20,50) // Compute Volume Oscillator (VO) using 20- and 50-day periods

plotVO = plot(myVO,"VO (20,50)","histogram") // Plot object for myVO

chart(plotVO) // Plot myVO in a clip

vpci(x:Data, shortPeriod:Number, longPeriod:Number):Array

Parameters

x:Data - Data object variable name whose volume price confirmation indicator is to be calculated.

shortPeriod:Number - VPCI short period.

longPeriod:Number - VPCI long period.

shortPeriod:Number - VPCI short period.

longPeriod:Number - VPCI long period.

Returns

Array - Volume price confirmation indicator array.

This function will return the volume price confirmation indicator array using the short and long periods provided (shortPeriod and longPeriod respectively).

VPCI is Buff Dormeier's effort to codify the old technical analysis concept of price-volume confirmation in a technical indicator. VPCI won the Dow Award in 2007. You can read the paper complete with examples of usage here. http://tinyurl.com/8clzjhq

There are four price/volume confirmation possibilities that this indicator encompasses:

Rising price and volume, strong demand, bullish.

Falling price and volume, weak supply, bullish.

Rising price and falling volume, weak demand, bearish.

Falling price and rising volume, strong supply, bearish.

VPCI is Buff Dormeier's effort to codify the old technical analysis concept of price-volume confirmation in a technical indicator. VPCI won the Dow Award in 2007. You can read the paper complete with examples of usage here. http://tinyurl.com/8clzjhq

There are four price/volume confirmation possibilities that this indicator encompasses:

Rising price and volume, strong demand, bullish.

Falling price and volume, weak supply, bullish.

Rising price and falling volume, weak demand, bearish.

Falling price and rising volume, strong supply, bearish.

Example

data("x") // Use the data from the chart

vpci_array = vpci(x,5,20) // VPCI short period 5, long period 20

plotVPCI = plot(vpci_array,"VPCI","line","000000") // Plot object for vpci

chart(plotVWMA) // Plot VPCI short period 5, long period 20 in a indicator clip

vpci_array = vpci(x,5,20) // VPCI short period 5, long period 20

plotVPCI = plot(vpci_array,"VPCI","line","000000") // Plot object for vpci

chart(plotVWMA) // Plot VPCI short period 5, long period 20 in a indicator clip

vwma(x:Data, p1:Number):Array

Parameters

x:Data - Data object variable name whose volume weight moving average is to be calculated.

p1:Number - Volume weighted moving average period value.

p1:Number - Volume weighted moving average period value.

Returns

Array - Volume weighted moving average array.

This function will return the volume weighted moving average array to the period p1 specified.

The volume weighted moving average is the average price weighted by volume.

The volume weighted moving average is the average price weighted by volume.

Example

data("x") // Use the data from the chart

vwma_array = vwma(x,20) // 20-period volume weighted moving average

plotVWMA = plot(vwma_array,"VWMA","line","000000") // Plot object for vwma

pchart(plotVWMA) // Plot 20-period vwma on price chart

vwma_array = vwma(x,20) // 20-period volume weighted moving average

plotVWMA = plot(vwma_array,"VWMA","line","000000") // Plot object for vwma

pchart(plotVWMA) // Plot 20-period vwma on price chart

vwmacd(x:Data, p1:Number, p2:Number, p3:Number, series:String["vwmacd","signal"]):Array

Parameters

x:Data - Data object variable name whose Volume-Weighted Moving Average Convergence-Divergence (VWMACD) is to be computed.

p1:Number - Short period value.

p2:Number - Long period value.

p3:Number - Signal period value.

series:String["vwmacd","signal"] - String to specify what is to be returned. Must be one of "vwmacd" or "signal" for Volume-Weighted Moving Average Convergence-Divergence (VWMACD) or Signal line, respectively.

p1:Number - Short period value.

p2:Number - Long period value.

p3:Number - Signal period value.

series:String["vwmacd","signal"] - String to specify what is to be returned. Must be one of "vwmacd" or "signal" for Volume-Weighted Moving Average Convergence-Divergence (VWMACD) or Signal line, respectively.

Returns

Array - If "vmacd" is specified for series, the Volume-Weighted Moving Average Convergence-Divergence of Data object x.

If "signal" is specified for series, the VWMACD Signal of Data object x.

If "signal" is specified for series, the VWMACD Signal of Data object x.

Volume-Weighted Moving Average Convergence-Divergence (VWMACD) was created by Buff Domeier and uses the same calculation as Moving Average Convergence-Divergence (MACD), but volume-weighted averages are used instead of exponential averages. Treat exactly as you would MACD. Specify the fast period using Number object p1, specify the slow period using Number object p2, and specify the signal period using Number object p3. If a decimal value is entered for p1, p2 or p3, the function will drop the decimal part and use the integer part for p1, p2 or p3 in the calculation without warning.

Returns the VWMACD curve of Data object x if "vwmacd" is specified by String object type, or returns the VWMACD Signal line of Data object x if "signal" is specified by String object type.

Returns the VWMACD curve of Data object x if "vwmacd" is specified by String object type, or returns the VWMACD Signal line of Data object x if "signal" is specified by String object type.

Example

data("x") // Use the data from the chart

myVWMACDcurve = vwmacd(x,24,50,12,"vwmacd") // VWMACD curve using 24- and 50-day exponential moving averages and 12-day signal line

myVWMACDsignal = vwmacd(x,24,50,12,"signal") // Signal line using 24-day and 50-day exponential moving averages and 12-day signal line

VWMACDdiff = myVWMACDcurve - myVWMACDsignal // Difference between VWMACD curve and VWMACD Signal line

plotVWMACDcurve = plot(myVWMACDcurve,"VWMACD","line","000000") // Plot object for myVWMACDcurve

plotVWMACDsignal = plot(myVWMACDsignal,"Signal","line","FF0000") // Plot object for myVWMACDsignal

plotVWMACDdiff = plot(VWMACDdiff,"Difference","histogram") // Plot object for VWMACDdiff

chart(plotVWMACDcurve,plotVWMACDsignal,plotVWMACDdiff) // Plot myVWMACDcurve, myVWMACDsignal and VWMACDdiff in a clip

myVWMACDcurve = vwmacd(x,24,50,12,"vwmacd") // VWMACD curve using 24- and 50-day exponential moving averages and 12-day signal line

myVWMACDsignal = vwmacd(x,24,50,12,"signal") // Signal line using 24-day and 50-day exponential moving averages and 12-day signal line

VWMACDdiff = myVWMACDcurve - myVWMACDsignal // Difference between VWMACD curve and VWMACD Signal line

plotVWMACDcurve = plot(myVWMACDcurve,"VWMACD","line","000000") // Plot object for myVWMACDcurve

plotVWMACDsignal = plot(myVWMACDsignal,"Signal","line","FF0000") // Plot object for myVWMACDsignal

plotVWMACDdiff = plot(VWMACDdiff,"Difference","histogram") // Plot object for VWMACDdiff

chart(plotVWMACDcurve,plotVWMACDsignal,plotVWMACDdiff) // Plot myVWMACDcurve, myVWMACDsignal and VWMACDdiff in a clip

williams(x:Data, period:Number):Array

Parameters

x:Data - Data object variable name whose Williams %R is to be calculated.

period:Number - Williams %R period value.

period:Number - Williams %R period value.

Returns

Array - Williams %R of Data object x.

This is a variation of Stochastics that some prefer. Williams %R depicts where you are in the range of the past *n*-days without smoothing. Note that the scale is reversed from that for Stochastics. Specify the %R period value using Number object period. If a decimal value is entered for period, the function will drop the decimal part and use the integer part as the period in the calculation without warning.

Returns %R of Data object x.

Returns %R of Data object x.

Example

data("x") // Use the data from the chart

myR1 = williams(x,5) // 5-period %R

myR2 = williams(x,21) // 21-period %R

myR3 = williams(x,50) // 50-period %R

plotR1 = plot(myR1,"5-period %R","line","000000") // Plot object for myR1

plotR2 = plot(myR2,"21-period %R","line","00CC00") // Plot object for myR2

plotR3 = plot(myR3,"50-period %R","line","FF0000") // Plot object for myR3

ref20 = plot(-20,"","line","808080") // Reference line at -20

ref80 = plot(-80,"","line","808080") // Reference line at -80

chart(plotR1,plotR2,plotR3,ref20,ref80) // Plot myR1, myR2, and myR3 with reference lines in a clip

myR1 = williams(x,5) // 5-period %R

myR2 = williams(x,21) // 21-period %R

myR3 = williams(x,50) // 50-period %R

plotR1 = plot(myR1,"5-period %R","line","000000") // Plot object for myR1

plotR2 = plot(myR2,"21-period %R","line","00CC00") // Plot object for myR2

plotR3 = plot(myR3,"50-period %R","line","FF0000") // Plot object for myR3

ref20 = plot(-20,"","line","808080") // Reference line at -20

ref80 = plot(-80,"","line","808080") // Reference line at -80

chart(plotR1,plotR2,plotR3,ref20,ref80) // Plot myR1, myR2, and myR3 with reference lines in a clip

wynia(x:Data, threshold:Number):Array

Parameters

x:Data - Data object variable name whose Wynia Volume Profile (WVP) is to be calculated.

threshold:Number - Zig zag price filter threshold in percent

threshold:Number - Zig zag price filter threshold in percent

Returns

Array - Wynia Volume Profile (WVP) of Data object x.

The Wynia Volume Profile (WVP) was developed by Fred Wynia and uses a zig zag function to filter price and then compares the volume in up swings versus down swings. The function computes the ratio of the volume in the up swings to the volume in the down swings or vice versa.

The calculation is performed daily and the function returns the daily data in an Array object.

The calculation is performed daily and the function returns the daily data in an Array object.

Example

data("x") // Use the data from the chart

threshold = 5; // Set the zig zag price filter to 5%

myWVP = wynia(x,threshold) // Get the Wynia Volume Profile (WVP)

myWVPplot = plot(myWVP,"myWVP","line","000000") // Create a plot object

chart(myWVPplot) // Plot myWVP in a clip

threshold = 5; // Set the zig zag price filter to 5%

myWVP = wynia(x,threshold) // Get the Wynia Volume Profile (WVP)

myWVPplot = plot(myWVP,"myWVP","line","000000") // Create a plot object

chart(myWVPplot) // Plot myWVP in a clip

and(x:Array or Number, y:Array or Number):Array or Number

Parameters

x:Array or Number - First logical state parameter for AND expression.

y:Array or Number - Second logical state parameter for AND expression.

y:Array or Number - Second logical state parameter for AND expression.

Returns

Evaluates the logical AND of x and y and returns the logical result 1 for true, 0 for false.

Example

a = and(1,0)

print(a)

b = and(1,1]

print(b)

print(a)

b = and(1,1]

print(b)

not(x:Array or Number):Array or Number

Parameters

Returns

Returns the logical opposite of x: !x.

Example

bool = 0

reverseBool = !bool

print(reverseBool)

reverseBool = !bool

print(reverseBool)

or(x:Array or Number, y:Array or Number):Array or Number

Parameters

x:Array or Number - First logical state parameter for OR expression.

y:Array or Number - Second logical state parameter for OR expression.

y:Array or Number - Second logical state parameter for OR expression.

Returns

Evaluates the logical OR of x and y and returns the logical result 1 for true, 0 for false.

Example

a = or(1,0)

print(a)

b = or(0,0)

print(b)

print(a)

b = or(0,0)

print(b)

equal(x:Array or Number or String, y:Array or Number or String):Array or Number

Parameters

x:Array or Number or String - Left side value to compare to right side value.

y:Array or Number or String - Right side value to compare to left side value.

y:Array or Number or String - Right side value to compare to left side value.

Returns

if(x equals to y) returns 1, otherwise returns 0.

Example

isEqual = equal(3,3)

print(isEqual)

print(isEqual)

greater(x:Array or Number or String, y:Array or Number or String):Array or Number

Parameters

x:Array or Number or String - Left side value to compare to right side value.

y:Array or Number or String - Right side value to compare to left side value.

y:Array or Number or String - Right side value to compare to left side value.

Returns

if(x greater than y) returns 1, otherwise returns 0.

Example

isGreater = greater(5,4)

print(isGreater)

print(isGreater)

greaterorequal(x:Array or Number or String, y:Array or Number or String):Array or Number

Parameters

x:Array or Number or String - Left side value to compare to right side value.

y:Array or Number or String - Right side value to compare to left side value.

y:Array or Number or String - Right side value to compare to left side value.

Returns

if(x greater than or equal to y) returns 1, otherwise returns 0.

Example

isGreaterOrEqual = greaterorequal(5,4)

print(isGreaterOrEqual)

print(isGreaterOrEqual)

less(x:Array or Number or String, y:Array or Number or String):Array or Number

x:Array or Number or String - Left side value to compare to right side value.

y:Array or Number or String - Right side value to compare to left side value.

Parameters

y:Array or Number or String - Right side value to compare to left side value.

Returns

if(x less than y) returns 1, otherwise returns 0.

Example

isLess = less(5,4)

print(isLess)

print(isLess)

lessorequal(x:Array or Number or String, y:Array or Number or String):Array or Number

x:Array or Number or String - Left side value to compare to right side value.

y:Array or Number or String - Right side value to compare to left side value.

Parameters

y:Array or Number or String - Right side value to compare to left side value.

Returns

if(x less than or equal to y) returns 1, otherwise returns 0.

Example

isLessOrEqual = greaterorequal(3,4)

print(isLessOrEqual)

print(isLessOrEqual)

notequal(x:Array or Number or String, y:Array or Number or String):Array or Number

x:Array or Number or String - Left side value to compare to right side value.

y:Array or Number or String - Right side value to compare to left side value.

Parameters

y:Array or Number or String - Right side value to compare to left side value.

Returns

if(x not equal to y) returns 1, otherwise returns 0.

Example

isNotEqual = notequal(3,3)

print(isNotEqual)

print(isNotEqual)

if(x:Array or Number, y:Array or Number, z:Array or Number):Array or Number

Parameters

x:Array or Number - Logical state to check whether it is true or false.

y:Array or Number - Result to be returned if true.

z:Array or Number - Result to be returned if false.

y:Array or Number - Result to be returned if true.

z:Array or Number - Result to be returned if false.

Returns

Conditional statement, checks for x, returns y if x is true, z if x is false.

Example

true = 5

false = -5

a = if(1,true,false)

print(a)

false = -5

a = if(1,true,false)

print(a)

else():null

Parameters

Returns

null - This function takes no parameter and has no returned value.

Used in a conditional block within a manual iteration block as a last option after all preceding startif or elseif function are skipped (their conditions were not met).
else will always execute the next statements without any condition unless a previous startif or elseif condition is met. Only one else statement can be used within a manual conditional block and the block has to always be initialized by a startif function.
This function will only run inside a manual iteration block. For conditional statements outside an iteration block, use the if function.

Example

//create random array and check probabilities of number above 0.5 and below

rnd = randomarray() //create random array of numbers

len = length(rnd) //get length of array

above =0 //initialize number of occurrences above 0.5 to 0

below=0 //initialize number of occurrences below 0.5 to 0

i=0 //initialize iterator index to 0 (array index starts at 0)

iterate(len) //repeat throughout the array length

startif(greaterorequal(rnd[i],0.5)) //if current value is greater than or equal to 0.5

above =above+1 //increment above

else() //otherwise

below=below+1 //increment below

endif() //end conditional block

i=i+1 //increment iterator index

end() //end repeating block

percentAbove = above/(above+below)*100 //get percentage of occurrences above 0.5

percentBelow = below/(above+below)*100 //get percentage of occurrences below 0.5

print("above 0.5: ",percentAbove,"%") //print percentage of occurrences above 0.

print("below 0.5: ",percentBelow,"%") //print percentage of occurrences below 0.5

rnd = randomarray() //create random array of numbers

len = length(rnd) //get length of array

above =0 //initialize number of occurrences above 0.5 to 0

below=0 //initialize number of occurrences below 0.5 to 0

i=0 //initialize iterator index to 0 (array index starts at 0)

iterate(len) //repeat throughout the array length

startif(greaterorequal(rnd[i],0.5)) //if current value is greater than or equal to 0.5

above =above+1 //increment above

else() //otherwise

below=below+1 //increment below

endif() //end conditional block

i=i+1 //increment iterator index

end() //end repeating block

percentAbove = above/(above+below)*100 //get percentage of occurrences above 0.5

percentBelow = below/(above+below)*100 //get percentage of occurrences below 0.5

print("above 0.5: ",percentAbove,"%") //print percentage of occurrences above 0.

print("below 0.5: ",percentBelow,"%") //print percentage of occurrences below 0.5

elseif(x:Number):null

Parameters

x:Number - Logical state to check whether it is true or false

Returns

null - This function has no returned value.

Used in a conditional block within a manual iteration block after a preceding startif or elseif function is skipped (their conditions were not met).
elseif will check for x and executes next statements if x is true, otherwise it will skip them and move on to the next elseif or else function call. Multiple elseif statements can be used within a block as long as they are preceded by a starting startif function.
This function will only run inside a manual iteration block. For conditional statements outside an iteration block, use the if function.

Example

//example how to find the maximum and minimum closing prices

data("x") //get data object

price_close = close(x) //get array of closing prices

max_price = 0 //initialize maximum price to zero

min_price = 2147483647 //initialize minimum price a very large number

len = length(price_close) //len is the size of the array

i=0 //initialize the iterator index to zero

iterate(len) //repeat the following statements len times

//start of conditional block

startif(greater(price_close[i],max_price)) //if the current price at index i is greater than the current max price

max_price = price_close[i] //update the maximum price

elseif(less(price_close[i],min_price)) //if the current price at index i is less than the current min price

min_price = price_close[i] //update the minimum price

endif() //end of conditional block

i=i+1 //increment main loop iterator index

end() //end of the main repeating block

print("maximum price:",max_price) //print maximum price computed

print("minimum price:",min_price) //print minimum price computed

data("x") //get data object

price_close = close(x) //get array of closing prices

max_price = 0 //initialize maximum price to zero

min_price = 2147483647 //initialize minimum price a very large number

len = length(price_close) //len is the size of the array

i=0 //initialize the iterator index to zero

iterate(len) //repeat the following statements len times

//start of conditional block

startif(greater(price_close[i],max_price)) //if the current price at index i is greater than the current max price

max_price = price_close[i] //update the maximum price

elseif(less(price_close[i],min_price)) //if the current price at index i is less than the current min price

min_price = price_close[i] //update the minimum price

endif() //end of conditional block

i=i+1 //increment main loop iterator index

end() //end of the main repeating block

print("maximum price:",max_price) //print maximum price computed

print("minimum price:",min_price) //print minimum price computed

end():null

Parameters

Returns

null - This function takes no parameter and has no returned value.

This function serves as the marker for the end of a repeating block of statements. It cannot be placed anywhere else in the block. It closes a manual block of iterations and must be paired with an iterate function call.

Example

data("x") //get data

c=close(x) //get array of closes

d=date(x) //get array of dates

i=0 //initialize iterator index to the start index of the arrays above which is zero

iterate(length(c)) //repeat the statements within this block as many times as there are elements in the array of closing prices

print(d[i]," ",c[i]) //print the date and closing price of the current index i separated by a comma

i=i+1 //increment the iterator index so on the next iteration, the next index in the array will be displayed

end() //this is where the repeating block ends

c=close(x) //get array of closes

d=date(x) //get array of dates

i=0 //initialize iterator index to the start index of the arrays above which is zero

iterate(length(c)) //repeat the statements within this block as many times as there are elements in the array of closing prices

print(d[i]," ",c[i]) //print the date and closing price of the current index i separated by a comma

i=i+1 //increment the iterator index so on the next iteration, the next index in the array will be displayed

end() //this is where the repeating block ends

endif():null

Parameters

Returns

null - This function takes no parameter and has no returned value.

Marks the end of a conditional block inside a manual iteration.
This function must be paired with a startif function and must be placed no where except at the end of a conditional block.
No additional else or elseif statement is allowed after an endif call unless that call is initialized by a startif function call.

Example

//example how to find the maximum closing price

data("x") //get data object

price_close = close(x) //get array of closing prices

max_price = 0 //initialize maximum price to zero

len = length(price_close) //len is the size of the array

i=0 //initialize the iterator index to zero

iterate(len) //repeat the following statements len times

//start of conditional block

startif(greater(price_close[i],max_price)) //if the current price at index i is greater than the current max price

max_price = price_close[i] //update the maximum price

endif() //end of conditional block

i=i+1 //increment main loop iterator index

end() //end of the main repeating block

print(max_price) //print maximum price computed

data("x") //get data object

price_close = close(x) //get array of closing prices

max_price = 0 //initialize maximum price to zero

len = length(price_close) //len is the size of the array

i=0 //initialize the iterator index to zero

iterate(len) //repeat the following statements len times

//start of conditional block

startif(greater(price_close[i],max_price)) //if the current price at index i is greater than the current max price

max_price = price_close[i] //update the maximum price

endif() //end of conditional block

i=i+1 //increment main loop iterator index

end() //end of the main repeating block

print(max_price) //print maximum price computed

iterate(n:Number):null

Parameters

n:Number - Number of times the inside statements will be iterated

Returns

null - This function has no returned value.

Creates a repeating block of statements according to the specified number of times n passed.
It is similar to a "for" loop in standard programming languages.
Every "iterate" call must be paired with an end call.
A maximum of 2 other manual iterations can be nested within a manual iteration.
No array functions can be used within an iterate block. On each iteration, the statements within the block will run on a specified index of an array.
Given an array "my_array", when the iterator index "i" is 0, then "my_array[i]" will be interpreted as the first point in the array "my_array" where array indices always start at zero.
Ideally this is used for recursive procedures like the "On Balance Volume" indicator or "Bollinger Bands" manual implementation.

Example

//example to print out dates and their prices sequentially

data("x") //get data

c=close(x) //get array of closes

d=date(x) //get array of dates

i=0 //initialize iterator index to the start index of the arrays above which is zero

iterate(length(c)) //repeat the statements within this block as many times as there are elements in the array of closing prices

print(d[i]," ",c[i]) //print the date and closing price of the current index i separated by a comma

i=i+1 //increment the iterator index so on the next iteration, the next index in the array will be displayed

end() //this is where the repeating block ends

data("x") //get data

c=close(x) //get array of closes

d=date(x) //get array of dates

i=0 //initialize iterator index to the start index of the arrays above which is zero

iterate(length(c)) //repeat the statements within this block as many times as there are elements in the array of closing prices

print(d[i]," ",c[i]) //print the date and closing price of the current index i separated by a comma

i=i+1 //increment the iterator index so on the next iteration, the next index in the array will be displayed

end() //this is where the repeating block ends

startif(x:Number):null

Parameters

x:Number - Logical state to check whether it is true or false

Returns

null - This function has no returned value.

Initializes a conditional block inside a manual iteration block.
This function will only run inside a manual iteration block. For conditional statements outside an iteration block, use the if function.
This function will check for the value of x and executes next statements if true, otherwise it will skip them and move on to the next elseif or else statement if available.
An error is issued if this function is not paired with an endif.

Example

//example how to find the maximum closing price

data("x") //get data object

price_close = close(x) //get array of closing prices

max_price = 0 //initialize maximum price to zero

len = length(price_close) //len is the size of the array

i=0 //initialize the iterator index to zero

iterate(len) //repeat the following statements len times

//start of conditional block

startif(greater(price_close[i],max_price)) //if the current price at index i is greater than the current max price

max_price = price_close[i] //update the maximum price

endif() //end of conditional block

i=i+1 //increment main loop iterator index

end() //end of the main repeating block

print(max_price) //print maximum price computed

data("x") //get data object

price_close = close(x) //get array of closing prices

max_price = 0 //initialize maximum price to zero

len = length(price_close) //len is the size of the array

i=0 //initialize the iterator index to zero

iterate(len) //repeat the following statements len times

//start of conditional block

startif(greater(price_close[i],max_price)) //if the current price at index i is greater than the current max price

max_price = price_close[i] //update the maximum price

endif() //end of conditional block

i=i+1 //increment main loop iterator index

end() //end of the main repeating block

print(max_price) //print maximum price computed

acos(x:Array or Number):Array or Number

Parameters

Returns

Calculates and returns the arc cosine for x, in radians.

Example

a = acos(0.5)

print(a)

print(a)

asin(x:Array or Number):Array or Number

Parameters

Returns

Calculates and returns the arc sine for x, in radians.

Example

a = asin(0.5)

print(a)

print(a)

atan(x:Array or Number):Array or Number

Parameters

Returns

Calculates and returns the value, in radians, of the angle whose tangent is specified in x.

Example

a = atan(1)

print(a)

print(a)

atan2(y:Array or Number, x:Array or Number):Array or Number

Parameters

Returns

Calculates and returns the angle of the point y/x in radians, when measured counterclockwise from a circle's x axis (where 0,0 represents the center of the circle).

Example

a = atan2(1,0.5)

print(a)

print(a)

ceil(x:Array or Number):Array or Number

Parameters

Returns

Returns the ceiling (round up) of the specified value x.

Example

a = 1.55

print(ceil(a))

print(ceil(a))

cos(x:Array or Number):Array or Number

Parameters

Returns

Returns the cosine of angle x where x is in radians.

Example

a = cos(PI)

print(a)

print(a)

ceil(x:Array or Number):Array or Number

Parameters

Returns

Returns the ceiling (round up) of the specified value x.

Example

a = 1.55

print(ceil(a))

print(ceil(a))

abs(x:Array or Number):Array or Number

Parameters

Returns

Returns the absolute value of x.

Example

a = -2

print(abs(a))

print(abs(a))

exp(x:Array or Number):Array or Number

Parameters

Returns

Returns the value of the base of the natural logarithm (e), to the power of x.

Example

a = exp(2)

print(a)

print(a)

max(x:Array or Number, y:Array or Number):Array or Number

Parameters

x:Array or Number - Value to be returned if it is the maximum among the parameters passed.

y:Array or Number - Value to be returned if it is the maximum among the parameters passed.

y:Array or Number - Value to be returned if it is the maximum among the parameters passed.

Returns

Returns the maximum of x and y.

Example

a = max(3.5,3.7)

print(a)

print(a)

min(x:Array or Number, y:Array or Number):Array or Number

Parameters

x:Array or Number - Value to be returned if it is the minimum among the parameters passed.

y:Array or Number - Value to be returned if it is the minimum among the parameters passed.

y:Array or Number - Value to be returned if it is the minimum among the parameters passed.

Returns

Returns the minimum of x and y.

Example

a = min(3.9,3.7)

print(a)

print(a)

mod(x:Array or Number, y:Array or Number):Array or Number

Parameters

Returns

Returns the remainder of the division x/y.

Example

remainder = mod(5,4)

print(remainder)

print(remainder)

pow(x:Array or Number, y:Array or Number):Array or Number

Parameters

Returns

Calculates and returns x to the power of y.

Example

a = pow(2,5)

print(a)

print(a)

array(x:Number):Array

Parameters

x:Number - Number to initialize all Array values to.

Returns

Array - Array object.

Creates and returns an Array of length same as time series and initializes all elements to x.

Example

myArray = array(10)

print(myArray)

print(myArray)

counter(x:Array):Array

Parameters

x:Array - Array whose corresponding increasing counter Array is to be returned.

Returns

Array - Array of increasing values.

Returns an Array of increasing values 0,1,2,3, length of Array x, (each value corresponds to the index of Array x) while discarding leading and trailing NaN.

Example

data("x")

myClose = close(x)

myCounter = counter(myClose)

print(myCounter)

myClose = close(x)

myCounter = counter(myClose)

print(myCounter)

length(x:Array):Number

Parameters

x:Array - Array whose total number of elements is to be returned.

Returns

Number - Size of Array x.

Returns the total length of Array x excluding leading and trailing NaN.

Example

data("x")

myClose = close(x)

totalQuotes = length(myClose)

print(totalQuotes)

myClose = close(x)

totalQuotes = length(myClose)

print(totalQuotes)

randomarray():Array

Parameters

Returns

Array - Array of random numbers between 0 and 1.

Returns a random Array of length same as time series with different pseudo-random Numbers n[i], where 0 <= n[i] < 1.

Example

myRandomArray = randomarray()

print(myRandomArray)

print(myRandomArray)

replacenan(array_with_NaN:Array, replacement_of_NaN:Number or Array):Array

Parameters

array_with_NaN:Array - Array with NaN values that need to be replaced with a scalar value or corresponding values from another array

replacement_of_NaN:Number or Array - The scalar number that will replace all NaN occurrences in the array specified or array whose corresponding elements will replace NaN occurrences in input array

replacement_of_NaN:Number or Array - The scalar number that will replace all NaN occurrences in the array specified or array whose corresponding elements will replace NaN occurrences in input array

Returns

Array - Original input array with all NaN occurrences replaced by a scalar number or corresponding values from another array

Replaces all NaN occurrences in an input array "array_with_NaN" which are never plotted in a chart with a scalar number "replacement_of_NaN" or when an array replacement is used, the corresponding elements of the second array will replace the NaN occurrences in the input array.

Example

data("x") //data object

sma200_array_with_NaN = sma(close(x),200) //200 day moving average

sma200_array_with_zero_replacement = replacenan(sma200_array_with_NaN,0) //replace missing data (NaN) in first 199 elements with 0

plotSMAWithZero=plot(sma200_array_with_zero_replacement, "sma_0","line","ff0000") //create plot for sma with NaN replaced with 0

sma200_array_with_close_replacement = replacenan(sma200_array_with_NaN,close(x)) //replace missing data (NaN) in first 199 elements with corresponding close values

plotSMAWithClose=plot(sma200_array_with_close_replacement, "sma_close", "line", "0000ff") //create plot for sma with NaN replaced with close values

pchart(plotSMAWithZero, plotSMAWithClose) //plot both sma with NaN replace by zero and close values in price chart

sma200_array_with_NaN = sma(close(x),200) //200 day moving average

sma200_array_with_zero_replacement = replacenan(sma200_array_with_NaN,0) //replace missing data (NaN) in first 199 elements with 0

plotSMAWithZero=plot(sma200_array_with_zero_replacement, "sma_0","line","ff0000") //create plot for sma with NaN replaced with 0

sma200_array_with_close_replacement = replacenan(sma200_array_with_NaN,close(x)) //replace missing data (NaN) in first 199 elements with corresponding close values

plotSMAWithClose=plot(sma200_array_with_close_replacement, "sma_close", "line", "0000ff") //create plot for sma with NaN replaced with close values

pchart(plotSMAWithZero, plotSMAWithClose) //plot both sma with NaN replace by zero and close values in price chart

absdev(x:Array, p:Number(optional)):Array or Number

Parameters

x:Array - Array whose absolute deviation is to be computed.

p:Number(optional) - Absolute deviation period.

p:Number(optional) - Absolute deviation period.

Returns

Returns the Array of moving absolute deviation with period p of Array x. First undefined p - 1 elements in Array are populated with NaN. When p not provided, returns the absolute deviation of the whole Array x.

Example

data("x")

myClose = close(x)

myAbsDev = absdev(myClose, 20)

print(myAbsDev)

myClose = close(x)

myAbsDev = absdev(myClose, 20)

print(myAbsDev)

ema(x:Array, p:Number(optional)):Array or Number

Parameters

x:Array - Array whose exponential moving average is to be computed.

p:Number(optional) - Exponential moving average period.

p:Number(optional) - Exponential moving average period.

Returns

Returns the Array of exponential moving average with period p of Array x. First undefined p - 1 elements in Array are populated with NaN. When p not provided, returns the exponential average of the whole Array x.

Example

data("x")

myClose = close(x)

myEMA = ema(myClose, 20)

print(myEMA)

myClose = close(x)

myEMA = ema(myClose, 20)

print(myEMA)

lwma(x:Array, n:Number):Array

Parameters

x:Array - Array whose linear weighted moving average is to be computed.

n:Number - Linear weighted moving average window length.

n:Number - Linear weighted moving average window length.

Returns

Array - Linear weighted moving average of Array x of window length n.

Returns the Array of linear weighted moving average of Array x using the linear weight coefficient window 1, 2, 3...n. n not be equal to zero. Each result in the array is calculated using the following formula: wmaArray[i] = (1*x[i-(n-1)] + 2*x[i -(n-2)] + ... n*x[i])/(1 + 2 + 3 + ... +n)

Example

data("x")

myClose = close(x)

myLWMA = lwma(myClose, 5)//compute linear weighted moving average using linear coefficients [1, 2, 3, 4, 5]

plotLWMA = plot(myLWMA,"lwma","line","ff00ff")//get the lwma plot

pchart(plotLWMA)//plot the lwma on the price chart

myClose = close(x)

myLWMA = lwma(myClose, 5)//compute linear weighted moving average using linear coefficients [1, 2, 3, 4, 5]

plotLWMA = plot(myLWMA,"lwma","line","ff00ff")//get the lwma plot

pchart(plotLWMA)//plot the lwma on the price chart

median(x:Array, p:Number(optional)):Array or Number

Parameters

Returns

Returns the moving Median (the middle value) of the moving sorted window (p elements) from Array x. First undefined p - 1 elements in Array are populated with NaN. When p not provided, returns the Median (the middle value) of the sorted values of the whole Array x.

Example

data("x")

myClose = close(x)

myCloseMedian = median(myClose,20)

print(myCloseMedian)

myClose = close(x)

myCloseMedian = median(myClose,20)

print(myCloseMedian)

movmax(x:Array, p:Number(optional)):Array or Number

Parameters

x:Array - Array whose moving maximum is to be computed.

p:Number(optional) - Period of moving maximum.

p:Number(optional) - Period of moving maximum.

Returns

Returns the Array of maximums in a moving window of period p from Array x. First undefined p - 1 elements in Array are populated with NaN. When p not provided, returns the maximum of Array x.

Example

data("x")

myClose = close(x)

myMovMax = movmax(myClose, 20)

print(myMovMax)

myClose = close(x)

myMovMax = movmax(myClose, 20)

print(myMovMax)

movmin(x:Array, p:Number(optional)):Array or Number

Parameters

x:Array - Array whose moving minimum is to be computed.

p:Number(optional) - Period of moving minimum.

p:Number(optional) - Period of moving minimum.

Returns

Returns the Array of minimums in a moving window of period p from Array x. First undefined p - 1 elements in Array are populated with NaN. When p not provided, returns the minimum of Array x.

Example

data("x")

myClose = close(x)

myMovMin = movmin(myClose, 20)

print(myMovMin)

myClose = close(x)

myMovMin = movmin(myClose, 20)

print(myMovMin)

movsum(x:Array, p:Number(optional)):Array or Number

Parameters

Returns

Creates and returns an Array of moving sums of period p for Array x. First undefined p - 1 elements in Array are populated with NaN. When p not provided, returns the total sum of elements in Array x.

Example

data("x")

myClose = close(x)

myMovSum = movsum(myClose, 20)

print(myMovSum)

myClose = close(x)

myMovSum = movsum(myClose, 20)

print(myMovSum)

since(x:Array, n:Number(optional)):Number

Parameters

x:Array - Array whose elements are to be checked for nth occurrence index of a true value from the end of the array.

n:Number(optional) - nth occurrence index of a true value to be looked for starting from the end of the array. Default is 1 when not passed.

n:Number(optional) - nth occurrence index of a true value to be looked for starting from the end of the array. Default is 1 when not passed.

Returns

Number - The index of the nth occurrence of a true value starting from the end of array x.

Returns the index of the nth occurrence of a true value starting from the end of array x. It returns -1 if the nth occurrence is not found. If n is not provided, the default value is 1. The function searches from the nth occurrence starting from the end of the array. A returned index of 0 implies the occurrence was at the last element in the array. An occurrence index of 7 implies the nth occurrence was at the 8th element from the end of the array. n can be between 1 and the length of the array.

Example

data("x")

lows = low(x)//array of lows

lops = if(less(lows, lows[1]),if(less(lows,lows[-1]),1,0),0)//get array of lops (low points)

print(since(lops,1))//get the latest occurrence of a lop (1st occurrence from the end of the lops array)

highs = high(x)//array of highs

hips = if(greater(highs, highs[1]),if(greater(highs,highs[-1]),1,0),0)//get array of hips (high points)

print(since(lops,5))//get the 5th latest occurrence of a hip (5th occurrence from the end of the hips array)

lows = low(x)//array of lows

lops = if(less(lows, lows[1]),if(less(lows,lows[-1]),1,0),0)//get array of lops (low points)

print(since(lops,1))//get the latest occurrence of a lop (1st occurrence from the end of the lops array)

highs = high(x)//array of highs

hips = if(greater(highs, highs[1]),if(greater(highs,highs[-1]),1,0),0)//get array of hips (high points)

print(since(lops,5))//get the 5th latest occurrence of a hip (5th occurrence from the end of the hips array)

sma(x:Array, p:Number(optional)):Array or Number

Parameters

x:Array - Array whose simple moving average is to be computed.

p:Number(optional) - Simple moving average period.

p:Number(optional) - Simple moving average period.

Returns

Returns the Array of simple moving average with period p of Array x. First undefined p - 1 elements in Array are populated with NaN. When p not provided, returns the simple average of the whole Array x.

Example

data("x")

myClose = close(x)

mySMA = sma(myClose, 20)

print(mySMA)

myClose = close(x)

mySMA = sma(myClose, 20)

print(mySMA)

stdev(x:Array, p:Number(optional)):Array or Number

Parameters

x:Array - Array whose standard deviation is to be computed.

p:Number(optional) - Standard deviation period.

p:Number(optional) - Standard deviation period.

Returns

Returns the Array of moving standard deviation with period p of Array x. First undefined p - 1 elements in Array are populated with NaN. When p not provided, returns the standard deviation of the whole Array x.

Example

data("x")

myClose = close(x)

myStDev = stdev(myClose, 20)

print(myStDev)

myClose = close(x)

myStDev = stdev(myClose, 20)

print(myStDev)

within(x:Array, p:Number(optional)):Array or Number

Parameters

x:Array - Array whose moving sum of true values is to be returned.

p:Number(optional) - Period of moving sum of true values.

p:Number(optional) - Period of moving sum of true values.

Returns

Returns Array of number of times x is true within p moving period. First undefined p - 1 elements in Array are populated with NaN. When p not provided, returns total number of times x is true in Array x.

Example

data("x")

myClose = close(x)

mySMA = sma(myClose, 20)

closeXoverSMA = xover(myClose,mySMA)

totalMovingXover = within(closeXoverSMA, 20)

print(totalMovingXover)

myClose = close(x)

mySMA = sma(myClose, 20)

closeXoverSMA = xover(myClose,mySMA)

totalMovingXover = within(closeXoverSMA, 20)

print(totalMovingXover)

wma(x:Array, c1:Number, c2:Number, c3:Number(optional), cn:Number(optional)):Array

Parameters

x:Array - Array whose weighted moving average is to be computed.

c1:Number - Moving window first weight coefficient.

c2:Number - Moving window second weight coefficient.

c3:Number(optional) - Moving window third weight coefficient.

cn:Number(optional) - Moving window nth weight coefficient.

c1:Number - Moving window first weight coefficient.

c2:Number - Moving window second weight coefficient.

c3:Number(optional) - Moving window third weight coefficient.

cn:Number(optional) - Moving window nth weight coefficient.

Returns

Array - Weighted moving average of Array x using the weight coefficient window c1, c2, c3...cn.

Returns the Array of weighted moving average of Array x using the weight coefficient window c1, c2, c3...cn. Up to 50 coefficients are allowed. At least 2 coefficients need to be specified. The sum of the coefficients should not be equal to zero. Each result in the array is calculated using the following formula: wmaArray[i] = (c1*x[i-(n-1)] + c2*x[i -(n-2)] + ... cn*x[i])/(c1 + c2 + c3 + ... +cn)

Example

data("x")

myClose = close(x)

myWMA = wma(myClose, 1,2,3,2,1)//compute weighted moving average using coefficients [1, 2, 3, 2, 1]

plotWMA = plot(myWMA,"wma","line","ff00ff")//get the wma plot

pchart(plotWMA)//plot the wma on the price chart

myClose = close(x)

myWMA = wma(myClose, 1,2,3,2,1)//compute weighted moving average using coefficients [1, 2, 3, 2, 1]

plotWMA = plot(myWMA,"wma","line","ff00ff")//get the wma plot

pchart(plotWMA)//plot the wma on the price chart

xover(x:Array, y:Array):Array

Parameters

x:Array - First Array to check for crossings over a second Array.

y:Array - Second Array to check for crossings under the first Array.

y:Array - Second Array to check for crossings under the first Array.

Returns

Array - Array of 1s where x crosses over y, 0s otherwise.

Returns Array of true values(1] when first Array crosses over second Array, false(0) otherwise as defined by the formula: AND( x > y, x[-1] < y[-1]). First undefined element of returned Array is NaN.

Example

data("x")

myClose = close(x)

mySMA = sma(myClose, 20)

closeXoverSMA = xover(myClose,mySMA)

print(closeXoverSMA)

myClose = close(x)

mySMA = sma(myClose, 20)

closeXoverSMA = xover(myClose,mySMA)

print(closeXoverSMA)

xunder(x:Array, y:Array):Array

Parameters

x:Array - First Array to check for crossings under a second Array.

y:Array - Second Array to check for crossings over the first Array.

y:Array - Second Array to check for crossings over the first Array.

Returns

Array - Array of 1s where x crosses under y, 0s otherwise.

Returns Array of true values(1] when first Array crosses under second Array, false(0) otherwise as defined by the formula: AND(x < y, x[-1] > y[-1]). First undefined element of returned Array is NaN.

Example

data("x")

myClose = close(x)

mySMA = sma(myClose, 20)

closeXunderSMA = xunder(myClose,mySMA)

print(closeXunderSMA)

myClose = close(x)

mySMA = sma(myClose, 20)

closeXunderSMA = xunder(myClose,mySMA)

print(closeXunderSMA)

chart(p1:Plot, p2:Plot(optional), p3:Plot(optional), p4:Plot(optional), p5:Plot(optional), p6:Plot(optional), p7:Plot(optional), p8:Plot(optional), p9:Plot(optional), p10:Plot(optional)):null

Parameters

p1:Plot - Plot object to be displayed in the indicator chart.

p2:Plot(optional) - Plot object to be displayed in the indicator chart.

p3:Plot(optional) - Plot object to be displayed in the indicator chart.

p4:Plot(optional) - Plot object to be displayed in the indicator chart.

p5:Plot(optional) - Plot object to be displayed in the indicator chart.

p6:Plot(optional) - Plot object to be displayed in the indicator chart.

p7:Plot(optional) - Plot object to be displayed in the indicator chart.

p8:Plot(optional) - Plot object to be displayed in the indicator chart.

p9:Plot(optional) - Plot object to be displayed in the indicator chart.

p10:Plot(optional) - Plot object to be displayed in the indicator chart.

p2:Plot(optional) - Plot object to be displayed in the indicator chart.

p3:Plot(optional) - Plot object to be displayed in the indicator chart.

p4:Plot(optional) - Plot object to be displayed in the indicator chart.

p5:Plot(optional) - Plot object to be displayed in the indicator chart.

p6:Plot(optional) - Plot object to be displayed in the indicator chart.

p7:Plot(optional) - Plot object to be displayed in the indicator chart.

p8:Plot(optional) - Plot object to be displayed in the indicator chart.

p9:Plot(optional) - Plot object to be displayed in the indicator chart.

p10:Plot(optional) - Plot object to be displayed in the indicator chart.

Returns

null - No returned value.

Draws the indicator chart for all parameter Plots(all in one chart), up to 10 plots can be plotted in one chart, returns null.

Example

data("x")

myPlot1 = plot(close(x))

myPlot2 = plot(20)

chart(myPlot1, myPlot2)

myPlot1 = plot(close(x))

myPlot2 = plot(20)

chart(myPlot1, myPlot2)

pchart(p1:Plot, p2:Plot(optional), p3:Plot(optional), p4:Plot(optional), p5:Plot(optional), p6:Plot(optional), p7:Plot(optional), p8:Plot(optional), p9:Plot(optional), p10:Plot(optional)):null

Parameters

p1:Plot - Plot object to be displayed in the price chart.

p2:Plot(optional) - Plot object to be displayed in the price chart.

p3:Plot(optional) - Plot object to be displayed in the price chart.

p4:Plot(optional) - Plot object to be displayed in the price chart.

p5:Plot(optional) - Plot object to be displayed in the price chart.

p6:Plot(optional) - Plot object to be displayed in the price chart.

p7:Plot(optional) - Plot object to be displayed in the price chart.

p8:Plot(optional) - Plot object to be displayed in the price chart.

p9:Plot(optional) - Plot object to be displayed in the price chart.

p10:Plot(optional) - Plot object to be displayed in the price chart.

p2:Plot(optional) - Plot object to be displayed in the price chart.

p3:Plot(optional) - Plot object to be displayed in the price chart.

p4:Plot(optional) - Plot object to be displayed in the price chart.

p5:Plot(optional) - Plot object to be displayed in the price chart.

p6:Plot(optional) - Plot object to be displayed in the price chart.

p7:Plot(optional) - Plot object to be displayed in the price chart.

p8:Plot(optional) - Plot object to be displayed in the price chart.

p9:Plot(optional) - Plot object to be displayed in the price chart.

p10:Plot(optional) - Plot object to be displayed in the price chart.

Returns

null - No returned value.

Draws all input Plots on the price chart, up to 10 Plots in one price chart can be plotted. If this function is called again, the previous call will be overwritten, returns null.

Example

data("x")

simpleMovingAvg = sma(close(x),20)

myPlot1 = plot(simpleMovingAvg)

pchart(myPlot1)

simpleMovingAvg = sma(close(x),20)

myPlot1 = plot(simpleMovingAvg)

pchart(myPlot1)

plot(x:Array or Number, name:String(optional), type:String(optional), color:String(optional), s:Array or Backtest(optional)):Plot

Parameters

x:Array or Number - Array or Number whose curve is to be drawn in a chart.

name:String(optional) - Plot label to be displayed in chart.

type:String(optional) - Type of curve (line or histogram).

color:String(optional) - 6 (no alpha channel RRGGBB) or 8 (alpha channel AARRGGBB) character hexadecimal String specifying the color of the curve.

s:Array or Backtest(optional) - Array of signals to be displayed on the curve (1 for buys, -1 for sells, 0 for none) or a Backtest object whose signals/stops are to be displayed along with their trade labels.

name:String(optional) - Plot label to be displayed in chart.

type:String(optional) - Type of curve (line or histogram).

color:String(optional) - 6 (no alpha channel RRGGBB) or 8 (alpha channel AARRGGBB) character hexadecimal String specifying the color of the curve.

s:Array or Backtest(optional) - Array of signals to be displayed on the curve (1 for buys, -1 for sells, 0 for none) or a Backtest object whose signals/stops are to be displayed along with their trade labels.

Returns

Plot - Plot object.

Creates and returns a Plot object for the Array or Number x of optional type ("line" or "histogram") where "line" is the default type, optional name of data line is "name" and optional color is "color" a string of 6 or 8 hexadecimal characters where black "000000" is the default, if 8 are passed the first 2 characters are the alpha channel (ff for opaque, 00 for fully transparent), the last 6 hex characters are the color channel. In the first example below a transparent black line is drawn and signals are anchored to that transparent line. The second plot is fully opaque. The third plot is a semi transparent red line. The fourth plot defaults to fully opaque when no alpha channel is specified and will draw a fully opaque green line. An optional signal Array s can be passed (values of 0,1,-1] where buy signals will be added on plot for values of 1 and sell signals for values of -1.

Example

data("x")

myPlot1 = plot(close(x),"close","line","00000000",signal(x))

myPlot2 = plot(volume(x),"volume","histogram","ff00ff00")

myPlot3 = plot(high(x),"highs","line","80ff0000")

myPlot4 = plot(low(x),"lows","line","00ff00")

//backtest example

// Use the close

myData = close(x)

// Set the length

period = 20

// Set the width

width = 2.0

// The middle band is a simple moving average

middleBB =sma(myData, period)

// The width is driven by standard deviation

volatility = stdev(myData, period)

// This is the upper band

upperBB = middleBB + width * volatility

// This is the lower band

lowerBB = middleBB - width * volatility

//long exit signal when high crosses above upper band

signal1 = -1*xover(high(x),upperBB)

//long entry signal when low crosses below upper band

signal2 = 1*xunder(low(x),lowerBB)

//combine long exit and entry signals

signal = signal1 + signal2

//use discrete trade with stops and no pyramiding system

system_type = 4

//use chandelier stops

stop_type = 0

//chandelier stop parameters

m = 10

n = 3

//run backtester, this should generate a trade report and summary in the backtester window

bt = backtest(x,signal,system_type, stop_type, m, n)

//create backtest signal/stops plot with their label

myPlot5=plot(myData,"signals","line","00000000",bt)

//display signals and their labels in price chart

pchart(myPlot5)

myPlot1 = plot(close(x),"close","line","00000000",signal(x))

myPlot2 = plot(volume(x),"volume","histogram","ff00ff00")

myPlot3 = plot(high(x),"highs","line","80ff0000")

myPlot4 = plot(low(x),"lows","line","00ff00")

//backtest example

// Use the close

myData = close(x)

// Set the length

period = 20

// Set the width

width = 2.0

// The middle band is a simple moving average

middleBB =sma(myData, period)

// The width is driven by standard deviation

volatility = stdev(myData, period)

// This is the upper band

upperBB = middleBB + width * volatility

// This is the lower band

lowerBB = middleBB - width * volatility

//long exit signal when high crosses above upper band

signal1 = -1*xover(high(x),upperBB)

//long entry signal when low crosses below upper band

signal2 = 1*xunder(low(x),lowerBB)

//combine long exit and entry signals

signal = signal1 + signal2

//use discrete trade with stops and no pyramiding system

system_type = 4

//use chandelier stops

stop_type = 0

//chandelier stop parameters

m = 10

n = 3

//run backtester, this should generate a trade report and summary in the backtester window

bt = backtest(x,signal,system_type, stop_type, m, n)

//create backtest signal/stops plot with their label

myPlot5=plot(myData,"signals","line","00000000",bt)

//display signals and their labels in price chart

pchart(myPlot5)

backtest(x:Data, s:Array, optionalSystemType:Number[0,1,2,3,4,5], optionalStopType:Number[0,1,2], optionalStopParameter1:Number, optionalStopParameter2:Number, optionalStopParameter3:Number):Backtest

Parameters

x:Data - Data object variable name representing the security on which to backtest the system

s:Array - Array of signals (Possible Numbers: 0: no signal, +1: long entry, -1: long exit, +2: short exit, -2: short entry)

optionalSystemType:Number[0,1,2,3,4,5] - Number to specify the system type: 0 for Mode One (Default Option) (Always in the market/no pyramiding), 1 for Mode Two (Always in the market/with pyramiding), 2 for Mode Three (Discrete Trades without stops/no pyramiding), 3 for Mode Four (Discrete Trades without stops/with pyramiding), 4 for Mode Five (Discrete Trades with stops/no pyramiding), or 5 for Mode Six (Discrete Trades with stops and pyramiding)

optionalStopType:Number[0,1,2] - Number to specify the stop type: 0 for Chandelier Stop, 1 for Parabolic Stop or 2 for Bollinger Stop

optionalStopParameter1:Number - Optional stop parameter 1 (m for Chandelier stop: default 10, AF step for Parabolic/Bollinger: default 0.02)

optionalStopParameter2:Number - Optional stop parameter 2 (n for Chandelier stop: default 3, AF max for Parabolic/Bollinger: default 0.2)

optionalStopParameter3:Number - Optional stop parameter 3 (Bollinger Envelope Multiplier for Bollinger Stop: default 1.5)

s:Array - Array of signals (Possible Numbers: 0: no signal, +1: long entry, -1: long exit, +2: short exit, -2: short entry)

optionalSystemType:Number[0,1,2,3,4,5] - Number to specify the system type: 0 for Mode One (Default Option) (Always in the market/no pyramiding), 1 for Mode Two (Always in the market/with pyramiding), 2 for Mode Three (Discrete Trades without stops/no pyramiding), 3 for Mode Four (Discrete Trades without stops/with pyramiding), 4 for Mode Five (Discrete Trades with stops/no pyramiding), or 5 for Mode Six (Discrete Trades with stops and pyramiding)

optionalStopType:Number[0,1,2] - Number to specify the stop type: 0 for Chandelier Stop, 1 for Parabolic Stop or 2 for Bollinger Stop

optionalStopParameter1:Number - Optional stop parameter 1 (m for Chandelier stop: default 10, AF step for Parabolic/Bollinger: default 0.02)

optionalStopParameter2:Number - Optional stop parameter 2 (n for Chandelier stop: default 3, AF max for Parabolic/Bollinger: default 0.2)

optionalStopParameter3:Number - Optional stop parameter 3 (Bollinger Envelope Multiplier for Bollinger Stop: default 1.5)

Returns

Backtest - Backtest object to analyze the requested system

Generates a trade report with all the entry and exit signals using the provided signals array for the data object requested.
The array of signals uses the following values for mode 3, 4, 5 and 6:

0: no signal,

+1: long entry,

-1: long exit,

+2: short exit,

-2: short entry

The array of signals uses the following values for mode 1 and 2:

0: no signal,

>0: buy,

<0: sell

The trade entry and exit is chosen depending on the system type:

0 for mode One: always in the market, no pyramiding

wait for first signal and enter the market long or short

ignore subsequent signals of the same sign

reverse to opposite state on next signal of opposite type

ignore subsequent signals of the same sign, Repeat

Example, if buy first, buy 1(long entry), sell 2(long exit and short entry), buy 2, sell 2...

Example, if sell first, sell 1, buy 2, sell 2, buy 2...

1 for mode two: always in the market, with pyramiding

wait for first signal and enter the market long or short

on subsequent signals of the same sign add a position, +1 if long, -1 if short

Reverse to opposite state on next signal of opposite type.

If long sell net position plus one more unit, if short cover net position plus one more unit

Example, if long first, buy 1, sell 2, sell 1(an add-on), buy 3(2 long exits, one short entry), sell 2...

2 for mode three: (Discrete trades) Match buys and sells, shorts and covers, no stops, no pyramiding

wait for the first long entry signal, march forward until matching exit is found, record trade and look for next long entry signal.

wait for the first short entry signal, march forward until matching exit is found, record trade and look for next short entry signal.

3 for mode four: (Discrete trades), Match buys and sells, shorts and covers, no stops, with pyramiding

wait for the first long entry signal, march forward until matching exit is found, record trade.

Return to long entry and look for next long entry signal.

wait for the first short entry signal, march forward until matching exit is found, record trade.

Return to short entry and look for next short entry signal.

4 for mode five: (Discrete trades with stops), Match buys, sells and stops, shorts, covers, and stops, no pyramiding

wait for the first long entry signal, march forward until matching exit or stop is found, record trade and look for next long entry signal.

wait for the first short entry signal, march forward until matching exit or stop is found, record trade and look for next short entry signal.

5 for mode six: (Discrete trades with stops), Match buys, sells and stops, shorts, covers, and stops, with pyramiding

wait for the first long entry signal, march forward until matching exit or stop is found, record trade.

Return to long entry and look for next long entry signal.

wait for the first short entry signal, march forward until matching exit or stop is found, record trade.

Return to short entry and look for next short entry signal.

In addition there is an optional stop type and stop parameters to be passed when systems with stops (Mode 5 and 6) are selected. There are three types of stops: Chandelier (0), Parabolic (1) and Bollinger (2) stops. The 4th parameter specifies the type. These stops can be customized by passing additional stop parameters: m and n when Chandelier stops are selected, AF step and max when Parabolic stops are selected and AF stop, AF max and Bollinger Envelope multiplier when Bollinger stops are selected. These parameters are passed respectively after the 4th parameter depending on the stop type.

Additional backtest functions are available to analyze the signals/stops generated exluding ignored signals and help plot the different equity curves.

0: no signal,

+1: long entry,

-1: long exit,

+2: short exit,

-2: short entry

The array of signals uses the following values for mode 1 and 2:

0: no signal,

>0: buy,

<0: sell

The trade entry and exit is chosen depending on the system type:

0 for mode One: always in the market, no pyramiding

wait for first signal and enter the market long or short

ignore subsequent signals of the same sign

reverse to opposite state on next signal of opposite type

ignore subsequent signals of the same sign, Repeat

Example, if buy first, buy 1(long entry), sell 2(long exit and short entry), buy 2, sell 2...

Example, if sell first, sell 1, buy 2, sell 2, buy 2...

1 for mode two: always in the market, with pyramiding

wait for first signal and enter the market long or short

on subsequent signals of the same sign add a position, +1 if long, -1 if short

Reverse to opposite state on next signal of opposite type.

If long sell net position plus one more unit, if short cover net position plus one more unit

Example, if long first, buy 1, sell 2, sell 1(an add-on), buy 3(2 long exits, one short entry), sell 2...

2 for mode three: (Discrete trades) Match buys and sells, shorts and covers, no stops, no pyramiding

wait for the first long entry signal, march forward until matching exit is found, record trade and look for next long entry signal.

wait for the first short entry signal, march forward until matching exit is found, record trade and look for next short entry signal.

3 for mode four: (Discrete trades), Match buys and sells, shorts and covers, no stops, with pyramiding

wait for the first long entry signal, march forward until matching exit is found, record trade.

Return to long entry and look for next long entry signal.

wait for the first short entry signal, march forward until matching exit is found, record trade.

Return to short entry and look for next short entry signal.

4 for mode five: (Discrete trades with stops), Match buys, sells and stops, shorts, covers, and stops, no pyramiding

wait for the first long entry signal, march forward until matching exit or stop is found, record trade and look for next long entry signal.

wait for the first short entry signal, march forward until matching exit or stop is found, record trade and look for next short entry signal.

5 for mode six: (Discrete trades with stops), Match buys, sells and stops, shorts, covers, and stops, with pyramiding

wait for the first long entry signal, march forward until matching exit or stop is found, record trade.

Return to long entry and look for next long entry signal.

wait for the first short entry signal, march forward until matching exit or stop is found, record trade.

Return to short entry and look for next short entry signal.

In addition there is an optional stop type and stop parameters to be passed when systems with stops (Mode 5 and 6) are selected. There are three types of stops: Chandelier (0), Parabolic (1) and Bollinger (2) stops. The 4th parameter specifies the type. These stops can be customized by passing additional stop parameters: m and n when Chandelier stops are selected, AF step and max when Parabolic stops are selected and AF stop, AF max and Bollinger Envelope multiplier when Bollinger stops are selected. These parameters are passed respectively after the 4th parameter depending on the stop type.

Additional backtest functions are available to analyze the signals/stops generated exluding ignored signals and help plot the different equity curves.

Example

data("x")

// Use the close

myData = close(x)

// Set the length

period = 20

// Set the width

width = 2.0

// The middle band is a simple moving average

middleBB =sma(myData, period)

// The width is driven by standard deviation

volatility = stdev(myData, period)

// This is the upper band

upperBB = middleBB + width * volatility

// This is the lower band

lowerBB = middleBB - width * volatility

//long exit signal when high crosses above upper band

signal1 = -1*xover(high(x),upperBB)

//long entry signal when low crosses below upper band

signal2 = 1*xunder(low(x),lowerBB)

//combine long exit and entry signals

signal = signal1 + signal2

//use discrete trade with stops and no pyramiding system

system_type = 4

//use chandelier stops

stop_type = 0

//chandelier stop parameters

m = 10

n = 3

//run backtester, this should generate a trade report and summary in the backtester window

bt = backtest(x,signal,system_type, stop_type, m, n)

//create backtest signal/stops plot with their label

plot1=plot(myData,"signals","line","00000000",bt)

//display signals and their labels in price chart

pchart(plot1)

//use discrete trade with stops and with pyramiding system

system_type = 5

//use parabolic stops

stop_type = 1

//parabolic stop parameters

af_step = 10

af_max = 3

//run backtester, this should generate a trade report and summary in the backtester window

bt = backtest(x,signal,system_type, stop_type, af_step, af_max)

//create backtest signal/stops plot with their label

plot1=plot(myData,"signals","line","00000000",bt)

//display signals and their labels in price chart

pchart(plot1)

//use discrete trade without stops and without pyramiding system

system_type = 2

bt = backtest(x,signal,system_type)

//use always in the market and without pyramiding system

system_type = 0

bt = backtest(x,signal,system_type)

//create backtest signal/stops plot with their label

plot1=plot(myData,"signals","line","00000000",bt)

//display signals and their labels in price chart

pchart(plot1)

// Use the close

myData = close(x)

// Set the length

period = 20

// Set the width

width = 2.0

// The middle band is a simple moving average

middleBB =sma(myData, period)

// The width is driven by standard deviation

volatility = stdev(myData, period)

// This is the upper band

upperBB = middleBB + width * volatility

// This is the lower band

lowerBB = middleBB - width * volatility

//long exit signal when high crosses above upper band

signal1 = -1*xover(high(x),upperBB)

//long entry signal when low crosses below upper band

signal2 = 1*xunder(low(x),lowerBB)

//combine long exit and entry signals

signal = signal1 + signal2

//use discrete trade with stops and no pyramiding system

system_type = 4

//use chandelier stops

stop_type = 0

//chandelier stop parameters

m = 10

n = 3

//run backtester, this should generate a trade report and summary in the backtester window

bt = backtest(x,signal,system_type, stop_type, m, n)

//create backtest signal/stops plot with their label

plot1=plot(myData,"signals","line","00000000",bt)

//display signals and their labels in price chart

pchart(plot1)

//use discrete trade with stops and with pyramiding system

system_type = 5

//use parabolic stops

stop_type = 1

//parabolic stop parameters

af_step = 10

af_max = 3

//run backtester, this should generate a trade report and summary in the backtester window

bt = backtest(x,signal,system_type, stop_type, af_step, af_max)

//create backtest signal/stops plot with their label

plot1=plot(myData,"signals","line","00000000",bt)

//display signals and their labels in price chart

pchart(plot1)

//use discrete trade without stops and without pyramiding system

system_type = 2

bt = backtest(x,signal,system_type)

//use always in the market and without pyramiding system

system_type = 0

bt = backtest(x,signal,system_type)

//create backtest signal/stops plot with their label

plot1=plot(myData,"signals","line","00000000",bt)

//display signals and their labels in price chart

pchart(plot1)

equitycurve(bt:Backtest, equitycurve_type:Number[0,1]):Array

Parameters

bt:Backtest - Backtest object which define a trading system whose equity curve data is to be returned.

equitycurve_type:Number[0,1] - Scalar number which defines the type of calculation used in the equity curve construction [0: daily trade gains are added, 1: daily trade gains are compounded]. The default is 0.

equitycurve_type:Number[0,1] - Scalar number which defines the type of calculation used in the equity curve construction [0: daily trade gains are added, 1: daily trade gains are compounded]. The default is 0.

Returns

Array - Array of data used to plot the equity curve. The data represents the historical percent gains using the specified input system, starting with 0%.

Returns an array of data used to plot the equity curve. The data represents the historical percent gains using the specified input system defined by the Backtest object, starting with 0%.
There are two ways to calculate the equity curve daily gains. A scalar number "equitycurve_type" defines the type of calculation used in the equity curve construction [0: daily trade gains are added, 1: daily trade gains are compounded]. The default is 0.

Example

data("x")

// Use the close

myData = close(x)

// Set the length

period = 20

// Set the width

width = 2.0

// The middle band is a simple moving average

middleBB =sma(myData, period)

// The width is driven by standard deviation

volatility = stdev(myData, period)

// This is the upper band

upperBB = middleBB + width * volatility

// This is the lower band

lowerBB = middleBB - width * volatility

//long exit signal when high crosses above upper band

signal1 = -1*xover(high(x),upperBB)

//long entry signal when low crosses below upper band

signal2 = 1*xunder(low(x),lowerBB)

//combine long exit and entry signals

signal = signal1 + signal2

//use discrete trade with stops and no pyramiding system

system_type = 4

//use chandelier stops

stop_type = 0

//chandelier stop parameters

m = 10

n = 3

//run backtester, this should generate a trade report and summary in the backtester window

bt = backtest(x,signal,system_type, stop_type, m, n)

//create backtest signal/stops plot with their label

plot1=plot(myData,"signals","line","00000000",bt)

//display signals and their labels in price chart

pchart(plot1)

//calculate equity curve using daily compounding where all daily trade gains are compounded instead of added

equity_curve_calculation = 1

//get equity curve array using backtester object created

eqc1 = equitycurve(bt,equity_curve_calculation)

//create equity curve plot

plot2=plot(eqc1,"EQC1","line","0000ff")

//display equity curve chart

chart(plot2)

//calculate equity curve without daily compounding where all daily trade gains are added instead of compounded

equity_curve_calculation = 0

//get equity curve array using backtester object created

eqc2 = equitycurve(bt,equity_curve_calculation)

//create equity curve plot

plot3=plot(eqc2,"EQC2","line","0000ff")

//display equity curve chart

chart(plot3)

// Use the close

myData = close(x)

// Set the length

period = 20

// Set the width

width = 2.0

// The middle band is a simple moving average

middleBB =sma(myData, period)

// The width is driven by standard deviation

volatility = stdev(myData, period)

// This is the upper band

upperBB = middleBB + width * volatility

// This is the lower band

lowerBB = middleBB - width * volatility

//long exit signal when high crosses above upper band

signal1 = -1*xover(high(x),upperBB)

//long entry signal when low crosses below upper band

signal2 = 1*xunder(low(x),lowerBB)

//combine long exit and entry signals

signal = signal1 + signal2

//use discrete trade with stops and no pyramiding system

system_type = 4

//use chandelier stops

stop_type = 0

//chandelier stop parameters

m = 10

n = 3

//run backtester, this should generate a trade report and summary in the backtester window

bt = backtest(x,signal,system_type, stop_type, m, n)

//create backtest signal/stops plot with their label

plot1=plot(myData,"signals","line","00000000",bt)

//display signals and their labels in price chart

pchart(plot1)

//calculate equity curve using daily compounding where all daily trade gains are compounded instead of added

equity_curve_calculation = 1

//get equity curve array using backtester object created

eqc1 = equitycurve(bt,equity_curve_calculation)

//create equity curve plot

plot2=plot(eqc1,"EQC1","line","0000ff")

//display equity curve chart

chart(plot2)

//calculate equity curve without daily compounding where all daily trade gains are added instead of compounded

equity_curve_calculation = 0

//get equity curve array using backtester object created

eqc2 = equitycurve(bt,equity_curve_calculation)

//create equity curve plot

plot3=plot(eqc2,"EQC2","line","0000ff")

//display equity curve chart

chart(plot3)

tradesig(bt:Backtest):Array

Parameters

bt:Backtest - Backtest object which define a trading system whose active signals/stops are to be returned, exluding the ignored ones.

Returns

Array - Array of active signals and stops corresponding to the system defined by the backtest object passed.

Returns an Array of signals/stops that correspond to the trade report generated by the system defined in the Backtest object passed. The array returned has the following values:
For mode 3, 4, 5 and 6:

0: no signal,

+1: long entry,

-1: long exit,

+2: short exit,

-2: short entry

For mode 1 and 2:

0: no signal,

>0: buy,

<0: sell

Note that the array returned is different from the signal array used to create the Backtest object. This array will exclude ignored signals and will also include generated stops (mode 5 and 6) which are generated by certain systems.

0: no signal,

+1: long entry,

-1: long exit,

+2: short exit,

-2: short entry

For mode 1 and 2:

0: no signal,

>0: buy,

<0: sell

Note that the array returned is different from the signal array used to create the Backtest object. This array will exclude ignored signals and will also include generated stops (mode 5 and 6) which are generated by certain systems.

Example

data("x")

// Use the close

myData = close(x)

// Set the length

period = 20

// Set the width

width = 2.0

// The middle band is a simple moving average

middleBB =sma(myData, period)

// The width is driven by standard deviation

volatility = stdev(myData, period)

// This is the upper band

upperBB = middleBB + width * volatility

// This is the lower band

lowerBB = middleBB - width * volatility

//long exit signal when high crosses above upper band

signal1 = -1*xover(high(x),upperBB)

//long entry signal when low crosses below upper band

signal2 = 1*xunder(low(x),lowerBB)

//combine long exit and entry signals

signal = signal1 + signal2

//use discrete trade with stops and no pyramiding system

system_type = 4

//use chandelier stops

stop_type = 0

//chandelier stop parameters

m = 10

n = 3

//run backtester, this should generate a trade report and summary in the backtester window

bt = backtest(x,signal,system_type, stop_type, m, n)

//get backtester signals and stops

signals_with_stops = tradesig(bt)

//create signals with stops plot, however this will not display the trade labels above and below the signals on the chart

plot1=plot(myData,"signals","line","00000000",signals_with_stops)

//to display the labels with the signals uncomment the following //plot1=plot(myData,"signals","line","00000000",bt)

//display signals in price chart

pchart(plot1)

// Use the close

myData = close(x)

// Set the length

period = 20

// Set the width

width = 2.0

// The middle band is a simple moving average

middleBB =sma(myData, period)

// The width is driven by standard deviation

volatility = stdev(myData, period)

// This is the upper band

upperBB = middleBB + width * volatility

// This is the lower band

lowerBB = middleBB - width * volatility

//long exit signal when high crosses above upper band

signal1 = -1*xover(high(x),upperBB)

//long entry signal when low crosses below upper band

signal2 = 1*xunder(low(x),lowerBB)

//combine long exit and entry signals

signal = signal1 + signal2

//use discrete trade with stops and no pyramiding system

system_type = 4

//use chandelier stops

stop_type = 0

//chandelier stop parameters

m = 10

n = 3

//run backtester, this should generate a trade report and summary in the backtester window

bt = backtest(x,signal,system_type, stop_type, m, n)

//get backtester signals and stops

signals_with_stops = tradesig(bt)

//create signals with stops plot, however this will not display the trade labels above and below the signals on the chart

plot1=plot(myData,"signals","line","00000000",signals_with_stops)

//to display the labels with the signals uncomment the following //plot1=plot(myData,"signals","line","00000000",bt)

//display signals in price chart

pchart(plot1)

print(x1:Array or Number or String or Plot or Data, x2:Array or Number or String or Plot or Data, x3:Array or Number or String or Plot or Data, ...:Array or Number or String or Plot or Data):null

Parameters

x1:Array or Number or String or Plot or Data - Variable whose value (String, Number or Array content) is to be displayed in output panel.

x2:Array or Number or String or Plot or Data - Variable whose value (String, Number or Array content) is to be displayed in output panel.

x3:Array or Number or String or Plot or Data - Variable whose value (String, Number or Array content) is to be displayed in output panel.

...:Array or Number or String or Plot or Data - Variable whose value (String, Number or Array content) is to be displayed in output panel.

x2:Array or Number or String or Plot or Data - Variable whose value (String, Number or Array content) is to be displayed in output panel.

x3:Array or Number or String or Plot or Data - Variable whose value (String, Number or Array content) is to be displayed in output panel.

...:Array or Number or String or Plot or Data - Variable whose value (String, Number or Array content) is to be displayed in output panel.

Returns

null - No returned value.

Prints all the values of the parameters passed in the exact sequence passed, returns null. For array parameters, it prints out the entire content of the array.

Example

print("The value of parameter a is ",a, " and b is ", b)

myArray = array(0)

print("The content of the array is:", myArray)

data("x")

closeQuotes=close(x)

print(closeQuotes)

myArray = array(0)

print("The content of the array is:", myArray)

data("x")

closeQuotes=close(x)

print(closeQuotes)