Download MetaTrader 5
To add comments, please log in or register
Traders have already contributed more than 300 articles. Write your own one!
Michael
496
Michael 2014.05.26 21:59 

Well, If you put the following code into a script and load it up on a chart, you won't get the correct time value.  Why?

int start()
  {
   struct OrderInfo
     {
       datetime dOpen[];
     };
   OrderInfo myOrder;
   int OrderCount=0;
   myOrder.dOpen[OrderCount]=Time[2];
   Comment(TimeToString(myOrder.dOpen[OrderCount],TIME_DATE|TIME_MINUTES));
   return(0);
  }
I'm running similar code in another script and get array out range errors.  I'm thinking they're related.
Halley
198
Halley 2014.05.27 01:55  
nondisclosure:

Well, If you put the following code into a script and load it up on a chart, you won't get the correct time value.  Why?

I'm running similar code in another script and get array out range errors.  I'm thinking they're related.

 


I assume your other code initializes the array first, or specifies the array size in declaration.
Carl Schreiber
5962
Carl Schreiber 2014.05.27 06:16  

First you miss to ArrayResize(dOpen,..) as DeepThought said!

But I would use this way:

struct OrderInfo{
    datetime dOpen;
    // ...
};
OrderInfo ArrOrdInf[];
..
ArrayResize(ArrOrdInf,..);
...

Gooly

Michael
496
Michael 2014.05.28 14:38  

Thanks everyone.  The stroke had me posting the question before implementing the correct way.

/
To add comments, please log in or register