Situation
You want to know which plot types are available in MultiCharts .NET.

The three steps for plotting in MultiCharts .NET

To plot indicator values in MultiCharts .NET, three steps are required (MultiCharts, 2013):

  1. The plot object needs to be declared: graphic plots require the use of IPlotObject, while textual plots require IPlotObjectStr;
  2. The plot needs to be initialised (i.e., created) in the Create() override method with the AddPlot() method. This last method requires a PlotAttributes argument for graphic plots, while a StringPlotAttributes argument is needed for textual plots;
  3. To set the value of the plot on each bar, its Set() method needs to be called in the CalcBar() method.

The examples below further discuss these three steps and show how to create a basic plot for each of the available plots in MultiCharts .NET.

Creating a line plot in MultiCharts .NET

The example below shows how to create a basic line plot:

using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;

namespace PowerLanguage.Indicator
{
    public class Example_BasicPlot : IndicatorObject
    {
        private IPlotObject linePlot;
        
        public Example_BasicPlot(object _ctx) : base(_ctx) { }

        protected override void Create()
        {
            linePlot = AddPlot(new PlotAttributes());
        }

        protected override void CalcBar()
        {
            linePlot.Set(Bars.High[0] - Bars.Low[0]);
        }
    }
}

Here an IPlotObject object is declared in line 10. This linePlot object is subsequently initialised in the Create() method by calling the AddPlot() method (line 16). The last step is setting the value of the line plot on each bar, which is done with its Set() method in the CalcBar() method (line 21).

Creating a histogram plot in MultiCharts .NET

Plotting a histogram in MultiCharts .NET is done as follows:

using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;

namespace PowerLanguage.Indicator
{
    public class Example_BasicPlot : IndicatorObject
    {
        private IPlotObject histogramPlot;
        
        public Example_BasicPlot(object _ctx) : base(_ctx) { }

        protected override void Create()
        {
            histogramPlot = AddPlot(new PlotAttributes("", EPlotShapes.Histogram, Color.DarkOrange));
        }

        protected override void CalcBar()
        {
            histogramPlot.Set(Bars.High[0] - Bars.Low[0]);
        }
    }
}

Creating a histogram plot is highly similar to creating a line plot: first an IPlotObject (line 10) is declared followed by initialising this object with the AddPlot() method (line 16).

A difference with a basic line plot is the overloaded PlotAttributes constructor that allows setting the EPlotShapes enumeration to Histogram. That alternative version of PlotAttributes also requires a colour argument (see PowerLanguage .NET Help, n.d.), which is set to dark orange in line 16.

In the CalcBar() override method, the histogram value is set to the difference between the high and low of the current price bar (line 21).

Creating a dotted line plot in MultiCharts .NET

The example below shows how to create a basic dotted line:

using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;

namespace PowerLanguage.Indicator
{
    public class Example_BasicPlot : IndicatorObject
    {
        private IPlotObject dotPlot;
        
        public Example_BasicPlot(object _ctx) : base(_ctx) { }

        protected override void Create()
        {
            dotPlot = AddPlot(new PlotAttributes("", EPlotShapes.Point, Color.Blue));
        }

        protected override void CalcBar()
        {
            dotPlot.Set(Bars.High[0] - Bars.Low[0]);
        }
    }
}

Creating a dotted line plot is much alike creating a histogram plot. First, an IPlotObject is declared and then initialised in the Create() method with AddPlot() (line 16). In that statement the plot is set to dots (EPlotShapes.Point). Lastly, in the CalcBar() method the value of the plot is set to the range of the current bar.

Creating a cross plot line in MultiCharts .NET

To create a basic cross plot (a line that consists out of + signs), the following needs to be done:

using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;

namespace PowerLanguage.Indicator
{
    public class Example_BasicPlot : IndicatorObject
    {
        private IPlotObject crossPlot;
        
        public Example_BasicPlot(object _ctx) : base(_ctx) { }

        protected override void Create()
        {
            crossPlot = AddPlot(new PlotAttributes("", EPlotShapes.Cross, Color.Purple));
        }

        protected override void CalcBar()
        {
            crossPlot.Set(Bars.Close[0] - Bars.Close[1]);
        }
    }
}

