Está perdiendo oportunidades comerciales:
- Aplicaciones de trading gratuitas
- 8 000+ señales para copiar
- Noticias económicas para analizar los mercados financieros
Registro
Entrada
Usted acepta la política del sitio web y las condiciones de uso
Si no tiene cuenta de usuario, regístrese
Hola mladen,
Creo que me estoy volviendo loco, aquí está mi código cambiado del PeriodConverter.
//+------------------------------------------------------------------+
//| PeriodConverter.mq4 |
//| Copyright 2006-2014, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "2006-2014, MetaQuotes Software Corp."
#property link "http://www.mql4.com"
#property description "Period Converter to updated format of history base"
#property strict
#property show_inputs
#include
input int StartHour = 9;
input int StartMinute = 0;
input int CloseHour = 17;
input int CloseMinute = 30;
int ExtHandle=-1;
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
datetime time0;
ulong last_fpos=0;
long last_volume=0;
int i,start_pos;
int hwnd=0,cnt=0;
//---- History header
int file_version=401;
string c_copyright;
string c_symbol=Symbol();
int i_period=Period();
int i_digits=Digits;
int i_unused[13];
MqlRates rate;
//---
ExtHandle=FileOpenHistory("TT_"+c_symbol+(string)i_period+".hst",FILE_BIN|FILE_WRITE|FILE_SHARE_WRITE|FILE_SHARE_READ|FILE_ANSI);
if(ExtHandle<0)
return;
c_copyright="(C)opyright 2003, MetaQuotes Software Corp.";
ArrayInitialize(i_unused,0);
//--- write history file header
FileWriteInteger(ExtHandle,file_version,LONG_VALUE);
FileWriteString(ExtHandle,c_copyright,64);
FileWriteString(ExtHandle,c_symbol,12);
FileWriteInteger(ExtHandle,i_period,LONG_VALUE);
FileWriteInteger(ExtHandle,i_digits,LONG_VALUE);
FileWriteInteger(ExtHandle,0,LONG_VALUE);
FileWriteInteger(ExtHandle,0,LONG_VALUE);
FileWriteArray(ExtHandle,i_unused,0,13);
//--- write history file
start_pos=Bars-1;
rate.open=Open[start_pos];
rate.low=Low[start_pos];
rate.high=High[start_pos];
rate.tick_volume=(long)Volume[start_pos];
rate.spread=0;
rate.real_volume=0;
//--- normalize open time
rate.time=Time[start_pos];
for(i=start_pos-1; i>=0; i--)
{
if(IsStopped())
break;
time0=Time;
//--- history may be updated
if(i==0)
{
//--- modify index if history was updated
if(RefreshRates())
i=iBarShift(NULL,0,time0);
}
//---
if((time0>=rate.time || i==0) && MainTime(time0)==true)
{
if(i==0)
{
rate.tick_volume+=(long)Volume[0];
if(rate.low>Low[0])
rate.low=Low[0];
if(rate.high<High[0])
rate.high=High[0];
rate.close=Close[0];
}
last_fpos=FileTell(ExtHandle);
last_volume=(long)Volume;
FileWriteStruct(ExtHandle,rate);
cnt++;
if(time0>=rate.time)
{
rate.time=time0;
rate.open=Open;
rate.low=Low;
rate.high=High;
rate.close=Close;
rate.tick_volume=last_volume;
}
}
else if(MainTime(time0)==true)
{
rate.tick_volume+=(long)Volume;
if(rate.low>Low)
rate.low=Low;
if(rate.high<High)
rate.high=High;
rate.close=Close;
}
}
FileFlush(ExtHandle);
Print(cnt," record(s) written");
//--- collect incoming ticks
datetime last_time=LocalTime()-5;
while(!IsStopped())
{
datetime cur_time=LocalTime();
//--- check for new rates
if(RefreshRates())
{
time0=Time[0];
FileSeek(ExtHandle,last_fpos,SEEK_SET);
//--- is there current bar?
if(time0<rate.time && MainTime(time0)==true)
{
rate.tick_volume+=(long)Volume[0]-last_volume;
last_volume=(long)Volume[0];
if(rate.low>Low[0])
rate.low=Low[0];
if(rate.high<High[0])
rate.high=High[0];
rate.close=Close[0];
}
else if(MainTime(time0)==true)
{
//--- no, there is new bar
rate.tick_volume+=(long)Volume[1]-last_volume;
if(rate.low>Low[1])
rate.low=Low[1];
if(rate.high<High[1])
rate.high=High[1];
//--- write previous bar remains
FileWriteStruct(ExtHandle,rate);
last_fpos=FileTell(ExtHandle);
//----
rate.time=time0;
rate.open=Open[0];
rate.low=Low[0];
rate.high=High[0];
rate.close=Close[0];
rate.tick_volume=(long)Volume[0];
last_volume=rate.tick_volume;
}
//----
FileWriteStruct(ExtHandle,rate);
FileFlush(ExtHandle);
//---
if(hwnd==0)
{
hwnd=WindowHandle(Symbol(),i_period);
if(hwnd!=0)
Print("Chart window detected");
}
//--- refresh window not frequently than 1 time in 2 seconds
if(hwnd!=0 && cur_time-last_time>=2)
{
PostMessageA(hwnd,WM_COMMAND,33324,0);
last_time=cur_time;
}
}
Sleep(50);
}
//---
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
if(ExtHandle>=0)
{
FileClose(ExtHandle);
ExtHandle=-1;
}
//---
}
//+------------------------------------------------------------------+
bool MainTime(datetime time0)
{
datetime temp = time0 - 1 * 60 *60;
if(((TimeHour(temp) == StartHour && TimeMinute(temp) >= StartMinute) ||
TimeHour(temp) > StartHour) &&
(TimeHour(temp)< CloseHour ||
(TimeHour(temp) == CloseHour && TimeMinute(temp) < CloseMinute)))
{
Print(".......return (true) - Time0 = "+TimeToString(time0) + " tempTime = "+TimeToString(temp));
return(true);
}
else
{
Print("+++++++false - Time0 = "+TimeToString(time0) + " tempTime = "+TimeToString(temp));
return(false);
}
}
He añadido la función MainTime para seleccionar las barras que quiero mostrar en mi nuevo gráfico offline.
(También moví el tiempo por una hora pero eso no es importante).
Ahora cuando pruebo esto en un gráfico con 15046 barras (M5) de 0:00 (Starttime) - 12:00 (Closetime)
Estoy recibiendo mensajes de impresión correctos y al final la información, que 7596 barras fueron escritas.
Así que es aproximadamente la mitad del gráfico original y creo que todo ha funcionado bien.
Pero cuando abro el gráfico offline correspondiente se ve exactamente como el gráfico original con todas las barras.
No puedo entender este comportamiento.
Hola mladen,
Creo que me estoy volviendo loco, aquí está mi código cambiado del PeriodConverter.
//+------------------------------------------------------------------+
//| PeriodConverter.mq4 |
//| Copyright 2006-2014, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "2006-2014, MetaQuotes Software Corp."
#property link "http://www.mql4.com"
#property description "Period Converter to updated format of history base"
#property strict
#property show_inputs
#include
input int StartHour = 9;
input int StartMinute = 0;
input int CloseHour = 17;
input int CloseMinute = 30;
int ExtHandle=-1;
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
datetime time0;
ulong last_fpos=0;
long last_volume=0;
int i,start_pos;
int hwnd=0,cnt=0;
//---- History header
int file_version=401;
string c_copyright;
string c_symbol=Symbol();
int i_period=Period();
int i_digits=Digits;
int i_unused[13];
MqlRates rate;
//---
ExtHandle=FileOpenHistory("TT_"+c_symbol+(string)i_period+".hst",FILE_BIN|FILE_WRITE|FILE_SHARE_WRITE|FILE_SHARE_READ|FILE_ANSI);
if(ExtHandle<0)
return;
c_copyright="(C)opyright 2003, MetaQuotes Software Corp.";
ArrayInitialize(i_unused,0);
//--- write history file header
FileWriteInteger(ExtHandle,file_version,LONG_VALUE);
FileWriteString(ExtHandle,c_copyright,64);
FileWriteString(ExtHandle,c_symbol,12);
FileWriteInteger(ExtHandle,i_period,LONG_VALUE);
FileWriteInteger(ExtHandle,i_digits,LONG_VALUE);
FileWriteInteger(ExtHandle,0,LONG_VALUE);
FileWriteInteger(ExtHandle,0,LONG_VALUE);
FileWriteArray(ExtHandle,i_unused,0,13);
//--- write history file
start_pos=Bars-1;
rate.open=Open[start_pos];
rate.low=Low[start_pos];
rate.high=High[start_pos];
rate.tick_volume=(long)Volume[start_pos];
rate.spread=0;
rate.real_volume=0;
//--- normalize open time
rate.time=Time[start_pos];
for(i=start_pos-1; i>=0; i--)
{
if(IsStopped())
break;
time0=Time;
//--- history may be updated
if(i==0)
{
//--- modify index if history was updated
if(RefreshRates())
i=iBarShift(NULL,0,time0);
}
//---
if((time0>=rate.time || i==0) && MainTime(time0)==true)
{
if(i==0)
{
rate.tick_volume+=(long)Volume[0];
if(rate.low>Low[0])
rate.low=Low[0];
if(rate.high<High[0])
rate.high=High[0];
rate.close=Close[0];
}
last_fpos=FileTell(ExtHandle);
last_volume=(long)Volume;
FileWriteStruct(ExtHandle,rate);
cnt++;
if(time0>=rate.time)
{
rate.time=time0;
rate.open=Open;
rate.low=Low;
rate.high=High;
rate.close=Close;
rate.tick_volume=last_volume;
}
}
else if(MainTime(time0)==true)
{
rate.tick_volume+=(long)Volume;
if(rate.low>Low)
rate.low=Low;
if(rate.high<High)
rate.high=High;
rate.close=Close;
}
}
FileFlush(ExtHandle);
Print(cnt," record(s) written");
//--- collect incoming ticks
datetime last_time=LocalTime()-5;
while(!IsStopped())
{
datetime cur_time=LocalTime();
//--- check for new rates
if(RefreshRates())
{
time0=Time[0];
FileSeek(ExtHandle,last_fpos,SEEK_SET);
//--- is there current bar?
if(time0<rate.time && MainTime(time0)==true)
{
rate.tick_volume+=(long)Volume[0]-last_volume;
last_volume=(long)Volume[0];
if(rate.low>Low[0])
rate.low=Low[0];
if(rate.high<High[0])
rate.high=High[0];
rate.close=Close[0];
}
else if(MainTime(time0)==true)
{
//--- no, there is new bar
rate.tick_volume+=(long)Volume[1]-last_volume;
if(rate.low>Low[1])
rate.low=Low[1];
if(rate.high<High[1])
rate.high=High[1];
//--- write previous bar remains
FileWriteStruct(ExtHandle,rate);
last_fpos=FileTell(ExtHandle);
//----
rate.time=time0;
rate.open=Open[0];
rate.low=Low[0];
rate.high=High[0];
rate.close=Close[0];
rate.tick_volume=(long)Volume[0];
last_volume=rate.tick_volume;
}
//----
FileWriteStruct(ExtHandle,rate);
FileFlush(ExtHandle);
//---
if(hwnd==0)
{
hwnd=WindowHandle(Symbol(),i_period);
if(hwnd!=0)
Print("Chart window detected");
}
//--- refresh window not frequently than 1 time in 2 seconds
if(hwnd!=0 && cur_time-last_time>=2)
{
PostMessageA(hwnd,WM_COMMAND,33324,0);
last_time=cur_time;
}
}
Sleep(50);
}
//---
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
if(ExtHandle>=0)
{
FileClose(ExtHandle);
ExtHandle=-1;
}
//---
}
//+------------------------------------------------------------------+
bool MainTime(datetime time0)
{
datetime temp = time0 - 1 * 60 *60;
if(((TimeHour(temp) == StartHour && TimeMinute(temp) >= StartMinute) ||
TimeHour(temp) > StartHour) &&
(TimeHour(temp)< CloseHour ||
(TimeHour(temp) == CloseHour && TimeMinute(temp) < CloseMinute)))
{
Print(".......return (true) - Time0 = "+TimeToString(time0) + " tempTime = "+TimeToString(temp));
return(true);
}
else
{
Print("+++++++false - Time0 = "+TimeToString(time0) + " tempTime = "+TimeToString(temp));
return(false);
}
}
He añadido la función MainTime para seleccionar las barras que quiero mostrar en mi nuevo gráfico offline.
(También moví el tiempo por una hora pero eso no es importante).
Ahora cuando pruebo esto en un gráfico con 15046 barras (M5) de 0:00 (Starttime) - 12:00 (Closetime)
Estoy recibiendo mensajes de impresión correctos y al final la información, que 7596 barras fueron escritas.
Así que es aproximadamente la mitad del gráfico original y creo que todo ha funcionado bien.
Pero cuando abro el gráfico offline correspondiente se ve exactamente como el gráfico original con todas las barras.
No puedo entender ese comportamiento.Esto se debe a que está utilizando el nombre original y el marco de tiempo del símbolo. Tienes que cambiar el nombre del símbolo o el marco temporal (mejor cambiar el marco temporal, de esa manera todo tu código debería reconocer el nombre correcto del símbolo)
Si cambias el marco de tiempo, asegúrate de no utilizar algunos marcos de tiempo "legales" (1,5,15,30,60,...)
Hola,
Este ea se utiliza para la protección de la equidad en combinación con otros ea. Usted puede introducir los límites de ganancia y pérdida de la equidad y cuando el límite es golpeado ea cerrará todas las órdenes y cerrar otra EA.
El problema con la protección de la equidad ea es que sólo funciona cuando mt4 se maximiza. Si su minimizado o mt4 se está ejecutando en VPS, cuando el límite es golpeado EA no comenzará a cerrar las órdenes hasta que maximizar EA o inicio de sesión en VPS. En el momento en que me conecto o maximizo el EA empieza a cerrar.
Thnx.
Hola,
Este EA se utiliza para la protección de la equidad en combinación con otro EA. Usted puede introducir los límites de ganancia y pérdida de la equidad y cuando el límite es golpeado ea cerrará todas las órdenes y cerrar otra EA.
El problema con la protección de la equidad ea es que sólo funciona cuando mt4 se maximiza. Si su minimizado o mt4 se ejecuta en VPS, cuando el límite es golpeado EA no comenzará a cerrar las órdenes hasta que maximizar EA o inicio de sesión en VPS. En el momento en que me conecto o maximizo el EA comienza a cerrarse.
Thnx.¿Se comporta de la misma manera en su PC (no en el VPS)?
Si funciona bien en tu PC en las mismas condiciones entonces tienes un problema con tu V PS
Es porque estás usando el nombre original y el marco de tiempo del símbolo. Tienes que cambiar el nombre del símbolo o el marco de tiempo (mejor cambiar el marco de tiempo, de esa manera todo tu código debería reconocer el nombre correcto del símbolo) Si cambias el marco de tiempo, asegúrate de no usar algunos marcos de tiempo "legales" (1,5,15,30,60,...)
Gracias, he cambiado
ExtHandle=FileOpenHistory("TT_"+c_symbol+(string)3+".hst",FILE_BIN|FILE_WRITE|FILE_SHARE_WRITE|FILE_SHARE_READ|FILE_ANSI);
and
FileWriteInteger(ExtHandle,3,LONG_VALUE);
Pero si abro el gráfico offline ...,M3 sólo muestra "Waiting for Updates"... y no pasa nada
Gracias, he cambiado
ExtHandle=FileOpenHistory("TT_"+c_symbol+(string)3+".hst",FILE_BIN|FILE_WRITE|FILE_SHARE_WRITE|FILE_SHARE_READ|FILE_ANSI);
and
FileWriteInteger(ExtHandle,3,LONG_VALUE);
Interesante
Utiliza este como base para tu indicador. Este funciona (parece que la versión que usaste como base tiene errores)
Ayuda! para este ea
Saludos
Por favor expertos
establecer en el EA el stop lose y el take profit
gaps.ex4
gaps.mq4
Hola,
¿Puede ayudar a añadir una opción DEMA al indicador adjunto?
Actualmente las opciones son:
0= sma
1=ema
2=smma
3=lwma
Me gustaría añadir:
4= DEMA¿Es esto posible?Muchas gracias
Hola,
¿Puede ayudar a añadir una opción DEMA al indicador adjunto?
Actualmente las opciones son
0= sma
1=ema
2=smma
3=lwma
Me gustaría añadir:
4= DEMA¿Es esto posible?Muchas gracias.MrWigglesworth
Aquí hay una versión con dema añadido como tipo 4 : ma__dema_crossover_with_arrow_and_email.mq4
Saludos
Por favor, expertos
establecer en el EA el stop lose y el take profit
gaps.ex4
gaps.mq4amirreza132
Ese EA está diseñado para captar gaps y ya tiene take profit en los casos en los que se produce el gap