Advanced Analytics

Creating Conditions and User Values

Download 0.61 Mb.
Size0.61 Mb.
1   ...   7   8   9   10   11   12   13   14   ...   20

Creating Conditions and User Values



Conditions are used for marking an event or state on a bar. They are binary. That is, they are either true or false for each bar.

Situational examples

Reversal days

Price crossing a moving average

Stochastic %K crossing %D

Formula components

Conditions are composed of bar, function, parameter, and study values.

Note: To enable you to quickly identify inserted conditions in your formulas, CQG inserts the letter “B” in front of the condition name.

Formula example

High(@) > High(@)[-1] AND Low(@) < Low(@)[-1]

Marks the outside bar on a chart. The outside bar is one with a higher high and lower low than the previous bar. (cqg.BarOutside)


Formula Builder Conditions window


Used with

Condition alerts

Market Scan

Signal Evaluator

Trade systems

Note: Function-type studies rely on the use of a condition as a parameter. When these studies are plotted on a chart, the values returned depend on the occurrence of the defined condition, as well as the other parameters used.

Pre-defined formulas

CQG offers these formulas (parameters in parentheses):



























User Values


User values yield definite numbers. You can think of them as a way to store calculations (or even actual numbers).

They are dynamic parameters that when changed, change all instances of that user value throughout the system. Suppose you create a user value @price and set its value to mid. When you change the value of @price to high, all instances of @price across all applications are then calculated by the high and not the mid.

Formula components

Conditions are composed of bar, function, and parameter values.

Note: To enable you to quickly identify inserted User Values in your formulas, CQG inserts the letter “V” in front of the condition name.

Formula example

MA_DIFF_15_60: MA (@Exp15) – MA (@Exp60)


Formula Builder User Values window


Used with

Signal Evaluator

Build other formulas from user values: QFormulas, conditions, custom studies, and trade systems.

User values appear as one of the choices in any study where price is a parameter.

Pre-defined formulas







18.To create new conditions or user values

  1. Click the New button on the Conditions or User Values tab from Formula Builder to open the Create a New Condition (or User Value) window.

  2. Enter a condition (user value) name in the Create a New…window. User values cannot be named the same as a bar value, for example, Open, Close, and so forth.

  3. Click OK to open Formula Builder.

  4. Click the Toolbox button to define the new condition (user value).

  5. Select the elements from the Formula Toolbox to insert into the new condition (user value).

To copy a condition or user value

You can modify an existing condition or user value to use it as the basis for a new user value or formula.

  1. Click a Condition or User Value from the Available…. section on the relevant tab in Formula Builder.

  2. Click the Copy button to open the Copy a User Value window.

  3. Enter a different name for the Condition or User Value.

  4. Click OK to close the Copy a …window.

The newly named formula appears in the Formula for… section and can be modified either directly or by selecting and inserting items from the Formula Toolbox.

19.To define condition and user value parameters (Parms Button)

The Parameters window allows you to save specific, often-used values to be easily inserted into a condition, user value, custom study. Parameters are listed on the Special tab of the Formula Toolbox.

To open this window, click the Parms button associated with the condition, user value, and custom study or trade system.

To view and edit parameters used

  1. Select the Condition, User Value, Custom Study, or Trade System for which you want to view parameters.

  2. Click the Parms button. The standard parameters associated with the study are displayed.

  3. Make desired changes to the parameters, including adding a column or row header.

  4. Click OK.

To add a parameter

  1. Click the Parms button.

  2. Click the New button.

  3. Enter a name for the parameter.

  4. Select the Int check box if the parameter is going to be an integer. Leave the box unchecked if the parameter is going to be a floating-point decimal number.

  5. Enter a default value.

  6. Enter column and row header names if desired.

  7. Enter a note if desired.

  8. Click OK.

To delete a parameter

  1. Select the Condition, User Value, Custom Study, or Trade System that contains the parameter you want to delete.

  2. Click the Parms button.

  3. Select the parameter you want to delete.

  4. Click the Delete button.

To insert a parameter

After customizing and adding parameters, they can be inserted into a formula.

  1. Click in the location you want to add the parameter in the Formula Editor.

  2. Click the Toolbox button.

  3. Go to the Special tab.

  4. Click the parameter you want to add.

  5. Click the Insert button.

  6. Click Close.

Note: Each parameter can be inserted only into the condition for which it was defined. To re-use the same parameter for more than one condition, you must redefine the parameter.

20.Creating Conditions: Example

  1. Create a new condition.


  1. Choose studies using the toolbox. In this example, we inserted SSK, then used the Special menu to add XABOVE. Finally, we added SSD.

The formula is added to the list:

  1. Create new parameters for the condition (click Parms button).


  1. Change parameter values. Highlight the entire condition in the formula editor window:

  1. Click Setup.

  2. Select new values.



  1. Add the custom condition to a chart. Right-click on a bar or candlestick chart, and click Select conditions for marking Bar/Candl. Choose a color and/or symbol to add to chart.


Results :


21.Specify Conditions Window

The Specify Conditions window is used with several applications:

Portfolio Monitor and Instrument Monitor

Charts and Studies

DOMTrader (Show on Trading Interface button)


Market Scan

To create a new condition

Click the Define Condition button to open Formula Builder.

To add a condition

  1. Click a condition on the list.

  2. Click the Include button.

  3. Optionally, modify the display. Click the symbol to open a symbol; click the colored square to open a color palette:

  1. Optionally, modify the parameters by typing new values in the field. The parameters field is displayed only when a condition is selected for marking and that condition has parameters.

Click the Exclude button below the display parameters to remove the condition.

Click the Move Up and Move Down buttons to move the conditions up and down the list.

To create and manage folders

Right-click the Conditions list, then click Manage Folders to open the folder management window. You can also click the Folders button on the Utility toolbar|topic=Utility Toolbar.

Folder management here is the same as on Formula Builder. See: Manage Folders menu.

To add a condition to a folder, right-click a condition, then click Move to Folder.

Download 0.61 Mb.

Share with your friends:
1   ...   7   8   9   10   11   12   13   14   ...   20

The database is protected by copyright © 2023
send message

    Main page