The .bsi and .bsd Command Line commands change the bar spacing. But how can we change the bar spacing such that all price bars are displayed in the current chart view?

Showing all price bars in a single MultiCharts .NET price chart

The .eds Command Line command causes the entire data series to be displayed (MultiCharts Wiki, 2014). This is achieved by decreasing the bar spacing so that all price bars are displayed in the current chart view, like this:

Example of showing the full MultiCharts .NET data series

The more price bars there are on the chart, the lower the bar spacing value becomes (0.25 pixels in the image above). With multiple data series on the chart, .eds sets the bar spacing so that all price bars from all data series are visible in the chart view.

The .eds (Entire Data Series) command has no parameters. It’s executed programmatically with the ChartCommands.CommandLine() method (PowerLanguage .NET Help, n.d.).

Showing the entire data series with the Command Line

.eds can be combined with the .bsi command (which increases the bar spacing) to alternate between chart views, like this:

protected override void OnMouseEvent(MouseClickArgs arg)
{
    if (arg.buttons == MouseButtons.Left && arg.keys == Keys.Shift)
    {
        barSpacing = Environment.BarSpacing;
        ChartCommands.CommandLine(".eds");
        Thread.Sleep(100);

        Output.WriteLine("Bar spacing was {0}px, and is now {1}px.", 
            barSpacing, Environment.BarSpacing);
    }

    else if (arg.buttons == MouseButtons.Left && 
        arg.keys == Keys.Control)
    {
        while (Environment.BarSpacing < barSpacing)
        {
            ChartCommands.CommandLine(".bsi");
            Thread.Sleep(100);
        }
        Output.WriteLine("The bar spacing is now {0}px again.",
            Environment.BarSpacing);
    }
}

//> Bar spacing was 10px, and is now 0,25px.
//> The bar spacing is now 10px again.

Mouse clicks are processed in two ways here. The first is when there is a left mouse click (arg.buttons == MouseButtons.Left) together with the Shift key (arg.keys == Keys.Shift). The current bar spacing, which is returned by the Environment.BarSpacing property (PowerLanguage .NET Help, n.d.), is then stored in the barSpacing variable. We use this variable at a later point to revert back to the ‘old’ bar spacing.

Then the ChartCommands.CommandLine() method is called with the .eds command to display the entire data series. Since ChartCommands.CommandLine() is asynchronous, Thread.Sleep() is used to pause the current thread for 100 milliseconds (see Albahari & Albahari, 2012). The last statement in this part prints the previous and current bar spacing to the Output Window.

Reverting back to the old bar spacing programmatically

The second part of the OnMouseEvent() method processes left mouse clicks with the Control key (arg.keys == Keys.Control).

With those clicks a while loop begins that continues as long as the bar spacing (Environment.BarSpacing) is less than the bar spacing before executing .eds, which we stored in the barSpacing variable. During each loop iteration, the ChartCommands.CommandLine() method is executed with the .bsi command to increase the bar spacing. With Thread.Sleep() the ChartCommands.CommandLine() method is given a chance to complete its asynchronous work before a new loop iteration begins.

When the while loop has stopped, bar spacing information is outputted to the Output Window and the chart view is similar to where it began.

Summary

The .eds Command Line command changes the bar spacing such that all price bars from all data series are displayed in the current chart view. It can be executed programmatically with the ChartCommands.CommandLine() method.

Full MultiCharts .NET indicator programming example

using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;
using System.Windows.Forms;     // For MouseButtons and Keys enumerations
using System.Threading;         // For Thread.Sleep()

namespace PowerLanguage.Indicator
{
    [SameAsSymbol(true), MouseEvents(true)]
    public class Example_ShowFullDataSeries : IndicatorObject
    {
        private double barSpacing = 0;

        public Example_ShowFullDataSeries(object _ctx) : base(_ctx) { }

        protected override void StartCalc()
        {
            Output.Clear();
            barSpacing = Environment.BarSpacing;
        }

        protected override void CalcBar() { }

        protected override void OnMouseEvent(MouseClickArgs arg)
        {
            if (arg.buttons == MouseButtons.Left && arg.keys == Keys.Shift)
            {
                barSpacing = Environment.BarSpacing;
                ChartCommands.CommandLine(".eds");
                Thread.Sleep(100);

                Output.WriteLine("Bar spacing was {0}px, and is now {1}px.", 
                    barSpacing, Environment.BarSpacing);
            }

            else if (arg.buttons == MouseButtons.Left && 
                arg.keys == Keys.Control)
            {
                while (Environment.BarSpacing < barSpacing)
                {
                    ChartCommands.CommandLine(".bsi");
                    Thread.Sleep(100);
                }
                Output.WriteLine("The bar spacing is now {0}px again.",
                    Environment.BarSpacing);
            }
        }

        //> Bar spacing was 10px, and is now 0,25px.
        //> The bar spacing is now 10px again.
    }
}

References

Albahari, J. & Albahari, B. (2012). C# 5.0 in a Nutshell: The Definitive Reference (5th edition). Sebastopol, CA: O’Reilly Media.

MultiCharts Wiki (2014, August 18). MultiCharts Work Area: Understanding Command Line. Retrieved on November 19, 2014, from http://www.multicharts.com/trading-software/index.php/MultiCharts_Work_Area#Understanding_Command_Line

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