¿Por qué no funciona el indicador de noticias en Windows 7?
90% - sacar el terminal de la carpeta del programa filec...
90% - sacar el terminal de la carpeta del programa filec...
entonces mira en el firewall (pero primero, mira donde se guardan los archivos)
Envíe el indicador aquí
Envíe el indicador aquí
//| Noticias.mq4 |
//| * |
//| * |
//+------------------------------------------------------------------+
#property copyright "Bulagin Andrey"
#enlace de propiedad "andre9@ya.ru"
#propiedad ventana_del_gráfica_del_indicador
#property indicator_buffers 0
//----
#importar "wininet.dll"
int InternetAttemptConnect (int x);
int InternetOpenA(string sAgent, int lAccessType,
string sProxyName = "", string sProxyBypass = "",
int lFlags = 0);
int InternetOpenUrlA(int hInternetSession, string sUrl,
string sHeaders = "", int lHeadersLength = 0,
int lFlags = 0, int lContext = 0);
int InternetReadFile(int hFile, int& sBuffer[], int lNumBytesToRead,
int& lNumberOfBytesRead[]);
int InternetCloseHandle(int hInet);
#importar.
extern bool today = false; // mostrar sólo las noticias de hoy (dd$)
extern bool lines = true; // mostrar líneas verticales en el gráfico en los momentos de publicación de noticias
extern bool texts = true; // mostrar etiquetas de texto con descripciones de noticias
extern bool comments = true; // mostrar la lista de noticias futuras y pasadas más cercanas
extern int int total_in_list = 22; // número de noticias en la lista
extern bool high = true; // mostrar noticias importantes
extern bool medium = true; // mostrar noticias de importancia media
extern bool low = true; // mostrar noticias de baja importancia
extern int update = 15; // actualizar la lista de noticias cada 15 minutos
extern bool auto = true; // auto-selección de noticias adecuadas para el par de divisas del gráfico
extern bool eur = true; // mostrar noticias para las monedas especificadas
extern bool usd = true;
extern bool jpy = true;
extern bool gbp = true;
extern bool chf = true;
extern bool cad = true;
extern bool aud = true;
extern bool nzd = true;
extern color high_color = Maroon; // color de las noticias importantes
extern color medium_color = Sienna; // color para noticias generales
extern color low_color = DarkSlateGray; // color para noticias menores
extern bool russian = false; // utilizar un archivo de traducción para la rusificación de las noticias
extern int zona_horaria_servidor = 2; // zona horaria del servidor (Alpary - GMT+2)
extern int show_timezone = 4; // mostrar zona horaria (Moscú - GMT+4)
extern bool alerts = false; // Alerta al servidor mediante señales sonoras.
extern int alert_before = 5; // alerta 5 minutos antes de la publicación de la noticia.
extern int alert_every = 30; // pita cada 30 segundos
// -----------------------------------------------------------------------------------------------------------------------------
int TotalNews = 0;
cadena Noticias[1000][10];
datetime LastUpdate = 0;
int SiguienteLíneaDeNoticias = 0;
int ÚltimaAlerta = 0;
cadena Traducir[1000][2];
int TotalTranslate = 0;
// -----------------------------------------------------------------------------------------------------------------------------
int init()
{
if(auto) // selecciona automáticamente las noticias adecuadas para el par de divisas actual
{
string sym = Symbol();
if(StringFind(sym, "EUR") != -1) eur = true; si no, eur = false;
if(StringFind(sym, "USD") != -1) usd = true; si no usd = false;
if(StringFind(sym, "JPY") != -1) jpy = true; si no, jpy = false;
if(StringFind(sym, "GBP") != -1) gbp = true; si no, gbp = false;
if(StringFind(sym, "CHF") != -1) chf = true; si no, chf = false;
if(StringFind(sym, "CAD") != -1) cad = true; si no, cad = false;
if(StringFind(sym, "AUD") != -1) aud = true; si no, aud = false;
if(StringFind(sym, "NZD") != -1) nzd = true; si no, nzd = false;
}
if(russian) //preparación de patrones de traducción de noticias
{
int fhandle = FileOpen("translate.txt", FILE_READ);
if(fhandle>0)
{
int i = 0;
while(!FileIsEnding(fhandle))
{
string str = FileReadString(fhandle);
if(str == "") break;
Translate[i][0] = str;
Translate[i][1] = FileReadString(fhandle);
if(Translate[i][1] == "") Translate[i][1] = Translate[i][0];
i++;
}
TotalTranslate = i;
FileClose(fhandle);
}
}
return(0);
}
// -----------------------------------------------------------------------------------------------------------------------------
int deinit()
{
for(int i=0; i<Total de noticias; i++)
{
ObjectDelete("Línea de noticias "+i);
ObjectDelete("Texto de noticias "+i);
}
return(0);
}
// -----------------------------------------------------------------------------------------------------------------------------
int inicio()
{
string Filtro1 = "";
if(!eur) Filtro1 = Filtro1 + "EUR|";
if(!usd) Filter1 = Filter1 + "USD|";
if(!jpy) Filter1 = Filter1 + "JPY|";
if(!gbp) Filter1 = Filter1 + "GBP|";
if(!chf) Filter1 = Filter1 + "CHF|";
if(!cad) Filter1 = Filter1 + "CAD|";
if(!aud) Filter1 = Filter1 + "AUD|";
if(!nzd) Filter1 = Filter1 + "NZD|";
string Filtro2 = "";
if(!high) Filter2 = Filter2 + "high|";
if(!medium) Filter2 = Filter2 + "Medium|";
if(!low) Filter2 = Filter2 + "Low|";
datetime time = TimeCurrent();
if(time >= LastUpdate+update*60) // actualizar la lista de noticias
{
for(int i=0; i<Total de noticias; i++)
{
ObjectDelete("Línea de noticias "+i);
ObjectDelete("Texto de noticias "+i);
}
LastUpdate = tiempo;
if(today==true)
{
string str = ReadWebPage("http://www.dailyfx.com/calendar/Dailyfx_Global_Economic_Calendar.csv?direction=none&collector=allInFolderDateDesc&view=today&timezone=GMT¤cyFilter="+Filter1+"&importanceFilter="+Filter2+"&time="+time);
}
else str = ReadWebPage("http://www.dailyfx.com/calendar/Dailyfx_Global_Economic_Calendar.csv?direction=none&collector=allInFolderDateDesc&view=week&timezone=GMT¤cyFilter="+Filter1+"&importanceFilter="+Filter2+"&time="+time);
if(str == "") return(0);
int pos = StringFind(str,"\r\n\r\n");
str = StringTrimRight(StringTrimLeft(StringSubstr(str,pos+6));
cadena arr[1000];
TotalNews = Explode(str, "\r\n\r\n", arr);
for( i=0; i<Total de noticias; i++)
{
cadena arr1[10];
Explode(arr[i], ",", arr1);
for( int j=0; j<10; j++ )
Noticias[i][j] = arr1[j];
cadena tmp[3], tmp1[2];
Explode(News[i][0], " ", tmp);
int mon = 0;
if(tmp[1]=="Jan") mon=1; else
if(tmp[1]=="Feb") mon=2; else
if(tmp[1]=="Mar") mon=3; else
if(tmp[1]=="Apr") mon=4; else
if(tmp[1]=="May") mon=5; else
if(tmp[1]=="Jun") mon=6; else
if(tmp[1]=="Jul") mon=7; else
if(tmp[1]=="Aug") mon=8; else
if(tmp[1]=="Sep") mon=9; else
if(tmp[1]=="Oct") mon=10; else
if(tmp[1]=="Nov") mon=11; else
if(tmp[1]=="Dec") mon=12;
Noticias[i][0] = Año()+". "+mon+". "+tmp[2];
Explode(Noticias[i][1], " ", tmp);
bool pm = tmp[1]=="PM";
Explode(tmp[0], ":", tmp1);
tmp1[0] = StrToInteger(tmp1[0])%12;
if(pm) tmp1[0] = StrToInteger(tmp1[0])+12;
News[i][1] = tmp1[0]+": "+tmp1[1];
datetime dt = StrToTime(Noticias[i][0]+""+Noticias[i][1]);
News[i][0] = TimeToStr(dt + server_timezone*60*60, TIME_DATE);
News[i][1] = TimeToStr(dt + server_timezone*60*60, TIME_MINUTES);
News[i][9] = TimeToStr(dt + show_timezone*60*60, TIME_MINUTES);
si(ruso)
{
for(j=0; j<TotalTranslate; j++)
{
pos = StringFind(News[i][4], Translate[j][0]);
if(pos != -1) News[i][4] = StringSubstr(News[i][4], 0, pos) + Translate[j][1] + StringSubstr(News[i][4], pos+StringLen(Translate[j][0]);
}
}
}
datetime current = 0;
for( i=0; i<TotalNews; i++) // crear líneas y títulos de noticias en el gráfico
{
if(StrToTime(News[i][0]+""+News[i][1]) == current) continue;
current = StrToTime(Noticias[i][0]+""+Noticias[i][1]);
color clr;
if(News[i][5] == "Low") clr = low_color; else
if(News[i][5] == "Medium") clr = medium_color; else
if(News[i][5] == "High") clr = high_color;
cadena de texto = "";
if(News[i][8] != "" || News[i][7] != "") text = "[" + News[i][8] + ", " + News[i][7] + "]";
if(News[i][6] != "") text = text + " + News[i][6];
si(líneas)
{
ObjectCreate("Línea de noticias "+i, OBJ_VLINE, 0, current, 0);
ObjectSet("Línea de noticias "+i, OBJPROP_COLOR, clr);
ObjectSet("Línea de noticias "+i, OBJPROP_STYLE, STYLE_DASHDOTDOT);
ObjectSet("Línea de noticias "+i, OBJPROP_BACK, true);
ObjectSetText("Línea de noticias "+i, Noticias[i][9] + " " + Noticias[i][4] + " + texto, 8);
}
si (textos)
{
ObjectCreate("Texto de noticias "+i, OBJ_TEXT, 0, current, WindowPriceMin()+(WindowPriceMax()-WindowPriceMin())*0.8 );
ObjectSet("Texto de noticias "+i, OBJPROP_COLOR, clr;)
ObjectSet("Texto de noticias "+i, OBJPROP_ANGLE, 90);
ObjectSetText("Texto de las noticias "+i, Noticias[i][9] + " " + Noticias[i][4] + " + texto, 8);
}
}
for(i=0; i<Total de noticias; i++)
if(StrToTime(News[i][0]+""+News[i][1]) > time) break;
SiguienteLíneaDeNoticias = i;
LastAlert = 0;
if(comentarios) //creación de la lista de noticias en el gráfico
{
int inicio = 0;
if(NextNewsLine >= 5) start = NextNewsLine - 5;
string com = "_____ LastNewsLine ______________________\n";
for(i=start; i<start+total_in_list && i<TotalNews; i++)
{
texto = "";
if(News[i][8] != "" || News[i][7] != "") text = "[" + News[i][8] + ", " + News[i][7] + "]";
if(News[i][6] != "") text = text + " + News[i][6];
com = com + News[i][9] + " + StringSubstr(News[i][5], 0, 1) + " + News[i][4] + " + text + "\n";
if(i==NextNewsLine-1) com = com + "_____ Future News ________________________\n";
}
Comentario(com);
}
} // fin de la actualización de la lista de noticias
datetime next_time = StrToTime(News[NextNewsLine][0]+""+News[NextNewsLine][1]);
if(time >= next_time) // la siguiente noticia ha salido
{
LastUpdate = time - update*60 + 60; // actualizar la lista de noticias un minuto después de la siguiente publicación de noticias
for(i=0; i<Total de noticias; i++)
if(StrToTime(News[i][0]+""+News[i][1]) > time) break;
SiguienteLíneaDeNoticias = i;
LastAlert = 0;
si(comentarios)
{
inicio = 0;
if(NextNewsLine >= 5) start = NextNewsLine - 5;
com = "";
for(i=start; i<start+10 && i<TotalNews; i++)
{
texto = "";
if(News[i][8] != "" || News[i][7] != "") text = "[" + News[i][8] + ", " + News[i][7] + "]";
if(News[i][6] != "") text = text + " + News[i][6];
com = com + News[i][9] + " + StringSubstr(News[i][5], 0, 1) + " " + News[i][4] + " + text + "\n";
}
Comentario(com);
}
}
next_time = StrToTime(News[NextNewsLine][0]+""+News[NextNewsLine][1]);
if(time >= next_time - alert_before*60) // la siguiente noticia está a punto de publicarse
{
if(time >= LastAlert + alert_every)
{
if(alerts) PlaySound("alert.wav");
Print("La próxima noticia se publicará en " + (((tiempo_próximo)-(tiempo_próximo)%60)/60) + " + ((tiempo_próximo)%60) + " segundos(s)");
ÚltimaAlerta = tiempo;
}
}
return(0);
}
// -----------------------------------------------------------------------------------------------------------------------------
int Explode(string str, string delimiter, string& arr[])
{
int i = 0;
int pos = StringFind(str, delimiter);
while(pos != -1)
{
if(pos == 0) arr[i] = ""; si no arr[i] = StringSubstr(str, 0, pos);
i++;
str = StringSubstr(str, pos+StringLen(delimitador));
pos = StringFind(str, delimiter);
if(pos == -1 || str == "") break;
}
arr[i] = str;
return(i+1);
}
// -----------------------------------------------------------------------------------------------------------------------------
string ReadWebPage(string url)
{
if(!IsDllsAllowed())
{
Alert("Debemos permitir las DLL en la configuración;)
return(");
}
int rv = InternetAttemptConnect(0);
if(rv != 0)
{
Alert("Error al llamar a InternetAttemptConnect()");
return(");
}
int hInternetSession = InternetOpenA("Microsoft Internet Explorer",
0, "", "", 0);
if(hInternetSession <= 0)
{
Alert("Error al llamar a InternetOpenA()");
return(");
}
int hURL = InternetOpenUrlA(hInternetSession,
url, "", 0, 0, 0);
if(hURL <= 0)
{
Alert("Error al llamar a InternetOpenUrlA();
InternetCloseHandle(hInternetSession);
return(0);
}
int cBuffer[256];
int dwBytesRead[1];
cadena TXT = "";
while(!IsStopped())
{
for(int i = 0; i<256; i++) cBuffer[i] = 0;
El bool bResultado = InternetReadFile(hURL, cBuffer, 1024, dwBytesRead);
if(dwBytesRead[0] == 0) break;
cadena de texto = "";
for(i = 0; i < 256; i++)
{
text = text + CharToStr(cBuffer[i] & 0x000000FF);
if(StringLen(text) == dwBytesRead[0]) break;
text = text + CharToStr(cBuffer[i] >> 8 & 0x000000FF);
if(StringLen(text) == dwBytesRead[0]) break;
text = text + CharToStr(cBuffer[i] >> 16 & 0x000000FF);
if(StringLen(text) == dwBytesRead[0]) break;
text = text + CharToStr(cBuffer[i] >> 24 & 0x000000FF);
}
TXT = TXT + texto;
Dormir(1);
}
if(TXT == "") Alert("No hay datos leídos");
InternetCloseHandle(hInternetSession);
return(TXT);
}
// -----------------------------------------------------------------------------------------------------------------------------
Borro el resto del hilo. ¿Cuánto spam se puede hacer?
Y si aparece más spam, se me dará la opción de banearte. Esto es sólo una advertencia.