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
MrWigglesworth Aquí hay una versión con dema añadido como tipo 4 : ma__dema_crossover_with_arrow_and_email.mq4
¡Muy bien! Muchas gracias por tu ayuda MLaden
¡¡¡Felices Fiestas!!!
¿Alguien sabe cómo puedo averiguar el GMT del broker automáticamente (no mi propio GMT) desde el código?
¿Alguien sabe cómo puedo averiguar el GMT del broker automáticamente (no mi propio GMT) desde el código?
No hay manera automática para el corredor (no hay tal información disponible en todos los datos - ni siquiera en el nuevo metatrader 4 - al menos no lo he encontrado)
Hola mladen,
He hecho una pregunta sobre un script que cortaba unas horas del gráfico actual. Ahora quiero poner un retardo en cada barra, para tener un timeoffset en mi gráfico.
Lo he intentado así, pero no funciona (como creo)
input int TimeDelay_Minutes = 60;
input int StartHour = 8;
input int StartMinute = 0;
input int CloseHour = 16;
input int CloseMinute = 30;
int InpPeriodMultiplier=1; // Period multiplier factor
int ExtHandle=-1;
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
datetime time0;
ulong last_fpos=0;
long last_volume=0;
int i, start_pos, periodseconds;
int hwnd=0, cnt=0;
//---- History header
int version=401;
string c_copyright;
string c_symbol=Symbol();
int i_period=Period()*InpPeriodMultiplier;
int i_digits=Digits;
int i_unused[13];
MqlRates rate;
//---
ExtHandle=FileOpenHistory(c_symbol+(string)3+".hst", FILE_BIN|FILE_WRITE|FILE_SHARE_READ|FILE_ANSI);
if(ExtHandle<0)
return;
ArrayInitialize(i_unused,0);
//--- write history file header
FileWriteInteger(ExtHandle, version, LONG_VALUE);
FileWriteString(ExtHandle, c_copyright, 64);
FileWriteString(ExtHandle, c_symbol, 12);
FileWriteInteger(ExtHandle, 3, LONG_VALUE);
FileWriteInteger(ExtHandle, i_digits, LONG_VALUE);
FileWriteInteger(ExtHandle, 0, LONG_VALUE); //timesign
FileWriteInteger(ExtHandle, 0, LONG_VALUE); //last_sync
FileWriteArray(ExtHandle, i_unused, 0, 13);
//--- write history file
periodseconds=i_period*60;
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]/periodseconds;
rate.time*=periodseconds;
for(i=start_pos-1; i>=0; i--)
{
if(IsStopped())
break;
time0=Time- 1 * 60 *TimeDelay_Minutes;
//--- history may be updated
if(i==0)
{
//--- modify index if history was updated
if(RefreshRates())
i=iBarShift(NULL,0,time0);
}
//---
if((time0>=rate.time+periodseconds || i==0)&& MainTime(time0)==true)
{
if(i==0)
{
rate.time=time0/periodseconds; //NEU
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+periodseconds)
{
rate.time=time0/periodseconds;
rate.time*=periodseconds;
rate.open=Open;
rate.low=Low;
rate.high=High;
rate.close=Close;
rate.tick_volume=last_volume;
}
}
else if(MainTime(time0)==true)
{
rate.time=time0/periodseconds; //NEU
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]- 1 * 60 *TimeDelay_Minutes;
FileSeek(ExtHandle,last_fpos,SEEK_SET);
//--- is there current bar?
if(time0<rate.time+periodseconds && 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/periodseconds;
rate.time*=periodseconds;
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;
}
//---
}
Hola mladen,
He hecho una pregunta sobre un script que cortaba unas horas del gráfico actual. Ahora quiero poner un retardo en cada barra, para tener un timeoffset en mi gráfico.
Lo he intentado así, pero no funciona (como creo)
input int TimeDelay_Minutes = 60;
input int StartHour = 8;
input int StartMinute = 0;
input int CloseHour = 16;
input int CloseMinute = 30;
int InpPeriodMultiplier=1; // Period multiplier factor
int ExtHandle=-1;
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
datetime time0;
ulong last_fpos=0;
long last_volume=0;
int i, start_pos, periodseconds;
int hwnd=0, cnt=0;
//---- History header
int version=401;
string c_copyright;
string c_symbol=Symbol();
int i_period=Period()*InpPeriodMultiplier;
int i_digits=Digits;
int i_unused[13];
MqlRates rate;
//---
ExtHandle=FileOpenHistory(c_symbol+(string)3+".hst", FILE_BIN|FILE_WRITE|FILE_SHARE_READ|FILE_ANSI);
if(ExtHandle<0)
return;
ArrayInitialize(i_unused,0);
//--- write history file header
FileWriteInteger(ExtHandle, version, LONG_VALUE);
FileWriteString(ExtHandle, c_copyright, 64);
FileWriteString(ExtHandle, c_symbol, 12);
FileWriteInteger(ExtHandle, 3, LONG_VALUE);
FileWriteInteger(ExtHandle, i_digits, LONG_VALUE);
FileWriteInteger(ExtHandle, 0, LONG_VALUE); //timesign
FileWriteInteger(ExtHandle, 0, LONG_VALUE); //last_sync
FileWriteArray(ExtHandle, i_unused, 0, 13);
//--- write history file
periodseconds=i_period*60;
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]/periodseconds;
rate.time*=periodseconds;
for(i=start_pos-1; i>=0; i--)
{
if(IsStopped())
break;
time0=Time- 1 * 60 *TimeDelay_Minutes;
//--- history may be updated
if(i==0)
{
//--- modify index if history was updated
if(RefreshRates())
i=iBarShift(NULL,0,time0);
}
//---
if((time0>=rate.time+periodseconds || i==0)&& MainTime(time0)==true)
{
if(i==0)
{
rate.time=time0/periodseconds; //NEU
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+periodseconds)
{
rate.time=time0/periodseconds;
rate.time*=periodseconds;
rate.open=Open;
rate.low=Low;
rate.high=High;
rate.close=Close;
rate.tick_volume=last_volume;
}
}
else if(MainTime(time0)==true)
{
rate.time=time0/periodseconds; //NEU
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]- 1 * 60 *TimeDelay_Minutes;
FileSeek(ExtHandle,last_fpos,SEEK_SET);
//--- is there current bar?
if(time0<rate.time+periodseconds && 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/periodseconds;
rate.time*=periodseconds;
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;
}
//---
}
¿Por qué no añades simplemente algún desplazamiento de tiempo a rate. time antes de escribir en el archivo (la adición puede ser positiva o negativa) y luego, cuando escribes el archivo, reviertes el valor original del mismo?
MrWigglesworth Aquí hay una versión con dema añadido como tipo 4 : ma__dema_crossover_with_arrow_and_email.mq4
Hola Sr. MLaden,
¿Cómo estás hoy? Adjunto un gráfico con los indicadores 5 y 12 DEMA..También en el gráfico está el indicador ma+DEMA que usted modificó. Está configurado en 5-ma1 y 12-ma2 y eligió el tipo 4 (DEMA) para ambas MA's...Como puede ver en las flechas, no parecen coincidir con las líneas...¿Alguna idea sobre lo que está mal? ¡Muchas gracias!
Hola Sr. MLaden,
¿Cómo estás hoy? Adjunto un gráfico con los indicadores 5 y 12 DEMA..También en el gráfico está el indicador ma+DEMA que modificaste. Está configurado en 5-ma1 y 12-ma2 y eligió el tipo 4 (DEMA) para ambos MA's...Como se puede ver en las flechas, no parecen coincidir con las líneas...¿Alguna idea sobre lo que está mal? ¡Muchas gracias!
Ah y por cierto aquí está el indicador DEMA que estoy usando si ayuda
Hola Sr. MLaden,
¿Cómo estás hoy? Adjunto un gráfico con los indicadores 5 y 12 DEMA..También en el gráfico está el indicador ma+DEMA que modificaste. Está configurado en 5-ma1 y 12-ma2 y eligió el tipo 4 (DEMA) para ambos MA's...Como se puede ver en las flechas, no parecen coincidir con las líneas...¿Alguna idea sobre lo que está mal? Muchas gracias.
¿Qué dema estás usando para comparar?
Solo para recordar : dema no es un ema de un ema sino una diferencia de 2 x ema y ema. de ema
Fórmula para que se puede encontrar incluso aquí : Doble media móvil exponencial - MetaTrader 5 Ayuda
saludos
¿Qué dema está utilizando para la comparación?
Vea el post 2631 arriba con el DEMA.mq4 adjunto... ¿Ayuda eso?
¿Qué dema estás usando para comparar?
Solo para recordar : dema no es un ema de un ema sino una diferencia de 2 x ema y ema. de ema
La fórmula para esto se puede encontrar incluso aquí : Doble Media Móvil Exponencial - MetaTrader 5 Ayuda
saludosSí, estoy familiarizado con DEMA aunque nunca memorizado la fórmula ... Aquí está la diferencia práctica entre un 5-SMA (rojo) y 5-DEMA (verde)