Indicadores Multi Timeframe - página 669

 
alessandromagno:
Hola, ¿alguien puede hacer de este indi un indi MTF?

¡¡¡Muchas gracias!!!

wprv2.mq4

alessandromagno

Pruébalo ahora

Versión actualizada publicada aquí : https://www.mql5.com/en/forum/173574

Archivos adjuntos:
wprv2_mtf.mq4  8 kb
 

¡Ayuda, por favor!

Necesito la configuración de la zona horaria.

Archivos adjuntos:
 
DMNIK:
Ayuda, por favor, necesito la configuración de la zona horaria.

Dmnik, ese indicador es una versión descompilada alguna posibilidad de que tengas el código fuente original.

 

Actualizado nuevo indicador de tendencia : newtrend_mtf_nmc.mq4

Originalmente fue publicado aquí : https://www.mql5.com/en/forum/173574/page389

Archivos adjuntos:
 
vaider:
newtrend.mq4mtf version_ ¡Gracias!

Vaider, lo hizo mtf.

Versión actualizada publicada aquí : https://www.mql5.com/en/forum/173574

Archivos adjuntos:
 

Actualización de 3 barras de stop loss : 3barstoploss_mtf_nmc.mq4

Original fue publicado aquí : https://www.mql5.com/en/forum/173574/page389

Archivos adjuntos:
 
niqcom:
Hola, ¿puede hacer este indi un MTF ??? Por favor.....

3barstoploss.mq4

¡Muchas gracias !

niqcom

Aquí hay una versión de múltiples marcos de tiempo de ese indicador

Versión actualizada publicada aquí : https://www.mql5.com/en/forum/173574

Archivos adjuntos:
 

Hola programadores, sólo una pregunta sobre la marcha.

A partir de un backtest encontré particularmente interesante este filtro laguerre. ¿Se repinta? Lo pregunto porque veo la variable "lookback" en las opciones.

¿Es una especie de indicador adaptativo/repintado?

//------------------------------------------------------------------

//

//------------------------------------------------------------------

#property indicator_chart_window

#property indicator_buffers 3

#property indicator_color1 LimeGreen

#property indicator_color2 Orange

#property indicator_color3 Orange

#property indicator_width1 2

#property indicator_width2 2

#property indicator_width3 2

extern string TimeFrame = "Current time frame";

extern int LookBack = 20;

extern int Median = 5;

extern int Price = PRICE_MEDIAN;

double Filter[];

double Filterda[];

double Filterdb[];

double Diff[];

double Slope[];

double sortDiff[];

string indicatorFileName;

bool returnBars;

int timeFrame;

//------------------------------------------------------------------

//

//------------------------------------------------------------------

//

//

//

//

//

int init()

{

IndicatorBuffers(5);

SetIndexBuffer(0,Filter);

SetIndexBuffer(1,Filterda);

SetIndexBuffer(2,Filterdb);

SetIndexBuffer(3,Diff);

SetIndexBuffer(4,Slope);

ArrayResize(sortDiff,Median);

indicatorFileName = WindowExpertName();

returnBars = TimeFrame == "returnBars"; if (returnBars) return(0);

timeFrame = stringToTimeFrame(TimeFrame);

return (0);

}

//------------------------------------------------------------------

//

//------------------------------------------------------------------

//

//

//

//

//

int start()

{

int counted_bars=IndicatorCounted();

if(counted_bars<0) return(-1);

if(counted_bars>0) counted_bars--;

int limit = MathMin(Bars-counted_bars,Bars-1);

if (returnBars) { Filter[0] = limit+1; return(0); }

if (timeFrame!=Period())

{

limit = MathMax(limit,MathMin(Bars-1,iCustom(NULL,timeFrame,indicatorFileName,"returnBars",0,0)*timeFrame/Period()));

if (Slope[limit]==-1) CleanPoint(limit,Filterda,Filterdb);

for (int i=limit; i>=0; i--)

{

int y = iBarShift(NULL,timeFrame,Time);

Filter = iCustom(NULL,timeFrame,indicatorFileName,"calculateValue",LookBack,Median,Price,0,y);

Slope = iCustom(NULL,timeFrame,indicatorFileName,"calculateValue",LookBack,Median,Price,4,y);

Filterda = EMPTY_VALUE;

Filterdb = EMPTY_VALUE;

if (Slope == -1) PlotPoint(i,Filterda,Filterdb,Filter);

}

return(0);

}

//

//

//

//

//

if (Slope[limit]==-1) CleanPoint(limit,Filterda,Filterdb);

for (i=limit; i>=0; i--)

{

double price = iMA(NULL,0,1,0,MODE_SMA,Price,i);

Diff = MathAbs(price - Filter);

double hi = Diff[ArrayMaximum(Diff,LookBack,i)];

double lo = Diff[ArrayMinimum(Diff,LookBack,i)];

double alpha = 0;

if (hi!=lo)

{

for (int j=0; j<Median; j++) sortDiff[j] = (Diff-lo)/(hi-lo);

ArraySort(sortDiff,WHOLE_ARRAY,0,MODE_ASCEND);

if (MathMod(Median,2.0) != 0) alpha = sortDiff[Median/2];

else alpha = (sortDiff[Median/2]+sortDiff[(Median/2)-1])/2;

}

Filter = iLaGuerreFilter(price, 1.0-alpha, i, 0);

Filterda = EMPTY_VALUE;

Filterdb = EMPTY_VALUE;

Slope = Slope;

if (Filter>Filter) Slope = 1;

if (Filter<Filter) Slope = -1;

if (Slope == -1) PlotPoint(i,Filterda,Filterdb,Filter);

}

return (0);

}

