RefreshRates()

 
I have a little issue with the update of prices.
I call RefreshRates() and the Ask and the Bid are updated OK.
But the other historic price information are wrong.
Any idea why this could be?
Many thanks!
09:45:21 test #FDXU2,Daily: Ask: 6747.5
09:45:21 test #FDXU2,Daily: Bid: 6746
09:45:21 test #FDXU2,Daily: iHigh(Symbol(), PERIOD_M1, 1): 6787.5
09:45:21 test #FDXU2,Daily: iLow(Symbol(), PERIOD_M1, 1): 6784.5

 

RefreshRates() does a very specific task, namely . . . Refreshing of data in pre-defined variables and series arrays. iHigh, iLow, etc are functions and are not predefined variables or series arrays.

Test for error 4066 after each call, (iHigh, iLow, etc), if you get an error 4066 repeat the call and test again, only move on when the error 4066 is no longer being generated.

 
Are you running under the tester and do you have history for those timeframes?
 
RaptorUK:

RefreshRates() does a very specific task, namely . . . Refreshing of data in pre-defined variables and series arrays. iHigh, iLow, etc are functions and are not predefined variables or series arrays.

Test for error 4066 after each call, (iHigh, iLow, etc), if you get an error 4066 repeat the call and test again, only move on when the error 4066 is no longer being generated.


You were right - catching 4066 did the trick - many thanks!!! However I notice that although I do a iHigh(Symbol(), PERIOD_M1, 1) I access the time series several periods ago and not 1 period ago as I would have expected.

 
TradeIT:

You were right - catching 4066 did the trick - many thanks!!! However I notice that although I do a iHigh(Symbol(), PERIOD_M1, 1) I access the time series several periods ago and not 1 period ago as I would have expected.

There isn't always a tick during some minutes of the day, if there are no ticks there is no bar.
 
RaptorUK:
There isn't always a tick during some minutes of the day, if there are no ticks there is no bar.


But in history center the data is there...

Does it mean history center data is not connected to the data I get with iHigh(Symbol(), PERIOD_M1, 1)?

 
TradeIT:

But in history center the data is there...

Does it mean history center data is not connected to the data I get with iHigh(Symbol(), PERIOD_M1, 1)?


The data in the History centre is the data you get on your chart and the data yo will get when you call iHigh(), iLow() etc

Perhaps some screen grabs might help us to understand your issue better.

 
RaptorUK:


The data in the History centre is the data you get on your chart and the data yo will get when you call iHigh(), iLow() etc

Perhaps some screen grabs might help us to understand your issue better.

The functions return the following at 19:16 hrs:
19:16:16 test #FDXU2,Daily: iHigh(Symbol(), PERIOD_M1, 1): 6795

19:16:16 test #FDXU2,Daily: iLow(Symbol(), PERIOD_M1, 1): 6792.5

In the screenshot one can see that this data existed at 18:23 hrs but not at 19:16 hrs or 19:15 hrs. Although I did a RefreshRates() and catched error 4066.

So the function return data which is about 35 minutes old.

Without catching 4066 the data was even older.


 
Can you show your code ? if not, can you create a script that gives the same problem and share that code please . . .
 
RaptorUK:
Can you show your code ? if not, can you create a script that gives the same problem and share that code please . . .

Here is the code.

start()

{

myRefreshRates();

Print("iHigh(Symbol(), PERIOD_M1, 1): ", iHigh(Symbol(), PERIOD_M1, 1));
Print("iLow(Symbol(), PERIOD_M1, 1): ", iLow(Symbol(), PERIOD_M1, 1));

}


bool myRefreshRates()
{
RefreshRates();
iHigh(Symbol(), PERIOD_M1, 1);

while(GetLastError() == 4066)
{
iHigh(Symbol(), PERIOD_M1, 1);
Print("RefreshRates error 4066");
}
return (true);

}

When run at 19:16 hrs this returns:

19:16:16 test #FDXU2,Daily: iHigh(Symbol(), PERIOD_M1, 1): 6795

19:16:16 test #FDXU2,Daily: iLow(Symbol(), PERIOD_M1, 1): 6792.5

 

Can you make this addition and re-run it please.

int start()
   {
   myRefreshRates();

   Print("iHigh(Symbol(), PERIOD_M1, 1): ", iHigh(Symbol(), PERIOD_M1, 1));
   Print("iLow(Symbol(), PERIOD_M1, 1): ", iLow(Symbol(), PERIOD_M1, 1));

   Print("iTime(Symbol(), PERIOD_M1, 1): ", TimeToStr(iTime(Symbol(), PERIOD_M1, 1), TIME_DATE|TIME_SECONDS));  // <--  add this line 
   }



bool myRefreshRates()
   {
   RefreshRates();
   iHigh(Symbol(), PERIOD_M1, 1);

   while(GetLastError() == 4066)
      {
      iHigh(Symbol(), PERIOD_M1, 1);
      Print("RefreshRates error 4066");
      }
   return (true);
   }