Chart Variables - C# Variables

Duration:10:49
Variable speed version: Watch

This video discusses a new concept introduced in Investor/RT 12.2: Chart Variables or C# Variables. Unlike User Variables (V#1,...V#512), Chart Variables are not associated with a specific instrument (ticker) but with a specific chart. The RTL language and indicator setup dialogs support these C# variables, C#1,...C#32. Chart variables may be used in the same places as V# variables are, typically as variables/periods within indicator settings.

C# variables can be assigned values using RTL, e.g. SET(C#1, ). Since C#'s are associated with a specific chart name, the RTL SET method can be used only when an RTL signal or custom indicator is being evaluated within a chart. Typically, the most convenient way to assign a value to a C# will be to add a button to the chart for this purpose. Setup the button with the purpose "Set C# from a list of values". Like with V# variables, you can setup the button so you will be prompted for the value to assign to the C# in question and the chart's indicators will then update to reflect the newly assigned C# value. This button purpose can also be used to create buttons that set a specific value into a C# without prompting, or to create menu buttons that offer a menu of various values to be set into a particular C#, both avoiding the prompting message.

Each chart has its own set of 32 C# variables. Chart_A has a value for C#1 and that value does not change when you change instruments in Chart_A. Assigning a value to C#1 when using Chart_B has no effect on Chart_A. This applies to export/import of chart definition. When you import a chart definition that uses C#'s there is no need to be concerned about conflicts of C# usage with other charts you already have. The chart will be imported and setup using the C# values exported in the definition. You can duplicate a chart that makes use of C# variables. In the duplicate chart you can assign different values to the C#'s and observe the effect while the original chart remains unchanged. In contrast, if you have an indicator that depends on V#33 to supply the period of some average and you duplicate that chart (same symbol) and change V#33 to a different value, both charts will show the same result since V#33 changes in chart A are reflected in all charts that reference the same symbol's V#33.

There are usage cases for V#'s where you need to have variability per symbol so that symbol changes in charts causes different values of the V# to be used. Choose a C# instead of a V# in situations where you want variability per chart, but you want the same value to be used consistently for any symbol you place in a particular chart.

When viewing a chart that uses C# variables, if you wish to see the C# values currently setup in that chart, right-click in the chart and choose Calc Statistics. Values for each non-zero C# are shown at the bottom of the statistics in the ensuing text window.

The values of each non-zero C# variable in a chart are exported in chart definition by Version 12.2 and higher. When importing chart definitions produced by earlier version of Investor/RT, all C# variables will initially be set to zero in the imported chart.