Indicator Scripts#

PowerLanguage has two main script types: Signal and Indicator. A Signal script places buy and sell orders; an Indicator script draws calculated values on the chart — moving averages, RSI, Bollinger Bands, and so on.

Both script types share the same syntax. The key difference is that an Indicator uses the Plot function to output values to the chart, whereas a Signal uses Buy, Sell, and related order commands.

The Plot Function#

The Plot function draws a value onto the chart. Each indicator supports up to 999 lines, named Plot1 through Plot999.

Syntax#

1
Plot1(Value, "Name", Color, Width);
ParameterDescription
ValueThe numeric value to draw
NameLabel shown in the chart legend
ColorLine color — use a color name (e.g. Red) or RGB(R, G, B). Omit to use the default color
WidthLine width as an integer. Omit to use the default width

Color and Width are both optional; omitted parameters fall back to the chart’s default settings.

Examples#

1
2
3
4
5
// 20-period moving average, blue, width 2
Plot1(Average(Close, 20), "MA20", Blue, 2);

// Volume
Plot2(Volume, "Vol", Yellow, 1);

Setting Colors#

Instead of setting color once inside the Plot call, you can update it bar-by-bar using SetPlotColor and SetPlotWidth.

SetPlotColor(PlotNumber, Color)#

Dynamically sets the color of a plot line.

ParameterDescription
PlotNumberLine number corresponding to Plot1Plot999
ColorColor name or RGB(R, G, B)

SetPlotWidth(PlotNumber, Width)#

Dynamically sets the width of a plot line.

ParameterDescription
PlotNumberLine number
WidthWidth as an integer

NoPlot(PlotNumber)#

Clears the drawn point for a specified plot on the current bar.

The typical use case is conditional plotting: Plot is called only when a condition is true. In real-time, the open bar is recalculated on every new tick, and the condition may flip from true back to false. The point that was already drawn does not disappear on its own — you must call NoPlot to remove it.

1
2
3
4
5
// Plot a point only when close breaks above the prior bar's high
If Close > High[1] Then
  Plot1(Close, "Breakout")
Else
  NoPlot(1);  // Clears the point if the condition becomes false mid-bar
ParameterDescription
PlotNumberLine number

Dynamic Colors#

Changing a line’s color based on a condition is a common indicator technique — for example, green when price rises and red when it falls.

1
2
3
4
5
6
Plot1(Close, "Close");

If Close >= Open Then
  SetPlotColor(1, Green)
Else
  SetPlotColor(1, Red);

Complete Example: MA Crossover Indicator#

The indicator below draws a fast and a slow moving average. The fast line turns green when it is above the slow line, and red when it is below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
Inputs: FastLength(10), SlowLength(20);
Variables: FastMA(0), SlowMA(0);

FastMA = Average(Close, FastLength);
SlowMA = Average(Close, SlowLength);

Plot1(FastMA, "FastMA");
Plot2(SlowMA, "SlowMA", White, 2);

If FastMA >= SlowMA Then
  SetPlotColor(1, Green)
Else
  SetPlotColor(1, Red);

Two lines appear on the chart:

  • Plot1 (FastMA): color changes dynamically — green when the fast MA is above the slow MA, red otherwise.
  • Plot2 (SlowMA): fixed white color, width 2.

Reference#

https://www.multicharts.com/trading-software/index.php?title=Plot

https://www.multicharts.com/trading-software/index.php?title=SetPlotColor

https://www.multicharts.com/trading-software/index.php?title=SetPlotWidth

https://www.multicharts.com/trading-software/index.php?title=NoPlot