Necesito indicador Demarker exponencial MT4

Responder
Avatar de Usuario
Gamelu
Mensajes: 787
Registrado: 21 May 2009 16:49

Necesito indicador Demarker exponencial MT4

Mensaje por Gamelu »

Para crear un expert necesito este indicador, el mt4 trae por defecto el demarker con calculo simple, necesito que haga el calculo exponencial, si teneis este indicador a ver si lo podeis subir, de todas formas, como se podria recalcular los resultados del demarker para convertirlo en exponencial¿?
Un Saludo
Avatar de Usuario
X-Trader
Administrador
Mensajes: 12794
Registrado: 06 Sep 2004 10:18
Contactar:

Re: Necesito indicador Demarker exponencial MT4

Mensaje por X-Trader »

Aquí tienes el código del DeMarker original, no tienes más que buscar en las últimas líneas el siguiente texto:

Código: Seleccionar todo

MODE_SMA
y reemplazarlo por:

Código: Seleccionar todo

MODE_EMA
Saludos,
X-Trader

Código: Seleccionar todo

//+------------------------------------------------------------------+
//|                                                     DeMarker.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
 
#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 1
#property indicator_buffers 1
#property indicator_color1 DodgerBlue
#property indicator_level1 0.3
#property indicator_level2 0.7
//---- input parameters
extern int DeMarkerPeriod=14;
//---- buffers
double DeMarkerBuffer[];
double ExtMaxBuffer[];
double ExtMinBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- 2 additional buffers are used for counting.
   IndicatorBuffers(3);
   SetIndexBuffer(0,DeMarkerBuffer);
   SetIndexBuffer(1,ExtMaxBuffer);
   SetIndexBuffer(2,ExtMinBuffer);
//---- indicator line
   SetIndexStyle(0,DRAW_LINE);
//---- name for DataWindow and indicator subwindow label
   short_name="DeM("+DeMarkerPeriod+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
//---- first values aren't drawn
   SetIndexDrawBegin(0,DeMarkerPeriod);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| DeMarker                                                         |
//+------------------------------------------------------------------+
int start()
  {
   double dNum;
   int    i,nCountedBars;
//---- insufficient data
   if(Bars<=DeMarkerPeriod) return(0);
//---- bars count that does not changed after last indicator launch.
   nCountedBars=IndicatorCounted();
//----
   ExtMaxBuffer[Bars-1]=0.0;
   ExtMinBuffer[Bars-1]=0.0;
   if(nCountedBars>2) i=Bars-nCountedBars-1;
   else               i=Bars-2;
   while(i>=0)
     {
      dNum=High[i]-High[i+1];
      if(dNum<0.0) dNum=0.0;
      ExtMaxBuffer[i]=dNum; 
      
      dNum=Low[i+1]-Low[i];
      if(dNum<0.0) dNum=0.0;
      ExtMinBuffer[i]=dNum; 
 
      i--;
     }   
//---- initial zero
   if(nCountedBars<1)
      for(i=1; i<=DeMarkerPeriod; i++)
         DeMarkerBuffer[Bars-i]=0.0;   
//----
   i=Bars-DeMarkerPeriod-1;
   if(nCountedBars>=DeMarkerPeriod) i=Bars-nCountedBars-1;
   while(i>=0)
     {
[b]      dNum=iMAOnArray(ExtMaxBuffer,0,DeMarkerPeriod,0,MODE_SMA,i)+
           iMAOnArray(ExtMinBuffer,0,DeMarkerPeriod,0,MODE_SMA,i);[/b]
      if(dNum!=0.0)
         [b]DeMarkerBuffer[i]=iMAOnArray(ExtMaxBuffer,0,DeMarkerPeriod,0,MODE_SMA,i)/dNum;[/b]
      else
         DeMarkerBuffer[i]=0.0;
      
      i--;
     }
   return(0);
  }
//+------------------------------------------------------------------+
"Los sistemas de trading pueden funcionar en ciertas condiciones de mercado todo el tiempo, en todas las condiciones de mercado en algún momento del tiempo, pero nunca en todas las condiciones de mercado todo el tiempo."
Avatar de Usuario
Gamelu
Mensajes: 787
Registrado: 21 May 2009 16:49

Re: Necesito indicador Demarker exponencial MT4

Mensaje por Gamelu »

Que bueno X, mañana si saco tiempo lo pongo en marcha, de donde has sacado el codigo, no encontraba el indicador en la carpera "indicators", curioso
Muchas gracias,
Un saludo

P.D: Al compilar me da un error "b variable not defined", que representa esa b entre corchetes¿?
Última edición por Gamelu el 21 Sep 2010 23:32, editado 1 vez en total.
Avatar de Usuario
Gamelu
Mensajes: 787
Registrado: 21 May 2009 16:49

Re: Necesito indicador Demarker exponencial MT4

Mensaje por Gamelu »

Ya esta en marcha,
Sobra lo siguiente,

Código: Seleccionar todo

[b][/b]
El indicador queda asi:

Código: Seleccionar todo

//+------------------------------------------------------------------+
//|                                                     DeMarker.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 1
#property indicator_buffers 1
#property indicator_color1 DodgerBlue
#property indicator_level1 0.3
#property indicator_level2 0.7
//---- input parameters
extern int DeMarkerPeriod=14;
//---- buffers
double DeMarkerBuffer[];
double ExtMaxBuffer[];
double ExtMinBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- 2 additional buffers are used for counting.
   IndicatorBuffers(3);
   SetIndexBuffer(0,DeMarkerBuffer);
   SetIndexBuffer(1,ExtMaxBuffer);
   SetIndexBuffer(2,ExtMinBuffer);
//---- indicator line
   SetIndexStyle(0,DRAW_LINE);
//---- name for DataWindow and indicator subwindow label
   short_name="DeM("+DeMarkerPeriod+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
//---- first values aren't drawn
   SetIndexDrawBegin(0,DeMarkerPeriod);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| DeMarker                                                         |
//+------------------------------------------------------------------+
int start()
  {
   double dNum;
   int    i,nCountedBars;
//---- insufficient data
   if(Bars<=DeMarkerPeriod) return(0);
//---- bars count that does not changed after last indicator launch.
   nCountedBars=IndicatorCounted();
//----
   ExtMaxBuffer[Bars-1]=0.0;
   ExtMinBuffer[Bars-1]=0.0;
   if(nCountedBars>2) i=Bars-nCountedBars-1;
   else               i=Bars-2;
   while(i>=0)
     {
      dNum=High[i]-High[i+1];
      if(dNum<0.0) dNum=0.0;
      ExtMaxBuffer[i]=dNum; 
      
      dNum=Low[i+1]-Low[i];
      if(dNum<0.0) dNum=0.0;
      ExtMinBuffer[i]=dNum; 

      i--;
     }   
//---- initial zero
   if(nCountedBars<1)
      for(i=1; i<=DeMarkerPeriod; i++)
         DeMarkerBuffer[Bars-i]=0.0;   
//----
   i=Bars-DeMarkerPeriod-1;
   if(nCountedBars>=DeMarkerPeriod) i=Bars-nCountedBars-1;
   while(i>=0)
     {
      dNum=iMAOnArray(ExtMaxBuffer,0,DeMarkerPeriod,0,MODE_EMA,i)+
           iMAOnArray(ExtMinBuffer,0,DeMarkerPeriod,0,MODE_EMA,i);
      if(dNum!=0.0)
         DeMarkerBuffer[i]=iMAOnArray(ExtMaxBuffer,0,DeMarkerPeriod,0,MODE_EMA,i)/dNum;
      else
         DeMarkerBuffer[i]=0.0;
      
      i--;
     }
   return(0);
  }
//+------------------------------------------------------------------+
Si te ha gustado este hilo del Foro, ¡compártelo en redes!


Responder

Volver a “Indicadores”