Problems with basic code

 

Hi,

I'm having trouble with the following code:

int OnInit()
  {
   OrderSelect(0);
   Print(OrderGetString(ORDER_SYMBOL));
   Print(OrderGetString(ORDER_COMMENT));
   Print(OrderGetInteger(ORDER_MAGIC));
  
  //---
  return(INIT_SUCCEEDED);
  }

The Prints return empty when there are Pending Orders placed.  I don't know what I'm doing wrong.

Could someone help me?

Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Order Properties
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Order Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Order Properties - Documentation on MQL5
 
Will404:

Hi,

I'm having trouble with the following code:

The Prints return empty when there are Pending Orders placed.  I don't know what I'm doing wrong.

Could someone help me?

Have you read the documentation ? OrderSelect() takes a ticket number as parameter. 0 is not a valid ticket number.

 
Will404:

Hi,

I'm having trouble with the following code:

The Prints return empty when there are Pending Orders placed.  I don't know what I'm doing wrong.

Could someone help me?

Found the problem.. the input for OrderSelect() is the ticket and not the index number... I just had to change it for OrderGetTicket(0);


 
angevoyageur:

Have you read the documentation ? OrderSelect() takes a ticket number as parameter. 0 is not a valid ticket number.

Also, I'm 4 min late to your reply.. Thanks for the input anyways! :)
 
Will404:
Also, I'm 4 min late to your reply.. Thanks for the input anyways! :)
Don't worry, you found it yourself which is even better.