So frustrated I haven't any idea how this happened!
The code ran on 2 brokers for 3 months. Today the issue below suddenly happened at 1 broker.
Please refer to the log and code below. The code should run sentence by sentence based OnTick. However, please refere to the time marked in yellow. Why were the closed orders printed after hours?
I thought and thought, but thought of nothing about the root cause except the doubt. Sentences of new tick can start to run although the sentences of previous ticks haven't been executed or completed while VPS is slow.
Is it possible? How do the MQL4 code run indeed? Please, please help!!! Thank you very, very, very much!!!
2015.12.16 16:30:17.426 xDangerEN_4D EURNOK.pro,M5: modify #36653643 buy 0.07 EURNOK.pro at 9.5695 sl: 0.0000 tp: 9.5813 ok
2015.12.16 16:30:17.426 xDangerEN_4D EURNOK.pro,M5: MP.B3_ModifyBuy(step) succeeded at 9.5813 with Bid/Ask 9.5634/9.5664
2015.12.16 16:30:18.363 xDangerEN_4D EURNOK.pro,M5: modify #36653643 buy 0.07 EURNOK.pro at 9.5695 sl: 0.0000 tp: 9.6025 ok
2015.12.16 16:30:18.363 xDangerEN_4D EURNOK.pro,M5: MP.B1_ModifyBuy(first) succeeded at 9.6025
2015.12.16 16:30:23.677 xDangerEN_4D EURNOK.pro,M5: modify #36653643 buy 0.07 EURNOK.pro at 9.5695 sl: 0.0000 tp: 9.5813 ok
2015.12.16 16:30:23.677 xDangerEN_4D EURNOK.pro,M5: MP.B3_ModifyBuy(step) succeeded at 9.5813 with Bid/Ask 9.5637/9.5663
2015.12.16 16:48:13.529 xDangerEN_4D EURNOK.pro,M5: PPP.1_This history POS 93 was closed with Possible Bid/Ask 9.5589/9.5622 as TakeProfit.
2015.12.16 16:48:13.529 xDangerEN_4D EURNOK.pro,M5: #36652937 2015.12.16 14:48:49 buy 0.07 EURNOK.pro 9.5658 0.0000 9.5947 2015.12.16 15:29:56 9.5735 -0.49 0.00 6.15 1 5858688
2015.12.17 00:20:08.525 xDangerES_4D EURSEK.pro,M5: WE.1_File updated successfully: EURSEK.pro_xDangerES_4D_20151113.txt
2015.12.17 00:20:08.525 xDangerES_4D EURSEK.pro,M5: MP.B4_ModifyBuy(step) at 9.3056 with Error: Trade timeout
2015.12.17 00:21:00.635 xDangerES_4D EURSEK.pro,M5: WE.1_File updated successfully: EURSEK.pro_xDangerES_4D_20151113.txt
2015.12.17 00:21:00.635 xDangerES_4D EURSEK.pro,M5: MP.B4_ModifyBuy(step) at 9.3056 with Error: No connection with trade server
2015.12.17 01:32:09.287 xDangerES_4D EURSEK.pro,M5: modify #36655076 buy 0.24 EURSEK.pro at 9.3169 sl: 0.0000 tp: 9.2732 ok
2015.12.17 01:32:09.287 xDangerES_4D EURSEK.pro,M5: MP.B3_ModifyBuy(step) succeeded at 9.2732 with Bid/Ask 9.2700/9.2744
2015.12.17 02:12:53.761 xDangerEN_4D EURNOK.pro,M5: PPP.1_This history POS 169 was closed with Possible Bid/Ask 9.5448/9.5477 as TakeProfit.
2015.12.17 02:12:53.761 xDangerEN_4D EURNOK.pro,M5: #36659173 2015.12.16 22:08:11 sell 0.06 EURNOK.pro 9.5895 0.0000 0.0000 2015.12.16 22:08:11 9.5929 -0.42 0.00 -2.34 0 5858688
for(i=historyPOS; i<historyTotal; i++)
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==true && OrderMagicNumber()==MAGIC)
PrintFormat("PPP.1_This history POS %i was closed with Possible Bid/Ask %s/%s as TakeProfit.",i+1,DoubleToStr(Bid,Digits),DoubleToStr(Ask,Digits));
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
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
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
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
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
The Expert Advisor is an assistant for the traders who use Bollinger Bands in their trading. With some additions, it includes three trading methods described in the book "BOLLINGER ON BOLLINGER BANDS" by John Bollinger.
EA inputs for three strategies:
Timeframe EA (graphics),Volume lots to trade,Stop Loss,Take Profit,Close the position at a profit, point. 0 =do not use,Set the breakeven point in points from the entry. 0 =do not use,Increase the amount of position at new signals
The indicator displays harmonic patterns on the chart based on Dynamic ZigZag (https://www.mql5.com/en/market/product/5357) and is almost a complete analog of one of the versions of well-known korHarmonics. The indicator recognizes the following patterns and their varieties: ABCD, Gartley (Butterfly, Crab, Bat), 3Drives, 5-0, Batman, SHS, One2One, Camel, Triangles, WXY, Fibo and Vibrations. Only display of ABCD and Gartley patterns is enabled in the settings by default. The reverse line allows d
This indicator draws the Keltner Channel using the rates chart calculated from any other timeframe.
The available Moving Averages are:
Simple Moving Average Exponential Moving Average Smoothed Moving Average Linear Weighted Moving Average Tillson's Moving AverageMoving Average line is coded into RED or BLUE according to its direction from the previous candle.
Example: User can display the Keltner Channel calculated on the basis of a Daily (D1) chart on a H4 chart.
NOTE: Timeframe must
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!
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
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 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
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.
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 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
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
Professional Constrictor Expert Advisor follows the market using the Parabolic Stop and Reverse system indicator. At each Parabolic SAR indicator signal, a position is opened in the direction approaching the indicator. In case of an opposite signal, a new position closing the previous one is opened (in other words, positions are opened and closed partially). Thus, the EA constantly follows the price.
The EA has been designed for working in the flat market. It features a critical drawdown, at wh
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.
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
This is a convenient tool for measuring the number of points between prices. It support magnetizing to OHLC prices. Calculates profit considering specified lot size and spread (optionally). It counts the number of bars between specified point and the time difference between them. Calculates the slope angle from the horizontal position. Unneeded parameters can be hidden. It does not occupy much space when inactive.
Once you add the indicator on the chart, Ruler caption will appear (according to
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
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 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
This is a panel for controlling the profit/loss in dollars, pips or % of balance. The panel can be used as a virtual Stop Loss or Take Profit. It also features the emergency button CLOSE ALL.
Other versions in this collection:
VirtualTradePad PositionsStyle VirtualTradePad Ordersstyle VirtualTradePad SignalsStyle VirtualTradePad Lite demo version Digit Market Time Pad Market Time Pad Scalper PadMain Features:
The panel can work only on its own symbol (Current Symbol) or consider the
Scalper with Automatic Parameter Setting
Would you like to have an Expert Advisor that could automatically calculate trade parameters and adjust to the current market situation?
We present you our new development for the Forex market. This is a tick scalper for МТ4 and МТ5 - TickSniper.
Trading with it is fully automated. Forget continuous monitoring - this Expert Advisor trades independently. Its settings have been optimized over the course of testing on our real accounts.
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
Is position management time consuming? The Trade Manager Pro EA performs an automatic and flawless position management for you, avoiding human errors and enhancing your trading activity. It represents a ten-fold increase in trading productivity!
Capital preservation is top priorityLet profits run without your attentionEnjoy risk-free trades as soon as possibleIt trails the stop-loss automatically
Initial SL and TP are also automatic
The EA performs the following tasks
Percent Crosshair is a powerful and easy percentage measure tool.
Measure the chart percentage very quick! Don't waste your time anymore!
Just attach the Percent Crosshair indicator in the chart, select crosshair mode at toolbars or press "Ctrl+F" and start using the crosshair as you always do! The percent measure will be next to the indicative price.
Customize your indicator the way you want!
There are 4 entry parameters:
Positive % color: set the desired color when % is positive. Negat
The indicator is based on the digital window-sinc filter with an excellent frequency division. Due to this property you can get a very smooth indicator line.
The indicator has three lines: the central line indicates the main trend direction and the "fair" price, the other two lines show the price range. When the central line is read, it is recommended to buy from the bottom line and close a position above the central line. When the line is blue, do the opposite - sell from the upper line and cl
Date and time at the beginning of the line (2015.12.16 16:48:13.529) are taken from your pc at the time of the printout.
The other time (2015.12.16 15:29:56) is the close time of your broker.
What if the pc clock has been changed or is heavily lagging due to a bad load distribution of the vps by the vps-provider?
I checked previous reasons and no problem at all. It proves there is problem since the closed orders should be printed in the next tick once the order is closed.
The code has run 3 months without problem and just has problem today. So my doubt is same as what you mentioned on VPS speed.
Is it possible for the Sentences of new tick can start to run although the sentences of previous ticks haven't been executed or completed while VPS is slow?
How does MQL4 proceed while VPS is slow?
MQL4 can't recognize it.The only hint is that the 'virtual' pc clock gets slower and slower. Compare the times of the pc clocks.
I once realized that the clock of the vps was more that 30 min per day slower than real time.
The difference was so big that the ntp software refuses to set that vps clock. Of course the provider refuses any responsibility - so I quit!
In my case, you can see the VPS time in the bottom-right is completely same as the MT4 server time. So believe it's not the issue of clock delay.
Instead, I'm doubting if this statement still works while CPU/Memory overloaded, "In case when OnTick() function for the previous quote is being processed when a new quote is received,
the new quote will be ignored by an Expert Advisor".
Has any friend any idea or experience on it? Thanks in advance!
Any comment or suggestion is welcome!
I used "EventSetMillisecondTimer(20)" on Amazon free VPS and did observe the delay from the VPS local time after hundreds of "OnTimer()" cycles.
How can it happen as the VPS local time is still accurate? I'm confused. Is there something I can do in my code to prevent or mitigate the impact?
Besides, my code runs in same speed all the time.
However you can see the VPS CPU is about 8% at the begining and it rises up gradually with hours. Finally it always be 100% busy.
May I ask a favor for you to help me better understand this kind of issue? Thank you very much!
Amazon's VPS seems to be very slow. If you run your terminal directly on a pc it will get let's say every 10th cpu-tick - the other 9 are for other threads.
On a VPS (same situation) the terminal didn't get every 10th tick of the cpu but if there are 100 other clients every it will get only every 100*10 tick of the cpu. BUT for your terminal it is again only the t10th tick.
I had once a VPS where the clock delayed about 30 min per day it was so slow that even ntp-time refuses to set times!
Beside that after I complained the admin of the VPS logged in onto my VPS and changed the automatic time adjust of Windows!
Have you changed the option for the VPS-Admin to login to your VPS?
Amazon's VPS is meant for normal user and their individual web idea - I don't think it suits a trader (There is no free lunch!)
Thanks a lot. But how to change the option?
The difference of the time you are expecting and the local time passed may be there in case your program needs more than 20ms for each iteration to complete; in that case, your estimated (expected) time should appear as less than the time passed
Regarding CPU going from 8% to 100%, I believe it is the result of Amazon Cloud automatically allocating the necessary CPU power to your program - and no more than that, so probably no problem here
Do you think the code below in "OnTimer()" costs over 20 ms to run?
input int timePeriod=50;
//| Expert initialization function |
//--- create timer
//| Expert deinitialization function |
void OnDeinit(const int reason)
//--- destroy timer
//| Timer function |
display+=StringFormat("\nEvent Ticks: %i Real Ticks: %u",timeTick,(curTime-iniTime)*1000/timePeriod);