Forex
Google

Go Back   Forex Trading > Metatrader Training > Metatrader 4 mql 4 - Development course > Lessons
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 (2) Thread Tools Display Modes
  1 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 10-22-2005, 02:47 PM
codersguru's Avatar
codersguru codersguru is offline
Senior Member
 
Join Date: Oct 2005
Posts: 987
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Wink Lesson 3 - MQL4 Data types

Hi there!

Welcome to my third lesson in my MQL4 course.

I hope you enjoyed the “SYNTAX” lesson, which tried to give you the answers for:
• What format you can use to write MQL4 code?
• How to make the world better by commenting your code?
• What the Identifiers are, and what are the rules of choosing them?
• What are the MQL4 Reserved words?

If you didn’t read the “SYNTAX” lesson please download it from here:
http://forex-tsd.com/attachment.php?attachmentid=399
And you can download the “Welcome” lesson from here:
http://forex-tsd.com/attachment.php?attachmentid=372
Don’t forget to login first.

Now, let’s enjoy the DATA TYPES.

-----------------------------------------

Download the lesson to know more.
Attached Images
File Type: pdf Lesson3.pdf (97.4 KB, 4313 views)
__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm

Last edited by forexts : 11-07-2005 at 08:36 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 10-30-2005, 11:41 AM
newdigital newdigital is offline
Administrator
 
Join Date: Sep 2005
Posts: 15,422
newdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud of
You described that we should write a null character after the last character of data in data type string.

But it was nothing in the examples:
string str1 = "Hello";

So no null.

May be it was for the explanation only?

Last edited by newdigital : 10-30-2005 at 04:11 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 10-30-2005, 12:36 PM
newdigital newdigital is offline
Administrator
 
Join Date: Sep 2005
Posts: 15,422
newdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud of
An other question.
double should be between 2.2e-308 to 1.8e308.
What is e?
Is it in hexadecimal format?

And an other question.
I know that somebody uses the letters before name of variables, for example:
int nSomeNumber = 12345;
bool bIsRightPlace = true;
double fCurrentPrice = 1.2344;
datetime tCurrentDate = D'2005.02.02. 8;00';
color cChartColor = Olive;
string sMyName = "Joel"


I mean n for int, b for bool, f for double, t for datatime, c for color and s for string. Is it still usable?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 10-30-2005, 02:56 PM
codersguru's Avatar
codersguru codersguru is offline
Senior Member
 
Join Date: Oct 2005
Posts: 987
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Arrow Null-terminated strings

Quote:
Originally Posted by newdigital
You described that we should write a null character after the last character of data in data type string.

But it was nothing in the examples:
string str1 = "Hello";

So no null.

May be it was for the explanation only?
Hi newdigital,

Thank you very much for your question, it's an intelligent one.
This kind of strings (and it's the only kind MQL4 uses) called Null-terminated strings


The NULL has putted for you automatically when you used the "string" keyword to create a string type variable.

So you must not add NULL to the end of your string, because MQL4 will add it automatically.

string str1 = "Hello"; will be presented in the memory like that:

H e l l o NULL
__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm

Last edited by newdigital : 10-30-2005 at 04:12 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 10-30-2005, 03:45 PM
codersguru's Avatar
codersguru codersguru is offline
Senior Member
 
Join Date: Oct 2005
Posts: 987
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Arrow Exponential notation & Hungarian notation.

Quote:
Originally Posted by newdigital
An other question.
double should be between 2.2e-308 to 1.8e308.
What is e?
Is it in hexadecimal format?

And an other question.
I know that somebody uses the letters before name of variables, for example:
int nSomeNumber = 12345;
bool bIsRightPlace = true;
double fCurrentPrice = 1.2344;
datetime tCurrentDate = D'2005.02.02. 8;00';
color cChartColor = Olive;
string sMyName = "Joel"


I mean n for int, b for bool, f for double, t for datatime, c for color and s for string. Is it still usable?
Thank you newdigital for your intelligent questions.

Question 1:

2.2e-308 and1.8e308 are numbers wrote in exponential notation.
Exponential notation is a way of writing large numbers without having to write out a lot of zeros, for example, 1,000,000,000 can be written as 1.0E9.
The number followed the E is called the exponent and it indicates how many places the decimal point must be moved to change the number to the normal decimal notation.
The exponent can be positive or negative; the exponential number 6.35E-5 is equivalent to 0.0000635 in decimal notation.

Question 2:

Yes, this is very a good programming practice, and it called Hungarian notation.
Hungarian notation is a naming convention in programming, in which the name of a variable (or function) indicates its type or intended use.

You prefixed every variable name with the first letter of the variable type, and that's what Hungarian notation mean.
__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm

Last edited by newdigital : 10-30-2005 at 04:10 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 10-30-2005, 08:19 PM
newdigital newdigital is offline
Administrator
 
Join Date: Sep 2005
Posts: 15,422
newdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud of
May exponential notation be used in the code?

for example:
double fCoefficient = 2.5E-4
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 10-30-2005, 11:00 PM
codersguru's Avatar
codersguru codersguru is offline
Senior Member
 
Join Date: Oct 2005
Posts: 987
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Arrow Exponential notation can't be used in MQL4.

Quote:
Originally Posted by newdigital
May exponential notation be used in the code?

for example:
double fCoefficient = 2.5E-4
newdigital,

Your questions enrich the course. Thanks!

I've used the exponential notation in my lesson to tell you what the range of float data type is (2.2e-308 to 1.8e308), because I can't write these numbers in decimal notation.
Do you imagine 307 zeros in the right of the number 18 to present the number 1.8e308.

In MQL4, you can't use the exponential notation.

To present the number 2.5E-4 in MQL4 you have to write it in decimal notation like this:
double fCoefficient = 0.00025;
__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm

Last edited by codersguru : 10-31-2005 at 12:59 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 11-27-2005, 04:33 PM
mike mike is offline
Junior Member
 
Join Date: Nov 2005
Posts: 2
mike is on a distinguished road
mike

Hi, I've found lessons 1 and 2 so no need to reply to my message about not being able to find them.

regards

mike
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 11-27-2005, 10:54 PM
codersguru's Avatar
codersguru codersguru is offline
Senior Member
 
Join Date: Oct 2005
Posts: 987
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Talking

Quote:
Originally Posted by mike
Hi, I've found lessons 1 and 2 so no need to reply to my message about not being able to find them.

regards

mike
Hi mike,

Welcome to my lessons, I hope you enjoy them.
__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 12-16-2005, 08:52 PM
mcintyd1 mcintyd1 is offline
Junior Member
 
Join Date: Dec 2005
Location: Portland, Oregon, USA
Posts: 7
mcintyd1 is on a distinguished road
Quote:
Originally Posted by codersguru
...
Question 1:

2.2e-308 and1.8e308 are numbers wrote in exponential notation.
Exponential notation is a way of writing large numbers without having to write out a lot of zeros, for example, 1,000,000,000 can be written as 1.0E9.
The number followed the E is called the exponent and it indicates how many places the decimal point must be moved to change the number to the normal decimal notation.
The exponent can be positive or negative; the exponential number 6.35E-5 is equivalent to 0.0000635 in decimal notation....
Hmmm, so I think 2.2e-308 = 2.2 x 10 to the power of -308, and 1.8e308 = 1.8 x 10 to the power of 308.
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

LinkBacks (?)
LinkBack to this Thread: http://www.forex-tsd.com/lessons/158-lesson-3-mql4-data-types.html
Posted By For Type Date
Untitled document This thread Refback 03-20-2008 02:26 PM
Forex Indicators With Explanation - Type Your Search Here This thread Refback 12-04-2007 10:20 PM

Similar Threads
Thread Thread Starter Forum Replies Last Post
mql4 tutorial - Where is Lesson 1, etc.? ftsdPadawan Metatrader 4 mql 4 - Development course 2 01-15-2007 08:36 PM
Lesson 4 - MQL4 Operations & Expressions codersguru Lessons 28 12-20-2006 07:25 AM
Lesson 8 - Variables in MQL4 codersguru Lessons 11 09-15-2006 01:06 PM
Lesson 17 - Your First Script codersguru Metatrader 4 mql 4 - Development course 0 01-04-2006 11:37 PM
Lesson 7 - Functions codersguru Lessons 2 11-02-2005 03:32 PM


All times are GMT. The time now is 09:04 PM.