Forex
Google

Go Back   Forex Trading > Metatrader Training > Metatrader 4 mql 4 - Development course > Questions
Forex Forum Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


Register in Forex TSD!
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time).
Click here to register and get more information

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-06-2007, 02:46 PM
clippertm clippertm is offline
Junior Member
 
Join Date: Feb 2007
Posts: 7
clippertm is on a distinguished road
Arrow Arrays in MQL4

Hello Everyone!

I am trying to understand how to programme arrays in MQL4. Can you please let me know if my interpretations are correct?

Code:
int data_z[51];
the above declares a single dimension 52 element array of integers with default value 0.

Code:
int data_x[][6];
the above declares declares a two dimensional array, one dynamic, and one of 7 element array of integers with default value 0.

Many thanks,
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-07-2007, 12:14 AM
ralph.ronnquist's Avatar
ralph.ronnquist ralph.ronnquist is offline
Senior Member
 
Join Date: Oct 2006
Posts: 280
ralph.ronnquist is on a distinguished road
slightly wrong: the declaration number is the size. So the first array is of 51 elements, and the second is an indefinite number as a multiple of 6; "dynamic" as you say.

You access elements by a zero based index, which would be 0-50 for the first array, and 0-5 for the second dimension of the second array.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-07-2007, 05:59 PM
clippertm clippertm is offline
Junior Member
 
Join Date: Feb 2007
Posts: 7
clippertm is on a distinguished road
Hello Ralph!

Thank you very much for your reply!

So if my understanding is correct,

Code:
int data_z[51];
would result in:

0
.
.
.
50

and

Code:
 int x = 2 ;
int data_x[x][6];
would result in something like:
0 0
1 1
2 2
3 3
4 4
5 5


?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-08-2007, 09:47 AM
ralph.ronnquist's Avatar
ralph.ronnquist ralph.ronnquist is offline
Senior Member
 
Join Date: Oct 2006
Posts: 280
ralph.ronnquist is on a distinguished road
The first is right. The first element has index 0, second index 1, and so forth, with each n:th element having index n-1, up to the 51:st element.

The second is probably right thinking as well, assuming there is an invisible column heading of "0" for the first column and "1" for the second column. It's a fair enough interpretation to think of the first index as telling which column to look in, and the second index as telling which row (of that column).
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-12-2007, 09:35 PM
clippertm clippertm is offline
Junior Member
 
Join Date: Feb 2007
Posts: 7
clippertm is on a distinguished road
Hello Ralph!

Thank you again for your time. It is very helpful!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


Similar Threads
Thread Thread Starter Forum Replies Last Post
Welcome to the MQL4 course codersguru Metatrader 4 mql 4 - Development course 84 05-18-2008 05:59 PM
Using Arrays to track info for All Open Orders deeforex Questions 6 09-12-2006 06:01 PM
www.mql4.com DeSt Metatrader 4 18 02-01-2006 11:59 PM


All times are GMT. The time now is 08:07 AM.