What is the truly different between input & extern on EA vs Indicator?

 

Hi community.

This is not very serious.

I'm a programmer, I worked with MQL4 for about 2 years, wrote many EAs & Indicators for me, but I cared about the functions, performance, logical, ... only.

Normally, I use extern when I write EA & input for Indicator (as I saw on many EAs & Indicators when I started to learn MQL4).

Today, I suddenly notice that I can use extern or input for both EA & Indicator.

It might be my small mistake, I used extern for 1 Indicator for about 3 months ago, it didn't affect to the program. I saw that when I've just opened that Indicator to modify.

That's very interesting, then I tried to use input for EA & vice versa. Perfect! All worked well.

What is the truly different between input & extern on EA vs Indicator?

Yours sincerely,

Giang Nguyen

 
You can modify extern variables (not good practice,) never input variables.
 
Giang Nguyen:

Hi community.

This is not very serious.

I'm a programmer, I worked with MQL4 for about 2 years, wrote many EAs & Indicators for me, but I cared about the functions, performance, logical, ... only.

Normally, I use extern when I write EA & input for Indicator (as I saw on many EAs & Indicators when I started to learn MQL4).

Today, I suddenly notice that I can use extern or input for both EA & Indicator.

It might be my small mistake, I used extern for 1 Indicator for about 3 months ago, it didn't affect to the program. I saw that when I've just opened that Indicator to modify.

That's very interesting, then I tried to use input for EA & vice versa. Perfect! All worked well.

What is the truly different between input & extern on EA vs Indicator?

Yours sincerely,

Giang Nguyen

I think you mean like this maybe....

1: input int Hello = 10;

or

2: extern int Hello = 10;

You can read some documentation about it https://www.mql5.com/en/docs/basis/variables/inputvariables

Documentation on MQL5: Language Basics / Variables / Input Variables
Documentation on MQL5: Language Basics / Variables / Input Variables
  • www.mql5.com
modifier is indicated before the data type. A variable with the input modifier can't be changed inside mql5-programs, such variables can be accessed for reading only. Values of input variables can be changed only by a user from the program properties window. External variables are always reinitialized immediately before the OnInit() is called...
 

I understand now.

Both of them are nearly the same, but the input is constant in program.

Thanks all.

Reason: