[¡Archivo!] Cualquier pregunta de novato, para no saturar el foro. Profesionales, no pasen de largo. No puedo ir a ningún sitio sin ti - 4. - página 101

 
Zhunko:
Se aclararán los comentarios anteriores.
Gracias
 

Hola a todos.

Por favor, ayúdenme a entender este ejemplo de la cartilla MQL4. Este es el lugar:

He subrayado en rojo lo que no entiendo. ¿Por qué IndicatorCounted() devuelve 299 en el Tick 3? La vela anterior no ha cambiado desde la última llamada del indicador (Tick 2), y es la vela número 300. Así que la función debería devolver 300.

Y una pregunta más: ¿podríais decirme si en esta imagen la apertura de la última barra es el precio que salió en el Tick 2 o en el Tick 3?

Gracias a todos, que no pasarán por el sufrimiento :-))

 
Skander:

Hola a todos.

Ayúdame con un ejemplo del tutorial de MQL4. Este es el lugar:

He subrayado en rojo lo que no he entendido. ¿Por qué IndicatorCounted() devuelve 299 en el Tick 3? Después de todo

En el momento t2 la barra aún no se considera terminada, porque técnicamente el periodo de tiempo no ha terminado. No tenemos forma de determinar de antemano si este es el último tick de la barra o si habrá más ticks antes de que comience la siguiente barra. Y en consecuencia, el Indicador Contado devuelve lo que se supone que debe devolver según la documentación: el número de barras contadas en el momento t2 excluyendo la barra cero (de nuevo en el momento t2), es decir, 300-1=299.

 
alsu:

En el momento t2 la barra aún no se considera terminada, porque técnicamente el periodo de tiempo no ha terminado. No tenemos forma de determinar de antemano si este es el último tick de la barra o si habrá más ticks antes de que comience la siguiente barra. Y en consecuencia, el Indicador Contado devuelve lo que debería según la documentación: el número de barras contadas en el momento t2 excluyendo la barra cero (de nuevo en el momento t2), es decir, 300-1=299.


Entiendo lo que quieres decir: describes la situación en el momento t2, pero el libro de texto dice que en el momento t3 la función Indicador Contado devuelve el mismo número que en el momento t2. No me queda claro, ¿por qué lo hace? Este fragmento de aquí:

¿O es la situación en el momento t2 la que se describe aquí?

 
Skander:

Entiendo lo que quieres decir: describes la situación en el momento t2, pero el libro de texto dice que en el momento t3 la función Indicador Contado devuelve el mismo número que en el momento t2. No me queda claro, ¿por qué lo hace? Este párrafo de aquí:

¿O es la situación en el momento t2 la que se describe aquí?

No, en el momento t3. La cuestión es que t3 es el primer tick de una barra, y eso significa que, como todavía no se han hecho cálculos sobre él, el valor de IndicatorCounted() no ha tenido tiempo de cambiar - sólo ocurre después de que la función start() termine su trabajo. Esto es bastante lógico - la función da el número de barras calculadas, por lo que no tiene sentido cambiar su valor hasta que se haya calculado al menos un tick de la barra dada. Por lo tanto, en el momento t3 todavía vemos el valor 299, pero en el siguiente tick será 300.

¿Está más claro?

 
Amigos, por favor, aconsejen lo que es un archivo de cabecera (MQH), se puede crear en el editor. La ayuda del editor no dice nada al respecto.
 
Las-tochka:
Amigos, díganme qué es un archivo de cabecera (MQH), se puede crear en el editor. La ayuda del editor no dice nada al respecto.

Biblioteca Con funciones, se puede crear en MetaEditor, Bloc de notas ...

La compilación no es necesaria.El include incluye las funciones necesarias en el expert al compilar, y la libreríaLibraries ex4 se compila e importa (es decir, accede constantemente a ella para obtener los f-ms necesarios).
 
Las-tochka:
La gente aconseja lo que es, archivo de cabecera (MQH), se puede crear en el editor. La ayuda del editor no dice nada al respecto.


Creo que el archivo de cabecera en MKL también merece la pena ser analizado desde este punto de vista:

como sabemos no hay clases en el lenguaje, pero esto es conveniente. Se puede crear algún tipo de clase con un archivo de cabecera. En él, creamos un entorno que describe el objeto (variables) y definimos las funciones que trabajarán con este entorno. Bastante práctico (suponiendo que el proyecto sea lo suficientemente complejo).

 
220Volt: Como ya sabes, no hay clases de idiomas, pero es conveniente. Puede crear una apariencia de clase utilizando un archivo de cabecera. En él, creamos un entorno que describe el objeto (variables) y definimos las funciones que trabajarán con este entorno. Bastante conveniente (siempre que el proyecto sea bastante complejo).

¿Puede ser más específico? ¿Podría darme un ejemplo, por favor?

A un principiante como Las-tochk'i estas sus ingeniosas cartas no le dicen absolutamente nada.

 
Mathemat:

¿Puede ser más específico? Por favor, danos un ejemplo de algún tipo.

Para un principiante como Las-tochk'i estas cartas inteligentes suyas no dicen absolutamente nada.

No creo que a nadie le interese rebuscar en el código de otra persona, un ejemplo de esa clase:

//+------------------------------------------------------------------+
//|                                                  WaveCounter.mq4 |
//|                                                             Паха |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Паха"

#define wC_SHADECOLOR   C'121,0,0'
#define wC_NAMEPART  "WaveCounter"
//#define NEW_LINE_COLOR  DarkKhaki
#define NEW_LINE_STILE  2
#define NEW_LINE_RAY 0
#define SCARP_LINE_STILE   1
//#define SCARP_LINE_COLOR White

#include <WaveCounterCore.mqh>
///////////////////////////////////////////////////////////////////// Var
string wC_sName = "";
int wC_iTimeframe;
int wC_iDirection;
bool wC_bFirst;
int iwC_iLockBar;
double wC_dSizePorog[][2];
//------------------------ rez
int wC_iMoveBar[2];
double wC_dMovePrice[2];
bool wC_bScarp;
int wC_iStop;
/////////////////////////////////////////////////////////////////////
/*
//-------------------------------------------------- private
bool wC_vn_getWaveSizeArray();
//-------------------------------------------------- public
string wC_Create(bool bSizeFilter,
                  bool bAddToExtr);
bool wC_Check(string &sName, 
               bool bFromBegin, 
               bool bFirst);
bool wC_IsScarp();
int wC_IsStop();
bool wC_Redraw();
*/
/////////////////////////////////////////////////////////////////////

