Skip to content

Bar Variables and Properties

By Optuma Team · Updated 2020-04-03

You can setup Bar = references to a variable, and display that variables value in the properties panel of the scripting tool, allowing it to be modified via the panel, rather than needing to edit the script each time.

To setup a bar variable script functions such as MA() can reference you use the $ symbol.

For example:

$a = 50;

This sets the bar variable to 50. This can then be referenced in other areas of the script (anywhere a function contains a Bar= property.)

plot1 = MA(BARS = $a);

In this example the script would plot a 50SMA on the chart.

Bar Variables can be more than static numbers, they can be build from any script function, for example:

$b = ATR(BARS = 100, MULT = 1);
$c = Close() +100;
plot1 = MA(BARS = $b);
plot2 = MA(BARS = $c);

In this example b would be the value of an ATR and c would be the value of the Closing price + 100.

When a bar variable has been setup in a script, you can add a property for this value to the tools properties panel. This is done using the ”#” symbol.

For example:

#$a = 50

When looking at the properties of a tool containing this script, the value for a would be displayed and could be adjusted from the panel.

Properties

This setup allows you to modify parts of the script like you would a standard tool, without the need to edit the underlying script code.

Tool Properties Example

Example script from above image:

#$MA1 = 20;
#$MA2 = 50;
plot1 = MA(Bars = $MA1);
plot2 = MA(Bars = $MA2);

Choose which categories of cookies you allow. Strictly-necessary cookies are always on. You can change this any time via the "Cookie Settings" link in the footer.

  • Functional

    Remember preferences like dismissed banners and your dark-mode choice.

  • Analytics

    Help us understand how the site is used so we can improve it.

  • Marketing

    Measure our advertising and help us reach people who may be interested in Optuma.