[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

 
Infinity:

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);
 
zhuki:

Firstly, from the help

double GlobalVariableGet(string name)

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.
 
Infinity:

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";}

 
keekkenen:

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:

//жжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжж
// Поиск экстремумов
//жжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжж
void   SaveDataIND(double &TempIND[], int nBars)
{
   ArrayResize(TempIND,nBars);                     // Размер массива под переданный в ф-цию размер
   for (int j=0; j<=nBars-1; j++)
      {
         TempIND[j]=iAD(NULL,PERIOD_M5,j);         // Запишем данные инд. в цикле в массив
         Print("TempIND[",j,"] = ",TempIND[j]);
      }
//------------------------------------------------------------------
// Заполнение массивов данными о пичках и донышках
//------------------------------------------------------------------
   double   PeakUP[], PeakDN[];                    // Объявляем массивы пичков/донышков
   int i, k, l, asize;
   if (TempIND[nBars-1]<TempIND[1])                // Если последний бар массива ниже первого - тенденция вверх
      {
         k=0;                                      // Инициализируем индекс массива донышков
         for (i=3; i<=nBars-1; i++)                // Пробежимся по массиву значений
            {
               if (TempIND[i]>TempIND[i-1] && 
                   TempIND[i-1]<TempIND[i-2])      // Нашли донышко
                  {
                     PeakDN[k]=TempIND[i-1];       // Заносим его значение в массив донышек 
                     k++;                          // Увеличиваем индекс массива донышков
                  }
            }
         asize=ArraySize(PeakDN);
         for (l=0; l<=asize; l++)
            {
               Print("PeakDN[",l,"] = ",PeakDN[l]);
            }
      }
   if (TempIND[nBars-1]>TempIND[1])                // Если последний бар массива выше первого - тенденция вниз
      {
         k=0;                                      // Инициализируем индекс массива пичков
         for (i=3; i<=nBars-1; i++)                // Пробежимся по массиву значений
            {
               if (TempIND[i]<TempIND[i-1] && 
                   TempIND[i-1]>TempIND[i-2])      // Нашли пичёк
                  {
                     PeakUP[k]=TempIND[i-1];       // Заносим его значение в массив пичков 
                     k++;                          // Увеличиваем индекс массива пичков
                  }
            }
         asize=ArraySize(PeakUP);
         for (l=0; l<=asize; l++)
            {
               Print("PeakUP[",l,"] = ",PeakUP[l]);
            }
      }            
         

}   

The journal always shows the data of the array of indicator values, but then stop...
... only one zero cell... and only zero... Help please...


 
odiseif:
Sorry, there's been a mistake ..... here's the original

Odyssey, if you don't have them, you should add them :))

Files:
 
artmedia70:

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.

if (TempIND[nBars-1]<TempIND[1])                // Если последний бар массива ниже первого - тенденция вверх
      {
         k=0;                                      // Инициализируем индекс массива донышков
         for (i=3; i<=nBars-1; i++)                // Пробежимся по массиву значений
            {
               if (TempIND[i]>TempIND[i-1] && 
                   TempIND[i-1]<TempIND[i-2])      // Нашли донышко
                  {
                     ArrayResize(PeakDN, k + 1);
                     PeakDN[k]=TempIND[i-1];       // Заносим его значение в массив донышек 
                     k++;                          // Увеличиваем индекс массива донышков
                  }
            }
         asize=ArraySize(PeakDN);
         for (l=0; l< asize; l++)
            {
               Print("PeakDN[",l,"] = ",PeakDN[l]);
            }
      }
   if (TempIND[nBars-1]>TempIND[1])                // Если последний бар массива выше первого - тенденция вниз
      {
         k=0;                                      // Инициализируем индекс массива пичков
         for (i=3; i<=nBars-1; i++)                // Пробежимся по массиву значений
            {
               if (TempIND[i]<TempIND[i-1] && 
                   TempIND[i-1]>TempIND[i-2])      // Нашли пичёк
                  {
                     ArrayResize(PeakUP, k + 1);
                     PeakUP[k]=TempIND[i-1];       // Заносим его значение в массив пичков 
                     k++;                          // Увеличиваем индекс массива пичков
                  }
            }
         asize=ArraySize(PeakUP);
         for (l=0; l< asize; l++)
            {
               Print("PeakUP[",l,"] = ",PeakUP[l]);
            }
      }    

ArraySize() returns the total number of array elements, but since indexing starts from zero, the actual number of elements is ArraySize() - 1.

 
Here I am again with questions) The question now is of the following nature. (Thanks to everyone who helped earlier), now my Expert Advisor receives data of global variables from indicators, by detecting from which symbol the data has been received. On the basis of these data I open an order in Expert Advisor on the currency from which I have received data of the global variable. I attach the EA to one chart and indicators to all other charts. It gets data but opens order only for a currency it is standing on (EA itself) ... I think it should be a multi-expert ... i don't know how to do it or at least what should be in it so it opens orders on other pairs (...) i don't want to run several EAs (...)
 
Infinity:
...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 ((
OrderSend(Name of currency pair.... and other parameters......)
 
ToLik_SRGV:

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.

Anatoly! A monument should be erected to you - a bust in your homeland! The most interesting thing is that I did it for the TempIND array, but I forgot about them and worked on them half the night... :))
Reason: