## Symbol Equations

The chart engine is capable of display plots representing the result of equations involving one or more instruments/symbols.

To allow equations to be used on a chart, the CIQ.ChartEngine#allowEquations parameter must be set to `true`

.

All equations must be preceded by an equals sign `=`

in order for them to be parsed and calculated; otherwise it will be assumed to be a single symbol.

An equation can consist of symbols and the following operators:

`+`

`-`

`/`

`*`

`%`

`(`

`)`

PEMDAS (Parentheses, Exponents, Multiplication/Division, Addition/Subtraction) order is followed.

Valid examples:

- =3IBM
- =4+(IBM2)
- =(IBM-GM)/2

Additionally, symbols can be enclosed in brackets `[]`

to treat them as literal non-parseables. This is useful if the required symbol happens to include one of the operators as part of its naming convention. Example: `=[XYZ-PR]*2`

The symbol will be `XYZ-PR`

, rather than the equation trying to subtract `PR`

from `XYZ`

It is important to note that currently equations can only operate on the 'close' price of the instrument rather than any other value such as high, low, open, etc.

For example, instantiating a chart with a plot that represents 2 times the difference of closing prices between IBM and GM would look look this:

`stxx.newChart("=2*(IBM-GM)");`

Equations are also supported for additional series using CIQ.ChartEngine#addSeries

Example:

```
// using equations as symbols, this will display an inverted chart for instrument 'T'
// note the formatter used to change the sign of the axis values
var axis2=new CIQ.ChartEngine.YAxis({position:"left",textStyle:"#FFBE00",priceFormatter:function(stx, panel, price, decimalPlaces){return stx.formatYAxisPrice(price, panel, decimalPlaces)*-1}});
stxx.addSeries("=-1*T", {display:"Test",width:4,renderer:"Lines",color:"#FFBEDD",yAxis:axis2},function(){});
//this will display the same series in the standard scale.
var axis3=new CIQ.ChartEngine.YAxis({position:"left",textStyle:"#FFBE00"});
stxx.addSeries("T", {display:"Test",width:4,renderer:"Lines",color:"#FFBEDD",yAxis:axis3},function(){});
```

Equations require the use of a "quotefeed" to fetch the individual instruments on the equation real time.

### Studies vs. Equations

Studies are different than equations. Studies are designed to produce outputs for more involved requirements, such as multi layered formulas, multiple lines, or special displays that go beyond lines, histograms, candles, etc.

Equations should be used for the more basic single-line formulas that can be typed in a symbol input field.