Download MetaTrader 5
To add comments, please log in or register
Searching on MQL5.community is performed in all sections. Try it!
Foed
24
Foed 2016.02.26 21:43 

Hello guys,

I need advice. I have never met with anything like this. I have EA, where in code I have this ( Im using high of previous day in my calculation)


[source]

 if(den==0) // for historical reason, all is same
      {
            y_high=iHigh(Symbol(),PERIOD_D1,1);//previous day
            y_low=iLow(Symbol(),PERIOD_D1,1); //previous day
      }
      else if(den==1) // for historical reason, all is same
      {
            y_high=iHigh(Symbol(),PERIOD_D1,1); //previous day
            y_low=iLow(Symbol(),PERIOD_D1,1); //previous day
      }
      else // for historical reason, all is same
      {
            y_high=iHigh(Symbol(),PERIOD_D1,1); //previous day
            y_low=iLow(Symbol(),PERIOD_D1,1); //previous day
      }


[source]

Im using it for DAX. I have two brokers - one with night session (u can trade at night) and another one where I can trade only since 8am til 22 pm.

So my problem is that this code is not taking "yesterdays" high, but its taking high of 2 - 3  days before. On monday it took high of thursday of last week. On wednesday it took mondays high.

Im working with yesterday's high 5 minuts after market opens, so my problem can not be caused beacause of - like "Todays is not yte even a tick, so PERIOD_D1 is not yesterday but yesterday-1. EA is on H1 TF.

While backtesting in MT4 everything is fine and ok, but on DEMO account with live data, its causing my problem.

Im really confused. Im programmer a little bit, but this is ridiculous.

Could anyone help me please? Sorry for my english.

Ovo Cz
2987
Ovo Cz 2016.02.26 22:09  

Have either an additional D1 chart open (may be minimized),

or call iBars(Symbol(),PERIOD_D1) a couple of minutes before you call the iHigh.

Foed
24
Foed 2016.02.26 22:13  

What should it suppose to do? iBARS returns only number of bars right?

Why to have opened D1 graph? Do you think it will recalucate and will it help? Ill give it try. Thank you

Ovo Cz
2987
Ovo Cz 2016.02.26 22:18  
It only triggers the asynchronous chart fetch, you do not need to care about the return value.
Foed
24
Foed 2016.02.27 08:52  
ok, lets see on monday. Thank you very much.
whroeder1
13977
whroeder1 2016.02.27 12:37  
Ovo Cz
2987
Ovo Cz 2016.02.27 13:30  
I wrote it here several times here - ERR_HISTORY_WILL_UPDATED does not signal the history state is (or is not) ready, but rather it signals the last command initiated asynchronous chart download. 
whroeder1
13977
whroeder1 2016.02.28 02:59  
And if you had looked at my code you would have seen that it loops until the "asynchronous chart download" has downloaded.
Ovo Cz
2987
Ovo Cz 2016.02.28 07:48  
WHRoeder:
And if you had looked at my code you would have seen that it loops until the "asynchronous chart download" has downloaded.

Ok, disregard my remark., my fault, sometimes it happens to me. Anyway, I noticed that the correct zero index candle time seemed to be present even if the rest of the chart, i.e. indexes >=1 were still missing, so not sure if it was 100% reliable.

/
To add comments, please log in or register