Some options in MultiCharts .NET can be enabled or disabled through the programming code. These options are set programmatically with class attributes.

What are class attributes in C#?

Attributes in C# provide special metadata about a class (Liberty & MacDonald, 2009). They can be conceptually thought of as a special tag (Stellman & Greene, 2010), a code annotation (Troelsen, 2012), or a post-it note (Gishu, 2010) that adds custom information to the code element.

The metadata they provide further redefines a class’ definition, and provides information to the compiler and runtime system about how the code should be used or treated (Liberty & MacDonald, 2009; Stellman & Greene, 2010; Stephens, 2014).

Attributes are rather specialised and address issues that arise from performing specific tasks (Stephens, 2014). In MultiCharts .NET, things attributes can do range from allowing exit orders to be reused to not deleting intra-bar generated drawings.

How to work with class attributes in MultiCharts .NET?

An attribute is added to a class by placing it enclosed in square brackets ([ and ]) immediately above the class to which it should be applied (Dorman, 2010). Multiple attributes can be placed above another or added with a comma-delimited list between the square brackets (Dorman, 2010; Troelsen, 2012).

The image below shows two attributes added to a script in the PowerLanguage .NET Editor (highlighted with green):

MultiCharts .NET - placement of class attributes

Both attributes (SkipIdenticalTicks and SameAsSymbol) are enclosed in square brackets, separated with a comma, and placed directly above the Example_SkipIdenticalTicks class. Due to layout of indicators and strategies in MultiCharts .NET, attributes need to be added around line number 8 by default.

By the way, if you’ve already added the indicator or strategy to a chart and then add or change an attribute, the script needs to be removed and re-added again before the effect of the modified code is visible (see Henry MultiCharts, 2014).

What kind of attributes are there in MultiCharts .NET?

MultiCharts .NET’s attributes can be divided into three groups: attributes for indicators, those that work with both indicators and strategies, and attributes for trading strategies.

Changing indicator settings with attributes

The following attributes can be used with indicators:

Attributes for trading strategies and indicators

A few attributes work with both indicators and trading strategies:

Trading strategies and their attributes in MultiCharts .NET

The next attributes change strategy options and features:

The ‘chapter’ on class attributes concludes with a summary of MultiCharts .NET class attributes.


References

Gishu (2012, April 20). How do attribute classes work? StackOverflow discussion. Retrieved on January 26, 2015, from http://stackoverflow.com/a/2677354/531257

Henry MultiCharts (2014, December 11). MultiCharts .NET FAQ – forum discussion. Retrieved on January 25, 2015, from http://www.multicharts.com/discussion/viewtopic.php?f=19&t=45848#p111375

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

Stellman, A. & Greene, J. (2010). Head First C#: A Brain-Friendly Guide (2nd edition). Sebastopol, CA: O’Reilly Media.

Stephens, R. (2014). C# 5.0 Programmer Reference. Indianapolis, IN: John Wiley & Sons.

Troelsen, A. (2012). Pro C# 5.0 and the .NET 4.5 Framework (6th edition). Apress.