Download MetaTrader 5
To add comments, please log in or register
Find out the latest MQL5.community news!
Max Enrik
665
Max Enrik 2016.12.01 06:35  

I need a bit more clearly explanation about the 'GlobalVariable Functions' which one how can I use it. 
I already read documentation.

( if would be example that would be awesome ) 

Thanks in advance.

Keith Watford
Moderator
8873
Keith Watford 2016.12.01 06:52  
Max Enrik:

I need a bit more clearly explanation about the 'GlobalVariable Functions' which one how can I use it. 
I already read documentation.

( if would be example that would be awesome ) 

Thanks in advance.

The documentation is quite self explanatory regarding this.

Use them in the same way as globally declared variables when you need a value retained after an EA or indicator has been removed or the terminal is shut down or timeframe changed on the chart to which an indicator is attached.

The most important thing is to make sure that they are given individual names. You could use magic number and Symbol in the name. It could cause problems if more than 1 EA or indicator were trying to access and change the same Global Variable (of the client terminal).

Alain Verleyen
Moderator
29640
Alain Verleyen 2016.12.01 08:41  
Max Enrik:

I need a bit more clearly explanation about the 'GlobalVariable Functions' which one how can I use it. 
I already read documentation.

( if would be example that would be awesome ) 

Thanks in advance.


Article for mql5, but it works the same with mql4.
MQL5 Programming Basics: Global Variables of the Terminal
MQL5 Programming Basics: Global Variables of the Terminal
  • 2016.11.25
  • Dmitry Fedoseev
  • www.mql5.com
Global variables of the terminal provide an indispensable tool for developing sophisticated and reliable Expert Advisors. If you master the global variables, you will no more be able to imagine developing EAs on MQL5 without them.
Max Enrik
665
Max Enrik 2016.12.01 23:20  
Keith Watford:

The documentation is quite self explanatory regarding this.
... 

Alain Verleyen:

Article for mql5, but it works the same with mql4.

Big thanks for more informative comments.

And I try like below code but I do not get good result. So I try to terminal would save my latest changes.
e.g: Default Lot Size is 0.01 after I changed Lot Size then I change TimeFrames - Lot Size turn to Default.
Please, help me or give me good (clearly) advice!

Thanks in advance.

//Global Variables
string  _lotGV;

//-----------------------------------------------------------------------------

int OnInit()
{
    //Global Variables

    _lotGV = _prefix + _Symbol + " _lotGV";
  
    if ( GlobalVariableCheck( _lotGV ) == true )
    {
        GlobalVariableGet( _lotGV );
    }   //---if Close
    else
    {
        GlobalVariableSet( _lotGV, _lotSize );
    }
}
Max Enrik
665
Max Enrik 2016.12.02 01:31  

#GlobalVariable - Closed

I solved like below code.

//--------------------------------------------

_lotGV = _prefix + _Symbol + " _lotGV";

if ( GlobalVariableCheck( _lotGV ) == true )
{
    _lotSize = GlobalVariableGet( _lotGV );
}   //---if Close
else
{
    GlobalVariableSet( _lotGV, _lotSize );
}
Special thanks to @Alain Verleyen @Keith Watford
Max Enrik
665
Max Enrik 2016.12.02 14:42  

#Lot Reset - Open

I have not any idea about 'Lot Reset' Button. some describe: And I need to when I click reset button lot size turn to default lot size value. ( e.g lot size value 1 )
So, I need good advice with example.

( also I am still researching )

All the best to you.

Max Enrik
665
Max Enrik 2016.12.03 04:01  

I am really struggle, someone please help me.

Thanks. 

Keith Watford
Moderator
8873
Keith Watford 2016.12.03 04:17  
Max Enrik:

#Lot Reset - Open

I have not any idea about 'Lot Reset' Button. some describe: And I need to when I click reset button lot size turn to default lot size value. ( e.g lot size value 1 )
So, I need good advice with example.

( also I am still researching )

All the best to you.

It may help if you describe what you are referring to.
Marco vd Heijden
Moderator
4229
Marco vd Heijden 2016.12.03 08:53  
if(sparam=="reset")
{
  Lotsize=0.01;
}
Max Enrik
665
Max Enrik 2016.12.04 07:37  
Marco vd Heijden:
if(sparam=="reset")
{
  Lotsize=0.01;
}

You clearly understand me, thank you great man, much appreciate.
( it is simple, but sometimes I struggle.. )

/ /123456789101112...26
To add comments, please log in or register