Are there any Spanish or speak Spanish? ... buffer problems downloading custom flag.

 
He says the moderator in English and not in Spanish ...

I spent three months ago MQL5. Attracted by improvements in optimization and use multicurrency, I've been translating the EA that was designed as an excuse to learn MQL4 MQL5 and rebuild all the libraries I had in MQL4. All the problems I have solved with patience Franciscan ... but reached a point where I think I can get into "efficiency", I'm stuck for a week:

I designed an indicator that measures the angle of inclination of MA, parameterizing the type of MA that apply, then optimized parameter also in the EA; worked perfectly in MQL4 and MQL5 now.

In the EA, the warning algorithm works perfectly in debug phase: get the variable "pointer" that points to the typical function "iCustom (...)", get with "CoppyBuffer () the last 4 buffer values (from 0-3), with applied indexes ArraySetAsSeries as traditionally made MQL4; those 4 values ​​compare them to detect a signal to buy or sell ... and everything perfect until tick reiteration or 15 or 20 in which the indicator starts to return those 4 values ​​as zero and graphical "display" Tester measure return strategies with zero horizontal line when another independent graphical indicator is functioning normally. The program runs normally without giving messages error, but the indicator pointer returns zero values.

I had been warned of the high consumption of resources compared with MT4 MT5, but I have a I5 with 4 processors at 2.5 GHz and 4 MB of Ram.

What someone has raised this issue with the use of custom indicator?. For in the same signal algorithm using the 4 values ​​of MA and do not give me this problem

Activation of the I with puntAngMA pointer = iCustom (symbolic, marcoTmp, "Angle of MAs" METMA, MAPER, price, barraSalto) in OnInit ().

load function values ​​has no secrets and I call on each sail within the signal algorithm, is ...

//--------------------------------- FUNCTION INDICATOR LOAD DATA FROM BUFFER  -------------------------------
bool cargaDesdeBuffer( int puntero,          // puntero del indicador
                    double &arValores[],     // array donde descargar los valores del indicador
                       int cantidad= 0,          //número de valores a copiar
                       int velaIni= 0,        //vela inicial de la descarga
                       int indBuffer= 0)      //índice del buffer del indicador a descargar
{
   bool correcto= _No;
   int copiados= -1;
   if (cantidad==0) cantidad= ArraySize(arValores);
   ResetLastError();
   copiados= CopyBuffer(puntero, indBuffer, velaIni, cantidad, arValores);
   if(copiados>0)       
   {
      correcto= true;
      ArraySetAsSeries(arValores, true);  //ojo, para que responda ArraySetAsSeries, arValores[] debe ser dinámico
   }
   else infoError(_LastError, __FUNCTION__);
   return(correcto);
}

 Gracias... perdón, Thank you.

Documentation on MQL5: Standard Constants, Enumerations and Structures / Objects Constants / Object Types
Documentation on MQL5: Standard Constants, Enumerations and Structures / Objects Constants / Object Types
  • www.mql5.com
Standard Constants, Enumerations and Structures / Objects Constants / Object Types - Documentation on MQL5
 
Thanks, another time, you can edit your first post and not create a new one.
 

This line isn't necessary :

   if (cantidad==0) cantidad= ArraySize(arValores);

You can also put the following line in OnInit() (if your array is declared globally), or before you call to cargeDesdeBuffer()

      ArraySetAsSeries(arValores, true);  //ojo, para que responda ArraySetAsSeries, arValores[] debe ser dinámico

Don't know if that help, as you published only this snippet of code.

 
I am spanish. You can send me a private message if you want, as your issue seems interesting, but I don't know if I fully understand what is happening.
MQL5.community - User Memo
MQL5.community - User Memo
  • 2010.02.25
  • MetaQuotes Software Corp.
  • www.mql5.com
You have just registered and most likely you have questions such as, "How do I insert a picture to my a message?" "How do I format my MQL5 source code?" "Where are my personal messages kept?" You may have many other questions. In this article, we have prepared some hands-on tips that will help you get accustomed in MQL5.community and take full advantage of its available features.
 
angevoyageur:

This line isn't necessary :

You can also put the following line in OnInit() (if your array is declared globally), or before you call to cargeDesdeBuffer()

Don't know if that help, as you published only this snippet of code.

//--------------------------------- CARGA DATOS DESDE BUFFER INDICADOR  -------------------------------
bool cargaDesdeBuffer( int puntero,           // puntero del indicador
                    double &arCopiaInv[],     // array donde descargar los valores del indicador
                       int cantidad= 0,       //número de valores a copiar
                       int velaIni= 0,        //vela inicial de la descarga
                       int indBuffer= 0)      //índice del buffer del indicador a descargar
{
   double arValores[];
   bool correcto= _No, arDinam= ArrayIsDynamic(arCopiaInv);
   int copiados= -1;
   if (arDinam) ArrayResize(arCopiaInv, cantidad);
   else if(cantidad==0) cantidad= ArraySize(arCopiaInv);      //asumimos que el array pasado es estático
   ArrayResize(arValores, cantidad);
   ResetLastError();
   copiados= CopyBuffer(puntero, indBuffer, velaIni, cantidad, arValores);
   if(copiados>0)
   {
      correcto= true;
      if (arDinam) ArraySetAsSeries(arCopiaInv, true);     //esta función sólo funciona sobre arrays dinámicos
      else invierteArray(arValores, arCopiaInv);
   }
   else infoError(_LastError, __FUNCTION__);
   return(correcto);
}

//------------------------- FUNCION INVIERTE ARRAY  ------------------------------------
bool invierteArray(double &arDer[], double &arInv[])
{                             //arInv[] debe ser dinámico
   bool resp;
   int dim= ArraySize(arDer);
   ResetLastError();
   for(int k=dim-1; k>=0; k--) arInv[(dim-1)-k]= arDer[k];
   resp= _LastError==0;
   return(resp);
}

Seeking solution to the problem, which is, I modified the function as above.

The variable "pointer" to charge with iCustom in OnInit () is forced to do so because otherwise during execution each call to buffer an indicator I load indicator on screen to saturate the RAM.

The following statement does not allow me to specify the size of the array which introduced the function call, but knowing that I have removed the problem does not affect

if (cantidad==0) cantidad= ArraySize(arValores);
The fact is that I still have the same problem:
The algorithm works in the first iterations and then the light starts to return zero values.
I can apply the algorithm directly indicator EA code but not solve a problem that can give me in the future with other personal indicators that use other strategies.
There is a error. The function must be...
//--------------------------------- CARGA DATOS DESDE BUFFER INDICADOR  -------------------------------
bool cargaDesdeBuffer( int puntero,           // puntero del indicador
                    double &arCopiaInv[],     // array donde descargar los valores del indicador
                       int cantidad= 0,       //número de valores a copiar
                       int velaIni= 0,        //vela inicial de la descarga
                       int indBuffer= 0)      //índice del buffer del indicador a descargar
{
   double arValores[];
   bool correcto= _No, arDinam= ArrayIsDynamic(arCopiaInv);
   int copiados= -1;
   if (arDinam) ArrayResize(arCopiaInv, cantidad);
   else if(cantidad==0) cantidad= ArraySize(arCopiaInv);      //asumimos que el array pasado es estático
   ArrayResize(arValores, cantidad);
   ResetLastError();
   copiados= CopyBuffer(puntero, indBuffer, velaIni, cantidad, arValores);
   if(copiados>0)
   {
      correcto= true;
      if (arDinam)
      {
         ArrayCopy(arCopiaInv, arValores);
         ArraySetAsSeries(arCopiaInv, true);     //esta función sólo funciona sobre arrays dinámicos
      }
      else invierteArray(arValores, arCopiaInv);
   }
   else infoError(_LastError, __FUNCTION__);
   return(correcto);
}

	          
 
josemiguel1812:

Seeking solution to the problem, which is, I modified the function as above.

The variable "pointer" to charge with iCustom in OnInit () is forced to do so because otherwise during execution each call to buffer an indicator I load indicator on screen to saturate the RAM.

As I already said you only show one function and not the main code of your indicator. Maybe someone can help you with this, but personally I can't.
 
angevoyageur:
As I already said you only show one function and not the main code of your indicator. Maybe someone can help you with this, but personally I can't.

I introduced the indicator algorithm in the EA indicator directly and the program works as expected ... as has worked in MQL4. Introduce the indicator in OnInit () with ChartIndicatorADD () and the problem persists: the indicator provides zero values ​​to the graph.

If not I have an error in your code indicator, the problem must be in the internal management makes mql5 with buffers. Unless someone inform me of any errors that I see, for now I miss custom indicators in MQL5

Attached indicator file...

Custom Indicators in MQL5 for Newbies
Custom Indicators in MQL5 for Newbies
  • 2010.03.03
  • Nikolay Kositsin
  • www.mql5.com
Any new subject seems complicated and hard-to-learn for a newbie. Subjects that we know seem very simple and clear to us. But we simply do not remember, that everyone has to study something from scratch, and even our native language. The same is with the MQL5 programming language that offers wide possibilities of developing one's own trading strategies - you can start learning it from basic notions and simplest examples. Interaction of a technical indicator with the MetaTrader 5 client terminal is consider in this article on the example of the simple custom indicator SMA.
Files:
 
josemiguel1812:
Attached indicator file...
Your code doesn't compile. Maybe as I don't have #include <include MovingAverages.mqh>
 
angevoyageur:
Your code doesn't compile. Maybe as I don't have #include <include MovingAverages.mqh>

I introduced the indicator algorithm in the EA indicator directly and the program works as expected ... as has worked in MQL4. Introduce the indicator in OnInit () with ChartIndicatorADD () and the problem persists: the indicator provides zero values ​​to the graph.

If not I have an error in your code indicator, the problem must be in the internal management makes mql5 with buffers. Unless someone inform me of any errors that I see, for now I miss custom indicators in MQL5

Attached include and indicator files with a little error corrected...

 
josemiguel1812:

I introduced the indicator algorithm in the EA indicator directly and the program works as expected ... as has worked in MQL4. Introduce the indicator in OnInit () with ChartIndicatorADD () and the problem persists: the indicator provides zero values ​​to the graph.

If not I have an error in your code indicator, the problem must be in the internal management makes mql5 with buffers. Unless someone inform me of any errors that I see, for now I miss custom indicators in MQL5

Attached include and indicator files with a little error corrected...

Ok, now it miss include_Base.mqh to compile :-) Once I can compile your code, then I will checked and help you (if I can).
 
angevoyageur:
Ok, now it miss include_Base.mqh to compile :-) Once I can compile your code, then I will checked and help you (if I can).
angevoyageur
:

Ok, now it miss include_Base.mqh to compile :-) Once I can compile your code, then I will checked and help you (if I can).
I removed the include...
Files:
Reason: