update prices for a specific symbol

 

I have an Expert Advisor which is operating on multiple pairs.

The problem is that when i close positions, from time to time i get repeated 136 errors ( off quotes ).

I'm getting Bid Ask through MarketInfo; since RefreshRates() is totally uneffective, how to update the prices for a specific symbol?

Thank you

 
On MT4: Unless the current chart is that specific pair/TF referenced, you must handle 4066/4073 errors before accessing prices.
          Download history in MQL4 EA - MQL4 and MetaTrader 4 - MQL4 programming forum
          Corrected
 

That's fine, thank you. I guess this way i can avoid those requote errors. But what if i want to update prices in order to prevent requotes?

Even if i'm handling those errors i have no way to refresh all pairs prices, and i'm probably going to enter late in the trade because of the repetition of this error

 

Price Data Structure

or
double bid = SymbolInfoDouble(symbol, SYMBOL_BID),
       ask = SymbolInfoDouble(symbol, SYMBOL_ASK);
 
Marco Strazzeri: But what if i want to update prices in order to prevent requotes?

What part of "you must handle" and the links provided was unclear?

 
Konstantin Nikitin:
  1. Those will be zero for symbols not in Market Watch or on an open chart.
  2. Since OP is trading the symbol, he'll need history as well.

The function linked to, opens a hidden chart for the symbol/TF in question (if not already open,) thus updating history, and temporarily placing the symbol on Market Watch (if not already there,) so SymbolInfoDouble(symbol, SYMBOL_BID) or MarketInfo(symbol, MODE_BID) don't return zero the first call.

 

William,

the unclear part is: it is almost useless to handle an error if i don't even try to get the new data. First, let's try to refresh price data, then i will handle error if prices were not updated.

If i need data from a website, then

a=getWebsiteData (url)

read a, use it

handle error or exceptions if needed


This works. The following doesn't work

read a, use it

handle error or exceptions if needed


a has not been updated, so the rest is useless

 
Marco Strazzeri: almost useless to handle an error if i don't even try to get the new data.
  1. What part of "you must handle 4066/4073 errors before accessing prices" was unclear?
  2. What part of calling the function linked to, starts the download, is unclear?
  3. You asked how. I told you how, twice (#1 and #5.) Why are you ignoring your answers?
 

Well,

actually i didn't need to download history, so it looked like some kind of solution but NOT the right solution. In that sense, it was really unclear.

Anyway, if there's no other ways, it's fine.

Secondly, i think you will avoid people arguing about your answers if you just add one plus line to your comments, the link looked quite off topic.

It's not mandatory, it's just if you want people to be more happy about your answers and try to get more popularity / authority / whatever.

 
William Roeder:

What part of "you must handle" and the links provided was unclear?

The user's question is clear.

Why does SymbolInfoDouble () - MarketInfo () not work for other pairs, except for the pair selected in the expert?

And you, in praise of idiocy, have filled all the forums with a copy and paste of information that does not help.

The error is not from Historics (although it could be) the error is that SymbolInfoDouble () - MarketInfo () do not work.

If you are going to help, give your opinion. If you want (and you know some programming) create an expert that shows the ASK prices of all available pairs.

 
  1. Hely Rojas: Why does SymbolInfoDouble () - MarketInfo () not work for other pairs, except for the pair selected in the expert?

    It does, if you update before accessing values.

  2. Marco Strazzeri: actually i didn't need to download history, so it looked like some kind of solution but NOT the right solution. 
    So replace the function provided with the equivalent:
       ResetLastError();
       double bid = SymbolInfoDouble(symbol, SYMBOL_BID);
       if(_LastError != 0){
          if(_LastError != ERR_HISTORY_WILL_UPDATED
          && _LastError != ERR_NO_HISTORY_DATA
             Print(StringFormat("iTime(%s,%i) Failed: %i", symbol, period,_LastError));
          return;
       }
    When in doubt, think!
Reason: