거래 로봇을 무료로 다운로드 하는 법을 시청해보세요
당사를 Facebook에서 찾아주십시오!
당사 팬 페이지에 가입하십시오
스크립트가 흥미로우신가요?
그렇다면 링크 to it -
하셔서 다른 이들이 평가할 수 있도록 해보세요
스크립트가 마음에 드시나요? MetaTrader 5 터미널에서 시도해보십시오
라이브러리

Vertical histograms constructor - MetaTrader 5용 라이브러리

조회수:
6647
평가:
(29)
게시됨:
2017.01.18 09:25
\MQL5\Include\
Histogram.mqh (30.65 KB) 조회
\MQL5\Indicators\
이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동

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.

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.

void CHistogram(
   string name,                     // unique name prefix
   int    hsize,                    // chart scale
   int    width,                    // width of the histogram line bars
   color  active,                   // color of the active line bars
   color  passive,                  // color of the passive line bars
   bool   Left_Right=true,          // left=false or right=true
   bool   relative_frequency=false, // relative or absolute histogram
   int    sub_win=0                 // index of the window for plotting histogram
   );

Parameters:

name

   [in] The unique name prefix for the columns of the histogram.

hsize

   [in] The scale of the histogram display.

width

   [in] The width of the histogram line bars

active

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

passive

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

Left_Right=true

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

relative_frequency=false

   [in] The method of accounting the frequency values. false — absolute frequency values, true — relative frequency values.

sub_win=0

   [in] The index of the window for plotting the histogram. 0 — main chart window.

Returned value:

   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.

void DrawHistogram(
   double price,  // value of the variant
   datetime time  // time of the current bar
   );

Parameters:

price

   [in] Value of the variant of the studied market characteristics.

time

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

Returned value:

   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.

sVseries HistogramCharacteristics();

Parameters:

   No input parameters.

Returned value:

   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.

struct sVseries
  {
   long     N;    // total number of observations
   double   Na;   // average value of frequencies
   double   Vmax; // maximum value of the variant
   double   Vmin; // minimum value of the variant
   double   A;    // amplitude of the order statistic
   double   Mean; // weighted arithmetic mean
   double   D;    // variance
   double   SD;   // standard deviation
  };
Variable of sVseries type allows to obtain the values of all main characteristics of the order statistic displayed as a histogram by using a single call to the HistogramCharacteristics() function.

Method: visualization of the mean value DrawMean.

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

void DrawMean(
   double coord,     // value of the weighted arithmetic mean
   datetime time,    // time of the current bar
   bool marker=false,// display the marker or not
   bool save=false   // store the value to history or not
   );

Parameters:

coord

   [in] The value of the weighted arithmetic mean.

time

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

marker=false

   [in] Display marker on the chart or not. false — marker is not displayed, true — marker is displayed on the chart.

save=false

   [in]  Store the value of the weighted arithmetic mean to history. false — do not display, true — display the value on the chart.

Returned value:

   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.

void DrawSD(
   sVseries &coord,        // variable of type sVseries
   datetime time,          // time of the current bar
   double deviation=1.0,   // deviation
   color clr=clrYellow     // display color
   );

Parameters:

coord

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

time

   [in] Time of the current bar.

deviation=1.0

   [in] Coefficient to increase the value of the standard deviation.

clr=clrYellow

   [in] Color of the rectangle that visualizes the standard deviation.

Returned value:

   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.


Tips:

  • It is better to use the class on the smaller timeframes.

MetaQuotes Ltd에서 러시아어로 번역함.
원본 코드: https://www.mql5.com/ru/code/16365

Exp_AFL_WinnerV2 Exp_AFL_WinnerV2

The Exp_AFL_WinnerV2 Expert Advisor that uses the AFL_WinnerV2 indicator.

AFL_WinnerV2_HTF AFL_WinnerV2_HTF

The AFL_WinnerV2 indicator with the timeframe selection option available in input parameters.

JSatl_Digit_System JSatl_Digit_System

The indicator implements a breakout system using a channel based on the High and Low price series processed by the algorithm of JSatl_Digit.

Exp_JSatl_Digit_System Exp_JSatl_Digit_System

Trading system based on the signals of the JSatl_Digit_System indicator.