MultiCharts .NET programming articles
This page lists all MultiCharts .NET programming articles in order of increasing difficulty. While MultiCharts .NET scripts can also be coded in Visual Basic, all articles below are written in C#.
MultiCharts .NET content
The MultiCharts .NET platform
We start our articles by looking at the MultiCharts .NET platform and its features.
The PowerLanguage .NET Editor
The articles in this chapter explore the different features and capabilities of the PowerLanguage .NET Editor, such as creating a trading strategy, indicator, function, and DLL. See the introduction for an overview and description of the complete chapter.
PowerLanguage .NET Editor features
- Exploring the PowerLanguage .NET Editor toolbar
- The menu items in the PowerLanguage .NET Editor
- Keyboard shortcuts for the PowerLanguage .NET Editor
Changing the editor's appearance
- Customising the window panels of the PowerLanguage .NET Editor
- Changing the syntax highlighting in the PowerLanguage .NET Editor
- Resetting the layout of the PowerLanguage .NET Editor
Working with scripts in the editor
- Opening MultiCharts .NET scripts
- Organising scripts in PowerLanguage .NET Editor folders
- Changing script settings in the PowerLanguage .NET Editor
- Working with the IntelliSense code completion feature
- Deleting MultiCharts .NET scripts in the PowerLanguage .NET Editor
- Backing-up MultiCharts .NET scripts in the cloud
Importing and exporting scripts
- Creating a MultiCharts .NET indicator
- Creating your first MultiCharts .NET trading strategy
- Programming a MultiCharts .NET function
Creating scripts - advanced
- Compiling scripts in the PowerLanguage .NET Editor
- Creating and adding a DLL reference in the PowerLanguage .NET Editor
Getting more help
The fundamentals of PowerLanguage .NET
The articles in this part focus on developing an understanding of the MultiCharts .NET programming language.
Class attributes are used in MultiCharts .NET to set indicator or trading strategy options. The articles below discuss the different attributes and how they work, with the introduction providing an overview and the summary a quick recap.
SameAsSymbol: plotting an indicator on a data series or not
SkipIdenticalTicks: only process ticks that matter for a MultiCharts .NET indicator
UpdateOnEveryTick: calculate an indicator only on bar close (or not)
Attributes for both indicators and strategies
MouseEvents: enabling a script’s mouse click processing
RecoverDrawings: keeping the intra-bar generated drawings on the chart
Trading strategy attributes
CalcAtOpenNextBar: changing when a strategy’s orders are submitted
IOGMode: generating and filling orders intra-bar instead of on bar close
ExitFromOneEntryOnce: reuse an exit order when scaling out of a position
AllowSendOrdersAlways: send trading orders at any time, regardless of bar status
Working with MultiCharts .NET
The articles in this part look at how several features of MultiCharts .NET can be used programmatically.
Programmatically working with trend lines in MultiCharts .NET is discussed in this long chapter. The introduction places all articles and the various trend line features into context, while the summary provides a concise overview.
The basics of trend lines
- The essentials of drawing trend lines in MultiCharts .NET
- What are ChartPoint structs and how to use them?
- Working with a trend line: the properties and methods explained
Drawing trend lines
- How to draw a trend line programmatically?
- How to draw a trend line into the future?
- How to draw trend lines on different data series?
- How to copy a trend line to another data series?
- Drawing a trend line in a subchart with price data
- Creating a subchart trend line based on indicator values
Accessing trend lines
Working with trend lines
- Adjusting a trend line’s colour, size, and style
- Changing a trend line’s location in MultiCharts .NET
- Using mouse clicks to lock or unlock trend lines
Extending trend lines
- How to extend a trend line?
- Extending a trend line with a few bars to its past and future values
- How to create multiple horizontal trend lines?
- How to draw a vertical trend line?
- Drawing a vertical trend line that extends to its subchart
Removing and deleting a line
- How to remove a trend line programmatically?
- How to verify if a trend line exists on the chart?
- Deleting a MultiCharts .NET trend line object completely – how to?
Trend line examples
- Drawing trend lines semi-automatically with mouse clicks
- Trend lines that ‘snap to’ indicator values with mouse clicks
- Drawing trend lines between swing pivot highs and lows
- Highlighting an instrument’s opening range with trend lines
- Drawing a triangle with trend lines
- Drawing boxes with trend lines to capture price movements
Working with a line's price values
- How to get the price value of a trend line?
- How to colour price bars above or below a trend line?
- How to get a trend line’s future price values?
- How long before a trend line reaches some future price target?
Triggering alerts with lines
- Automatically generating trend line alerts
- Generate custom trend line alerts on bar close
- Generating custom, intra-bar trend line alerts
- Triggering alerts with a manually drawn trend line
- How to create a trend line with flashing colours?
Trading with trend lines
- Submit market orders with a trend line
- Using a manually drawn trend line as a (trailing) stop-loss
- Visually highlighting a strategy’s trailing stop-loss with trend lines
Trend line collections
- Retrieving a collection of trend lines from the chart
- Looping over a collection of trend lines
- How to get all trend lines from the chart?
- Working with manual trend lines: removing and changing them
- How to use a trend line ID to select specific lines?
- How to change a specific line amongst several trend lines?
- How to clear the chart from all trend lines?
- How to remove the first trend line from a price chart?
Custom trend line collections
- Working with multiple trend lines: using a VariableSeries class
- Managing groups of trend lines with generic lists
- Tracking multiple trend lines with a C# Dictionary
- Introduction to the Command Line in MultiCharts .NET
- Working with the asynchronous Command Line method in MultiCharts .NET
Adjusting the chart's layout
- Changing the bar spacing with the Command Line
- Displaying the entire data series with the Command Line
Changing a symbol with the Command Line
- Change the chart symbol programmatically with the Command Line
- How to change additional data series through the Command Line?
- Loop through a symbol list with the Command Line
- Rotate through symbol pairs with the Command Line
- Tip: verify if a MultiCharts .NET symbol exists before switching to it
- How to cycle through a list of data feed symbols from the QuoteManager?
Adjusting symbol settings
- Changing the date range with the Command Line
- How to only change a symbol’s start or end date with the Command Line?
- Changing the data range to a certain amount of trading days
- Loading a minimum number of price bars on the chart with the Command Line
- Changing the resolution of a data series through the Command Line
- Cycling through chart resolutions with the Command Line
Adding symbols, indicators, and trading strategies to the chart
- Adding a data series to the chart with the Command Line
- Adding an indicator to the chart with the Command Line
- Adding a list of indicators to a MultiCharts .NET price chart
- Adding a MultiCharts .NET trading strategy to the chart with the Command Line
- Tip: verify if a script exists before adding it to the chart
The Command Line and trading strategies
- Calling the Strategy Performance Report through the Command Line
- Enable or disable auto-trading programmatically with the Command Line
Reloading data with the Command Line
- Reloading price data with the MultiCharts .NET Command Line
- Reloading a data gap with the Command Line programmatically
- Using the Command Line to fix bad ticks and price spikes in MultiCharts .NET
The MultiCharts .NET programming recipes contain helpful and practical code that’s ready to use in your script directly. Each recipe describes a specific situation and then jumps to a verified solution, followed by an example of how to use the recipe’s solution and then a discussion to learn why and how it works.
That question-answer format provides complete solutions to problems and makes the recipes easy to read and use. Compared to the regular tutorials, recipes are less theoretical and more focused on learning by example. And by breaking down situations into individual steps, they hopefully demystify common and not-so common programming questions.
Note that these recipes aren’t intended as a definite reference; a recipe merely shows one possible solution, and there are nearly always multiple and perhaps even better (depending on your frame of reference) ways to tackle a particular programming problem.
The MultiCharts .NET language reference articles provide a complete overview of all PowerLanguage .NET code elements around a certain topic. They contain brief examples, helpful notes, and tips, and are intended as a quick lookup and refresher when you’re coding. Another goal of these articles is to provide an alternative to the help contents of the PowerLanguage .NET Editor, which contains a lot of information but often without examples, structure, and clear information.
These ‘legacy’ articles are my earlier articles. They still contain a lot of useful information, but aren’t written in the ‘chapter style’ I’ve adopted since then. Over time I’ll replace them with complete chapters.
MultiCharts .NET essentials
These ‘essentials’ articles address a few of the basics of programming in MultiCharts .NET and help to develop a better understanding of the platform.
Understanding MultiCharts .NET
- What are ‘MaxBarsBack’ and how do they work with indicators and trading strategies?
- What are up & down volume and ticks? And what is the impact of tick and volume count?
- How are indicators calculated in MultiCharts .NET?
PowerLanguage .NET fundamentals
Working with price data
Articles in this section deal with the various ways to use historical and real-time data.
Price data in general
- How to use price and time data from the primary data series?
- Working with volume data from the primary data series
- How to reference price data of historical bars? (with visual explanation and reference table)
- How to loop over historical price bars?
- Access any historical price bar (regardless of MaxBarsBack)
- How to access future price bars?
- How to access price bar data from additional data series?
The articles in this part deal with the ways to get data from the price chart to, for example, alert pop-ups or to the PowerLanguage .NET Editor.
Formatting data to text
- Formatting text with composite formatting and substitution parameters
- Formatting text with escape characters
- Formatting numeric values to text with standard formatting
- Outputting numeric data with custom format specifiers
- Converting DateTime’s dates to strings in different formats: print dates in readable text
- Converting DateTime time values to textual strings in different formats
PowerLanguage .NET Editor Output Window
- Outputting data to the PowerLanguage .NET Editor Output Window
- Basic ‘debugging’ with the PowerLanguage Editor
- Conditionally ‘debugging’ with preprocessor directives in the PowerLanguage .NET Editor
- Working with the Expert Commentary window
- How to prevent code recalculation with the Expert Commentary window?
Controlling MultiCharts .NET
These articles deal with influencing the main MultiCharts .NET program itself, for example with mouse clicks.
- How to force a periodic recalculation of a strategy or indicator?
- Recalculating an indicator or trading strategy immediately
- Abort a script calculation and generate an error message
- How to ‘stop’ an indicator or strategy from calculating?
- Working with mouse clicks in MultiCharts .NET
- Combining mouse clicks with keyboard keys
- Working with mouse click location: dividing a price chart into quadrants
- Using mouse clicks to reload a price chart in different ways
- Recalculating a MultiCharts .NET script with a mouse click
- Using mouse clicks to turn a MultiCharts .NET script on or off
- How to only calculate a MultiCharts .NET indicator or trading strategy with mouse clicks?
- Cycling through a list of trading charts with a mouse click
- Only execute methods with a mouse click plus reading and writing text files
- How to submit trading strategy market orders with a mouse click?
- How to submit trading strategy limit orders based on the mouse click location?
Scrolling to a price bar
Dates and times
These articles deal with the different ways to use dates, days, times, and time periods in MultiCharts .NET.
- Calculating the time difference between two bars
- Working with session information: first session start and last session end time
These articles deal with the various aspects of indicators in MultiCharts .NET.
- The different types of plots in MultiCharts .NET: an overview
- Setting plot options programmatically in MultiCharts .NET: a closer look at PlotAttributes
- Plotting in an indicator with the moving average MultiCharts .NET function
- How to colour a price bar in MultiCharts .NET?
- Random colours: creatively painting price bars in MultiCharts .NET
- Plotting text in the Status Line: display the average bid/ask spread
- Colouring the Status Line and displaying the time since last tick
Trading strategies (single instrument)
The trading strategy articles deal with MultiCharts .NET trading strategies, from managed orders to idea examples and backtesting.
- Creating an averaging down trading strategy
- How to trade only during certain times with a trading strategy?
- How to exit a strategy position prior to the close?
- How do I trade only on certain days?
- Open and close trades in a strategy based on the number of bars since the last trade or the last position
Symbol, chart, and environment information
These articles address things like getting QuoteManager data for a symbol or retrieving the chart properties.
- How to determine the calculation reason of a script?
- How to get information about the data series resolution in MultiCharts .NET?