Bid-Price on a specific time

 

Hi,

how can I get the price of an underlying from yesterday at 14:00?

 

Find the bar with opentime yesterday 14:00 iBarShift(Symbol(),1,datetime yesterday time, true/false)

int iBarShift( string symbol, int timeframe, datetime time, bool exact=false) 
Search for bar by open time. The function returns bar shift with the open time specified. 
If the bar having the specified open time is missing, the function will return -1 or the nearest bar shift depending on the exact.


If you have found the shift you need
only to find iOpen(Symbol(),1,BarShift)

 
Thanks, that's exactly the way I want to. But I don't know how to calculate the time "Yesterday 14:00"??
 
sunshineh:
Thanks, that's exactly the way I want to. But I don't know how to calculate the time "Yesterday 14:00"??

Midnight - (10 * Period_H1 * 60)

You will need to check for weekends, etc

 

Hi, thank you very much (especially for the "midnight" tip)

I have tested it and I realized, that the differences from trading days to close days is the result from my shift value

When I tried this

Print("TimeTemp-1 = "+ TimeToStr(TimeTemp-24*60*60)+" Shift = "+iBarShift(Symbol(), PERIOD_M1, TimeTemp-1*24*60*60)+" Kurs ist "+iClose(Symbol(),PERIOD_M1,iBarShift(Symbol(), PERIOD_M1, TimeTemp-1*24*60*60)));
Print("TimeTemp-2 = "+ TimeToStr(TimeTemp-2*24*60*60)+" Shift = "+iBarShift(Symbol(), PERIOD_M1, TimeTemp-2*24*60*60)+" Kurs ist "+iClose(Symbol(),PERIOD_M1,iBarShift(Symbol(), PERIOD_M1, TimeTemp-2*24*60*60)));
Print("TimeTemp-3 = "+ TimeToStr(TimeTemp-3*24*60*60)+" Shift = "+iBarShift(Symbol(), PERIOD_M1, TimeTemp-3*24*60*60)+" Kurs ist "+iClose(Symbol(),PERIOD_M1,iBarShift(Symbol(), PERIOD_M1, TimeTemp-3*24*60*60)));
Print("TimeTemp-4 = "+ TimeToStr(TimeTemp-4*24*60*60)+" Shift = "+iBarShift(Symbol(), PERIOD_M1, TimeTemp-4*24*60*60)+" Kurs ist "+iClose(Symbol(),PERIOD_M1,iBarShift(Symbol(), PERIOD_M1, TimeTemp-4*24*60*60)));
Print("TimeTemp-5 = "+ TimeToStr(TimeTemp-5*24*60*60)+" Shift = "+iBarShift(Symbol(), PERIOD_M1, TimeTemp-5*24*60*60)+" Kurs ist "+iClose(Symbol(),PERIOD_M1,iBarShift(Symbol(), PERIOD_M1, TimeTemp-5*24*60*60)));
Print("TimeTemp-6 = "+ TimeToStr(TimeTemp-6*24*60*60)+" Shift = "+iBarShift(Symbol(), PERIOD_M1, TimeTemp-6*24*60*60)+" Kurs ist "+iClose(Symbol(),PERIOD_M1,iBarShift(Symbol(), PERIOD_M1, TimeTemp-6*24*60*60)));
Print("TimeTemp-7 = "+ TimeToStr(TimeTemp-7*24*60*60)+" Shift = "+iBarShift(Symbol(), PERIOD_M1, TimeTemp-7*24*60*60)+" Kurs ist "+iClose(Symbol(),PERIOD_M1,iBarShift(Symbol(), PERIOD_M1, TimeTemp-7*24*60*60)));
Print("TimeTemp-8 = "+ TimeToStr(TimeTemp-8*24*60*60)+" Shift = "+iBarShift(Symbol(), PERIOD_M1, TimeTemp-8*24*60*60)+" Kurs ist "+iClose(Symbol(),PERIOD_M1,iBarShift(Symbol(), PERIOD_M1, TimeTemp-8*24*60*60)));
Print("TimeTemp-9 = "+ TimeToStr(TimeTemp-9*24*60*60)+" Shift = "+iBarShift(Symbol(), PERIOD_M1, TimeTemp-9*24*60*60)+" Kurs ist "+iClose(Symbol(),PERIOD_M1,iBarShift(Symbol(), PERIOD_M1, TimeTemp-9*24*60*60)));
Print("TimeTemp-10 = "+ TimeToStr(TimeTemp-10*24*60*60)+" Shift = "+iBarShift(Symbol(), PERIOD_M1, TimeTemp-10*24*60*60)+" Kurs ist "+iClose(Symbol(),PERIOD_M1,iBarShift(Symbol(), PERIOD_M1, TimeTemp-10*24*60*60)));
Print("TimeTemp-11 = "+ TimeToStr(TimeTemp-11*24*60*60)+" Shift = "+iBarShift(Symbol(), PERIOD_M1, TimeTemp-11*24*60*60)+" Kurs ist "+iClose(Symbol(),PERIOD_M1,iBarShift(Symbol(), PERIOD_M1, TimeTemp-11*24*60*60)));
Print("TimeTemp-12 = "+ TimeToStr(TimeTemp-12*24*60*60)+" Shift = "+iBarShift(Symbol(), PERIOD_M1, TimeTemp-12*24*60*60)+" Kurs ist "+iClose(Symbol(),PERIOD_M1,iBarShift(Symbol(), PERIOD_M1, TimeTemp-12*24*60*60)));

I can see, that if my calculated day doesn't exist (f.e.weekends) I got the value from the last close price that exist (friday evening).

On the shift-result I can see, that from one trading day to the other (between the week) the difference is from 814-835 in M30. I don't no, why I don't get always the same difference?

I thought my solution is to realize on the shift value, if the day is a normal trading day or not. But I can't see the rule for it clearly...

 
sunshineh:

Hi, thank you very much (especially for the "midnight" tip)

I have tested it and I realized, that the differences from trading days to close days is the result from my shift value

When I tried this

I can see, that if my calculated day doesn't exist (f.e.weekends) I got the value from the last close price that exist (friday evening).

On the shift-result I can see, that from one trading day to the other (between the week) the difference is from 814-835 in M30. I don't no, why I don't get always the same difference?

I thought my solution is to realize on the shift value, if the day is a normal trading day or not. But I can't see the rule for it clearly...


If the bar having the specified open time is missing, the function will return -1 or the nearest bar shift depending on the exact.

exact true or false

 

Oh yes, that's it !! I have totally forgotten this opinion....

Thank you!!

 

Another POV

 for (int pos = 0; pos <= Bars - 1; pos ++)
    {
    if ( TimeHour (Time [pos]) = 14 && TimeMinute (Time [pos] = 0)
      {
      Print ("Price at "+TimeToStr (Time [pos], TIME_DATE|TIME_SECONDS)+" Close = "+Close [pos]+" Open = "+Open [pos]+" High = "+High [pos]+" Low = "+Low [pos]);
      break;
      }
    }
Reason: