After a data series’ chart area has been clicked on, several mouse click keywords hold information about the click’s location. How can we programmatically place an arrow at that click location?

In this article:

Combining mouse clicks with arrows in MultiCharts PowerLanguage

The ProcessMouseEvents attribute needs to be enabled before mouse click data can be used (MultiCharts Wiki, 2012a). After that a click on a data series chart area updates several mouse click keywords, such as MouseClickPrice with the price level and MouseClickBarNumber with the click’s bar number.

This mouse click data can subsequently be used by any other PowerLanguage keyword, such as Arw_New_s(). This keyword draws an up or down arrow located at the specified date, time, and price (MultiCharts Wiki, 2012b).

Drawing arrows based on mouse clicks in PowerLanguage

Before discussing the code, let’s see it’s effect. Starting with a chart like:

Creating arrows in MultiCharts with mouse clicks - before

After clicking randomly with the Control and/or Shift key held down, the chart looks like:

Creating arrows in MultiCharts with mouse clicks - after

Programmatically drawing arrows with mouse clicks in MultiCharts

The programming code looks as follows:

[ProcessMouseEvents = true];
[RecoverDrawings = false];


if (MouseClickCtrlPressed or MouseClickShiftPressed) then begin 

    bar_num = (CurrentBar + MaxBarsBack) - MouseClickBarNumber;

    if (MouseClickPrice > Symbol_Close[bar_num]) then
        downArrow = true
        downArrow = false;

    // Creating the arrow
    arrowID = Arw_New_s(

    // Setting the arrow's size
    if (MouseClickCtrlPressed and MouseClickShiftPressed) then
        Arw_SetSize(arrowID, 1)  
    else if (MouseClickCtrlPressed) then
        Arw_SetSize(arrowID, 4)
    else if (MouseClickShiftPressed) then
        Arw_SetSize(arrowIDbar_num, 7);

    // Adjusting the arrow's colour
    if (Symbol_Close[bar_num] > Symbol_Close[bar_num + 1]) then 
        Arw_SetColor(arrowID, RGB(34, 139, 34))
        Arw_SetColor(arrowID, RGB(205, 38, 38));


The example begins with setting ProcessMouseEvents to true so that mouse clicks can be processed. Another attribute, RecoverDrawings, is set to false. This attribute determines if drawings that are generated intra-bar should be removed with the next script calculation (when set to true) or not (false) (MultiCharts Wiki, 2014). By setting it to false, the arrow drawn by the previous mouse click is not removed when a new click happens.

Next, a couple of variables are created and then an if statement checks whether the Control or Shift key were pressed down during the mouse click. When one or both were used, the if statement’s code is executed.

Accessing price bar data from the mouse click’s location

In the if statement we first determine how many bars ago (relative to the last bar) the click happened. For this we subtract the clicked on bar number (MouseClickBarNumber) from the number of bars on the chart (CurrentBar + MaxBarsBack) and store that value in the bar_num variable.

An if-else statement then evaluates whether the mouse click’s price (MouseClickPrice) was greater than the closing price of the bar in the chart region that was clicked on. This latter is retrieved with Symbol_Close, which can access any price bar regardless of the MaxBarsBack value (MultiCharts Wiki, 2012c). By setting downArrow to true when a click happened above the price bar, a downward arrow can be plotted for those clicks. And by giving it a value of false for clicks below the bar’s close, we’ll be able to create upward arrows.

Drawing an up/down arrow based on a mouse click in PowerLanguage

Then the actual arrow is created with Arw_New_s(). This keyword requires four parameters (MultiCharts Wiki, 2012b): the date, time, and price that together set the arrow’s location, and a true/false value that indicates if the arrow should point down (when true) or up (false).

To place the arrow at the location of the mouse click, we use the bar_num variable together with the Symbol_Date and Symbol_Time_s keywords. The arrow’s price location is set by MouseClickPrice, and the downArrow variable is used to signal the direction in which the arrow should point.

Arw_New_s returns an object-specific ID, needed to adjust the arrow after it has been created (MultiCharts Wiki, 2012b). That number is stored in the arrowID variable so we can modify the arrow later.

Adjusting the size and colour of a PowerLanguage arrow

That arrowID variable is subsequently used to change the arrow’s size. With an if-else statement three keyboard key combinations are evaluated that set the arrow size to either 1 (for Shift and Control), 4 (Control), or 7 (Shift) with Arw_SetSize(). This keyword requires an arrow ID and a numerical value indicating the arrow’s size (MultiCharts Wiki, 2012d).

An if statement then adjusts the colour of the arrow depending on whether the bar’s closing price of the clicked-on chart area (Symbol_Close[bar_num]) was higher than its preceding bar (Symbol_Close[bar_num + 1]). When it was, the arrow’s colour is set to the RGB value of ‘forestgreen’; otherwise, the ‘firebrick 3’ RGB value is applied. See for a list of colours and their accompanying RGB values. Changing the arrow’s colour is done with Arw_SetColor(), which assigns the specified colour to the specified arrow ID (MultiCharts Wiki, 2012e).

Besides using mouse clicks to draw arrows, we can also use clicks to freely draw trend lines and to create trend lines that snap to price bars.


Mouse clicks can be processed once ProcessMouseEvents is set to true. Arrows can be drawn on the price chart with Arw_New_s(), and mouse click keywords (like MouseClickPrice) can be used to set the arrow’s location. An arrow’s formatting can be changed with Arw_SetSize() and Arw_SetColor(). With RecoverDrawings set to false, arrows that are generated intra-bar aren’t removed with the next script calculation.


MultiCharts Wiki (2012a, February 24). ProcessMouseEvents. Retrieved on January 11, 2015, from

MultiCharts Wiki (2012b, February 19). Arw_New_s. Retrieved on January 11, 2015, from

MultiCharts Wiki (2012c, 1 March). Symbol_Close. Retrieved on January 11, 2015, from

MultiCharts Wiki (2012d, 19 February). Arw_SetSize. Retrieved on January 12, 2015, from

MultiCharts Wiki (2012e, 19 February). Arw_SetColor. Retrieved on January 12, 2015, from

MultiCharts Wiki (2014, January 23). RecoverDrawings. Retrieved on January 11, 2015, from

Visit programming tutorials for more helpful coding articles.