Maximum
This function can be accessed only in the Toolbox.
Maximum(@,@)returns the greater value of 2 inputs. For example, Maximum(5,10) will return 10.
Maximum can be nested to return the maximum of a series. Maximum(@,Maximum (@,Maximum(@,@))) returns the maximum value of 4 inputs.
The @ may be replaced with: studies, conditions, functions, or user values to return the maximum comparative value.
Example: Maximum(Open(@),Close(@))
This function has no parameters.
Maximum Over Period (MaxPrd)
This function is available on the Add Study window and in the Formula Toolbox.
MaxPrd returns the maximum value of an expression looking back over a specific number of bars. The unique value of MaxPrd the number of bars in the look back is determined by a condition being met.
For example: MaxPrd(High(@),BarsSince (MA1(@,9) Xabove MA2(@,18) returns to highest value traded since the first moving average crossed above the second moving average.
Example: MaxPrd(@,6)
Parameter

Description

Display

Opens a subwindow with display properties:
Color = Select a line color.
Weight = Type a value for line thickness.
Display = Select line style: line, histogram, or dash.
ShareScale = Assign a behavior for functions and studies sharing the vertical scale:
Auto = System determine whether sharing is feasible.
On = Scale is shared regardless of the functions and studies displayed.
Off = Scale is not shared.

MarkIt

Opens the Specify Conditions for Marking Bar window.

Price

Price used for calculations.

Period

Number of bars used in the calculation.

Maximum Since (MaxSince)
This function is available on the Add Study window and in the Formula Toolbox.
Maximum Since returns the maximum value of a Price (High, Low, and so on) that is specified in parameters and has occurred since the condition specified in parameters was true.
Example:
Add the Study MaxSince, rightclick, then click Modify All Study Parameters. Select a predefined condition from the dropdown list in the Condition column.
Press OK to see the result.
Parameter

Description

Display

Opens a subwindow with display properties:
Color = Select a line color.
Weight = Type a value for line thickness.
Display = Select line style: line, histogram, or dash.
ShareScale = Assign a behavior for functions and studies sharing the vertical scale:
Auto = System determine whether sharing is feasible.
On = Scale is shared regardless of the functions and studies displayed.
Off = Scale is not shared.

MarkIt

Opens the Specify Conditions for Marking Bar window.

Price

Price used for calculations.

Condition

Select a predefined condition from the dropdown list.

Mean Deviation (MnDev)
This function is available on the Add Study window and in the Formula Toolbox.
Mean deviation is the mean of the distribution between the close and the mean of the closes over the number of bars the user enters. For example: the mean deviation returns 1/N times the sum of the absolute value of the close minus the average of the closes over the user selected number of bars.
Example: MnDev(@,10)
Parameter

Description

Display

Opens a subwindow with display properties:
Color = Select a line color.
Weight = Type a value for line thickness.
Display = Select line style: line, histogram, or dash.
ShareScale = Assign a behavior for functions and studies sharing the vertical scale:
Auto = System determine whether sharing is feasible.
On = Scale is shared regardless of the functions and studies displayed.
Off = Scale is not shared.

MarkIt

Opens the Specify Conditions for Marking Bar window.

Price

Price used for calculations.

Period

Number of bars used in the calculation.

Median (Median)
This function is available on the Add Study window and in the Formula Toolbox.
The Median function returns the median of the userselected numbers. The median is the number in the middle of a set of numbers; that is, half the numbers have values that are greater than the median, and half have values that are less, or it is the average of the two middle numbers in the set.
Example: The median calculation for September 7th ends with the data for September 7th and goes back 2 additional periods for the 3period calculation.
Example: Median(@,20)
Parameter

Description

Display

Opens a subwindow with display properties:
Color = Select a line color.
Weight = Type a value for line thickness.
Display = Select line style: line, histogram, or dash.
ShareScale = Assign a behavior for functions and studies sharing the vertical scale:
Auto = System determine whether sharing is feasible.
On = Scale is shared regardless of the functions and studies displayed.
Off = Scale is not shared.

MarkIt

Opens the Specify Conditions for Marking Bar window.

Price

Price used for calculations.

Period

Number of bars used in the calculation.

Minimum (Minimum)
This function can be accessed only in the Toolbox.
Minimum(@,@)returns the lesser value of 2 inputs. For example, Minimum(5,10) will return 5.
Minimum can be nested to return the minimum of a series. Minimum(@, Minimum(@, Minimum(@,@))) returns the minimum value of 4 inputs.
The @ may be replaced with: studies, conditions, functions, or user values to return the minimum comparative value.
Example: Minimum(Open(@),Close(@))
This function has no parameters.
Minimum Over Period (MinPrd)
This function is available on the Add Study window and in the Formula Toolbox.
MinPrd returns low value of an expression over the look back number of bars. Like MaxPrd the unique value of this functionality is the ability to identify an event as the initialing point of the look back rather than a finite number.
For example: MinPrd(Low(@),BarSince MACDA(@) XBelow 0)
Example: MinPrd(@,6)
Parameter

Description

Display

Opens a subwindow with display properties:
Color = Select a line color.
Weight = Type a value for line thickness.
Display = Select line style: line, histogram, or dash.
ShareScale = Assign a behavior for functions and studies sharing the vertical scale:
Auto = System determine whether sharing is feasible.
On = Scale is shared regardless of the functions and studies displayed.
Off = Scale is not shared.

MarkIt

Opens the Specify Conditions for Marking Bar window.

Price

Price used for calculations.

Period

Number of bars used in the calculation.

Minimum Since (MinSince)
This function is available on the Add Study window and in the Formula Toolbox.
Minimum Since returns the minimum value of a price (High, Low, and so on) that is specified in parameters and has occurred since the condition specified in parameters was true.
Example: Similar to Maximum Since
Parameter

Description

Display

Opens a subwindow with display properties:
Color = Select a line color.
Weight = Type a value for line thickness.
Display = Select line style: line, histogram, or dash.
ShareScale = Assign a behavior for functions and studies sharing the vertical scale:
Auto = System determine whether sharing is feasible.
On = Scale is shared regardless of the functions and studies displayed.
Off = Scale is not shared.

MarkIt

Opens the Specify Conditions for Marking Bar window.

Price

Price used for calculations.

Condition

Identifies the condition used as starting point for the calculation.

Minutes Since Bar Opened (MinSinceBarOp)
This function is available on the Add Study window and in the Formula Toolbox.
The Minutes Since Bar Opened function shows the number of minutes after the bar opened that the selected tick occurred.
Example:MinSinceBarOp(@)
This function has no parameters.
Minutes After Session Open (MinutesAfterSessionOpen)
This function can be accessed only in the Toolbox.
The minutes after session open shows the number of minutes after the session opened that the selected tick occurred.
Example: MinutesAfterSessionOpen(@)
This function has no parameters.
Minutes Before Session Close (MinutesBeforeSessionClose)
This function can be accessed only in the Toolbox.
The minutes before session close shows the number of minutes before the session closed that the selected tick occurred.
Example: MinutesBeforeSessionClose(@)
This function has no parameters.
Modulus
This function can be accessed only in the Toolbox.
Modulus returns the remainder after division.
In mathematics, the remainder is the amount "left over" after division. For example, the remainder of 10 / 4 is 2, because 4 goes into ten twice with two left over. You'll see this written as 10 / 4 = 2 r 2, the 'r' standing for remainder.
Format: Modulus(@,@)
For example:
Modulus(10,4)
10 / 4 = 2 with a remainder of 2
Modulus returns 2
This function has no parameters.
Native Currency to Price (D2P)
This function is available on the Add Study window and in the Formula Toolbox.
Native Currency to Price converts US Dollars to price units. There are two forms:
Dollar2Price(X) converts X to price units using the currents contract for the price scale.
For example: Low(@) –Dollar2Price(2000) returns a price line equivalent to $2000 under the low of the bar or 2000 ticks.
Dollar2Price(y,x) converts X to price units, using y for the price scale.
For example: Low(@)Dollar2Price(SP,2000) will return a price line $2000 under the low using SP price scale. This would translate into 800 ticks under the low.
Example: DollarToPrice(@)
This function has no parameters.
Natural Log (Log)
This function is available on the Add Study window and in the Formula Toolbox.
Displays the natural log of chart values.
Example: Natlog(@)
Parameter

Description

Display

Opens a subwindow with display properties:
Color = Select a line color.
Weight = Type a value for line thickness.
Display = Select line style: line, histogram, or dash.
ShareScale = Assign a behavior for functions and studies sharing the vertical scale:
Auto = System determine whether sharing is feasible.
On = Scale is shared regardless of the functions and studies displayed.
Off = Scale is not shared.

MarkIt

Opens the Specify Conditions for Marking Bar window.

Price

Price used for calculations.

OB/OS

Opens a subwindow with properties for overbought and oversold indicators.
Color = Select a line color.
Weight = Type a value for line thickness.
Type = Select fixed or dynamic.
Std Dev = Choose a multiplier of the Standard Deviation used to derive high and low.
Lookback = Choose the number of bars that should be compared to the current bar.
Level = Assign a percentage value of average OB/OS to be used to calculate predictor OB/OS levels.
Display = Click this check box to display the line on the chart.
Style = Choose a line style: line, long dash, or short dash.

Net Change (NC)
This function is available only in the Formula Toolbox.
Net change is the difference between today’s current price and the settlement price.
Example: NC(@)
This function has no parameters.
Peak (Peak)
This function is available on the Add Study window and in the Formula Toolbox.
The Hi/Lo Peak study identifies important highs and lows based on the number of bars, both to the left and to the right (before and after), which have lower highs to identify a Hi Peak or higher lows to identify a Lo Peak. Hi/Lo Peak identifies extreme price points of the same magnitude, based on the surrounding price action.
Characteristics & Usage
Hi/Lo Peak provides a method to consistently identify extreme price points of the same magnitude.
Hi/Lo Peak is an effective tool to identify important support and resistance levels based on recent price extremes.
The Hi/Lo Peak lines may be used to define a trading range.
The Lo Peak line identifies the price that attracted a bid and the Hi Peak line identifies the price level that attracted an offer.
A break above or below a Peak line may be considered a breakout of the trading range.
Hi/Lo Peak may also be used in a trend following manner.
A bull trend is indicated when price action persists above the Hi Peak.
An upward adjustment of the Hi Peak indicates the trend has terminated (this is due to the fact that Hi Peak will only adjust upward once lower highs follow an extreme high, indicating the bulls have been unable to bid prices beyond the highs for several bars).
The opposite holds for using Lo Peak to identify a bear trend and its termination.
When the Min/Max parameter is On, Hi/Lo Peak may be used to track the maximum and minimum values dependent on the Reset parameters. Reset parameters are employed so that Hi/Lo Peak will continue to be a responsive indicator, rather than simply identifying the highest and lowest points on a chart.
Calculation
Hi Peak = Highest Price with LLev (number) of lower highs preceding the Hi Peak and RLev (number) of lower highs following it.
Lo Peak = Lowest Price with LLev (number) of higher lows preceding the Lo Peak and RLev (number) of higher lows following it.
For variations see Parameters for Peak.
Example: HiPeak(@,1,1), LoPeak(@,1,1)
Example: HiCount(@,1,1), Lo Count(@,1,1)
Parameter

Description

Display

Opens a subwindow with display properties:
Color = Select a line color.
Weight = Type a value for line thickness.
Display = Select line style: line, histogram, or dash.
ShareScale = Assign a behavior for functions and studies sharing the vertical scale:
Auto = System determine whether sharing is feasible.
On = Scale is shared regardless of the functions and studies displayed.
Off = Scale is not shared.

Price

Reference price. Optional settings include: Open, High, Low, Close, Midpt, HLC/3, Average, True High, True Low, Range, True Range, or Peak may reference Conditions.

LLev

Determines the number of bars to the left of the Hi/Lo peak which must have a lower Hi/higher Lo.

RLev

Determines the number of bars to the right of the Hi/Lo peak which must have a lower Hi/higher Lo.

Offset

Determines the number of bars to offset the PEAK Hi/Lo lines.

Resets

Opens a subwindow where you set Max/Min levels.
Min/Max values:
Hi Off = PEAK lines will move up or down in accordance with the parameters set above.
Hi On = PEAK will track the Price higher, identifying each higher PEAK. Hi PEAK maintains its maximum value until the Reset parameters force PEAK to accept a lower value, in accordance with the parameters below. Price falls below the Threshold and crosses back above the Threshold value at which point Hi PEAK will reset to the Threshold level.
Lo On = PEAK will track the Price lower identifying each lower PEAK. Lo PEAK will maintain its minimum value until the Reset parameters force PEAK to accept a higher value, in accordance with the parameters below. Price rises above the Threshold and crosses back below the Threshold value at which point Lo PEAK will reset to the Threshold level.
Reset vales:
<= or />= The Threshold level will serve as a Minimum/Maximum value which PEAK will take. Above this level Hi PEAK will identify extreme Prices as specified above, while Lo PEAK will identify extreme Prices below the Threshold level.
XA/XB = When the selected Price crosses above/below the Threshold PEAK will revert to the Threshold value and once again begin to track extreme Price values.
Trig = Activates the Reset Trigger as a method to force Hi PEAK to accept a lower value and Lo PEAK to accept a higher value.
Reset Trigger = Condition that serves as the Trigger for PEAK to assume the value of Price when the condition is true. The Reset Trig forces Hi PEAK to accept a lower value than the maximum while forcing the Lo PEAK to accept higher values.
Threshold = Threshold serves as a minimum value for Hi PEAK and a maximum value for Lo PEAK when either <=/>= is selected or when XA/XB is selected and Price has broken the Threshold. Once Hi/Lo PEAK crosses below/above the Threshold, PEAK will no longer respond to price action, until Price remains beyond the threshold for the total number of bars of LLev and RLev summed together (i.e. using the defaults, the price must remain beyond the Threshold for 3 days to be detected).

Power (Pwr)
This function is available on the Add Study window and in the Formula Toolbox.
This function takes the selected prices from a chart and raises them to a userselected power.
Example: Power(@,2.00000)
Parameter

Description

Display

Opens a subwindow with display properties:
Color = Select a line color.
Weight = Type a value for line thickness.
Display = Select line style: line, histogram, or dash.
ShareScale = Assign a behavior for functions and studies sharing the vertical scale:
Auto = System determine whether sharing is feasible.
On = Scale is shared regardless of the functions and studies displayed.
Off = Scale is not shared.

MarkIt

Opens the Specify Conditions for Marking Bar window.

Price

Price used for calculations.

ythPower

Power used to apply to the chart value.

OB/OS

Opens a subwindow with properties for overbought and oversold indicators.
Color = Select a line color.
Weight = Type a value for line thickness.
Type = Select fixed or dynamic.
Std Dev = Choose a multiplier of the Standard Deviation used to derive high and low.
Lookback = Choose the number of bars that should be compared to the current bar.
Level = Assign a percentage value of average OB/OS to be used to calculate predictor OB/OS levels.
Display = Click this check box to display the line on the chart.
Style = Choose a line style: line, long dash, or short dash.

Price to Native Currency (P2D)
This function is available on the Add Study window and in the Formula Toolbox.
Price to Native Currency converts price units to US dollars.
There are two forms:
Price2Dollar(X) converts X to dollars using the current contract scale.
For example: Price2Dollar(High(@)Low(@)) returns the range of the bar in dollars.
Price2Dollar(y,x) converts X to dollars using a specific price scale (Y) different than the one on the chart.
For example: Price2Dollar(SP,High(@)Low(@)) if applied to a NASDAQ (ND) chart, will return the price of the trading range of the NASDAQ futures bar using the SP price scale.
Example: PriceToDollar(@)
Parameter

Description

Price

Price used for calculation.

Round (Round)
This function is available on the Add Study window and in the Formula Toolbox.
The Round function takes a chart value and rounds it to the nearest integer value. Values greater than or equal to .5 round up to the next highest integer, and values less than .5 round down to the next lowest integer.
Example: Round(@)
Parameter

Description

Display

Opens a subwindow with display properties:
Color = Select a line color.
Weight = Type a value for line thickness.
Display = Select line style: line, histogram, or dash.
ShareScale = Assign a behavior for functions and studies sharing the vertical scale:
Auto = System determine whether sharing is feasible.
On = Scale is shared regardless of the functions and studies displayed.
Off = Scale is not shared.

MarkIt

Opens the Specify Conditions for Marking Bar window.

Price

Price used for calculations.

OB/OS

Opens a subwindow with properties for overbought and oversold indicators.
Color = Select a line color.
Weight = Type a value for line thickness.
Type = Select fixed or dynamic.
Std Dev = Choose a multiplier of the Standard Deviation used to derive high and low.
Lookback = Choose the number of bars that should be compared to the current bar.
Level = Assign a percentage value of average OB/OS to be used to calculate predictor OB/OS levels.
Display = Click this check box to display the line on the chart.
Style = Choose a line style: line, long dash, or short dash.

Sample (Samp)
This function is available on the Add Study window and in the Formula Toolbox.
Sample identifies the price at which a condition is met. This study evaluates a condition on a True/False basis and returns the desired input value (price) when the condition changes from False to True or remains True, depending on parameter settings.
Sample is an effective tool for identifying support and resistance points defined by the occurrence of a specific condition.
An example is to use High as the input on a downside reversal day. The Sample parameters would be set as following:
Price = High
Capture = At Edge (when condition changes from false to true)
Hold = On (continue calculating until condition changes from false to true again)
Condition = Higher High than prior bar and a close down.
Sample may be used to assist in the development of a trade system, since it enables the user to identify specific events and analyze the market behavior following such an event.
Sample is similar to an If function. Both functions return a Price or User value when a defined condition occurs.
Sample provides the user with greater flexibility to select or hold a specific value, based on the selected parameter settings.
Example:
Sample(@,1,1,1,B.cqg.ADXHigh(@,Period:=10,Threshold:=20))
Parameter

Description

Display

Opens a subwindow with display properties:
Color = Select a line color.
Weight = Type a value for line thickness.
Display = Select line style: line, histogram, or dash.
ShareScale = Assign a behavior for functions and studies sharing the vertical scale:
Auto = System determine whether sharing is feasible.
On = Scale is shared regardless of the functions and studies displayed.
Off = Scale is not shared.

MarkIt

Opens the Specify Conditions for Marking Bar window.

Price

Price used for calculations.

Capture

Values:
at edge = Value returned only changes when the condition changes from False to True. The resulting Sample is displayed as a horizontal line which shifts levels as the condition changes from False to True.
when true = Value returned will change on each observation for which the condition is True. If the input parameter is set to a price, the Sample follows the market up or down while the condition is True and will be a horizontal line when the condition is False.

Hold

Values:
on = a value is returned for all the following bars until the condition changes from false to true again
off = a value is returned when the condition is true

Duration

Starting from the bar at which the condition is true, the number of bars in the output.

Condition

Name for the condition which is evaluated for a "true" state to determine when to take a sample.
Condition (1)

Condition

Input

Sample

Hold

Value

FALSE

TRUE

LOW

At Edge

On

Low

TRUE

TRUE

LOW

At Edge

On

Low of initial TRUE


FALSE

LOW

At Edge

On

Last Low w/TRUE

FALSE

TRUE

LOW

At Edge

Off

Low

TRUE

TRUE

LOW

At Edge

Off

None


FALSE

LOW

At Edge

Off

None

FALSE

TRUE

LOW

When True

On

Low

TRUE

TRUE

LOW

When True

On

Low


FALSE

LOW

When True

On

Last Low w/TRUE

FALSE

TRUE

LOW

When True

Off

Low

TRUE

TRUE

LOW

When True

Off

None


FALSE

LOW

When True

Off

None


Seconds Since Bar Opened (SecSinceBarOp)
This function is available on the Add Study window and in the Formula Toolbox.
The Seconds Since Bar Opened function shows the number of minutes, seconds, and milliseconds after the bar opened that the selected tick occurred. Millisecond precision applies to all bars and not only the current bar.
Note that the time increment is taken from chart preferencestopic=Time Scale.
Example: SecSinceBarOp(@)
This function has no parameters.
Set/Reset (SetRst)
This function is available on the Add Study window and in the Formula Toolbox.
Set/Reset creates a picture of binary data for you, using two conditions. The first condition is displayed as an uptick on a line graph. The line continues on that level until the second condition is satisfied. Then the line returns to its baseline until the first condition occurs again. On a bar graph, the bars change colors to reflect the set and reset conditions.
For example:
mval := MACD(@,13,26);
diff := mval  MACDA(@,13,26,9);
SetReset(mval XABOVE 0, diff < diff[1])
In this example on a bar graph, this formula would color bars when MACD crossed above zero and would stop marking the bars when the difference between the MACD and the MACDA turned down.
Example: SetRst(Hour(@)=9,Hour(@)=12)
Parameter

Description

Display

Opens a subwindow with display properties:
Color = Select a line color.
Weight = Type a value for line thickness.
Display = Select line style: line, histogram, or dash.
ShareScale = Assign a behavior for functions and studies sharing the vertical scale:
Auto = System determine whether sharing is feasible.
On = Scale is shared regardless of the functions and studies displayed.
Off = Scale is not shared.

MarkIt

Opens the Specify Conditions for Marking Bar window.

Condition 1

Formula that defines the condition to return a positive response.

Condition 2

Formula that defines the condition to end the response started by the first condition.

Use Edges

SetRst(Hour(@)=9,Hour(@)=12) with Use Edges will not trip to 1 on a 5min bar chart until the first bar on which it turns is complete the 9:00 bar.
It actually returns 1 or true on the bar immediately following the first condition 9:05, hence the term “use edges.”
Rather than show true at start of the start condition bar, it waits until the starting condition  start bar is completed.
Without Use Edges, it will immediately turn to true when the start condition (Hour(@)=9) bar is first formed.

ShareScale (ShrScl)
This function is available on the Add Study window and in the Formula Toolbox.
ShareScale forces a bar value or formula (expression 1) to use the same scale as a bar chart or other value (expression2).
There are two forms for this function:
ShareScale(expr1): In this form, ShareScale forces expr1 to be displayed using the same units as the chart. For example: ShareScale(Low(@)10*TickSize(@)) will ensure the same scale is used for the line that is generated as the bar chart on which it is overlaid.
ShareScale(expr1, expr2): This forces expr1 to be displayed using the same scaling as expr2.
Example: ShrScale(@,@)
Parameter

Description

Display

Opens a subwindow with display properties:
Color = Select a line color.
Weight = Type a value for line thickness.
Display = Select line style: line, histogram, or dash.
ShareScale = Assign a behavior for functions and studies sharing the vertical scale:
Auto = System determine whether sharing is feasible.
On = Scale is shared regardless of the functions and studies displayed.
Off = Scale is not shared.

MarkIt

Opens the Specify Conditions for Marking Bar window.

Price

Price used for calculation.

Use Complete

Use complete should be used when trying to convert the spread to the sharescaled tick value, such as USA ticks ShrScale(EPEMD,USA).
Note that this parameter does not always change the value of the study.
Using ShrScale(EPEMD,USA), Use Complete fits the EPEMD into a 32nd scale 423 and 11 32nds.
If you don’t use complete, it is still a 32nds scale, but the returning value will be displayed as decimals: 423.344.

Sign (Sign)
This function is available on the Add Study window and in the Formula Toolbox.
The Sign function evaluates chart values as either positive, negative, or zero. On a Sign function chart, a positive value is displayed as a 1, a negative value is displayed as a –1, and a 0 value is displayed as 0.
Example: Sign(Mom(@))
Parameter

Description

Display

Opens a subwindow with display properties:
Color = Select a line color.
Weight = Type a value for line thickness.
Display = Select line style: line, histogram, or dash.
ShareScale = Assign a behavior for functions and studies sharing the vertical scale:
Auto = System determine whether sharing is feasible.
On = Scale is shared regardless of the functions and studies displayed.
Off = Scale is not shared.

MarkIt

Opens the Specify Conditions for Marking Bar window.

Price

Price used for calculations.

Sin (Sin)
This function is available on the Add Study window and in the Formula Toolbox.
The Sin function takes the selected chart value, converts it into radians and calculates a sine value. For example, the sine value 1090 is .13.
This value is calculated as follows:
1090/(2*pi) = 173.478 Calculates the laps around the unit circle.
.478 * (2*pi) = 3.00894 Takes the leftover lap and converts it to radians.
Sin(3.00894)radians = .13226249 Displays the sine for the calculated radians.
Example: Sin(@)
Parameter

Description

Display

Opens a subwindow with display properties:
Color = Select a line color.
Weight = Type a value for line thickness.
Display = Select line style: line, histogram, or dash.
ShareScale = Assign a behavior for functions and studies sharing the vertical scale:
Auto = System determine whether sharing is feasible.
On = Scale is shared regardless of the functions and studies displayed.
Off = Scale is not shared.

MarkIt

Opens the Specify Conditions for Marking Bar window.

Price

Price used for calculations.

Single Value Propagator (SVP)
This function is available on the Add Study window and in the Formula Toolbox.
The Single Value Propagator enables the user to plot or use in a formula a single value, for example, last bid or last offer. Using the SVP function in a custom study, for example, the user can place a horizontal line to represent the last bid and last offer with the actual market trading in between. This adds the ability to see if the traders are hitting the bids or lifting the offer.
Example: SValPropagator(@)
Parameter

Description

Display

Opens a subwindow with display properties:
Color = Select a line color.
Weight = Type a value for line thickness.
Display = Select line style: line, histogram, or dash.
ShareScale = Assign a behavior for functions and studies sharing the vertical scale:
Auto = System determine whether sharing is feasible.
On = Scale is shared regardless of the functions and studies displayed.
Off = Scale is not shared.

MarkIt

Opens the Specify Conditions for Marking Bar window.

Price

Price used for calculations.

Software Version (Version)
This function is available on the Add Study window and in the Formula Toolbox.
The Version function inserts the currently running CQG version number in the form x.xxxx.
Parameter

Description

Display

Opens a subwindow with display properties:
Color = Select a line color.
Weight = Type a value for line thickness.
Display = Select line style: line, histogram, or dash.

Digits

Number of digits in the version number.

Spread
This function can be accessed only in the Toolbox.
This function is applied to an expression to calculate the spread.
Example Formula: SPREAD(CLEET)
Spread parameters are set on the Setup Synthetic Strategy Calculation Parameters window.
Square Root (Sqrt)
This function is available on the Add Study window and in the Formula Toolbox.
The Square Root function calculates the square root of the underlying chart values. Small discrepancies may exist due to postsplit rounding by the exchanges.
Example: SqRoot(@)
Parameter

Description

Display

Opens a subwindow with display properties:
Color = Select a line color.
Weight = Type a value for line thickness.
Display = Select line style: line, histogram, or dash.
ShareScale = Assign a behavior for functions and studies sharing the vertical scale:
Auto = System determine whether sharing is feasible.
On = Scale is shared regardless of the functions and studies displayed.
Off = Scale is not shared.

MarkIt

Opens the Specify Conditions for Marking Bar window.

Price

Price used for calculations.

OB/OS

Opens a subwindow with properties for overbought and oversold indicators.
Color = Select a line color.
Weight = Type a value for line thickness.
Type = Select fixed or dynamic.
Std Dev = Choose a multiplier of the Standard Deviation used to derive high and low.
Lookback = Choose the number of bars that should be compared to the current bar.
Level = Assign a percentage value of average OB/OS to be used to calculate predictor OB/OS levels.
Display = Click this check box to display the line on the chart.
Style = Choose a line style: line, long dash, or short dash.

Square Root Deviation (SqrtDv)
This function is available on the Add Study window and in the Formula Toolbox.
Square root deviation is the square root of the deviations from a user specified moving average other than a simple moving average (which represents Standard Deviation).
The formula is the same as the Standard Deviation formula except the moving average can be of any type.
Example: SQRTDV(@,Smo,8)
Parameter

Description

Display

Opens a subwindow with display properties:
Color = Select a line color.
Weight = Type a value for line thickness.
Display = Select line style: line, histogram, or dash.
ShareScale = Assign a behavior for functions and studies sharing the vertical scale:
Auto = System determine whether sharing is feasible.
On = Scale is shared regardless of the functions and studies displayed.
Off = Scale is not shared.

MarkIt

Opens the Specify Conditions for Marking Bar window.

Price

Price used for calculations.

Type

Type of moving average used for the Average True Range calculations. Choices include: Simple, Smoothed, Exponential, Weighted, and Centered

Period

Time period for the moving average calculations.

OB/OS

Opens a subwindow with properties for overbought and oversold indicators.
Color = Select a line color.
Weight = Type a value for line thickness.
Type = Select fixed or dynamic.
Std Dev = Choose a multiplier of the Standard Deviation used to derive high and low.
Lookback = Choose the number of bars that should be compared to the current bar.
Level = Assign a percentage value of average OB/OS to be used to calculate predictor OB/OS levels.
Display = Click this check box to display the line on the chart.
Style = Choose a line style: line, long dash, or short dash.

Standard Deviation (StdDev)
This function is available on the Add Study window and in the Formula Toolbox.
Standard Deviation is a statistical measure indicating the variability of the data points. High standard deviations are believed by some analysts to indicate market tops, while the opposite is true for lower Standard Deviations. Calculating the Standard Deviation involves taking the square root of the deviations from a simple moving average.
The following formula describes the Standard Deviation ():
Sum the square of the difference of each PRICE (x) for the PERIOD (n), and the Simple Moving Average value (m).
Divide the sum by the PERIOD (n).
Calculate the square root of the above result.
Note: Bollinger divides the sum by n, whereas many other references use n – 1.
Example: STDDEV(@,8)
Parameter

Description

Display

Opens a subwindow with display properties:
Color = Select a line color.
Weight = Type a value for line thickness.
Display = Select line style: line, histogram, or dash.
ShareScale = Assign a behavior for functions and studies sharing the vertical scale:
Auto = System determine whether sharing is feasible.
On = Scale is shared regardless of the functions and studies displayed.
Off = Scale is not shared.

MarkIt

Opens the Specify Conditions for Marking Bar window.

Period

Time period for the moving average calculations.

Price

Price used for calculation.

OB/OS

Opens a subwindow with properties for overbought and oversold indicators.
Color = Select a line color.
Weight = Type a value for line thickness.
Type = Select fixed or dynamic.
Std Dev = Choose a multiplier of the Standard Deviation used to derive high and low.
Lookback = Choose the number of bars that should be compared to the current bar.
Level = Assign a percentage value of average OB/OS to be used to calculate predictor OB/OS levels.
Display = Click this check box to display the line on the chart.
Style = Choose a line style: line, long dash, or short dash.

Divisor

N = standard deviation calculation
N1 = population standard deviation calculation.

Summation (Sum)
This function is available on the Add Study window and in the Formula Toolbox.
The Summation study adds chart values over a specified period.
Example Formula:Sum(@,8)
Parameter

Description

Display

Opens a subwindow with display properties:
Color = Select a line color.
Weight = Type a value for line thickness.
Display = Select line style: line, histogram, or dash.
ShareScale = Assign a behavior for functions and studies sharing the vertical scale:
Auto = System determine whether sharing is feasible.
On = Scale is shared regardless of the functions and studies displayed.
Off = Scale is not shared.

MarkIt

Opens the Specify Conditions for Marking Bar window.

Period

Time period for the moving average calculations.

Price

Price used for calculations.

OB/OS

Opens a subwindow with properties for overbought and oversold indicators.
Color = Select a line color.
Weight = Type a value for line thickness.
Type = Select fixed or dynamic.
Std Dev = Choose a multiplier of the Standard Deviation used to derive high and low.
Lookback = Choose the number of bars that should be compared to the current bar.
Level = Assign a percentage value of average OB/OS to be used to calculate predictor OB/OS levels.
Display = Click this check box to display the line on the chart.
Style = Choose a line style: line, long dash, or short dash.

Tan (Tan)
This function is available on the Add Study window and in the Formula Toolbox.
The Tan function takes the selected chart value, converts it into radians, and calculates a tangent value. For example, the tangent value of 1090 would be .13. This value is calculated as follows:
1090/(2*pi) = 173.478 Calculates the laps around the unit circle
.478 * (2*pi) = 3.00894 Takes the leftover lap and converts it to radians
Sin( 3.00894) radians = .13226249 Calculates the sine for the calculated radians
Cos(3.00894) radians = .99124775 Calculates the cosine for the calculated radians
.13226249/.99124775 = .1334 Divides the sine by the cosine
Example: Tan(@)
Parameter

Description

Display

Opens a subwindow with display properties:
Color = Select a line color.
Weight = Type a value for line thickness.
Display = Select line style: line, histogram, or dash.
ShareScale = Assign a behavior for functions and studies sharing the vertical scale:
Auto = System determine whether sharing is feasible.
On = Scale is shared regardless of the functions and studies displayed.
Off = Scale is not shared.

MarkIt

Opens the Specify Conditions for Marking Bar window.

Price

Price used for calculations.

Tick Size (TSize)
This function is available on the Add Study window and in the Formula Toolbox.
TickSize returns the size of the minimum price units.
For example, High(@) +10*TickSize(@) returns a line ten ticks above the high of each bar.
TickSize can be used to create a channel line above and/or below a bar or candlestick chart. TickSize can also be used to define a specific price level in conditions, user formulas or trade systems.
Example: High(@) +10*TickSize(@)
Parameter

Description

Display

Opens a subwindow with display properties:
Color = Select a line color.
Weight = Type a value for line thickness.
Display = Select line style: line, histogram, or dash.
ShareScale = Assign a behavior for functions and studies sharing the vertical scale:
Auto = System determine whether sharing is feasible.
On = Scale is shared regardless of the functions and studies displayed.
Off = Scale is not shared.

MarkIt

Opens the Specify Conditions for Marking Bar window.

Time (Time)
This function is available on the Add Study window and in the Formula Toolbox.
The Time function plots the value of a point in time, allowing users to include these values in user formulas. The function plots the following:
Year
Month: 1 for January, 2 for February, 3 for March, etc.
Day
Hour
Minute
Day of Week
Week
Day of Year
Local versions, e.g. Local Year and Local Day of Week, are available in the Formula Toolbox.
DayofWeek(@) returns 1 for Monday, 2 for Tuesday, 3 for Wednesday, 4 for Thursday, 5 for Friday, 6 for Saturday, and 7 for Sunday.
It uses the start time of the bar for its calculation.
For example, for Monday's daily bar it returns 7 (Sunday) because the bar actually starts at Sunday 15:30.
LocalDayofWeek(@) returns 1 for Monday, 2 for Tuesday, 3 for Wednesday, 4 for Thursday, 5 for Friday, 6 for Saturday, and 7 for Sunday.
It uses the time from the chart’s horizontal scale for its calculation and is sensitive to Time preferences.
For a daily bar it returns the day of the week for that day.
DOW(@) returns 1 for Sunday, 2 for Monday, 3 for Tuesday, 4 for Wednesday, 5 for Thursday, 6 for Friday, and 7 for Saturday.
For intraday, it uses the start time of the bar for its calculation, the same as Day of Week (DayofWeek).
For daily and above, it uses the trading date for its calculation. For example, for Monday's daily bar it returns 2 (Monday).
Parameter

Description

Display

Opens a subwindow with display options for year, month, day, hour, minute, day of the week, week, and day of the year.

Color: Select a color for the line.

Weight: Choose how thick you want the study line.

ShareScale

Determines whether sharing of the vertical scales between studies is accepted.

Digits

Number of digits displayed after the decimal point.

Use Local Time

Overrides any other time setting, so that local time is used.
 Time Average (TimAvg)
This function is available on the Add Study window and in the Formula Toolbox.
Calculates the average for values taken at the same time of day (typically BarIX).
Example: TimAvg(@,@,10)
Parameter

Description

Display

Opens a subwindow with display properties:
Color = Select a line color.
Weight = Type a value for line thickness.
Display = Select line style: line, histogram, or dash.
ShareScale = Assign a behavior for functions and studies sharing the vertical scale:
Auto = System determine whether sharing is feasible.
On = Scale is shared regardless of the functions and studies displayed.
Off = Scale is not shared.

MarkIt

Opens the Specify Conditions for Marking Bar window.

Price

Price used for calculation.

Checkup

Choices include: Close, Open, High Low, Mid, HLC3, Average, TrueHigh, TrueLow,Range, TrueRange, TickVol, Vol, CurrentOpen, CurrentHigh, CurrentLow, Last, CurrentVol, CurrentTickVol, BestBid, BestBidVol, BestAsk, BestAskVol.

Period

The time period for the moving average calculations.

Extra Steps

A look back maximum period that the formula will try to compute. If you were to create, for example, a 1001 period variable, but the steps only went back 1000 the calculation wouldn’t work.

Time Compare (TCmp)
This function is available on the Add Study window and in the Formula Toolbox.
The Time Compare function compares a userselected time (for intraday bars) or date (for daily or longer bars) to the time or date where the vertical cursor is positioned. The study reports values for six possibilities. It returns a 1 if the choice is true and a zero if it is false. The six possibilities are:
Time EQ: The time represented by the vertical cursor position is the same as the userselected time.
Time NE: The time represented by the vertical cursor position is not the same as the userselected time.
Time GT: The time represented by the vertical cursor position is later than the userselected time.
Time GE: The time represented by the vertical cursor position is later or the same as the userselected time.
Time LT: The time represented by the vertical cursor position is earlier than the userselected time.
Time LE: The time represented by the vertical cursor position is earlier or the same as the userselected time.
Parameter

Description

Display

Opens a subwindow with display properties:
Color = Select a line color.
Weight = Type a value for line thickness.
Display = Select line style: line, histogram, or dash.

Date

Selects the date for the comparison for daily or longer bars.

Time

Selects the time for the comparison for bars shorter than daily.

Truncate Display (TrncDsp)
This function can be accessed only in the Toolbox.
This formula restricts the display of a study by n bars. It works backward from the most recent bar.
For example, TrncDsp(MA(@,Sim,21),10) would display only the last 10 values of a 21period moving average. The average is still calculated using 21 periods; only the display is affected.
Example: TrncDsp(MA(@,Sim,21),10)
Parameter

Description

Trailing Bars

Select the number of bars to display.

Yield Value (Yield)
This function can be accessed only in the Toolbox.
It calculates the yield value for a contract, provided that contract has yield specified.
You can apply this function to a contract or to a spread strategy. For example:
Yield(TYA)
Yield(SPREAD(TYAUSA, , 0.001, 1:2, , 1))
SPREAD(Yield(TYA)YIELD(BTC10), , 0.001, 10:1, , 1)
Parameter

Description

Mode

Select a type: default, specific issue, or custom.

Calculation

Opens a subwindow with parameters for custom and specific issue modes:

For details, see yield charttopic=Yield (Yield) parameters.
Custom Functions
Our product specialists often assist customers in creating custom formulas. This section documents some of those formulas.
Function

Description

MultiStandard Deviation

Multistddev(xxx1,xxx2,xxx3...)
Standard Deviation is a statistical measure indicating the variability of the data points over a historical period of time. The MultiStandard Deviation is a statistical measure indicating the variability of the data points at a specific time period.

Clip

CLIP(@,0,10)
This function is often used instead of Truncate Display. Suppose you want to look at the moving average but not its history. Clip the last ten (or some other number) bars to see only that data.

Maximum Per and Minimum Per

MAXPER(High(@),BarIx(@,StartOfDay)+1)
MINPER(Low(@),BarIx(@,StartOfDay)+1)
These functions are used with Imoku and trade systems.
They do the same thing as MaxSince and MinSince except here you can insert conditions right into formula instead of using the parameters dropdown.

Bid Volume and Ask Volume

@:bidvolume
@:askvolume
These functions are used with TFlowtopic=TFlow (TFlow) in lieu of VolAsk and VolBid study outputstopic=Volume (Vol).

Filter Tick Bate

FilterTickBate(@,1) = bid
FilterTickBate(@,2) = ask
These studies are used to chart the bid and ask and is used most often by spread traders, who chart bid to bid or ask to ask.

Share with your friends: 