Some MultiCharts .NET attributes, like UpdateOnEveryTick and SkipIdenticalTicks, influence a script’s calculation process. But how can we calculate programming code manually with mouse clicks?

The MouseEvents attribute for using mouse clicks in a script

C#’s attributes provide special metadata about a class and modify how it operates (Liberty & MacDonald, 2009). Class attributes are used in MultiCharts .NET to change certain settings or features.

One of those features is processing mouse clicks by an indicator or trading strategy, which is enabled or disabled with the MouseEvents attribute (see PowerLanguage .NET Help, n.d.). When this attribute is set to true, clicks on the chart’s data series area are registered by the script – but clicks occurring in an indicator’s subchart aren’t. The image below highlights with grey where mouse clicks are not registered:

MultiCharts .NET MouseEvents - where are clicks registered?

Besides enabling MouseEvents, the OnMouseEvent() method also needs to be added to the script (see PowerLanguage .NET Help, n.d.). Each registered click on the chart causes this method to execute, which contains the programming code for how you want to process mouse clicks.

As opposed to other attributes, like SameAsSymbol and SkipIdenticalTicks, mouse click processing cannot be enabled manually.

Setting the MouseEvents attribute in MultiCharts .NET

To enable mouse click processing, set the attribute to true:

public class Example_MouseEvents : IndicatorObject
    // Script code

And set MouseEvents to false to disable dealing with mouse clicks:

public class Example_MouseEvents : IndicatorObject
    // Script code

When the MouseEvents attribute isn’t set, the default behaviour of no click processing applies.

Example of processing mouse clicks in MultiCharts .NET

A simple example of mouse clicks is the following:

[MouseEvents(true), SameAsSymbol(true)]
public class Example_MouseEvents : IndicatorObject
    public Example_MouseEvents(object _ctx) : base(_ctx) { }

    protected override void CalcBar() { }

    protected override void OnMouseEvent(MouseClickArgs arg)
        Output.WriteLine("A {0} click with the {1} key",

        Output.WriteLine("  Bar #{0}, price: {1}, time: {2}",

        //> A Left click with the None key
        //>   Bar #28, price: 1,13166792592593, time: 27-1-2015 3:45:00
        //> A Left click with the Shift, Control key
        //>   Bar #34, price: 1,13299118518519, time: 27-1-2015 4:45:00
        //> A Left click with the Shift key
        //>   Bar #51, price: 1,13196866666667, time: 27-1-2015 7:35:00
        //> A Left click with the Control key
        //>   Bar #70, price: 1,12535237037037, time: 27-1-2015 10:45:00
        //> A Right click with the None key
        //>   Bar #50, price: 1,13118674074074, time: 27-1-2015 7:25:00

We begin with setting MouseEvents and SameAsSymbol to true. The first enables mouse click processing while the second displays the indicator on the data series and not on a subchart.

In the OnMouseEvent() method the click’s data can be accessed through the MouseClickArgs variable, which is named arg here. The two Output.WriteLine() statements print the mouse click data to the PowerLanguage .NET Editor window.

The first statement outputs the mouse button (arg.buttons) together with the keyboard keys (arg.keys) that were pressed during the click. The second statement outputs information about the click’s location: the bar number (arg.bar_number), price value (arg.point.Price) and the time value (arg.point.Time).

Other attributes that enable special features are AllowSendOrdersAlways for sending orders regardless of a script’s bar status and ExitFromOneEntryOnce to manage partial exits from one entry order.


Mouse clicks can be processed programmatically when the MouseEvents attribute is set to true and when the OnMouseEvent() method is implemented to programmatically deal with the registered mouse clicks.


Liberty, J. & MacDonald, B. (2009). Learning C# 3.0: Master the Fundamentals of C# 3.0. Sebastopol, CA: O’Reilly Media.

PowerLanguage .NET Help (n.d.). Retrieved on November 18, 2014, from