//------------------------------------------------------------------

//

//------------------------------------------------------------------

//

//

//

//

//

double workLagFil[][4];

double iLaGuerreFilter(double price, double gamma, int i, int instanceNo=0)

{

if (ArrayRange(workLagFil,0)!=Bars) ArrayResize(workLagFil,Bars); i=Bars-i-1; instanceNo*=4;

if (gamma<=0) return(price);

//

//

//

//

//

workLagFil = (1.0 - gamma)*price + gamma*workLagFil;

workLagFil = -gamma*workLagFil + workLagFil + gamma*workLagFil;

workLagFil = -gamma*workLagFil + workLagFil + gamma*workLagFil;

workLagFil = -gamma*workLagFil + workLagFil + gamma*workLagFil;

//

//

//

//

//

return((workLagFil+2.0*workLagFil+2.0*workLagFil+workLagFil)/6.0);

}

//-------------------------------------------------------------------

//

//-------------------------------------------------------------------

//

//

//

//

//

void CleanPoint(int i,double& first[],double& second[])

{

if ((second != EMPTY_VALUE) && (second != EMPTY_VALUE))

second = EMPTY_VALUE;

else

if ((first != EMPTY_VALUE) && (first != EMPTY_VALUE) && (first == EMPTY_VALUE))

first = EMPTY_VALUE;

}

//

//

//

//

//

void PlotPoint(int i,double& first[],double& second[],double& from[])

{

if (first == EMPTY_VALUE)

{

if (first == EMPTY_VALUE) {

first = from;

first = from;

second = EMPTY_VALUE;

}

else {

second = from;

second = from;

first = EMPTY_VALUE;

}

}

else

{

first = from;

second = EMPTY_VALUE;

}

}

//-------------------------------------------------------------------

//

//-------------------------------------------------------------------

//

//

//

//

//

string sTfTable[] = {"M1","M5","M15","M30","H1","H4","D1","W1","MN"};

int iTfTable[] = {1,5,15,30,60,240,1440,10080,43200};

//

//

//

//

//

int stringToTimeFrame(string tfs)

{

tfs = stringUpperCase(tfs);

for (int i=ArraySize(iTfTable)-1; i>=0; i--)

if (tfs==sTfTable || tfs==""+iTfTable) return(MathMax(iTfTable,Period()));

return(Period());

}

//

//

//

//

//

string stringUpperCase(string str)

{

string s = str;

for (int length=StringLen(str)-1; length>=0; length--)

{

int tchar = StringGetChar(s, length);

if((tchar > 96 && tchar 223 && tchar < 256))

s = StringSetChar(s, length, tchar - 32);

else if(tchar > -33 && tchar < 0)

s = StringSetChar(s, length, tchar + 224);

}

return(s);

}

 
thefxpros:
Hola programadores, solo una pregunta al vuelo.

A partir de un backtest encontré particularmente interesante este filtro laguerre. ¿Se repite? Lo pregunto porque veo la variable "lookback" en las opciones.

¿Es una especie de indicador adaptativo/repintado?

//------------------------------------------------------------------

//

//------------------------------------------------------------------

#property indicator_chart_window

#property indicator_buffers 3

#property indicator_color1 LimeGreen

#property indicator_color2 Orange

#property indicator_color3 Orange

#property indicator_width1 2

#property indicator_width2 2

#property indicator_width3 2

extern string TimeFrame = "Current time frame";

extern int LookBack = 20;

extern int Median = 5;

extern int Price = PRICE_MEDIAN;

double Filter[];

double Filterda[];

double Filterdb[];

double Diff[];

double Slope[];

double sortDiff[];

string indicatorFileName;

bool returnBars;

int timeFrame;

//------------------------------------------------------------------

//

//------------------------------------------------------------------

//

//

//

//

//

int init()

{

IndicatorBuffers(5);

SetIndexBuffer(0,Filter);

SetIndexBuffer(1,Filterda);

SetIndexBuffer(2,Filterdb);

SetIndexBuffer(3,Diff);

SetIndexBuffer(4,Slope);

ArrayResize(sortDiff,Median);

indicatorFileName = WindowExpertName();

returnBars = TimeFrame == "returnBars"; if (returnBars) return(0);

timeFrame = stringToTimeFrame(TimeFrame);

return (0);

}

//------------------------------------------------------------------

//

//------------------------------------------------------------------

//

//

//

//

//

int start()

{

int counted_bars=IndicatorCounted();

if(counted_bars<0) return(-1);

if(counted_bars>0) counted_bars--;

int limit = MathMin(Bars-counted_bars,Bars-1);

if (returnBars) { Filter[0] = limit+1; return(0); }

if (timeFrame!=Period())

{

limit = MathMax(limit,MathMin(Bars-1,iCustom(NULL,timeFrame,indicatorFileName,"returnBars",0,0)*timeFrame/Period()));

if (Slope[limit]==-1) CleanPoint(limit,Filterda,Filterdb);

for (int i=limit; i>=0; i--)

{

int y = iBarShift(NULL,timeFrame,Time);

Filter = iCustom(NULL,timeFrame,indicatorFileName,"calculateValue",LookBack,Median,Price,0,y);

Slope = iCustom(NULL,timeFrame,indicatorFileName,"calculateValue",LookBack,Median,Price,4,y);

Filterda = EMPTY_VALUE;

Filterdb = EMPTY_VALUE;

if (Slope == -1) PlotPoint(i,Filterda,Filterdb,Filter);

}

return(0);

}

//

//

//

//

//

if (Slope[limit]==-1) CleanPoint(limit,Filterda,Filterdb);

for (i=limit; i>=0; i--)

{

double price = iMA(NULL,0,1,0,MODE_SMA,Price,i);

Diff = MathAbs(price - Filter);

double hi = Diff[ArrayMaximum(Diff,LookBack,i)];

double lo = Diff[ArrayMinimum(Diff,LookBack,i)];

double alpha = 0;

if (hi!=lo)

{

for (int j=0; j<Median; j++) sortDiff[j] = (Diff-lo)/(hi-lo);

ArraySort(sortDiff,WHOLE_ARRAY,0,MODE_ASCEND);

if (MathMod(Median,2.0) != 0) alpha = sortDiff[Median/2];

else alpha = (sortDiff[Median/2]+sortDiff[(Median/2)-1])/2;

}

Filter = iLaGuerreFilter(price, 1.0-alpha, i, 0);

Filterda = EMPTY_VALUE;

Filterdb = EMPTY_VALUE;

Slope = Slope;

if (Filter>Filter) Slope = 1;

if (Filter<Filter) Slope = -1;

if (Slope == -1) PlotPoint(i,Filterda,Filterdb,Filter);

}

return (0);

}

//------------------------------------------------------------------

//

//------------------------------------------------------------------

//

//

//

//

//

double workLagFil[][4];

double iLaGuerreFilter(double price, double gamma, int i, int instanceNo=0)

{

if (ArrayRange(workLagFil,0)!=Bars) ArrayResize(workLagFil,Bars); i=Bars-i-1; instanceNo*=4;

if (gamma<=0) return(price);

//

//

//

//

//

workLagFil = (1.0 - gamma)*price + gamma*workLagFil;

workLagFil = -gamma*workLagFil + workLagFil + gamma*workLagFil;

workLagFil = -gamma*workLagFil + workLagFil + gamma*workLagFil;

workLagFil = -gamma*workLagFil + workLagFil + gamma*workLagFil;

//

//

//

//

//

return((workLagFil+2.0*workLagFil+2.0*workLagFil+workLagFil)/6.0);

}

//-------------------------------------------------------------------

//

//-------------------------------------------------------------------

//

//

//

//

//

void CleanPoint(int i,double& first[],double& second[])

