Statistics of candles - script for MetaTrader 5




Statistics of candles - script for MetaTrader 5


Counting the number of series of bullish and bearish bars. Displaying the result as a chart. Saving the screenshot of the resulting chart. The script uses the CGraphic class.


Input Parameters

  • Count of bars - the number of bars (from the rightmost bar on the chart), for which the calculation will be preformed;
  • Verification - the flag for printing the copied timeseries of this symbol and the resulting array of bar series. NOTE: should only be enabled if the Count of bars parameter does not exceed 15-30. Otherwise the amount of printed data will be very large;
  • Save screenShot - enable/disable saving of screenshots of the resulting chart;
  • Sleep (milliseconds) - a delay in displaying the resulting chart.

Series of bars are coded according to the following principle:

   enum ENUM_SERIES_TYPE
     {
      Bull=1,  // ↑
      Bear=-1, // ↓
     };

A "bullish" candlestick has the code of "1", a "bearish" candlestick has the code of "-1".

Another parameter for the name of the series is calculated as follows:

current series (ENUM_SERIES_TYPE) * the umber of bars in a row in this series

int name_series=current_series_type*count_series;

Note: the very last series is not included in calculations, because you cannot know how long the series will last.

Screenshots are saved (if Save screenShot is enabled) to [data folder]MQL5FilesStatistics of candles. An example of a saved screenshots of the resulting charts. Series are drawn along the X axis, i.e. the "-5" series means five bearish bars in a row, and "2" means two bullish bars in a row:

AUDCAD,H1. 1200 bars

Fig. 1. AUDCAD,H1. 1200 bars

EURUSD,H1. 1200 bars

Fig. 2. EURUSD,H1. 1200 bars

RTS-12.17,M5. 1200 bars

Fig. 3. RTS-12.17,M5. 1200 bars


Download Statistics of candles - script for MetaTrader 5




Related News




Latest News
Factbox: Timeline of the Russia doping case
07.12.2019 14:06
LAUSANNE, Switzerland (Reuters) - The World Anti-Doping Agency (WADA) will on Monday consider a recommendation from its compliance committee to hand Russia a four-year Olympic ban as part of a sanctions package to punish Moscow for handing WADA doctored and incomplete laboratory data. Russia, which has denied state involvement in doping, says the
Read more
Germany's SPD slip in polls after choosing new leftist leaders
07.12.2019 14:03
BERLIN (Reuters) - Support for Germany's Social Democrats (SPD) has fallen after members last week chose as leaders a leftist duo who are skeptical about remaining in government with Chancellor Angela Merkel's conservatives, a poll showed on Saturday. At a party conference on Friday, the SPD gave their new leaders, Saskia Esken and
Read more
United States and Iran swap prisoners in rare act of cooperation
07.12.2019 13:06
By Parisa Hafezi DUBAI (Reuters) - The United States and Iran swapped prisoners - a Chinese-American detained for three years on spying charges and an imprisoned Iranian - on Saturday in a rare act of cooperation between two longtime foes whose ties have worsened since President Donald Trump took office. Trump said Chinese-American Xiyue Wang was
Read more
Pope meets with Maltese PM hit by scandal over reporter's murder
07.12.2019 13:03
VATICAN CITY (Reuters) - Pope Francis on Saturday gave a private audience to outgoing Maltese Prime Minister Joseph Muscat, ignoring an appeal to cancel the meeting with a premier engulfed in crisis over a probe into a murdered journalist. Francis met Muscat and his wife and family on Saturday morning, the Vatican said, in an audience that was far
Read more
Buttigieg pledges billions to curb education disparities
07.12.2019 12:15
By Michael Martina DETROIT (Reuters) - Democratic presidential candidate Pete Buttigieg vowed on Saturday to spend hundreds of billions of dollars to improve public education if elected, with a plan that boosts funds for "underserved children" and expands early childhood learning. Buttigieg, who has campaign stops this weekend in Iowa where he has
Read more