iClose and Ilow not uptodate?

 

My EA is handling different instruments (eg. EURUSD and USDCAD and AUDUSD...) and within my EA I also use H1 and M1 periode.

To be sure to have the latest possible values into the history I already use arraycopy rates at every tick for every instrument and used periods (M1and H1)

For usdcad M1 I use the code below:

      ResetLastError();
      ArrayCopyRates(mqlrates_usdcad_m1,SymbolPrefix+"AUDUSD"+SymbolSuffix,PERIOD_M1);
      //ErrorHistory = GetLastError();
      //if (ErrorHistory ==4066) Alert("AUDUSD m1 error 4066");
      //if (ErrorHistory ==4073) Alert("AUDUSD m1 error 4073");
      //ErrorHistory=0;

Well then I thought my history info is most uptodate with that.

Somewhere in my code I use:

if(iClose(Pair,PERIOD_M1,0)-iLow(Pair,PERIOD_M1,0)>=InvalidateLevel*MarketInfo(Pair,MODE_POINT))

Now I have an issue which I only can explain if the iClose an or iLow is not uptodate

I also can't reproduce the issue in the tester (it works perfect)

Am I correct that with the ArrayCopyRates I also update the iLow and iClose
Am I correct that if iClose is uptodate that also iLow must be uptodate or isn't that in sync downloaded.

What can I try to make this issue solved?

 
  1. ArrayCopyRates(mqlrates_usdcad_m1,SymbolPrefix+"AUDUSD"+SymbolSuffix,PERIOD_M1);
    MT5 has no ArrayCopyRates. Why did you post your MT4 question in the Root / MT5 General section instead of the MQL4 section, (bottom of the Root page?)

  2. You don't have to use ACR at "every tick." Once it returns non-zero that pair/TF will always be up to date (assuming the array is global.) Check your return codes, sleep and loop in OnInit. You could also handle 4066/4073 errors yourself if you don't need the ACR.

  3. if(iClose(Pair,PERIOD_M1,0)-iLow(Pair,PERIOD_M1,0)>=InvalidateLevel*MarketInfo(Pair,MODE_POINT))
    We have no idea what Pair or InvalidateLevel is or what your chart is. Use the debugger or print out your variables, including _Symbol and find out why.

  4. Using _Point means your code breaks if you ever put it on 4 digit brokers, exotics (e.g. USDZAR where spread is over 500 points,) and metals. Compute what a PIP is and use it, not points.

 

Correct it's mql4 code....

Oke sorry for that.......then I ask the question in the MQL4 section (I thought this was just general...)

anyway thanks for the answers so far.....

 
Bert:

Correct it's mql4 code....

Oke sorry for that.......then I ask the question in the MQL4 section (I thought this was just general...)

anyway thanks for the answers so far.....

Don't create a new thread/topic now. That would be double posting. Continue here and let the Moderators move the thread if they decide to do that!

PS! Actually they did move the thread for you and I did not even notice!

 
Fernando Carreiro:

Don't create a new thread/topic now. That would be double posting. Continue here and let the Moderators move the thread if they decide to do that!

PS! Actually they did move the thread for you and I did not even notice!

I do it very often, but it's unnoticeable, and I can't write a message each time.

I would just suggest "power" users to don't care and let the moderators some time to act. Most people are anyway posting anywhere, as it doesn't matter for the search engine.

 
Alain Verleyen:

I would just suggest "power" users to don't care and let the moderators some time to act.


 *cough*whroeder1*cough*

 
Bert:

What can I try to make this issue solved?

This also works in MQL4
MqlRates usdcad[];
ArraySetAsSeries(usdcad,true);
CopyRates("USDCAD",PERIOD_M1,0,Bars,usdcad);
if(usdcad[0].close - usdcad[0].low >=InvalidateLevel*MarketInfo(Pair,MODE_POINT))

https://www.mql5.com/en/docs/series/copyrates

Documentation on MQL5: Timeseries and Indicators Access / CopyRates
Documentation on MQL5: Timeseries and Indicators Access / CopyRates
  • www.mql5.com
Timeseries and Indicators Access / CopyRates - Reference on algorithmic/automated trading language for MetaTrader 5
 
nicholishen: *cough*whroeder1*cough*

What's your problem? The topic hadn't yet been moved when I commented, and if nobody mentions it, how can the OP learn?

nicholishen: This also works in MQL4

And has nothing to do with the OPs question.

 
whroeder1:

What's your problem? The topic hadn't yet been moved when I commented, and if nobody mentions it, how can the OP learn?

And has nothing to do with the OPs question.

The problem is that your decorum is very rude on this forum. Often your responses aren't helpful and the essence of your posts scream, "YOU"RE WRONG!!!". You flat-out rub people the wrong way with your comments. I've said it to you before and I'm saying it again, it's better to not receive a response than have someone rudely play mql-cop... and the time I checked you aren't a mod.


Regarding OPs issues, "Now I have an issue which I only can explain if the iClose an or iLow is not uptodate"

 

Use rate structs instead.

Reason: