A histogram is a bar chart of frequencies. One of the axes represents variable values, while another — the frequency of these values' occurrence. The height of each bar shows the frequency (number) of values belonging to the respective interval equal to the column width. Such diagrams are usually displayed horizontally, i.e. variable values are located on a horizontal axis, while frequency — on a vertical one.
In this library, we will focus on the vertical histograms of the order statistics: price values of the analyzed parameters are to be located on the vertical axis in ascending order, while frequency is to be located on the horizontal axis. Incoming price data are distributed and grouped on the current bar and can be displayed relative to its axis from the left, right or both sides simultaneously.
Fig. 1. Vertical histogram of Bid and Ask prices distribution.
Constructor of vertical histograms is based on the CHistogram class. Implementation of all its methods are based on the use of so-called "graphic" memory.
Method: class constructor CHistogram.
Initializes an instance of the class.
[in] The unique name prefix for the columns of the histogram.
[in] The scale of the histogram display.
[in] The width of the histogram line bars
[in] The color of the histogram columns updated on the current bar.
[in] The color of the histogram columns not updated on the current bar.
[in] The direction of the histogram display. false — histogram to the left of the current bar, true — to the right.
[in] The method of accounting the frequency values. false — absolute frequency values, true — relative frequency values.
[in] The index of the window for plotting the histogram. 0 — main chart window.
No return value. If successful, it creates an instance of the class with the specified parameters.
Method: histogram display DrawHistogram.
Displays the histogram bars: creates new bars; edits existing bars; stores the frequency values to the graphic memory; displays the histogram on the current bar.
[in] Value of the variant of the studied market characteristics.
[in] Time of the current bar. This bar will be the histogram axis.
No return value. If successful, creates new or adjusts existing histogram column. If a new bar appeared, the histogram is shifted so that the axis is on the current bar.
Method: calculation of the histogram characteristics HistogramCharacteristics.
Returns the calculated characteristics of the order statistic in a variable of type sVseries.
No input parameters.
If successful, it returns the value of a variable of type sVseries.
Structure for getting the current values of the histogram characteristics (sVseries).
Structure for storing past values of the characteristics of the statistical distribution. Designed for getting the most demanded information on the order statistic.
Method: visualization of the mean value DrawMean.
Displays the value of the weighted arithmetic mean of order statistic 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] Display marker on the chart or not. false — marker is not displayed, true — marker is displayed on the chart.
[in] Store the value of the weighted arithmetic mean to history. false — do not display, true — display the value on the chart.
If successful, a horizontal line is displayed on the chart, which corresponds to the value of the weighted arithmetic mean.
Method: visualization of the standard deviation DrawSD.
Displays the value of standard deviation as a rectangle. The rectangle width matches the average frequency and its height matches the standard deviation plotted up and down of the weighted arithmetic mean value.
[in] The value of a variable of type sVseries.
[in] Time of the current bar.
[in] Coefficient to increase the value of the standard deviation.
[in] Color of the rectangle that visualizes the standard deviation.
If successful, displays a rectangle on the chart, which characterizes the standard deviation from the value of the weighted arithmetic mean.
Capabilities of the class are demonstrated in the video. Code of the test sample is provided in the attachment.
The provided code shows how to call a particular method (function) of the class.
Translated from Russian by MetaQuotes Software Corp.
Original code: https://www.mql5.com/ru/code/16365
The Exp_AFL_WinnerV2 Expert Advisor that uses the AFL_WinnerV2 indicator.AFL_WinnerV2_HTF
The AFL_WinnerV2 indicator with the timeframe selection option available in input parameters.