{

if ((second != EMPTY_VALUE) && (second != EMPTY_VALUE))

second = EMPTY_VALUE;

else

if ((first != EMPTY_VALUE) && (first != EMPTY_VALUE) && (first == EMPTY_VALUE))

first = EMPTY_VALUE;

}

//

//

//

//

//

void PlotPoint(int i,double& first[],double& second[],double& from[])

{

if (first == EMPTY_VALUE)

{

if (first == EMPTY_VALUE) {

first = from;

first = from;

second = EMPTY_VALUE;

}

else {

second = from;

second = from;

first = EMPTY_VALUE;

}

}

else

{

first = from;

second = EMPTY_VALUE;

}

}

//-------------------------------------------------------------------

//

//-------------------------------------------------------------------

//

//

//

//

//

string sTfTable[] = {"M1","M5","M15","M30","H1","H4","D1","W1","MN"};

int iTfTable[] = {1,5,15,30,60,240,1440,10080,43200};

//

//

//

//

//

int stringToTimeFrame(string tfs)

{

tfs = stringUpperCase(tfs);

for (int i=ArraySize(iTfTable)-1; i>=0; i--)

if (tfs==sTfTable || tfs==""+iTfTable) return(MathMax(iTfTable,Period()));

return(Period());

}

//

//

//

//

//

string stringUpperCase(string str)

{

string s = str;

for (int length=StringLen(str)-1; length>=0; length--)

{

int tchar = StringGetChar(s, length);

if((tchar > 96 && tchar 223 && tchar < 256))

s = StringSetChar(s, length, tchar - 32);

else if(tchar > -33 && tchar < 0)

s = StringSetChar(s, length, tchar + 224);

}

return(s);

}

Thefxpros, yo diría que es adaptativo pero no repinta.

 
thefxpros:
Hola programadores, solo una pregunta al vuelo.

A partir de un backtest encontré particularmente interesante este filtro laguerre. ¿Se repite? Lo pregunto porque veo la variable "lookback" en las opciones.

¿Es una especie de indicador adaptativo/repintado?

//------------------------------------------------------------------

//

//------------------------------------------------------------------

#property indicator_chart_window

#property indicator_buffers 3

#property indicator_color1 LimeGreen

#property indicator_color2 Orange

#property indicator_color3 Orange

#property indicator_width1 2

#property indicator_width2 2

#property indicator_width3 2

extern string TimeFrame = "Current time frame";

extern int LookBack = 20;

extern int Median = 5;

extern int Price = PRICE_MEDIAN;

double Filter[];

double Filterda[];

double Filterdb[];

double Diff[];

double Slope[];

double sortDiff[];

string indicatorFileName;

bool returnBars;

int timeFrame;

//------------------------------------------------------------------

//

//------------------------------------------------------------------

//

//

//

//

//

int init()

{

IndicatorBuffers(5);

SetIndexBuffer(0,Filter);

SetIndexBuffer(1,Filterda);

SetIndexBuffer(2,Filterdb);

SetIndexBuffer(3,Diff);

SetIndexBuffer(4,Slope);

ArrayResize(sortDiff,Median);

indicatorFileName = WindowExpertName();

returnBars = TimeFrame == "returnBars"; if (returnBars) return(0);

timeFrame = stringToTimeFrame(TimeFrame);

return (0);

}

//------------------------------------------------------------------

//

//------------------------------------------------------------------

//

//

//

//

//

int start()

{

int counted_bars=IndicatorCounted();

if(counted_bars<0) return(-1);

if(counted_bars>0) counted_bars--;

int limit = MathMin(Bars-counted_bars,Bars-1);

if (returnBars) { Filter[0] = limit+1; return(0); }

if (timeFrame!=Period())

{

limit = MathMax(limit,MathMin(Bars-1,iCustom(NULL,timeFrame,indicatorFileName,"returnBars",0,0)*timeFrame/Period()));

if (Slope[limit]==-1) CleanPoint(limit,Filterda,Filterdb);

for (int i=limit; i>=0; i--)

{

int y = iBarShift(NULL,timeFrame,Time);

Filter = iCustom(NULL,timeFrame,indicatorFileName,"calculateValue",LookBack,Median,Price,0,y);

Slope = iCustom(NULL,timeFrame,indicatorFileName,"calculateValue",LookBack,Median,Price,4,y);

Filterda = EMPTY_VALUE;

Filterdb = EMPTY_VALUE;

if (Slope == -1) PlotPoint(i,Filterda,Filterdb,Filter);

}

return(0);

}

//

//

//

//

//

if (Slope[limit]==-1) CleanPoint(limit,Filterda,Filterdb);

for (i=limit; i>=0; i--)

{

double price = iMA(NULL,0,1,0,MODE_SMA,Price,i);

Diff = MathAbs(price - Filter);

double hi = Diff[ArrayMaximum(Diff,LookBack,i)];

double lo = Diff[ArrayMinimum(Diff,LookBack,i)];

double alpha = 0;

if (hi!=lo)

{

for (int j=0; j<Median; j++) sortDiff[j] = (Diff-lo)/(hi-lo);

ArraySort(sortDiff,WHOLE_ARRAY,0,MODE_ASCEND);

if (MathMod(Median,2.0) != 0) alpha = sortDiff[Median/2];

else alpha = (sortDiff[Median/2]+sortDiff[(Median/2)-1])/2;

}

Filter = iLaGuerreFilter(price, 1.0-alpha, i, 0);

Filterda = EMPTY_VALUE;

Filterdb = EMPTY_VALUE;

Slope = Slope;

if (Filter>Filter) Slope = 1;

if (Filter<Filter) Slope = -1;

if (Slope == -1) PlotPoint(i,Filterda,Filterdb,Filter);

}

return (0);

}

//------------------------------------------------------------------

//

//------------------------------------------------------------------

//

//

//

//

//

double workLagFil[][4];

double iLaGuerreFilter(double price, double gamma, int i, int instanceNo=0)

{

if (ArrayRange(workLagFil,0)!=Bars) ArrayResize(workLagFil,Bars); i=Bars-i-1; instanceNo*=4;

if (gamma<=0) return(price);

//

//

//

//

//

workLagFil = (1.0 - gamma)*price + gamma*workLagFil;

workLagFil = -gamma*workLagFil + workLagFil + gamma*workLagFil;

workLagFil = -gamma*workLagFil + workLagFil + gamma*workLagFil;

workLagFil = -gamma*workLagFil + workLagFil + gamma*workLagFil;

//

//

//

//

//

return((workLagFil+2.0*workLagFil+2.0*workLagFil+workLagFil)/6.0);

}

//-------------------------------------------------------------------

//

//-------------------------------------------------------------------

//

//

//

//

//

void CleanPoint(int i,double& first[],double& second[])

{

if ((second != EMPTY_VALUE) && (second != EMPTY_VALUE))

second = EMPTY_VALUE;

else

if ((first != EMPTY_VALUE) && (first != EMPTY_VALUE) && (first == EMPTY_VALUE))

first = EMPTY_VALUE;

}

//

//

//

//

//

void PlotPoint(int i,double& first[],double& second[],double& from[])

{

if (first == EMPTY_VALUE)

{

if (first == EMPTY_VALUE) {

first = from;

first = from;

second = EMPTY_VALUE;

}

else {

second = from;

second = from;

first = EMPTY_VALUE;

}

}

else

{

first = from;

second = EMPTY_VALUE;

}

}

//-------------------------------------------------------------------

//

//-------------------------------------------------------------------

//

//

//

//

//

string sTfTable[] = {"M1","M5","M15","M30","H1","H4","D1","W1","MN"};

int iTfTable[] = {1,5,15,30,60,240,1440,10080,43200};

//

//

//

//

//

int stringToTimeFrame(string tfs)

{

tfs = stringUpperCase(tfs);

for (int i=ArraySize(iTfTable)-1; i>=0; i--)

if (tfs==sTfTable || tfs==""+iTfTable) return(MathMax(iTfTable,Period()));

return(Period());

}

//

//

//

//

//

string stringUpperCase(string str)

{

string s = str;

for (int length=StringLen(str)-1; length>=0; length--)

{

int tchar = StringGetChar(s, length);

if((tchar > 96 && tchar 223 && tchar < 256))

s = StringSetChar(s, length, tchar - 32);

else if(tchar > -33 && tchar < 0)

s = StringSetChar(s, length, tchar + 224);

}

return(s);

}

thefxpros

Hacer un indicador adaptativo no significa hacerlo repintar Adaptar nunca ha significado repintar (entre un montón de indicadores adaptativos, ahora mismo no recuerdo ninguno que repintara). Adaptar es algo completamente distinto.

En cuanto a ese laguerre : no, no repinta. El lookBack es simplemente un período que se utiliza para muestrear los datos que luego se utilizará para la adaptación (y es el uso de una especie de " estocástico crudo" del precio a los valores anteriores laguerre diferencias / momentos para la adaptación)

Razón de la queja: