Forex



Go Back   Forex Trading > Training > Metatrader > Metatrader 4 mql 4 - Development course > Lessons
Forex Forum Register More recent Blogs Calendar Advertising Others Help






Register
Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.

From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.

Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
  • Elite Section
    Get access to private discussions, specialized support, indicators and trading systems reported every week.
  • Advanced Elite Section
    For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
See more

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 10-29-2005, 09:16 PM
codersguru's Avatar
Senior Member
 
Join Date: Oct 2005
Posts: 994
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 Files
File Type: pdf Lesson8.pdf (68.4 KB, 5172 views)
__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm

Last edited by forexts; 11-07-2005 at 09:53 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #2 (permalink)  
Old 11-03-2005, 07:45 AM
Administrator
 
Join Date: Sep 2005
Posts: 20,058
Blog Entries: 241
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #3 (permalink)  
Old 11-03-2005, 07:47 AM
Administrator
 
Join Date: Sep 2005
Posts: 20,058
Blog Entries: 241
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #4 (permalink)  
Old 11-03-2005, 07:50 AM
Administrator
 
Join Date: Sep 2005
Posts: 20,058
Blog Entries: 241
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #5 (permalink)  
Old 11-03-2005, 02:14 PM
codersguru's Avatar
Senior Member
 
Join Date: Oct 2005
Posts: 994
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #6 (permalink)  
Old 11-03-2005, 02:36 PM
codersguru's Avatar
Senior Member
 
Join Date: Oct 2005
Posts: 994
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #7 (permalink)  
Old 11-03-2005, 02:48 PM
codersguru's Avatar
Senior Member
 
Join Date: Oct 2005
Posts: 994
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #8 (permalink)  
Old 12-22-2005, 05:49 PM
Member
 
Join Date: Dec 2005
Posts: 63
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #9 (permalink)  
Old 12-22-2005, 06:09 PM
codersguru's Avatar
Senior Member
 
Join Date: Oct 2005
Posts: 994
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #10 (permalink)  
Old 03-21-2006, 09:33 PM
chievo11's Avatar
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
Reply

Bookmarks

Tags
Blessing, blessing ea, lesson, MQL lessons, MQL4 lessons, mql4 variables


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Lesson 3 - MQL4 Data types codersguru Lessons 24 09-29-2008 05:39 PM
mql4 tutorial - Where is Lesson 1, etc.? ftsdPadawan Metatrader 4 mql 4 - Development course 2 01-15-2007 09:36 PM
Lesson 4 - MQL4 Operations & Expressions codersguru Lessons 28 12-20-2006 08:25 AM
How to enter external variables? icepeak Metatrader 4 6 12-05-2006 05:25 PM
MT 3 user defined variables! TallP Metatrader 3 0 07-12-2006 08:09 PM


All times are GMT. The time now is 10:55 PM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.