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 Thread Tools Display Modes
  #1 (permalink)  
Old 10-29-2005, 08:16 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 8 - Variables in MQL4

Hi folks!

I want to thank you all for your kind comments.

This is the eighth lesson. it's about MQL4 Variables, I hope you enjoy it.

And I hope to be a useful for all of you GREAT TRADERS.

Attached Images
File Type: pdf Lesson8.pdf (68.4 KB, 3570 views)
__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm

Last edited by forexts : 11-07-2005 at 08:53 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 11-03-2005, 06:45 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
I have a question.

What are the Ask, Bid, Bars, Close, Open, High, Low, Time and Volume?

Variables?
It was not mentioned in your lessons. May you describe about that?
What is the difference between Ask - Bid and other above mentioned variables?

Current bar is Bars = 0. Right?
And previous bar is Bars = 1.
And what is Bars = -1. Is it 10 or Is it the future bar?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 11-03-2005, 06:47 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
What are the GlobalVariableCheck, GlobalVariableSet, GlobalVariableGet, GlobalVariableDel and GlobalVariableDeleteAll.

In which cases we are using that?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 11-03-2005, 06:50 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
Some people using g for global variables only like
this:
int g_Lots;
void Function1 (int param1)

Is it still usable?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 11-03-2005, 01:14 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 Ask, Bid, Bars, Close, Open, High, Low, Time and Volume are functions not variables!

Quote:
Originally Posted by newdigital
I have a question.

What are the Ask, Bid, Bars, Close, Open, High, Low, Time and Volume?

Variables?
It was not mentioned in your lessons. May you describe about that?
What is the difference between Ask - Bid and other above mentioned variables?

Current bar is Bars = 0. Right?
And previous bar is Bars = 1.
And what is Bars = -1. Is it 10 or Is it the future bar?
Ask, Bid, Bars, Close, Open, High, Low, Time and Volume are functions Although MQL4 called them predefined variables.

Variable means a space in memory and data type you specify.
Function means do something and return some value, For example Bars collects and returns the number of the bars in chart. So, is it a variable?

Another example will proof for you that they are not variables:

If you type and compile this line of code:
Bars=1;
You will get this error:
'Bars' - unexpected token
That’s because they are not variables hence you can’t assign a value to them.

Please leave their description to lesson 11 (Today )
__________________
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
  #6 (permalink)  
Old 11-03-2005, 01:36 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

Quote:
Originally Posted by newdigital
What are the GlobalVariableCheck, GlobalVariableSet, GlobalVariableGet, GlobalVariableDel and GlobalVariableDeleteAll.

In which cases we are using that?
GlobalVariables are a special kind of variables which accessed in the MetaTrader client terminal level, so they are different form the global variables which you declare them in your code at the functions level (review the Scope section in Variables lesson).

I'll give you example of using GlobalVariables , Assume you have 2 EAs running in your client terminal and both of them want to Send Order (OrderSend() function), if they called the OrderSend() at the same time MetaTrader will raise an error, to solve this situation , you may write in your EAs a code like that:


while (GlobalVariableCheck("InTrade")) {
Sleep(1000);
}

GlobalVariableSet("InTrade", 1); // set lock indicator
res= OrderSend(....);
GlobalVariableDel("InTrade"); // clear lock indicator

Here the OrderSend() function will work only if the GlobalVariable InTrade has been set.
Note: You have to write this code in the both of the 2 EAs which are trading at the same time.

This is something called semaphore and it's an example of using GlobalVariables.
__________________
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
  #7 (permalink)  
Old 11-03-2005, 01:48 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

Quote:
Originally Posted by newdigital
Some people using g for global variables only like
this:
int g_Lots;
void Function1 (int param1)

Is it still usable?
Yes, this is 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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 12-22-2005, 04:49 PM
traden4x traden4x is online now
Member
 
Join Date: Dec 2005
Posts: 38
traden4x is on a distinguished road
codersguru,

I'd like to thank you for your efforts with the programming manual. I've worked on my own EA with the help of another and am taking an online class for programming and reading (when time permits). I've been able to see more of the overall pricture with your manual and get a better understanding of the EA programming method. This is really helping me to rewrite what I want to do next in my EA and has given me a better overall view of the programming method.
Thanks
cs
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 12-22-2005, 05:09 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 You're welcome!

Quote:
Originally Posted by traden4x
codersguru,

I'd like to thank you for your efforts with the programming manual. I've worked on my own EA with the help of another and am taking an online class for programming and reading (when time permits). I've been able to see more of the overall pricture with your manual and get a better understanding of the EA programming method. This is really helping me to rewrite what I want to do next in my EA and has given me a better overall view of the programming method.
Thanks
cs
cs,

You're welcome!
I'm so happy to see my lessons help you (and the others).
I hope you find the the coming ones as good as the previous.

And the ebook that gathering all the lessons is on the road to you all.
__________________
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 03-21-2006, 08:33 PM
chievo11's Avatar
chievo11 chievo11 is offline
Junior Member
 
Join Date: Oct 2005
Posts: 26
chievo11 is on a distinguished road
hi codersguru,
one problem ( for me, not for you I hope)

How can I integrate an indicator which gives out a global variable
name of the global varaiable : "trend".
If Value = +1 should be possible a buy action
If Value = -1 should be possible a sell action
If value = 0 nothing should appear

How have I to define the global variable? ( like an indicator??)
And what have I to write in the long entry signal condition???
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
Lesson 3 - MQL4 Data types codersguru Lessons 20 05-18-2007 03:55 AM
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
How to enter external variables? icepeak Metatrader 4 6 12-05-2006 04:25 PM
MT 3 user defined variables! TallP Metatrader 3 0 07-12-2006 07:09 PM


All times are GMT. The time now is 08:54 PM.