Voir comment télécharger gratuitement des robots de trading
Retrouvez-nous sur Telegram !
Rejoignez notre page de fans
Un script intéressant ?
Poster un lien vers celui-ci -
laisser les autres l'évaluer
Vous avez aimé le script ? Essayez-le dans le terminal MetaTrader 5
Bibliothèque

aChartsAndMW5Class - bibliothèque pour MetaTrader 5

Vues:
4799
Note:
(19)
Publié:
2017.03.02 12:01
Mise à jour:
2017.03.28 17:19
\MQL5\Include\ \MQL5\Experts\
MQL5 Freelance Besoin d'un robot ou d'un indicateur basé sur ce code ? Commandez-le sur Freelance Aller sur Freelance

The class allows to easily determine from your MQL5 programs any changes in the Market Watch window (change of symbol sorting, adding, deleting a symbol or a set of symbols), as well as opening and closure of charts, and the availability of the one click trading option on the current chart, on which the program is running. The class sends custom events to the control program.

The following public methods are available in the program:

Method
 DescriptionReturned value
Methods of working with charts
  
bool IsChartOneClick(void)
Returns the flag of the availability of the OneClick panel on the chart
bool true/false
uchar GetChartNumbers(void)
Returns the number of open charts in the terminal
uchar The number of open charts
long GetOpenedChartID(void)
Returns the ID of the newly opened chart
long ChartID()
string GetOpenedSymbol(void)
Returns the symbol name of the newly opened chart
string ChartSymbol()
ENUM_TIMEFRAMES GetOpenedTimeframe(void)
Returns the timeframe of the newly opened chartENUM_TIMEFRAMES ChartPeriod()
long GetClosedChartID(void)
Returns the ID of the newly closed chartlong ChartID()
string GetClosedSymbol(void)
Returns the symbol name of the newly closed chartstring ChartSymbol()
ENUM_TIMEFRAMES GetClosedTimeframe(void)
Returns the timeframe of the newly closed chartENUM_TIMEFRAMES ChartPeriod()
bool IsOpenedIsObject(void)
Returns the sign that the opened chart is an object
bool true/false
bool IsClosedIsObject(void)Returns the sign that the closed chart was an objectbool true/false
bool CheckOpenChart(string symbol_name);
Checks whether the symbol chart is open
bool true/false
bool CheckOpenChart(string symbol_name,ENUM_TIMEFRAMES timeframe)
Checks whether the symbol chart with the specified timeframe is open
bool true/false
long OpenChart(string symbol_name,ENUM_TIMEFRAMES timeframe)
Opens the symbol chart
long ChartID()
bool IsOpenedAllCharts(void)
Returns the flag of presence of open charts of all symbols from the Market Watch
bool true/false
Methods of working with the Market Watch


bool PutSymbolToMarketWatch(string symbol_name)
Adds a symbol to the Market Watch
bool true/false
bool IsExistSymbolInMW(string symbol_name, bool select=false)
Returns the flag of presence of a symbol in the Market Watch/on the server
bool true/false
int GetNumSymbolsInMW(void)
Returns the number of symbols in the Market Watch
int The number of symbols in the Market Watch
int GetNumAllSymbols(void)
Returns the number of available symbols
int The number of symbols on the server
void ClearMarketWatch(void)Deletes all possible symbols form the Market Watchvoid
Custom events that the class sends to the control program:
Identifier
Value
 Description
CHARTEVENT_CHART_OPEN32New chart opening event
CHARTEVENT_CHART_CLOSE33Chart closing event
CHARTEVENT_MW_SYMBOL_ADD34An event of adding a symbol to the Market Watch
CHARTEVENT_MW_FEW_SYMBOL_ADD35An event of adding multiple symbols to the Market Watch
CHARTEVENT_MW_SYMBOL_DEL36An event of symbol deletion from the Market Watch
CHARTEVENT_MW_FEW_SYMBOL_DEL37An event of deletion of multiple symbols from the Market Watch
CHARTEVENT_MW_CHANGE_SORT38An event of changing the symbol sorting in the Market Watch
CHARTEVENT_CHART_CHANGE_ONE_CLICK39OneClick panel opening/closing event

The identifier values are correlated to the identifiers from the graphical library by Anatoli Kazharski, although you can set them at your discretion.

The values that are passed to the control program along with the event:

Identifier
 lparamdparam
 sparam
CHARTEVENT_CHART_OPENlong ChartID of the open chart
ENUM_TIMEFRAMES Period of the open chart
string Symbol of the open chart
CHARTEVENT_CHART_CLOSElong ChartID of the closed chartENUM_TIMEFRAMES Period of the closed chartstring Symbol of the closed chart
CHARTEVENT_MW_SYMBOL_ADDint The current number of symbols
int The previous number of symbols
string The added symbol
CHARTEVENT_MW_FEW_SYMBOL_ADDint The current number of symbolsint The previous number of symbolsstring The last used symbol
CHARTEVENT_MW_SYMBOL_DELint The current number of symbolsint The previous number of symbolsstring The deleted symbol
CHARTEVENT_MW_FEW_SYMBOL_DELint The current number of symbolsint The previous number of symbolsstring The last used symbol
CHARTEVENT_MW_CHANGE_SORTint The current number of symbolsint The current number of symbolsstring The last used symbol
CHARTEVENT_CHART_CHANGE_ONE_CLICKint The X coordinate of the right border of the panel
int The Y coordinate of the right border of the panel
string The description of the panel state:
"CHART_IS_ONE_CLICK_ON" - there is a panel
"CHART_IS_ONE_CLICK_OFF" - there is no panel

In order to include the class to the program, you must include the file in the global area and create a class instance:

#include <aChartsAndMWClass.mqh>
CChartsMW   mw;

Then, in the OnTimer() function of the program, add the class timer:

//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer()
  {
//--- Adding the class timer
   mw.OnTimerEvent();
  }
//+------------------------------------------------------------------+

Add the class event handler in OnChartEvent():

//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//--- Adding the class event handler
   mw.OnEvent(id,lparam,dparam,sparam);

  }
//+------------------------------------------------------------------+

Now, events returned by the class can be accepted and processed in the program's OnChartEvent().

The example of receiving events from the class is available in the attached Expert Advisor exTestChartsMWClass.mq5

Traduit du russe par MetaQuotes Ltd.
Code original : https://www.mql5.com/ru/code/17448

SilverTrend v3 SilverTrend v3

SilverTrend v3 - trading based on the analysis of the High, Low and Close prices of bars.

New Martin New Martin

The New Martin Expert Advisor opens two opposite positions upon start. OnTradeTransaction handling. When Take Profit triggers, it opens a position (one position) in the same direction. The intersection of two MA indicators is a signal to open a position of a larger lot.

Alpha Trend Spotter Price Action Alpha Trend Spotter Price Action

Semaphore signal indicator based on the price action strategy looking for the strongest intraday trend, which can notify about trend change by generating an alert, sending an email or a push notification to a mobile device.

Exp_TDI-2_ReOpen Exp_TDI-2_ReOpen

The Exp_TDI-2_ReOpen trading system based on the intersection of TDI-2 indicator lines, with adding to trend-following positions.