A mouse click’s location can be determine with its price level (MouseClickPrice) and its date and time (MouseClickDateTime) value. But how can these keywords be used to determine where a click happened?

In this article:

Mouse clicks and their location in MultiCharts PowerLanguage

Mouse clicks in an indicator or trading strategy can be programmatically be processed when the ProcessMouseEvents attribute is enabled (MultiCharts Wiki, 2012a).

Then, after a click on a data series’ chart area, MouseClickPrice returns the price and MouseClickDateTime the DateTime value of the click’s location (MultiCharts Wiki, 2012b, 2012c). For more, see retrieving a click’s price level and getting the date and time of a click.

Now if we compare a click’s location to the values on the chart’s axes, we can determine the relative position of the click. To see how, let’s first divide a chart into chart areas.

Dividing a MultiCharts price chart into four quadrants

Just like a coordinate plane can be divided into four quadrants, we can imagine that a price chart consists out of four areas:

Diving a MultiCharts chart into four areas

By placing a green line at the middle of the time axis and red line halfway the price axis, we get four chart areas: upper right, upper left, lower left, and lower right.

To divide a chart programmatically into four areas, we need to get the midpoint of the x and y axes of the current chart view. This can be done with GetAppInfo() (MultiCharts Wiki, 2014):

  • GetAppInfo(aiHighestDispValue) returns the highest price currently displayed on the chart, while GetAppInfo(aiLowestDispValue) returns the lowest price value of the price axis.
  • GetAppInfo(aiLeftDispDateTime) returns the DateTime value of the leftmost bar in the current chart view, while GetAppInfo(aiRightDispDateTime) does so for the rightmost bar.

Determining a mouse click’s location in MultiCharts PowerLanguage

These GetAppInfo() values can be combined with mouse clicks to determine a click’s location as follows:

[ProcessMouseEvents = true];


leftClick = (GetAppInfo(aiCalcReason) = CalcReason_MouseLClick);

if (leftClick and MouseClickCtrlPressed) then begin

    // Determining the midpoints of both axes
    middlePriceAxis = (GetAppInfo(aiHighestDispValue) + 
        GetAppInfo(aiLowestDispValue)) / 2;

    middleTimeAxis = (GetAppInfo(aiLeftDispDateTime) +
        GetAppInfo(aiRightDispDateTime)) / 2;

    upperPartChart = (MouseClickPrice > middlePriceAxis);
    rightPartChart = (MouseClickDateTime > middleTimeAxis);

    Print("Click's price is ", NumToStr(MouseClickPrice, 2),
        ", with date: ", FormatDate("d-M-yyyy", MouseClickDateTime));

    // Evaluating where a click happened
    if (upperPartChart and rightPartChart) then 
        Print("  This click is in the upper right")
    else if (upperPartChart and not rightPartChart) then
        Print("  This click is in the upper left")
    else if (not upperPartChart and not rightPartChart) then
        Print("  This click is in the lower left")
    else if (not upperPartChart and rightPartChart) then
        Print("  This click is in the lower right");


//> Click's price is 2087.43, with date: 19-12-2014
//>   This click is in the upper right
//> Click's price is 2072.33, with date: 30-10-2014
//>   This click is in the upper left
//> Click's price is 1934.90, with date: 3-11-2014
//>   This click is in the lower left
//> Click's price is 1951.51, with date: 30-12-2014
//>   This click is in the lower right

The example starts with enabling mouse click processing and creating several variables.

Then the leftClick true/false variable is given the value of the equality test between GetAppInfo(aiCalcReason) (returns the calculation reason of the script) and CalcReason_MouseLClick, which signals that the calculation was triggered by a left mouse click. This gives leftClick a value of true when a left mouse click happened and a value of false otherwise. See how to differentiate between left and right mouse clicks for more.

Calculating the midpoint of the price chart’s axes in MultiCharts

The if statement then evaluates whether leftClick and MouseClickCtrlPressed are both true. This keyword returns true when the Control keyboard key was held down during the click (MultiCharts Wiki, 2012d).

When a left click with Control happened, the code inside the if statement is executed. The midpoint of the price axis is calculated by adding the chart’s highest price value (GetAppInfo(aiHighestDispValue)) to the lowest (GetAppInfo(aiLowestDispValue)) and dividing by 2. The resulting value is stored in middlePriceAxis (the red line in the image above).

Likewise, the value for the middleTimeAxis variable is arrived at by first adding the leftmost time (GetAppInfo(aiLeftDispDateTime)) to the time of the rightmost bar (GetAppInfo(aiRightDispDateTime)) and then dividing by 2. Since these are DateTime values, we can safely perform arithmetic with these times.

Determining the location of a mouse click in MultiCharts

Then the location of the mouse click is decided. For that we first evaluate if the MouseClickPrice value is greater than the middle of the price axis (middlePriceAxis). This results in a true/false value, which is stored in the upperPartChart variable. That means this variable will be true when a click happened above the price axis’ midpoint and a value of false for clicks below it.

The rightPartChart variable is given its true/false value depending on whether the MouseClickDateTime value is greater than the x-axis midpoint (middleTimeAxis). This means that rightPartChart is true with clicks to the right of the x-axis’ midpoint, and false for clicks happening to the left of the time axis’ middle. For verification both the price and date of the mouse click are subsequently outputted with Print().

Now that upperPartChart indicates whether the click was above or below the price axis’ midpoint and rightPartChart signals whether the click was to the left or right of the time axis’ middle, both can be combined to determine a click’s location. This is done with a cascaded if-else statement that checks all four possibilities. We use the not keyword for that, which returns the opposite of a true/false expression (MultiCharts Wiki, 2012e). So not rightPartChart returns true when rightPartChart is false.

The logic in the cascaded if-else statement is as follows: when the rightPartChart variable returns true, the click occurred in one of the right-hand chart areas; otherwise, it happened in a left chart area. And if upperPartChart returns true, the click took place in one of the upper quadrants; otherwise, in one of the lower parts. With these two true/false variables combined, each of the four chart areas can be identified.

Another usage of the chart’s axes is calculating a click’s location from a chart’s corner.


Mouse click processing requires the ProcessMouseEvents attribute set to true. By comparing a click’s price (MouseClickPrice) and time (MouseClickDateTime) with the time (GetAppInfo(aiLeftDispDateTime) and GetAppInfo(aiRightDispDateTime)) and price axis (GetAppInfo(aiHighestDispValue) and GetAppInfo(aiLowestDispValue)), the location of the click can be determined.


MultiCharts Wiki (2012a, February 24). ProcessMouseEvents. Retrieved on January 8, 2015, from http://www.multicharts.com/trading-software/index.php/ProcessMouseEvents

MultiCharts Wiki (2012b, February 24). MouseClickPrice. Retrieved on January 8, 2015, from http://www.multicharts.com/trading-software/index.php/MouseClickPrice

MultiCharts Wiki (2012c, February 24). MouseClickDateTime. Retrieved on January 8, 2015, from http://www.multicharts.com/trading-software/index.php/MouseClickDateTime

MultiCharts Wiki (2012d, February 24). MouseClickCtrlPressed. Retrieved on January 8, 2015, from http://www.multicharts.com/trading-software/index.php/MouseClickCtrlPressed

MultiCharts Wiki (2012e, February 19). Not. Retrieved on January 8, 2015, from http://www.multicharts.com/trading-software/index.php/Not

MultiCharts Wiki (2014, September 8). GetAppInfo. Retrieved on January 8, 2015, from http://www.multicharts.com/trading-software/index.php/GetAppInfo