iOPEN returns 0 (Zero)

 

Here is the code I used, just for checking. I am using GCI Demo Account. I get 0 as return value.

Can anyone suggest alternate code or method to get the output?

Output:

"2012.03.13 13:40:30 test1 Crude_Oil,M15: Current Open = 0.00000000"

void start()
  {
   double cur_open, cur_close, cur_high, cur_low, wap;
   int i = D'01:20';
   bool k = ObjectCreate("test_line", OBJ_VLINE, 0, i, 0); // I want to draw a vertical line at given time.
   cur_open = iOpen(Symbol(), 15, i); //want to get open price @ given time....
   bool l = ObjectCreate("Open_Line", OBJ_HLINE, 0, i, cur_open);
   cur_close = iClose(Symbol(), 15, i);
   bool m = ObjectCreate("iClose_Line", OBJ_HLINE, 0, i, cur_close);
   cur_high = iHigh(Symbol(), 15, i);
   cur_low = iLow(Symbol(), 15, i);
   
   Print("Current Open = "+cur_open);
  
  }		
 

Did you look at the Documentation for iOpen() ? it is used by passing it 3 variables, a string for the symbol, an int for the timeframe and an int for the bar number . . .

You are passing an int which seems to be based on a date ? why ? if you think about this question you will probably find the answer to you issue . . . if you can't, ask again and I'll help some more.

 
RaptorUK:

Did you look at the Documentation for iOpen() ? it is used by passing it 3 variables, a string for the symbol, an int for the timeframe and an int for the bar number . . .

You are passing an int which seems to be based on a date ? why ? if you think about this question you will probably find the answer to you issue . . . if you can't, ask again and I'll help some more.


I checked passing DateTime into an int. I worked.

Or If you can please give a method to mention the time-of-the-day in a integer format. Say 01:20 as an integer.

Code Below worked in same manner but time mentioned are different.

int start()
  {
   bool k = ObjectCreate("label_object_1", OBJ_VLINE, 0, D'06:45', 0);
   
   bool j = ObjectCreate("label_object_2", OBJ_VLINE, 0, 15342.05556, 0);
   retuen(0);
  }
 
krishna_gopal_2:


I checked passing DateTime into an int. I worked.

That isn't the problem . . . a datetime is basically a date, specified as the number of seconds since 1st Jan 1970 . . . . but a date is not a bar number, for iOpen you need a bar number.

Take a look at iBarshift()

 
RaptorUK:

That isn't the problem . . . a datetime is basically a date, specified as the number of seconds since 1st Jan 1970 . . . . but a date is not a bar number, for iOpen you need a bar number.

Take a look at iBarshift()


2012.03.13 17:28:44 Veri_Line Crude_Oil,M15: shift of bar with open time 2012.03.12 04:45 is 0

2012.03.13 17:32:12 Veri_Line Crude_Oil,M15: shift of bar with open time 2012.03.12 04:45 is 0

test_line is being drawn. But open time shift is 0(zero)

int start()
  {
  datetime some_time=D'2012.03.12 04:45';
  bool k = ObjectCreate("test_line", OBJ_VLINE, 0, some_time, 0);
  int shift=iBarShift("EUROUSD",PERIOD_M1,some_time);
  Print("shift of bar with open time ",TimeToStr(some_time)," is ",shift);
  }

 
I suspect your symbol name is wrong . . . "EUROUSD" . . . should it be "EURUSD" ?
 
RaptorUK:
I suspect your symbol name is wrong . . . "EUROUSD" . . . should it be "EURUSD" ?


I chnaged into Symbol()

I works. Thanks a lot friend. I am a newbie to MQL4. Do you have skype or Yahoo id? So that i can contact you instantly for my doubts.

 
krishna_gopal_2:


I chnaged into Symbol()

I works. Thanks a lot friend. I am a newbie to MQL4. Do you have skype or Yahoo id? So that i can contact you instantly for my doubts.

You are welcome . . . please contact me here so others can also learn from any issues you have.
 
RaptorUK:
You are welcome . . . please contact me here so others can also learn from any issues you have.


Hi Simon,

I have completed 90% of the project. Now I have a doubt. I placed an buying order with STOP_LEVEL and TAKE_PROFIT.

While sending the order I have mentioned the expiry time as 04:45. The order has been executed and a position is opened in mentioned price.

Now the time is 05:30. But still the STOP_LEVEL and TAKE_PROFIT orders are alive.

Can you explain how the expiry time works, which is not explained by the MQL4?

Note: I m using GCI Demo account.

 
Please don't post the same question in multiple posts.
Reason: