Rejoignez notre page de fans
aChartsAndMW5Class - bibliothèque pour MetaTrader 5
- Vues:
- 4799
- Note:
- Publié:
- 2017.03.02 12:01
- Mise à jour:
- 2017.03.28 17:19
- 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 | Description | Returned 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 chart | ENUM_TIMEFRAMES ChartPeriod() |
long GetClosedChartID(void) | Returns the ID of the newly closed chart | long ChartID() |
string GetClosedSymbol(void) | Returns the symbol name of the newly closed chart | string ChartSymbol() |
ENUM_TIMEFRAMES GetClosedTimeframe(void) | Returns the timeframe of the newly closed chart | ENUM_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 object | bool 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 Watch | void |
Identifier | Value | Description |
---|---|---|
CHARTEVENT_CHART_OPEN | 32 | New chart opening event |
CHARTEVENT_CHART_CLOSE | 33 | Chart closing event |
CHARTEVENT_MW_SYMBOL_ADD | 34 | An event of adding a symbol to the Market Watch |
CHARTEVENT_MW_FEW_SYMBOL_ADD | 35 | An event of adding multiple symbols to the Market Watch |
CHARTEVENT_MW_SYMBOL_DEL | 36 | An event of symbol deletion from the Market Watch |
CHARTEVENT_MW_FEW_SYMBOL_DEL | 37 | An event of deletion of multiple symbols from the Market Watch |
CHARTEVENT_MW_CHANGE_SORT | 38 | An event of changing the symbol sorting in the Market Watch |
CHARTEVENT_CHART_CHANGE_ONE_CLICK | 39 | OneClick 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 | lparam | dparam | sparam |
---|---|---|---|
CHARTEVENT_CHART_OPEN | long ChartID of the open chart | ENUM_TIMEFRAMES Period of the open chart | string Symbol of the open chart |
CHARTEVENT_CHART_CLOSE | long ChartID of the closed chart | ENUM_TIMEFRAMES Period of the closed chart | string Symbol of the closed chart |
CHARTEVENT_MW_SYMBOL_ADD | int The current number of symbols | int The previous number of symbols | string The added symbol |
CHARTEVENT_MW_FEW_SYMBOL_ADD | int The current number of symbols | int The previous number of symbols | string The last used symbol |
CHARTEVENT_MW_SYMBOL_DEL | int The current number of symbols | int The previous number of symbols | string The deleted symbol |
CHARTEVENT_MW_FEW_SYMBOL_DEL | int The current number of symbols | int The previous number of symbols | string The last used symbol |
CHARTEVENT_MW_CHANGE_SORT | int The current number of symbols | int The current number of symbols | string The last used symbol |
CHARTEVENT_CHART_CHANGE_ONE_CLICK | int 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:
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 - trading based on the analysis of the High, Low and Close prices of bars.
New MartinThe 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.
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_ReOpenThe Exp_TDI-2_ReOpen trading system based on the intersection of TDI-2 indicator lines, with adding to trend-following positions.