When in doubt, please refer to the documentation ...
Refreshing of data in pre-defined variables and series arrays
Calls a forced redrawing of a specified chart
When in doubt, please refer to the documentation ...
Refreshing of data in pre-defined variables and series arrays
Better be careful with this thing😄
Otherwise, you may not notice that the arrival of a new bar has shifted the indexing
void OnTick() { datetime time0Before = Time[0]; Alert(StringFormat("Before sleep: current %s, bar0 %s", toStr(TimeCurrent()), toStr(time0Before))); Sleep(61000); Alert(StringFormat("After sleep: current %s, bar0 %s", toStr(TimeCurrent()), toStr(Time[0])), ", same as before ", time0Before == Time[0]); RefreshRates(); Alert(StringFormat("After RefreshRates: current %s, bar0 %s", toStr(TimeCurrent()), toStr(Time[0])), ", same as before ", time0Before == Time[0]); ExpertRemove(); } string toStr(datetime time) { return(TimeToString(time, TIME_MINUTES)); }
After RefreshRates: current 17:56, bar0 17:56, same as before false After sleep: current 17:56, bar0 17:55, same as before true Before sleep: current 17:55, bar0 17:55
Otherwise, you may not notice that the arrival of a new bar has shifted the indexing
It will also update the indicators
(the test was performed on M1 to catch a new bar)
void OnTick() { Alert(StringFormat("Before sleep: current %s, MA1 %s", toStr(TimeCurrent()), getMa1Str())); Sleep(61000); Alert(StringFormat("After sleep: current %s, MA1 %s", toStr(TimeCurrent()), getMa1Str())); RefreshRates(); Alert(StringFormat("After RefreshRates: current %s, MA1 %s", toStr(TimeCurrent()), getMa1Str())); ExpertRemove(); } string getMa1Str() { return(DoubleToString(iMA(Symbol(), PERIOD_CURRENT, 1, 0, MODE_SMA, PRICE_OPEN, 1), Digits())); } string toStr(datetime time) { return(TimeToString(time, TIME_MINUTES)); }
After RefreshRates: current 18:16, MA1 1.07958 After sleep: current 18:16, MA1 1.07975 Before sleep: current 18:15, MA1 1.07975
Anyone knows of a function that refresh non current bars which someone has coded?
It means that I want to refresh non current charts using their ID's. I know Refreshrates() is used for refreshing the market data of current chart, but not that of non current charts. But I have come across a block of codes used to refresh non current chat somewhere, only the person did not give any guarantee that it would work.
-
There is nothing to refresh. RefreshRates only applies to predefine variables and predefined arrays, and they are only apply to the current chart.
-
On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
Download history in MQL4 EA - MQL4 programming forum - Page 3 #26.4 (2019)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use