Questions from Beginners MQL5 MT5 MetaTrader 5 - page 986
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
In OnInit() call the time series of the symbol: iTime(Symbol,Timeframe,1);
At the very beginning of OnTick(), ask for the needed bar of the needed timeseries via the corresponding iFunc(), or if( iTime(Symbol,Timeframe,10)==0) return;
In this case, the Expert Advisor will not detect a new bar and will wait for the next tick.
In OnInit() we have requested the time series data, thereby activating data paging.
In OnTick() we check if the minimally required history is available to the EA and if it is not yet available, we wait for the next tick.
And until all of the data required by the Expert Advisor is received, it will wait for the next tick.
As soon as all the necessary data is pumped and obtained, the Expert Advisor will start to work with the new bar and the required history.
To keep the serial data up to date, be sure to access it at least once every two minutes. Make a second timer for about a minute and a half (90 seconds) and in it, simply access any timeseries of the desired symbol, for example iTime(Symbol,Timeframe,1); Without checking the received data - just "move" the history. Then all data on the symbol will always be up to date.
Of course, I will try to check the new bar using all TFs but is it not synchronous, this is not MT4. The problem is not with the bar but with non-performance of indicators that are called from the indicator, which in turn is called from the Expert Advisor.
I work on minutes, so the history should always be up to date.
And, all these checks are done for the test and they will just slow down the work on a real account, because everything works slower there than in the tester's stationary conditions, I repeat that on a real account the indicator works correctly.
So far I have solved the problem by checking the readiness of indicators, which have failed, before the start of the main code
But this approach is not universal, because you need to list all the indicators, is there another, more universal method to make the tester environment work correctly?
In OnTick() we check if the minimally required history is available to the Expert Advisor, and if it is not available yet - we wait for the next tick.
And until all of the data required by the EA is obtained, it will wait for the next tick.
As soon as all the necessary data is pumped and obtained, the Expert Advisor will begin to work with the new bar and the required history.
How do you propose to check the availability of the history, I don't understand...
Add this line before the MQL4 function
and it will work in MT5.
That is genius. Thank you very much!
Can you tell MT5 can implement such buttons, maybe already have one, share the code ...
Provide for slippage and requotes.
Hello, if the Ask and Bid prices from the CSymbolInfo class are more or less clear, how to get for example SessionInterest or SessionBuyOrdersVolume or SessionPriceLimitMin, It gives out zeros, I can't understand why...
Hello, if the Ask and Bid prices from CSymbolInfo class is more or less clear, how to get e.g. SessionInterest or SessionBuyOrdersVolume or SessionPriceLimitMin, it gives out zeros, I can't understand why...
If the trading server broadcasts this information, you will receive it.
As a rule, this information is broadcasted by Brokers for stock symbols (do not confuse Brokers and dealing centres).
If a trading server broadcasts this information, you will receive it.
This information is usually broadcast by Brokers for exchange symbols (don't confuse Brokers and dealing centres).
Broker Otkritie, the RTS Index Futures, I assume must broadcast at least SessionPriceLimitMin and SessionPriceLimitMax (because they are as far as I understand the opening prices used in market orders). Doesn't the opening translate... I prescribe for example:
Print(m_symbol.Ask()," ",m_symbol.SessionBuyOrdersVolume()); - from your EA
I get only Ask prices in the log
Please help in writing a piece of code that would correctly determine the date of the last bar with any shift in any TF, accurate to the current TF.
This code generally works, but only if the start time of the current bar coincides with the actual (rounded to the minute) bar, as my current chart is M1. And if it doesn't coincide, then various mishaps occur, depending on different TFs. For example, I need to know the start date of the latest M1 bar in the last hour, if it was 12 o'clock no problem, the time will be 12:59, but if it was 13 o'clock it will be 13:58 because the hourly bar opened at 14:05 and not at 14:00 and theiBarShift function returned the nearest bar to 14:00, i.e. 13:59.
Added: made this, it seems to work
Otkritie broker, RTS index futures, I assume it should broadcast at least SessionPriceLimitMin and SessionPriceLimitMax (as I understand they are used in market orders by opening prices ). Doesn't the opening translate... I prescribe for example:
Print(m_symbol.Ask()," ",m_symbol.SessionBuyOrdersVolume()); - from your EA
I get only Ask prices in the log