Página 1 de 1
Indicador custom a CSV en el backtest. Como?
Publicado: 15 Jul 2014 22:57
por zamio
Hola, a ver si alguien me podría ayudar con un script o algo que me saque los datos de un indicador Custom cuando paso un backtest.
O alguno que este ya programado para modificar, no doy con la tecla.
Saludos.
Re: Indicador custom a CSV en el backtest. Como?
Publicado: 16 Jul 2014 12:28
por mascara
¿En qué plataforma?
Re: Indicador custom a CSV en el backtest. Como?
Publicado: 16 Jul 2014 12:49
por zamio
Joe que cacho BURRO!!!! En Mt4, ha sido fallo mio y del foro!!! xD
El post esta en el apartado Metatrader, bien podría ser Mt4 o Mt5 pero bueno es para Mt4 el problema en el que he caído a cuenta es que no es fácil ver donde esta el tema abierto.
Gracias.
Re: Indicador custom a CSV en el backtest. Como?
Publicado: 22 Jul 2014 11:18
por zamio
Puede alguien ayudarme?

Re: Indicador custom a CSV en el backtest. Como?
Publicado: 24 Jul 2014 00:04
por INtrader
zamio escribió:Hola, a ver si alguien me podría ayudar con un script o algo que me saque los datos de un indicador Custom cuando paso un backtest.
O alguno que este ya programado para modificar, no doy con la tecla.
Saludos.
Hola zamio,
Tienes ya algo de código??? Qué problema tienes??
He encontrado esto en FF, tal vez te sirva...
Código: Seleccionar todo
#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#property indicator_chart_window
extern int length = 100; // The amount of bars sent to be processed
double ExtMap[]; // Chart buffer
string nameData;
int init()
{
nameData = Symbol()+".txt"; // name of the data file to be sent
return(0);
}
int start()
{
static int old_bars = 0; // remember the amount of bars already known
if (old_bars != Bars) // if a new bar is received
{
write_data(); // write the data file
}
old_bars = Bars; // remember how many bars are known
return(0);
}
//+------------------------------------------------------------------+
void write_data()
{
int handle;
handle = FileOpen(nameData, FILE_CSV|FILE_WRITE,';');
if(handle < 1)
{
Comment("Creation of "+nameData+" failed. Error #", GetLastError());
return(0);
}
FileWrite(handle, ServerAddress(), Symbol(), Period()); // heading
FileWrite(handle, "DATE","TIME","HIGH","LOW","CLOSE","OPEN","VOLUME"); // heading
int i;
for (i=length-1; i>=0; i--)
{
FileWrite(handle, TimeToStr(Time, TIME_DATE), TimeToStr(Time, TIME_SECONDS),
High, Low, Close, Open, Volume,iCustom(NULL,0,"JJMA",5,100,0,0,i));
}
FileClose(handle);
Comment("");
Comment("File "+nameData+" has been created. "+TimeToStr(TimeCurrent(), TIME_SECONDS) );
return(0);
}
Un saludo
INtrader
Re: Indicador custom a CSV en el backtest. Como?
Publicado: 24 Jul 2014 00:26
por zamio
Hola, tal como esta no me ha dejado ni compilarlo, bueno me he puesto a modificarlo.
Consigo esto:
Código: Seleccionar todo
#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#property indicator_chart_window
extern int length = 100; // The amount of bars sent to be processed
double ExtMap[]; // Chart buffer
string nameData;
int init()
{
nameData = Symbol()+".CSV"; // name of the data file to be sent
return(0);
}
int start()
{
static int old_bars = 0; // remember the amount of bars already known
if (old_bars != Bars) // if a new bar is received
{
write_data(); // write the data file
}
old_bars = Bars; // remember how many bars are known
return(0);
}
//+------------------------------------------------------------------+
void write_data()
{
int handle;
handle = FileOpen(nameData, FILE_CSV|FILE_WRITE,',');
if(handle < 1)
{
Comment("Creation of "+nameData+" failed. Error #", GetLastError());
return(0);
}
FileWrite(handle, ServerAddress(), Symbol(), Period()); // heading
FileWrite(handle, "DATE","TIME","HIGH","LOW","CLOSE","OPEN","VOLUME"); // heading
int i;
for (i=length-1; i>=0; i--)
{
FileWrite(handle, TimeToStr(Time[i], TIME_DATE), TimeToStr(Time[i], TIME_SECONDS),
High[i], Low[i], Close[i], Open[i], Volume[i],iCustom(NULL,0,"JJMA",5,100,0,0,i));
}
FileClose(handle);
Comment("");
Comment("File "+nameData+" has been created. "+TimeToStr(TimeCurrent(), TIME_SECONDS) );
return(0);
}
Consigo extraer los datos desde la ultima fecha hacia atrás, no he probado si lo hace de algún indicador, pero me valdría, no creo que sea tan difícil, ahora el problema es que no le da la gana de leer los datos del backtest
Voy a seguir trasteando. Muchas gracias.
Re: Indicador custom a CSV en el backtest. Como?
Publicado: 24 Jul 2014 15:49
por zamio
Ya esta conseguido, ahora cuando tenga tiempo pongo el código y la manera de implementarlo como indicador o en un Ea directamente.
Gracias a los participantes.
Saludos.