Refresh rates when EA attached

 

Hello

I made EA for trading with day range and it is working as i want. It is depending on daily range and takes the high and the low of day candle, i attached the EA on 1H TF and takes the day H&L using below instruction, but i noticed something, when i attache the EA to 1H TF as example on any chart but did not open day chart to refresh it with new values, at first time Range2D variable shows at first time 0 value and after shows the correct value, i know that was stored values in computer and not from server, but i want to refresh the rate from the server if i did not open the day chart, i mean i dont want to see 0 value at first time but i want to see the correct value at first without attaching the EA to day chart. I used Refreshrate() with Sleep(500) after Start() function but nothing changed.

I hope you understood me .


        H2D= iHigh(Symbol(),PERIOD_D1,0);
        L2D=iLow(Symbol(),PERIOD_D1,0);
        Range2D=MathAbs(H2D-L2D)*(1/Point);
       
 
fx2013:

Hello

I made EA for trading with day range and it is working as i want. It is depending on daily range and takes the high and the low of day candle, i attached the EA on 1H TF and takes the day H&L using below instruction, but i noticed something, when i attache the EA to 1H TF as example on any chart but did not open day chart to refresh it with new values, at first time Range2D variable shows at first time 0 value and after shows the correct value, i know that was stored values in computer and not from server, but i want to refresh the rate from the server if i did not open the day chart, i mean i dont want to see 0 value at first time but i want to see the correct value at first without attaching the EA to day chart. I used Refreshrate() with Sleep(500) after Start() function but nothing changed.

I hope you understood me .

RefreshRates() only applies to the predefined variables . . .

Search for posts about error 4066 and read . . .
 
But if i do as example bool CASE= RefreshRates() and read the case on comment, the CASE gives 0 that means it is false bool RefreshRates() Refreshing of data in pre-defined variables and series arrays. This function is used when expert advisor has been calculating for a long time and needs data refreshing. Returns TRUE if data are refreshed, otherwise returns FALSE. The only reason for data cannot be refreshed is that they are the current data of the client terminal.
 
fx2013:
But if i do as example bool CASE= RefreshRates() and read the case on comment, the CASE gives 0 that means it is false bool RefreshRates() Refreshing of data in pre-defined variables and series arrays. This function is used when expert advisor has been calculating for a long time and needs data refreshing. Returns TRUE if data are refreshed, otherwise returns FALSE. The only reason for data cannot be refreshed is that they are the current data of the client terminal.
Believe me or don't believe me . . . but check for yourself and read what's at the links I posted . . . RefreshRates() . . . "Refreshing of data in pre-defined variables and series arrays. " is iLow() or iHigh() reading data from a Predefined variable or Series array ?
 
fx2013: i attached the EA on 1H TF and takes the day H&L. first time 0 value and after shows the correct value, I used Refreshrate()
Exactly what RaptorUK first said. If you read zero check GetLastError. If you get 4066 do like the your research will tell you: Sleep for 15 seconds (not 500 milliseconds) and retry. Call RefreshRates if you slept and now have data for the remainder processing.
Reason: