We define colours in MultiCharts scripts with a PowerLanguage keyword (like black or yellow) or with a numerical value. How that value is interpreted depends on the colour scheme used by the script. How do we switch between the old and new colour model?

In this article:

Working with legacy colour values in MultiCharts

A PowerLanguage attribute is a keyword that enables or disables a certain script feature. They’re applied when the code compiles and cannot be modified during run-time (e.g., MultiCharts Wiki, 2012b). This means that, once an attribute is added to a script, we can only change the feature it affects by setting the attribute to true or false and then recompiling the script. Since most attributes have no manual equivalent setting (including LegacyColorValue), using the attribute programmatically is often the only way to change the script’s behaviour.

PowerLanguage attributes can be added anywhere in the script, but their typical location is in the top of the script. For instance, here we’ve started the script with the IntrabarOrderGeneration and RecoverDrawings attributes:

Example location of MultiCharts attributes in a script

In MultiCharts PowerLanguage we can specify colours with keywords (like green, black, and red) or with numbers. What the LegacyColorValue attribute does is specifying which colour scheme is used for interpreting numerical colour values (MultiCharts Wiki, 2012a).

When that attribute is set to true, the old colour scheme with 16 different colours is used; when set to false or not present in the script’s code, then the new RGB colours are used (MultiCharts Wiki, 2012a). That latter colour scheme contains more than 16 million different colours, created by combining different shades of red, green, and blue (Wikipedia, 2016).

Comparing legacy colour values with RGB values

Each colour keyword (like red or green) returns a numerical value that’s indicates the specific colour. That returned value, however, depends on the script’s colour scheme: with LegacyColorValue set to true that number will be between 1 and 16; with LegacyColorValue set to false or when this attribute is missing from the script, then a RGB value is used (MultiCharts Wiki, 2012a).

The colour keywords have the following legacy and RGB values (TradeStation, 2007):

Colour keyword Legacy value RGB value
Black 1 0
Blue 2 16711680
Cyan 3 16776960
Green 4 65280
Magenta 5 16711935
Red 6 255
Yellow 7 65535
White 8 16777215
DarkBlue 9 8388608
DarkCyan 10 8421376
DarkGreen 11 32768
DarkMagenta 12 8388736
DarkRed 13 128
DarkBrown 14 32896
DarkGray 15 8421504
LightGray 16 12632256

So instead of using colour keywords like yellow and magenta in our code, we can also use numbers when specifying a colour (MultiCharts Wiki, 2012a). For instance, when LegacyColorValue is enabled then the first plot’s colour can be set to dark red with SetPlotColor(1, 13) instead of SetPlotColor(1, darkred). This also allows for calculating with numbers; when LegacyColorValue is set to true, then 4 refers to green but adding 2 give us red.

Programmatically enabling or disabling LegacyColorValue

To make a script use the legacy colour scheme with 16 colours, we set the LegacyColorValue attribute to `true:

[LegacyColorValue = true];
Note: When a script made with an EasyLanguage version prior to 8.1 is imported, MultiCharts automatically adds the LegacyColorValue attribute set to true to ensure compatibility (MultiCharts Wiki, 2012a).

To use the RGB colour scheme in a script we don’t add the LegacyColorValue attribute or set it to false instead:

[LegacyColorValue = false];

Note that a script’s colour scheme cannot be set manually; we can only set it programmatically with LegacyColorValue.

Example: working with the LegacyColorValue attribute in MultiCharts

Let’s look at how we can use LegacyColorValue. In the example indicator below we plot an EMA (Exponential Moving Average) and colour price bars based on this moving average. After discussing the code, we’ll look at charts to see the effect of LegacyColourValue.

[LegacyColorValue = true];

ema = XAverage(Close, EMA_Length);

Plot5(ema, "EMA", darkblue);
if (Close > ema) then
    PlotPaintBar(High, Low, Open, Close, "Uptrend", UpColour)

else if (Close < ema) then
    PlotPaintBar(High, Low, Open, Close, "Downtrend", DownColour);

We start by setting LegacyColorValue to true between two square brackets ([ and ]). Then we create three inputs:


We’ll use the UpColour and DownColour inputs when colouring the price bars. Those inputs are set to 4 and 6 by default, meaning they represent green and red when LegacyColorValue is enabled. The third input, EMA_Length, has a standard value of 20 and is used when computing the moving average.

Then we determine the EMA:

ema = XAverage(Close, EMA_Length);

After making the ema variable and setting it to a default value of 0, we assign (=) it the value returned by XAverage(). That function computes an exponential moving average based on two values: the data to compute on and the moving average length in number of bars. We set the first to the bar’s closing price (Close) and the second to EMA_Length, the input option that we gave a default value of 20 earlier.

Then we plot the EMA value on the chart:

Plot5(ema, "EMA", darkblue);

The plotting is done with Plot5(). The PlotN keywords plot a numerical value or string, with N specifying the plot number (MultiCharts Wiki, 2012c). That keyword has several parameters, of which we use three: the plot value (set to the ema variable here), its name ("EMA"), and its colour (darkblue). We use plot number 5 because later on in the script we use PlotPaintBar() and that keyword already uses the plot numbers 1 to 4. This way our EMA plot isn’t overridden by PlotPaintBar(), which would happen if we used one of the first four plots.

Next we colour price bars depending on how they relate to the EMA:

if (Close > ema) then
    PlotPaintBar(High, Low, Open, Close, "Uptrend", UpColour)

else if (Close < ema) then
    PlotPaintBar(High, Low, Open, Close, "Downtrend", DownColour);

The first part of this if/else statement checks whether the bar’s closing price (Close) is greater than (>) that bar’s EMA value (ema). When that’s the case, we call PlotPaintBar(). That keyword creates plots that are placed over the bars of the chart, in effect ‘paining’ the bars (MultiCharts Wiki, 2012d). PlotPaintBar() has several parameters, of which we use 6: with the High, Low, Open, and Close values we set the coloured price bar’s four prices followed by the name ("Uptrend") and colour of the painted price bar, which we set with the UpColour input.

The else if portion evaluates whether the bar’s closing price is below the EMA (Close < EMA). When that’s the case, we again plot a coloured price bar that’s similar to the first. This time, however, the plotted bar is named “Downtrend” and its colour is set to the DownColour input variable.

Working with legacy colour values in MultiCharts PowerLanguage

When we add the above example to a EUR/USD chart, it looks like:

Example of using LegacyColorValue in MultiCharts PowerLanguage

The price bars are coloured red and green here since we use the legacy colour scheme (with LegacyColorValue) and inputs that are by default set to 4 (green) and 6 (red):

Input options of our MultiCharts programming example

Now let’s change the script’s source code to see the effect of the LegacyColorValue attribute. For that, we set this attribute to false:

[LegacyColorValue = false];

We recompile the script without changing anything else. The indicator now looks like:

Using RGB colours instead of legacy colours in MultiCharts

Now all price bars are black while the EMA is still dark blue. That’s because we’ve set the EMA line’s colour with the darkblue keyword. That keyword returns 9 under the legacy colour scheme and 8388608 when using RGB colours (see table above). But while that number differs, in both cases it’s the same shade of blue. That is, LegacyColorValue doesn’t affect PowerLanguage colour keywords; they just return another value but for the same colour.

However, LegacyColorValue does affect the price bars in our example. That’s because we coloured them with values of 4 and 6, which represent green and red under the legacy colour system. But when using RGB colours (so LegacyColorValue disabled), green has a value of 65280 and red 255. Black, on the other hand, then has a value of 0, which is very close to the original values of green (4) and red (6). Since RGB colours are a continuous scale, our 4 and 6 colour values display in a very black tint when the RGB colour scheme is enabled.

But let’s change the indicator’s inputs to the following:

Changing the input options of our MultiCharts script

Now our example indicator displays as follows when LegacyColorValue is still set to false:

Plotting with RGB colours in MultiCharts

For other PowerLanguage attributes that can be used in both indicators and strategies, see RecoverDrawings for automatic removal of drawings and ProcessMouseEvents to work with mouse clicks in MultiCharts.


We can specify colours in MultiCharts by using a number. The LegacyColorValue attribute affects which colour scheme is used when interpreting those numbers. When this attribute is set to true, the script uses the 16 legacy colours that have values of 1 till 16. Should LegacyColorValue be set to false or isn’t present in the script’s code, then MultiCharts uses the new RGB colour scheme that has more than 16 million colours.


MultiCharts Wiki (2012a, February 19). LegacyColorValue. Retrieved on January 7, 2016, from https://www.multicharts.com/trading-software/index.php/LegacyColorValue

MultiCharts Wiki (2012b, August 31). IntrabarOrderGeneration. Retrieved on January 4, 2016, from http://www.multicharts.com/trading-software/index.php/IntrabarOrderGeneration

MultiCharts Wiki (2012c, February 19). Plot. Retrieved on January 9, 2016, from http://www.multicharts.com/trading-software/index.php/Plot

MultiCharts Wiki (2012d, February 19). PlotPaintBar. Retrieved on January 9, 2016, from https://www.multicharts.com/trading-software/index.php/PlotPaintBar

TradeStation (2007). EasyLanguage Essentials Programmers Guide. Retrieved from https://www.tradestation.com/~/media/Files/TradeStation/Education/University/School%20of%20EasyLanguage/Books/EL_Essentials.ashx

Wikipedia (2016, January 8). RGB color model. Retrieved on January 9, 2016, from https://en.wikipedia.org/wiki/RGB_color_model

Visit Kodify.net for more helpful coding articles.