Since when the external variables do not work?

 
Hello everyone,

Less than 40 days ago I made an indicator, in mql5 and inside the input parameters I can put external variables (extern int, extern color, etc), but now I can not put it anymore, since they do not appear in the input parameters tab when The indicator is loaded.

the question is:
If they have been removed, how to use these external variables?

To use as a replacement for external variables. (Extern int, extern string, etc?


thanks

Files:
Sin_t9tulo.jpg  27 kb
 

Nothing has changed so there is probably an issue in your code.

Trying posting the section of code where you declare them

 
honest_knave:

Nothing has changed so there is probably an issue in your code.

Trying posting the section of code where you declare them


are you sure,?? We are talking about mql5, (just to confirm jejeje)
The new indicators or advisers do not show me, with the old advisors or indicators, is observed correctly, but if I compile those indicators again, they are not seen from that moment

I thought it was because of the compiler update
I have the March 24 version.

Can you check again please

Look at the test images. The simplest of simple


//+------------------------------------------------------------------+
//|                                                      example.mq5 |
//|                        Copyright 2015, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_chart_window
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
extern int abc=123;   
input int def=234;   

//I want to see 2 parameters when attaching the indicator


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const int begin,
                const double &price[])
  {
//---
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

Look attached

Files:
222.jpg  40 kb
 

You know what, I didn't read your post properly. I thought you meant neither extern nor input were working.

I just tried it on build 1570 and you are quite right - no extern.

MQL4 is still happy with them though.

I'm not aware of any published change... but I may have missed it.

One of the other guys more clued up on MQL5 may be able to assist 

 

input does work. extern has other meaning, use input:

input int abc=123;  
 

extern is the very old way and obsolete for that purpose so use:

input
static input
sinput
These should all work.
 
extern in new version is a shared external variable (declared in different files)
 
Amir Yacoby:
extern in new version is a shared external variable (declared in different files)

Interesting, I did not notice that either.

Such tiny syntax changes move the MQL5 more apart from the MQL4 syntax (which is frozen currently). I am starting to doubt whether my attempt to unify my classes for use in both platforms had any sense.

 
Ex Ovo Omnia:

Interesante, no me di cuenta de que tampoco.

Tales cambios de sintaxis diminutas mover el MQL5 más aparte de la sintaxis MQL4 (que se congela en la actualidad). Estoy empezando a dudar de que mi intento de unificar mis clases para su uso en ambas plataformas tenía ningún sentido.

You're right, the gap widens.

Thank you all for replying
 

I think it is not very hard to retain the extern variable functionality in MQL5.

input ulong ulInpNotSoMagicID = 123;    //this is our test input variable
ulong ulMQL4ExtNotSoMagicID;            //this is the MQL4 extern-like variable

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{
        Print("Initialization");
        ulMQL4ExtNotSoMagicID = ulInpNotSoMagicID;
        return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
{
        ulMQL4ExtNotSoMagicID++;
        Print("Modified input variable: ", ulMQL4ExtNotSoMagicID);
}

Since the modification of an input variable invokes the OnInit() function we can synchronize our extern-like variable there. And since it is not an input variable we can modify it anywhere in the program.

 

maybe this can be added to https://www.mql5.com/en/articles/81 ?

that extern is obsolete and what to use instead

and it could be helpful in the MQL5 help under "extern" to mention that extern variables are not going to be visible in the inputs dialog
Migrating from MQL4 to MQL5
Migrating from MQL4 to MQL5
  • www.mql5.com
This article is a quick guide to MQL4 language functions, it will help you to migrate your programs from MQL4 to MQL5. For each MQL4 function (except trading functions) the description and MQL5 implementation are presented, it allows you to reduce the conversion time significantly. For convenience, the MQL4 functions are divided into groups, similar to MQL4 Reference.