Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

Vertical Histogram Constructor - MetaTrader 5 Library | MT5 EA Download - MetaTrader 5 Resources

author EAcpu | 2 reads | 0 comments |

Vertical histograms constructor - library for MetaTrader 5

A histogram is a bar graph of frequencies. One of the axes represents the variable values, while the other axis represents the frequency of occurrence of these values. The height of each bar shows the frequency (number) of values ​​that fall into the corresponding interval equal to the width of the column. Such charts are usually displayed horizontally, that is, the variable values ​​are on the horizontal axis and the frequency is on the vertical axis.

In this library we will focus on the vertical histogram of order statistics: the price values ​​of the analysis parameters will be located in ascending order on the vertical axis, while the frequency will be on the horizontal axis. Input price data is distributed and grouped on the current bar and can be displayed from the left, right or both sides simultaneously with respect to its axis.

Vertical histograms constructor - library for MetaTrader 5

Figure 1. Vertical histogram of bid and ask price distributions.

The vertical histogram constructor is based on the Histogram class. The implementation of all its methods is based on the use of so-called "graph" memory.

Method: Class constructor Histogram .

Initialize an instance of the class.

[in] Unique name prefix for the histogram columns.

[in] The scale of the histogram display.

[in] Width of histogram lines

[in] The color of the updated histogram column on the current bar.

[in] The color of the histogram columns that are not updated on the current bar.

left_right=true

[in] Direction of histogram display. false — the histogram is to the left of the current bar, true — to the right.

relative frequency = false

[in] Method for calculating frequency values. false — absolute frequency value, true — relative frequency value.

[in] Window index used to draw the histogram. 0 — Main chart window.

Return value:

No return value. If successful, it creates an instance of the class with the specified parameters.

Method: Histogram display draws a histogram .

Show Histogram Bars: Creates a new bar; edits an existing bar; stores frequency values ​​in graph memory; displays the histogram on the current bar.

[in] The value of a variant of the market characteristic under study.

[in] Time of the current bar. This bar will become the histogram axis.

Return value:

No return value. If successful, a new histogram column is created or an existing histogram column is adjusted. If a new bar appears, the histogram moves so that the axis is on the current bar.

Method: Calculate histogram features Histogram features .

Returns the computed characteristics of order statistics in variables of type sVseries.

There are no input parameters.

Return value:

If successful, it returns a variable value of type sVseries.

Structure for getting the current value of a histogram feature ( sV series ).

A structure used to store past values ​​of statistical distribution characteristics. Designed to obtain the most needed order statistics.

Method: Visualization of Means Plot the mean .

Displays the value of the weighted arithmetic mean of the order statistics on the chart.

[in] The value of the weighted arithmetic mean.

[in] Time of the current bar. The value of the weighted arithmetic mean will be measured on this bar.

[in] Whether to display markers on the chart. false — do not display markers, true — display markers on the chart.

[in] Stores the value of the weighted arithmetic mean into the history. false — do not display, true — display values ​​on the chart.

Return value:

If successful, a horizontal line is displayed on the chart, which corresponds to the value of the weighted arithmetic mean.

Methods: Visual plot of standard deviation.

Displays standard deviation values ​​as rectangles. The width of the rectangle matches the mean frequency and its height matches the standard deviation plotted above and below the weighted arithmetic mean.

[in] The value of a variable of type sVseries.

[in] Time of the current bar.

[in] Factor to increase the standard deviation value.

[in] Color of the rectangle visualizing the standard deviation.

Return value:

If successful, a rectangle is displayed on the chart that represents the standard deviation from the weighted arithmetic mean.

The class' abilities are demonstrated in the video. The code for the test sample is provided in the attachment.

The code provided shows how to call specific methods (functions) of the class.


Attachment download

📎 histogram.mqh (30.65 KB)

📎 histogram_bid_ask_2_indicators.mq5 (10.02 KB)

Source: MQL5 #16365

Verification code Refresh