Like other line plots, first an IPlotObject object is declared (line 10) followed by initialising with the AddPlot() method (line 16). Different is that the EPlotShapes enumeration is set to the Cross enumerator. The plot value is set in the CalcBar() method with the Set() method. The argument of this latter method is the close of the current price bar minus the close of a historical price bar.

Creating a paint bar plot in MultiCharts .NET

Creating a plot that colours the whole price bar is unlike creating a line plot:

using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;

namespace PowerLanguage.Indicator
{
    [SameAsSymbol(true)]
    public class Example_BasicPlot : IndicatorObject
    {
        private IPlotObject plotHigh, plotLow, plotClose, plotOpen;
        
        public Example_BasicPlot(object _ctx) : base(_ctx) { }

        protected override void Create()
        {
            plotHigh  = AddPlot(new PlotAttributes("", EPlotShapes.BarHigh, Color.ForestGreen));
            plotLow   = AddPlot(new PlotAttributes("", EPlotShapes.BarLow, Color.ForestGreen));
            plotClose = AddPlot(new PlotAttributes("", EPlotShapes.RightTick, Color.ForestGreen));
            plotOpen  = AddPlot(new PlotAttributes("", EPlotShapes.LeftTick, Color.ForestGreen));
        }

        protected override void CalcBar()
        {
            plotHigh.Set(Bars.High[0]);
            plotLow.Set(Bars.Low[0]);
            plotClose.Set(Bars.Close[0]);
            plotOpen.Set(Bars.Open[0]);
        }
    }
}

This example begins with setting the SameAsSymbol attribute to true (line 8) so that the plotted paint bars are overlaid on the price bars of the main chart (see MultiCharts, 2013).

To learn more about paint bar plots, see how to colour a price bar and creatively painting price bars.

Instead of declaring one IPlotObject object, four of these are declared (line 11): one for the high, low, close, and open of a price bar. Each is initialised in the Create() override method with the AddPlot() method and with EPlotShapes set to BarHigh, BarLow, RightTick (for the closing price) and LeftTick (for the open price).

In the CalcBar() method, each plot is set to their respective price of the current bar. As a result each price bar is coloured forest green.

Creating a textual plot in the MultiCharts .NET

Creating a textual plot, which displays a string in the chart’s Status Line or in a Market Scanner row, is done as follows:

using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;

namespace PowerLanguage.Indicator
{
    [SameAsSymbol(true)]
    public class Example_BasicPlot : IndicatorObject
    {
        private IPlotObjectStr textPlot;
        
        public Example_BasicPlot(object _ctx) : base(_ctx) { }

        protected override void Create()
        {
            textPlot = AddPlot(new StringPlotAttributes());
        }

        protected override void CalcBar()
        {
            textPlot.Set(Bars.Close[1].ToString());
        }
    }
}

By the way, see plotting text in the Status Line and colouring text in the Status Line to learn more about text plots.

Compared to a graphic plot, two things are unique to textual plots (see MultiCharts, 2013): declaring an IPlotObjectStr (line 11) and using the StringPlotAttributes struct as an argument in the AddPlot() method (line 17).

In this example, the SameAsSymbol attribute (line 8) is set to true so that no separate sub-chart is created. In the CalcBar() override method, the value of the text plot is set to the previous closing price with its ToString() method.

Key points:

  • Line plots, bar plots, and histogram plots require an IPlotObject object, whereas textual plots require an IPlotObjectStr object;
  • The different types of IPlotObject plots can be set with the EPlotShapes enumeration as an argument of the PlotAttributes struct;
  • A paint bar plot requires four IPlotObject objects, one for each price bar component (open, high, low, close);
  • Creating textual plots requires the StringPlotAttributes struct as an argument of the AddPlot() method.
References

MultiCharts (2013). MultiCharts .NET Programming Guide (version 1.0). Retrieved from http://www.multicharts.com/downloads/MultiCharts.NET-ProgrammingGuide-v1.0.pdf

PowerLanguage .NET Help (n.d.). Retrieved on May 16, 2014, from http://www.multicharts.com/downloads/PowerLanguage.NET.chm