string wC_Create(bool bSizeFilter,
                  bool bAddToExtr)
   {
   //----
   string sShadeName[2] = {"wC_Shade1", "wC_Shade2"};
   
   //--//
      if(ObjectFind(sShadeName[0]) < 0)
         {
         Shade_create( sShadeName[0], wC_SHADECOLOR );
         return("");
         }
      
      if(ObjectFind(sShadeName[1]) < 0)
         {
         Shade_create( sShadeName[1], wC_SHADECOLOR );
         return("");
         }
   //--\\
   
   if( ! Shade_attach(sShadeName, false) ) 
      return("");      
   if( ! Shade_direction(wC_iDirection, 0, 1) )
      return("");
   if( ! Shade_minTimeframe(0) )
      return("");
   wC_iTimeframe = Shade_getTimeframe();
   int iCorrectIndex[2] = {0, 1};
   Shade_correctKoord(iCorrectIndex); 
   
   datetime datPoint0;
   double dPoint0, dPoint1;
   if(wC_iDirection == 2)
      {
      if( ! Shade_getPointTimePrice(0, CONTMOV1,  false, datPoint0, dPoint0) )
         return("");
      }
   else
      {
      if( ! Shade_getPointTimePrice(0, CONTMOV1,  true, datPoint0, dPoint0) )
         return("");
      } 

   if(bSizeFilter)
      {
      if( ! wC_vn_getWaveSizeArray() )
         return("");
         
      int iIndexPoroga[1];
      if( ! MyInputBox("Индекс порога", iIndexPoroga) )
         return("");
      if( iIndexPoroga[0] < 0  || iIndexPoroga[0] + 1 > ArrayRange(wC_dSizePorog, 0) )
         {
         Alert("Недопустимый индекс");
         return("");
         }
         
      if(wC_iDirection == 2)
         dPoint1 = dPoint0 + wC_dSizePorog[ iIndexPoroga[0] ][0] * dPoint0;
      else
         dPoint1 = dPoint0 - wC_dSizePorog[ iIndexPoroga[0] ][0] * dPoint0;
      iwC_iLockBar = MYEMPTY;
      }
   else
      {
      if(wC_iDirection == 2)
         {
         if( ! Shade_getPoint(1, CONTMOV2, true, iwC_iLockBar) )
            return(false);
         dPoint1 = iHigh(NULL, wC_iTimeframe, iwC_iLockBar);
         }
      else
         {
         if( ! Shade_getPoint(1, CONTMOV2, false, iwC_iLockBar) )
            return(false);
         dPoint1 = iLow(NULL, wC_iTimeframe, iwC_iLockBar); 
         }
      if(dPoint1 == 0)
         return(false);
      if(bAddToExtr)
         iwC_iLockBar --;
      }

   if( ! Fun_partOfName(wC_sName) )
      return("");   
   wC_sName = StringConcatenate(wC_sName, wC_NAMEPART);
   
   if( ! ObjectCreate(wC_sName, OBJ_TREND, 0, datPoint0, dPoint0, datPoint0, dPoint1) )
      return("");
   if( ! ObjectSetText(wC_sName, "2") )
      return("");
   if( ! ObjectSet(wC_sName, OBJPROP_RAY, NEW_LINE_RAY) )
      return("");
   if( ! ObjectSet(wC_sName, OBJPROP_COLOR, Fun_ColorFromPanel()) )
      return("");
   if( ! ObjectSet(wC_sName, OBJPROP_STYLE, NEW_LINE_STILE) )
      return("");
   
   Fun_deleteObjects(sShadeName);
   return(wC_sName); 
   }
//--------------------------------------------------

bool wC_vn_getWaveSizeArray()
   {
   static bool bSizePorogInit = false;
   if(bSizePorogInit)
      return(true);
   string sSymbol = Symbol();
   if( sSymbol == "USDCHF" )
      {
      if(ArrayResize(wC_dSizePorog, ArrayRange(prop_dWaveSizeUSDCHF, 0)) < 0)
         return(false);
      if(ArrayCopy(wC_dSizePorog, prop_dWaveSizeUSDCHF) < 1)
         return(false);
      bSizePorogInit = true;
      return(true);
      }
         
   if( sSymbol == "AUDJPY" )
      {
      if(ArrayResize(wC_dSizePorog, ArrayRange(prop_dWaveSizeAUDJPY, 0)) < 0)
         return(false);
      if(ArrayCopy(wC_dSizePorog, prop_dWaveSizeAUDJPY) < 1)
         return(false);
      bSizePorogInit = true;
      return(true);
      }
         
   if( sSymbol == "EURUSD" )
      {
      if(ArrayResize(wC_dSizePorog, ArrayRange(prop_dWaveSizeEURUSD, 0)) < 0)
         return(false);
      if(ArrayCopy(wC_dSizePorog, prop_dWaveSizeEURUSD) < 1)
         return(false);
      bSizePorogInit = true;
      return(true);
      }
         
   if( sSymbol == "EURGBP" )         
      {
      if(ArrayResize(wC_dSizePorog, ArrayRange(prop_dWaveSizeEURGBP, 0)) < 0)
         return(false);
      if(ArrayCopy(wC_dSizePorog, prop_dWaveSizeEURGBP) < 1)
         return(false);
      bSizePorogInit = true;
      return(true);
      }
     
   if( sSymbol == "EURJPY" )           
      {
      if(ArrayResize(wC_dSizePorog, ArrayRange(prop_dWaveSizeEURJPY, 0)) < 0)
         return(false);
      if(ArrayCopy(wC_dSizePorog, prop_dWaveSizeEURJPY) < 1)
         return(false);
      bSizePorogInit = true;
      return(true);
      }
         
   if( sSymbol == "GBPUSD" )            
      {
      if(ArrayResize(wC_dSizePorog, ArrayRange(prop_dWaveSizeGBPUSD, 0)) < 0)
         return(false);
      if(ArrayCopy(wC_dSizePorog, prop_dWaveSizeGBPUSD) < 1)
         return(false);
      bSizePorogInit = true;
      return(true);
      }
         
   if( sSymbol == "USDCAD" )            
      {
      if(ArrayResize(wC_dSizePorog, ArrayRange(prop_dWaveSizeUSDCAD, 0)) < 0)
         return(false);
      if(ArrayCopy(wC_dSizePorog, prop_dWaveSizeUSDCAD) < 1)
         return(false);
      bSizePorogInit = true;
      return(true);
      }
         
   if( sSymbol == "USDJPY" )            
      {
      if(ArrayResize(wC_dSizePorog, ArrayRange(prop_dWaveSizeUSDJPY, 0)) < 0)
         return(false);
      if(ArrayCopy(wC_dSizePorog, prop_dWaveSizeUSDJPY) < 1)
         return(false);
      bSizePorogInit = true;
      return(true);
      }
         
   if( sSymbol == "AUDUSD" )            
      {
      if(ArrayResize(wC_dSizePorog, ArrayRange(prop_dWaveSizeAUDUSD, 0)) < 0)
         return(false);
      if(ArrayCopy(wC_dSizePorog, prop_dWaveSizeAUDUSD) < 1)
         return(false);
      bSizePorogInit = true;
      return(true);
      }
      
   Alert("У символа нет размерного массива, или он не прописан в функции Tl_vn_getWaveSizeArray()");
   return(false);
   }
