[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 705
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
So clear, looking in the book and not seeing, works thank you! Moving on) with questions. All about the same global variables. I have added the following condition to the indicator:
I want to define which global variable should be assigned a value, depending on what currency the indicator is based on.
I understand that in the global variable GlobalVariableSet(valuta,param), the name (valuta) should contain the value assigned to it above
call again the global variable in the Expert Advisor code
string valuta="valuta";
int i= GlobalVariableGet(valuta); // but I don't get the value, .... i.e. i get 0. May be it's impossible to change the global variable name this way?
If an EA checks the value saved by the indicator, then it would be logical to suppose that the value of the parameter valuta should correspond to the symbol name, i.e. EURUSD or GBPUSD.
Accordingly, if advisor checks the value of the current symbol, then
string valuta = Symbol();
int i= GlobalVariableGet(valuta);Firstly, from the help
Returns the value of the existing global variable or 0 in case of an error. Call GetLastError() to get error information.
Can you see the contents of the GV, but can't retrieve it?
Well, global variables show both name and value, .... I just can't get the value of global variable in my code via (parameter-name) global variable, I have to specify string name, then no problem it finds everything.
Well the global variables display both name and value,..... I just can't get the value of global variable in my code via (parameter-name) of global variable, I have to specify string name, then it finds no problems.
Replace
if (symb==EUR) {valuta=EUR;}
to
if (symb=="EURUSD") {valuta="EUR";}
If the EA checks the value saved by the indicator, then it would be logical to assume that the value of the parameter valuta should correspond to the name of the instrument, i.e. EURUSD or GBPUSD...
accordingly, if advisor checks the value for the current symbol, then
string valuta = Symbol();
int i= GlobalVariableGet(valuta);Yes, it works)) It's easier than it looks )
Many thanks to everyone who visits and helps!
Friends, tell me where I screwed up... I can't figure it out. The indicator reads data, but then it doesn't work. I can't find it. Maybe somebody can tell me what I don't understand:
The journal always shows the data of the array of indicator values, but then stop...
... only one zero cell... and only zero... Help please...
Sorry, there's been a mistake ..... here's the original
Odyssey, if you don't have them, you should add them :))
Friends, tell me where I screwed up... I can't figure it out. The indicator reads data, but then it doesn't work. I can't find it. Maybe somebody can tell me what I don't understand:
The journal always shows the data of the array of indicator values, but then stop...
... only one zero cell... and only zero... Help please...
Artyom, found the first error so far:
Arrays PeakUP[] and PeakDN[], are declared without specified quantity of elements, that is, you have created them at all without cells, and further in a code try to write something in them, but as they don't contain in themselves elements, naturally in them nothing is written, and in the printer constantly zero. Since you don't know exactly how many peaks and troughs there will be, I recommend you to increase dynamically number of elements in these arrays when new data arrive, corrected areas are marked red.
ArraySize() returns the total number of array elements, but since indexing starts from zero, the actual number of elements is ArraySize() - 1.
...how to make, or at least what should be specified in it, for it to open orders on other pairs. I don't want to run several EAs ((
Artyom, so far I have found the first error:
Arrays PeakUP[] and PeakDN[], are declared without specified quantity of elements, that is you have created them without cells at all, and further in the code try to write something in them, but as they don't contain elements in themselves, naturally nothing is written in them, and in the printer constantly zero. Since you don't know exactly how many peaks and troughs there will be, I recommend you to increase dynamically number of elements in these arrays when new data arrive, corrected areas are marked red.
ArraySize() returns the total number of array elements, but since indexing starts from zero, the actual number of elements is ArraySize() - 1.