- There is no such thing as iHigh[1]. There is iHigh( symbol, TF, shift) and predefined High[i].
- If you're using the former, does the TF match the chart?
- There are no mind readers here. Post your code.
Hey WhRoeder !
1:you are right about the missing part iHigh(Symbol(),TF,shift) I meant iHigh(Symbol(),TF,1) is returning the iHigh(Symbol(),TF,2) value when i look at the chart after
2: well yes but my understanding is that it doesn't mather if the Chart i run the script in is of the same TF or even Symbol as it is specified in the call itself..
(i doubt that iHigh(EURUSD,1440,1) is supposed to give 2 different value depending on the TF of the Chart i trow the script in.. the High of yesterday's bar for EURUSD is the same no mather what no ?)
3: end for mind readers well, i tryed to avoid such commentary by precising that I wasn't able to post the code until tonight because i am on remote desktop, I will post it later but I think people with enough knowlegde of mql4 could answer if yes or no there is something to think of before requesting the iHigh from an unopened chart in order to make sure the last bar (today's bar)is loaded
- If you get the error code history will be downloaded, You must wait for the chart to refresh.
- You didn't give enough information. We are not mind readers. You didn't say that TF is different than the chart.
- Are you assuming that iHigh(D1, 1) is yesterday. If you shut down the terminal over midnight, the D1 chart will not be updated the first tick, it won't be until the update completes.
- If you used this, you probably would ever see the problem.
#define HR2400 PERIOD_D1 * 60 // 86400 = 24 * 3600 int TimeOfDay(datetime when=0){ if(when == 0) when = TimeCurrent(); return( when % HR2400 ); } datetime DateOfDay(datetime when=0){ if(when == 0) when = TimeCurrent(); return( when - TimeOfDay(when) ); } //datetime Tomorrow( datetime when=0){ if(when == 0) when = TimeCurrent(); // return(DateOfDay(when) + HR2400); } //datetime Yesterday(datetime when=0){ if(when == 0) when = TimeCurrent(); // int iD1 = iBarShift(NULL, PERIOD_D1, DateOfDay(when) - 1); // return( iTime(NULL, PERIOD_D1, iD1) ); } datetime now = Time[0]; int iD1 = iBarShift(NULL, PERIOD_D1, DateOfDay(now) - 1); double hYesterday = iHigh(NULL, PERIOD_D1, iD1);
Here is the code, the problem i have is that sometimes it open the chart even if yesterday (Bar 1) high is higher than today's close (Bar 0)
by printing the value i saw that it refers to bar 2 high instead of bar 1. if i rerun the script, the job is ok..but the day after same problem happens
//+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { //--- string symtoscan[]= {"AUDUSD","AUDCHF","AUDJPY","AUDNZD"}; int i=0,limit= 4; while(i<limit) { Print(symtoscan[i],"CloseNow: ",iClose(symtoscan[i],1440,0),"HighHier: ",iHigh(symtoscan[i],1440,1)); if(iClose(symtoscan[i],0,0) > iHigh(symtoscan[i],1440,1)) { ChartOpen(symtoscan[i],1440); Print("UP: ",symtoscan[i]); } i++; } } //+------------------------------------------------------------------+
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
somebody knows why the first time of the day I run a script asking for iHigh[1] with in a loop, system returns me what is the iHigh[2] (third bar starting from end) , and when I re-run the script the same day it returns me the real iHigh[1] (second bar starting from end, in fact yesterday's High) ?
When I RE-RE-RE run the script after that i am ok, info is good, but the first time of the day is always strange..
Is there something I need to refresh before asking ?
it seems to me that system dont see the new bar until i ask for the info, and after that the new bar is upload...
Anything I can do to mass upload the new bar of each Symbol before I run the script so it would return me the real iHigh[1] the first time ?
*sorry i can't post the code at the moment because i am on remote
Thank you