//--------------------------------------------------

bool wC_Check(string &sName, 
               bool bFromBegin, 
               bool bFirst)
   {
   if(StringFind(sName, wC_NAMEPART) == -1)
      return(false);
   wC_bScarp = false;
   wC_iStop = -1;
   wC_sName = sName;
   string sDescrip = ObjectDescription(sName);
   int iID = StrToInteger(sName);
   if(iID == 0)
      return(false);
      
   datetime datLastTime;
   if(sDescrip == "1"  &&  ! bFirst)
      {
      datLastTime = FL_LastTime();
      if(datLastTime == -1)
         datLastTime = MYEMPTY;
      if( ! tlC_Load(iID, datLastTime) )
         return(false);
      wC_bFirst = false;
      if(bFromBegin)
         if( ! tlC_SeekToBegin())
            return(false);
      }
   else
      {
      if(sDescrip == "2"  &&  bFirst)
         {
         int iBeginBar = iBarShift(NULL, wC_iTimeframe, ObjectGet(sName, OBJPROP_TIME1), true);
         if(iBeginBar == -1)
            return(false);
         datLastTime = FL_LastTime();
         if(datLastTime == -1)
            datLastTime = MYEMPTY;
         if( ! tlC_Attach(iID, wC_iDirection, wC_iTimeframe, iBeginBar, ObjectGet(sName, OBJPROP_PRICE2), iwC_iLockBar, datLastTime) )
            return(false); 
         if(iwC_iLockBar != MYEMPTY)
            tlC_SetStops(false, MYEMPTY);
         wC_bFirst = true;
         }
      else
         return(false);
      }
   
   if( ! tlC_Check() )
      return(false);
      
   wC_bScarp = tlC_IsScarp();
   wC_iStop = tlC_IsStop();
   tlC_GetCurView(wC_iMoveBar, wC_dMovePrice);
   if(wC_bScarp)
      {
      int iTempVar;
      double dTempVar;
      tlC_GetCurPos(iTempVar, dTempVar);
      wC_iMoveBar[1] = iTempVar;
      wC_dMovePrice[1] = dTempVar;
      }
   
   return(true);
   }
//--------------------------------------------------

bool wC_IsScarp()
   {
   return(wC_bScarp);
   }
//--------------------------------------------------

int wC_IsStop()
   {
   return(wC_iStop);
   }
//--------------------------------------------------


  
Razón de la queja: