# Parameters inside CQG Code

We are getting a lot of questions about CQG parameters (Parms). In CQG, parameters are used for everything that needs to be controlled from the user interface and only Parms can be optimized.

The window above shows an example of a trading system using four different parameters. Two for the length of the moving averages and two for money management stops. This article is about creating the different parameters and associating them with your code. A subsequent article will focus on how to optimize them.

Parameters can be used for conditions, user values, custom studies and, of course, trading systems. The dialog for creating parameters for each desired element opens by clicking on the Parms button inside the Define User Formulas window.

The first step is to click New to create the parameters you need before you can use them inside your code.

There are five categories for parameters: Integer, Float, Boolean, Date, and Time.

• Integer: Numerical value, 0 - 9999999
• Float: Decimal (floating point value), 0 - 999999.99
• Boolean: Checkbox to switch something on or off
• Date: Specifies a unique date
• Time: Specifies a unique time

It is good practice to think about everything you might want to control from outside in your custom study or trading system and create the parameters before you actually start coding. Once you create parameters, they are not active unless you associate them with your code.

There are three different way to get your parameters inside your own code:

1. Parameters for Existing Studies or Functions

In order to substitute the default values of a study or function with your parameters, you need to highlight the desired study and click on the Setup button to start the Setup Study Parameters dialog. You can select multiple studies altogether; they will be listed in order of appearance.

Right-click the fixed value you want to substitute to view the list of available parameters.

Note: You cannot just type inside the code for studies; the dialog is mandatory.

2. Parameters for Values that are Plain Numbers inside the Code

If you typed a simple number inside your code; for example,

`RSI(@,21) XABOVE 25`

You can substitute the 25 by simply typing the name of the parameter instead of 25:

`RSI(@,21) XABOVE Level`

In this case, Level is the name of the parameter.

Make sure you do not mistype the name and remember to use proper casing.

Alternatively, you can highlight the number and select the parameter from the special tab in the Formula Toolbox and click Replace.

3. The Use of Parameters for Canned Exits in Trading Systems

If you intend to use one of CQG's canned exits inside a trading system, it is very easy to use parameters instead of fixed values. You can either just type the parameter name in the value box instead of a value, or alternatively, right-click to see the available substitutes.

For more insight on the different canned exits, please refer to the article Using the Super Template. There is also a good example for the use of Booleans inside the Super Template. The next article will feature CQG's Trade System Optimizer - stay tuned.