Hello, I'm currently confused as to why I keep getting this error when I compile: 'RSILength' - access to non-static member or function line 32
Maybe I haven't looked enough but I can't understand why it won't let me enter this variable into my RSI Handle. Thanks.
I just got the last update, and everyone, without exception of any code. They stopped working all with this same error.
I believe it is something with the latest update released a few minutes ago.
I just got the last update, and everyone, without exception of any code. They stopped working all with this same error.
I believe it is something with the latest update released a few minutes ago.
Thank you! Hopefully it gets fixed soon.
I managed to solve the problem, I declared all variables as static. Although I think this is wrong.
I managed to solve the problem, I declared all variables as static. Although I think this is wrong.
I just got another update (2410) and the bug was fixed.
Version 2408 was in trouble.
In it I noticed that if the variables were declared as statistical it would solve the problem, however it would generate optimization problems in the algorithms
int RSI_Handle = iRSI(NULL,0,RSILength,PRICE_CLOSE);
-
Global and static variables work exactly the same way in MT4/MT5/C/C++.
-
They are initialized once on program load.
-
They don't update unless you assign to them.
-
In C/C++ you can only initialize them with constants, and they default to zero. In MTx you should only initialize them with constants. There is no default in MT5, or MT4 with strict (which you should always use.)
MT4/MT5 actually compiles with non-constants, but the order that they are initialized is unspecified and don't try to use any price or server related functions in OnInit (or on load,) as there may be no connection/chart yet:
- Terminal starts.
- Indicators/EAs are loaded. Static and globally declared variables are initialized. (Do not depend on a specific order.)
- OnInit is called.
- For indicators OnCalculate is called with any existing history.
- Human may have to enter password, connection to server begins.
- New history is received, OnCalculate called again.
- New tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.
-
Unlike indicators, EAs are not reloaded on chart change so you must reinitialize them, if necessary.
external static variable - MQL4 programming forum
-
-
Perhaps you should read the manual, especially the examples. They all (including iCustom) return a handle (an int.) You get that in OnInit. In OnTick you use the handle, shift and count to get the data.
Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 2020.03.08
How to call indicators in MQL5 - MQL5 Articles 12 March 2010
-
Global and static variables work exactly the same way in MT4/MT5/C/C++.
-
They are initialized once on program load.
-
They don't update unless you assign to them.
-
In C/C++ you can only initialize them with constants, and they default to zero. In MTx you should only initialize them with constants. There is no default in MT5, or MT4 with strict (which you should always use.)
MT4/MT5 actually compiles with non-constants, but the order that they are initialized is unspecified and don't try to use any price or server related functions in OnInit (or on load,) as there may be no connection/chart yet:
- Terminal starts.
- Indicators/EAs are loaded. Static and globally declared variables are initialized. (Do not depend on a specific order.)
- OnInit is called.
- For indicators OnCalculate is called with any existing history.
- Human may have to enter password, connection to server begins.
- New history is received, OnCalculate called again.
- New tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.
-
Unlike indicators, EAs are not reloaded on chart change so you must reinitialize them, if necessary.
external static variable - MQL4 programming forum
-
-
Perhaps you should read the manual, especially the examples. They all (including iCustom) return a handle (an int.) You get that in OnInit. In OnTick you use the handle, shift and count to get the data.
Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 2020.03.08
How to call indicators in MQL5 - MQL5 Articles 12 March 2010
Unlike indicators, EAs are not reloaded on chart change so you must reinitialize them, if necessary.
I think you were wrong, every change in graphics generates a call in OnDenit (reason) and supports that OnInit is called.
Unlike indicators, EAs are not reloaded on chart change so you must reinitialize them, if necessary.
I think you were wrong, every change in graphics generates a call in OnDenit (reason) and supports that OnInit is called.
You have misunderstood.
With an EA, static and global variables are not reinitialized when the EA is reinitialized. If the coder requires that they are reinitialized, it must be coded to do do.
Unlike indicators, EAs are not reloaded on chart change so you must reinitialize them, if necessary.
A deinit/init are two function calls; that isn't reloading. Prove it to yourself:
int OnInit(){ static int loaded=0; Print(loaded); ++loaded; }
Attach to chart, see zero. Change TF, see one. Etc.
I consider it a bad practice to create a variable within OnInit
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello, I'm currently confused as to why I keep getting this error when I compile: 'RSILength' - access to non-static member or function line 32
Maybe I haven't looked enough but I can't understand why it won't let me enter this variable into my RSI Handle. Thanks.