I am a brand new member of this forum and wondered if I could get a little shove in the right direction with event handling such as OnTick and OnChartEvent etc and their precedence.
I have been playing with chart events to make a button that I can click on and get the program to deviate from its normal action by running some alternative code when I make a standalone button with no other code it works fine each time registering the mouse click on it. However, if I include the code in another expert advisor it seems as the OnTick takes precedence and the button activation never gets acknowledged.
My basic question is what are the rules for the Event Handling I have searched many topics but none seem to discuss how the terminal discriminates between OnTick and OnChartEvent.
I hope someone can point me towards some guidance on this topic.
The indicator consists of the two parts – entry system displayed on the chart and currency power analyzer.
The analyzer can take on values from 0 to 3:
the higher the value, the stronger the currency; the smaller the value, the weaker the currency; average values of the indicator suggest that the currency is in flat.Recommendations on usage:
Buy if Trader Dream shows Buy signal and the analyzer shows the currency's strength (the value exceeds 2). Sell if Trader Dream shows Se
Safe Automatic is a safe MetaТrader 5 trading robot working autonomously on a VPS server. The good results are achieved on EURUSD.
The EA applies modified versions of a trend-following strategy, half-pyramiding, scalping, Elliott Wave method and speculating trading with a deposit protection. The EA switches the strategies automatically. The program also takes the news calendar into account: the robot does not enter the market in a 10-minute interval before and after a news rel
The script creates account summary report in a separate window.
The report can be created for all deals and on deals for selected financial instruments.
It is possible to specify a time interval of calculation and save report to htm-file.
The script creates account summary report in a separate window.
The report can be created for all deals and for deals of the selected financial instruments.
It is possible to specify a time interval of calculation and save report to htm-file.
Here is the product, which truly reveals all the computing and graphical capabilities of the MetaTrader terminal.
The TrendNavigator indicator helps you take the most effective trading decisions, features stunning accuracy, unlimited graphical capabilities and highly developed notification service.
3D graphics 4 unique trend determining algorithms 5 types of notifications of trend change which appear as Buy and Sell signals Very high accuracy Shows local lows and highs Free notification
The script allows users to easily close positions if their profit/loss reaches or exceeds a value specified in pips.
Please set slippage value first. Sometimes some positions do not close due to high volatility of the market. Please set larger slippage or restart the script.
This is an open interest indicator for MetaTrader 5. It fixes open interest value once per minute and writes it to the file (on your PC). The product works on any timeframe but only with exchange instruments.
This is the Famous Timing Indicator
You can now use the most famous Timing indicator on the planet.
Millionaire Mostafa Belkhayate earned his reputation by using this specific indicator to validate the entry signals supplied by his also famous Center of Gravity indicator on the Forex market. I spent hours, days, weeks to decrypt the formula and now it is finally available to you.
New and Unique for MetaTrader 5
Timing will give you perfect validations for your entry signals. It is the first
We present you an effective software solution for arbitrage between brokers.
The Arbitrage on the market became widespread due to decentralization. There are many liquidity providers, whose quotes differ for various reasons. By tracking the dynamics of changes in the quotes of different brokers, it is possible to determine the delayed and leading brokers, thereby predicting the future prices of the delayed broker for a short time. Knowing these prices and using efficient built-in software filte
The PZ Day Trading indicator detects reversals in a zig-zag fashion, without repainting or backpainting. Based on breakouts of variable lengths, the indicator uses only price action to pick trades and reacts to the market very fast. The positional accuracy of its signals offers huge opportunity for profits, easily up to 80% winners.
Amazingly easy to tradeChart statistics will help you to optimize your tradingIt works on every single timeframe without fine tuningThe indicator analyzes its own q
IShift Lite is a lite version of IShift, and it doesn't include the tick chart.
IShift Lite allows:
perform trade operations directly from the depth of market with a "single touch"; automatically place Stop Loss and Take Profit; move position to breakeven; move Stop Loss along the price; automatically calculate the volume of an order depending on a fixed risk level or a fixed margin level.The program includes a visual help system.
Note: the demonstration version downloaded via the "Demo
Robust median renko style indicator for creating custom charts resembling median renko, mean renko, turbo renko and better renko candles as well as vanilla renko with wicks plus PointO charts. This all in one package provides all of the signals needed by day traders, scalpers and even long term traders.
Indicator is an overlay on the main chart so it is possible to utilize one click trading and order manipulation directly on the custom charts. Visual order placement is also
Trade in the opposite directions with HedgeTerminalApi library!
HedgeTerminalApi is a program interface allowing you to use HedgeTerminal virtualization technologies in your robots and scripts. With HedgeTerminalApi, you are able to trade in the opposite directions when two or more trading algorithms occupy opposite positions on a single symbol. The library allows robots to track their positions even if these positions overlap entirely or partially. Moreover, with this library, you are able to
A script for opening a grid of orders
If you need to quickly open several pending orders (Buy Limit, Sell Limit, Buy Stop, Sell Stop) on a certain distance from the current price, this script will do all the routine for you! Allow AutoTrading before running the script.
Run the script on a chart.
Language of messages displayed (EN, RU, DE, FR, ES) - language of the output messages (English, Russian, German, French, Spanish). Price for open - open price. If set to
The script is intended for automatic placing of Buy Stop pending orders, Stop Losses and Take Profits on the user specified levels.
Avoiding unwanted entering a long position in case of false hitting the level as a result of widening of the spread by a dealing center. Avoiding unwanted triggering of a Stop Loss in case a quote pierces a significant level (fractal) without further confirmation with the close price. Setting a necessary virtual order and entering the market in
The indicator is intended for determining the spread and swap size, the distance for setting stop orders and stop losses from the current price allowed and the risk per 1 point in the deposit currency.
The indicator informs a trader about possible additional expenses and profits connected with transferring a position to the next trade session of the financial instrument. It also informs about the spread size and the distance of pending orders, stop loss and trailing from the current price. In a
Active Lines - a powerful professional tool for operations with lines on charts. Active Lines provides a wide range of actions for events when the price crosses lines. For example: notify, open/modify/close a position, place/remove pending orders. With Active Lines you can assign several tasks to one line, for each of which you can set individual trigger conditions, as well as conditions for re-activations and the number of possible activations.
Active Lines helps you easily organize various tr
Exp COPYLOT CLIENT for MT5 is a copier for the МetaТrader 5 platform. It copies forex trades from any accounts. Including those from terminals МТ5 and МТ4.
Install the Expert Advisor in the terminal where you want to copy trades. Specify any text label name as pathRead, for example, "COPY". This should match the master terminal (to bind the two terminals). To copy trades, you need to install the free Master copier in the terminal from where you want to copy the trades: COPYLOT
Pipfinite creates unique, high quality and affordable trading tools.
Our tools may or may not work for you, so we strongly suggest to try the Demo Version for MT4 first. Please test the indicator prior to purchasing to determine if it works for you.
We want your good reviews, so hurry up and test it for free...we hope you will find it useful.
Energy Beam with Swing Control
Strategy: Confirm swing pullback signals Watch Video: (Click Here)Energy Beam with Trend Laser
Fast Copy MT5 allows to copy trades between different MetaTrader 5 (netting)(hedge) and MetaTrader 4 accounts in any direction and amount, quickly and easily (without loading the system).
Any type of copying is available
MT5 —> MT5 MT5 —> MT4 MT4 —> MT5 MT4 —> MT4
* For any interaction with the MT4, it is necessary to additionally install Fast Copy MT4
One tool for sending and receiving transactions: [master] > [slave] operation mode can be selected in
The Red Green Trade Signals indicator just gives you the direct signal to open and close your positions, just like traffic signals.
When the signal turns to red, the market goes to short position, while the signal turns to green, the market goes to long position.
This indicator also provides the precise time and price to open/close your positions with the 'buy' (green) and 'sell' (red) arrows. It's easy to use, and it's ready to go without any parameter to set.
This indicator is implemented b
This indicator allows you to enjoy the two most popular products for analyzing request volumes and market deals at a favorable price:
Actual Depth of Market Chart Actual Tick Footprint Volume ChartThis product combines the power of both indicators and is provided as a single file.
The functionality of Actual COMBO Depth of Market AND Tick Volume Chart is fully identical to the original indicators. You will enjoy the power of these two products combined into the single super-indicator!
The Expert Advisor implements the classic "triangular arbitrage", which is successfully used by hedge funds.
"Triangular" arbitrage refers to a class of neutral-market strategies, in which the profit or loss of open positions does not depend on the direction of the market movement as a whole.
In order to take profit, the EA exploits a weak spot of market makers - it utilizes the difficulty of balancing cross rates of all currency pairs.
The advantages of the strategy are the following:
The indicator bounds the price according to a cyclic wave dependency. Thus, all the crossing points, in which the movement is changed considering the indicator period, are the optimal ones. The crossing points can be used as the potential market reversal points. However, do not forget about the complex approach: the indicator signals require additional data to enter the market.
The indicator enhances the potential of standard fractals and allows you to identify, display and use them, calculating them for any odd length, i.e. 3,5,7,9 bars and so on.
The number of bars to be used is set in the 'Left fractal bars count' variable (by default set to 2). Its value determines the number of bars on one side, not including the central one, i.e. for a standard fractal of 5 bars it is equal to 2 (2 bars * 2 sides + 1 central bar = 5 bars for a fractal search and identification).
The script is intended for automatic placing of Sell Stop pending orders, Stop Losses and Take Profits on the user specified levels. This script is not that useful as "Virtual pending buy stop", since short positions are opened as Bid price crosses the levels. Thus spread widening is not dangerous. Nevertheless, you need to have this script to prevent unwanted hitting of the Stop Loss levels.
Automation of the process of placing the Sell Stop pending orders, Stop Losses and T
This is a classical trading strategy, which falls into the category of breakout systems. They form support and resistance levels, which temporarily limit further price movement. When the price breaks down the support level or breaks up the resistance level, there emerges a strong momentum in the breakout direction, which allows to make profit on strong price movements with moderate risk.
To create the strategy, we used historical data with the quality of history of 99.9%.
It uses filtration o
The most profitable trend traders are the ones who know how to recognize not only the market trend, but also the trading opportunities that arise once a trend has been established. The Pz Trend Trading indicator has been designed to profit has much as possible from trends taking place in the maket.
Established trends offer dozens of trading opportunities, but most trend trading indicators neglect them completely, and leave the trader completely uninformed about what the market is doing during a
The indicator generates early signals basing on ADX reading data combined with elements of price patterns.
Works on all symbols and timeframes.
The indicator does not redraw its signals. You see the same things on history and in real time.
For better visual perception signals are displayed as arrows (in order not to overload the chart).
The indicator is a complete analogues of the Trend Monitor indicator for MetaTrader 4
The best results are obtained when the indicator works o
The EASIEST way to manage your risk for each trade!
Add the indicator to your chart, configure a risk percentage (of account equity) Enter the number of pips for your stop loss into the text entry field that appears on the chart The position size to take will automatically be updatedThe product features two modes - a compact mode which allows entry of stop loss pips and shows the resulting lot size based on the percent risk setting, as well as an expanded mode that also shows
The indicator is intended for recognition and marking 1-2-3 buy and sell patterns on a chart. The indicator will help a trade to determine the starting and signal fractals, and to specify the possible entry points on all timeframes in МetaTrader 5. Fibonacci lines are drawn on the chart to indicate supposed targets of moving on the basis of the wave theory.
The 1-2-3 formations appear to be especially important as divergences (convergences) are formed on price tops and bottoms.
The indicator h
Yes I have it actually says nothing about the precedence of event handling, if the chart event has taken place and a tick also takes place which one is actioned the tick takes the control to OnTick the chart event takes control to the OnChartEvent function. In my case even though a chart event has happened the program continuously runs the OnTick.
A client terminal sends new events to the corresponding open charts. Events can also be generated by charts (chart events) or mql5-programs (custom events). Generation of events of creation or deletion of graphical objects on a chart can be enabled or disabled by setting CHART_EVENT_OBJECT_CREATE and CHART_EVENT_OBJECT_DELETE chart properties. Each MQL5 program and each chart has its own queue of events, where all new incoming events are added.
A program receives only events
from the chart it runs on. All events are processed one after another in
the order they are received. If a queue already has a NewTick
event, or this event is currently being processed, then the new NewTick
event is not placed in the queue of the MQL5 program. Similarly, if ChartEvent
is already enqueued, or this event is being processed, no new event of
this kind is enqueued. The timer events are handled the same way — if
the Timer event is in the queue or being handled, the new timer event is not enqueued.
Event queues have a limited but
sufficient size, so that the queue overflow for well written programs is
unlikely. In case of queue overflow, new events are discarded without
It is not recommended to use
infinite loops to handle events. The exception to this rule may be only
scripts that process only a single Start event.
Thanks again Alain
I have read this, However, it is not clear about which queued event is handled on completion of the current pass, the tick or the chart event or timer etc. Also, the text says that events are not enqueued if a current event is being processed. I realize that it must be my interpretation of this text as this is counter intuitive, what is the point of a queue if nothing is placed in it when the program is in mid-event processing.
I find this a lot with the MQL notes they are very difficult to interpretate.
Kind Regards and thank you for your time with this issue of my understanding, I would appreciate if you could summarise in your words how the new events are handled from different sources whils a current event is being processed.
Events queue is used to register the different events. But OnTick, OnChartEvent and OnTimer can only by queued once (or not if the same kind of event is currently processed).
The events are processed in the order they are queued.
So if an OnTick event is processed and you made some click the chart event is queued. It will executed once OnTick() (and eventual previously queued events) is done.
If you have click events not processed you are maybe falling in the case :
Event queues have a limited but sufficient size, so
that the queue overflow for well written programs is unlikely. In case
of queue overflow, new events are discarded without queuing.
Difficult to say more without any code available.
Many Many thanks Alain your explanation is clear and now that I understand this I can monitor my program flow to check this and establish where my error is.
I agree with William...
I have used sample code of Metatrader... I made lot of testing with mouse click events (clicking button or viewlist) and I found that :
1) time of processing ChartEvent is very long... sometimes few seconds
2) sometimes events are not processed at all.
Or the components and event handling is not working fine... or I have issue in the code.
If you have a simple application or code showing ChartEvents with buttons working fine.. I would be interested to test.
For now I am not satisfied the way events are processed.
... or I have issue in the code.
In comparison to C++ the OnChartEvent() is comparable to the action signal that executes clicked() function, however there are also pressed() and release() functions, and a toggled().
The close resemblance to these other functions is:
Button state (pressed / depressed)
This function can be used inside the OnTick() flow to capture the press of a button to circumvent the OnChartEvent() function so this can never result in delayed execution unless there is a long interval between incoming ticks, nor can the button change state be ignored because it's a part of the primary or main runtime.
One additional feature is that this method also works in the tester.