Need help with mql. PERIOD_D1 and weird behaviour

Back to topics list To post a new topic, please log in or register
avatar
3
foed 2016.02.26 22: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.



avatar
1109
Ovo 2016.02.26 23: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.

avatar
3
foed 2016.02.26 23: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

avatar
1109
Ovo 2016.02.26 23:18 #
 
It only triggers the asynchronous chart fetch, you do not need to care about the return value.
avatar
3
foed 2016.02.27 09:52 #
 
ok, lets see on monday. Thank you very much.
avatar
12985
avatar
1109
Ovo 2016.02.27 14: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. 
avatar
12985
WHRoeder 2016.02.28 03:59 #
 
And if you had looked at my code you would have seen that it loops until the "asynchronous chart download" has downloaded.
avatar
1109
Ovo 2016.02.28 08: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.

Back to topics list  

To add comments, please log in or register