Page 14 of 15 FirstFirst ... 4 12 13 14 15 LastLast
Results 131 to 140 of 150
Like Tree46Likes

DailyFX Economic Calendar

This is a discussion on DailyFX Economic Calendar within the Trading tools forums, part of the Trading Forum category; Example code for read web site Code: ////////////////////////////////////////////////////////////////////////////////// // Download CBOE page source code in a text variable // And ...

      
   
  1. #131
    Senior Member
    Join Date
    Jun 2016
    Posts
    258
    Example code for read web site

    Code:
    //////////////////////////////////////////////////////////////////////////////////
    // Download CBOE page source code in a text variable
    // And returns the result
    //////////////////////////////////////////////////////////////////////////////////
    string ReadCBOE()
    {
       string   cookie=NULL,
                headers;
       char     post[],
                result[];
       string   TXT="";
       int      res;
    //--- to work with the server, you must add the URL "https://www.google.com/finance"  
    //--- the list of allowed URL (Main menu-> Tools-> Settings tab "Advisors"): 
       string google_url="http://ec.forexprostools.com/?columns=exc_currency,exc_importance&importance=1,2,3&calType=week&timeZone=15&lang=1";
    //--- 
       ResetLastError();
    //--- download html-pages
       int timeout=5000; //--- timeout less than 1,000 (1 sec.) is insufficient at a low speed of the Internet
       res=WebRequest("GET",google_url,cookie,NULL,timeout,post,0,result,headers);
    //--- error checking
       if(res==-1)
       {
          Comment("WebRequest error, description =",ErrorDescription(GetLastError()));
          MessageBox("You must add the address ' "+google_url+"' in the list of allowed URL tab 'Advisors' "," Error ",MB_ICONINFORMATION);
          //--- You must add the address ' "+ google url"' in the list of allowed URL tab 'Advisors' "," Error "
       }
       else
       {
          //--- successful download
          //PrintFormat("File successfully downloaded, the file size in bytes  =%d.",ArraySize(result)); 
          //--- save the data in the file
          int filehandle=FileOpen("news-log.html",FILE_WRITE|FILE_BIN);
          //--- ïðîâåðêà îøèáêè 
          if(filehandle!=INVALID_HANDLE)
          {
             //---save the contents of the array result [] in file 
             FileWriteArray(filehandle,result,0,ArraySize(result));
             //--- close file 
             FileClose(filehandle);
    
             int filehandle2=FileOpen("news-log.html",FILE_READ|FILE_BIN);
             TXT=FileReadString(filehandle2,ArraySize(result));
             FileClose(filehandle2);
          }
          else
          {
             Comment("Error in FileOpen. Error description =",ErrorDescription(GetLastError()));
          }
       }
    
       return(TXT);
    }

  2. #132
    Senior Member
    Join Date
    Jun 2016
    Posts
    258
    I found this site that explains how it works but it is in Russian.

    WebRequest, ???? MQL4

  3. #133
    igorad
    Guest
    Quote Originally Posted by rogeriob28 View Post
    Hi ND and Igor,
    Is it possible to use this news source for EA?
    http://ec.forexprostools.com/?column...Zone=15&lang=1

    Regards,
    Rogério

    Hi Rogério,

    Thanks a lot for this link. I already wrote a parser for this page but maybe someone knows how to load the calendar using the week start and end dates.

    Attachment 27426


    Regards,
    Igor

  4. #134
    Senior Member
    Join Date
    Jun 2016
    Posts
    258
    Hi Igor,
    Good job.
    I already had all the functions ready with your old DailyFX filter now I'm creating a new news filter for my Ea.
    See Forex Factory

    Code:
    bool        skip,lotnotif;
    datetime    newsTime,calendardate;
    int         xmlHandle,BoEvent,end,begin,minsTillNews,tmpMins,idxOfNext,dispMinutes[9],newsIdx,next,i,WebUpdateFreq=60;
    string      xmlFileName,myEvent,mainData[100][7],sData,dispTitle[9],dispCountry[9],dispImpact[9],alertstring,prefix="NEWS_",News[],tmp;
    string      sUrl="http://www.forexfactory.com/ff_calendar_thisweek.xml";
    string      sTags[7]=
      {
       "<title>","<country>","<date><![CDATA[","<time><![CDATA[",
       "<impact><![CDATA[","<forecast><![CDATA[","<previous><![CDATA["
      };
    string      eTags[7]=
      {
       "</title>","</country>","]]></date>","]]></time>",
       "]]></impact>","]]></forecast>","]]></previous>"
      }; 
    
                                 
    int password_status = -1;
    
    
    // News Functions 
    
    int dpsstart()
    {
       //if (TimeCurrent() < allowed_until) 
       {     
          InitNews(sUrl);
          xmlHandle=FileOpen(xmlFileName,FILE_BIN|FILE_READ);
          if(xmlHandle>=0)
          {
             int size=FileSize(xmlHandle);
             sData=FileReadString(xmlHandle,size);
             FileClose(xmlHandle);
          }
          ArrayResize(News,0);
          Del_MyComment();
          newsIdx=0;
          tmpMins=10080;
          BoEvent= 0;
          while(true)
          {
             BoEvent=StringFind(sData,"<event>",BoEvent);
             if(BoEvent==-1) break;
             BoEvent+=7;
             next=StringFind(sData,"</event>",BoEvent);
             if(next == -1) break;
             myEvent = StringSubstr(sData, BoEvent, next - BoEvent);
             BoEvent = next;
             begin= 0;
             skip = false;
             for(i=0; i < 7; i++)
             {
                mainData[newsIdx][i]="";
                next=StringFind(myEvent,sTags[i],begin);
                if(next==-1) continue;
                else
                {
                begin=next+StringLen(sTags[i]);
                end=StringFind(myEvent,eTags[i],begin);
                if(end>begin && end!=-1)
                {mainData[newsIdx][i]=StringSubstr(myEvent,begin,end-begin);}
                }
             }
             
             if(!IsNewsCurrency(Symbol(),mainData[newsIdx][COUNTRY])){skip=true;}
             else if((!MediumImpactNews) && (mainData[newsIdx][IMPACT]=="Medium")){skip=true;}
             else if((!LowImpactNews) && (mainData[newsIdx][IMPACT]=="Low")){skip=true;}
             else if((StringSubstr(mainData[newsIdx][TITLE],0,4)=="Bank")){skip=true;}
             else if(StringSubstr(mainData[newsIdx][TITLE],0,8)!="Daylight"){skip=true;}
             else if((mainData[newsIdx][TIME]=="All Day" && mainData[newsIdx][TIME]=="") || 
             (mainData[newsIdx][TIME]=="Tentative" && mainData[newsIdx][TIME]=="") || 
             (mainData[newsIdx][TIME]=="")){skip=true;}
             if(!skip)
             {
                newsTime=MakeDateTime(mainData[newsIdx][DATE],mainData[newsIdx][TIME]);
                minsTillNews=(newsTime-TimeGMT())/60;
                if(minsTillNews<0 || MathAbs(tmpMins)>minsTillNews)
                {idxOfNext=newsIdx; tmpMins=minsTillNews;}
                datetime time=newsTime-TimeGMTOffset();
                int ind=ArraySize(News);
                ArrayResize(News,ind+1);
                News[ind]=TimeToString(time)+"'"+
                 mainData[newsIdx][COUNTRY]+"'"+
                 mainData[newsIdx][IMPACT]+"'"+
                 mainData[newsIdx][Forecast]+"'"+
                 mainData[newsIdx][Previous]+"'"+
                 mainData[newsIdx][TITLE];
                Add_MyComment();
                
                
                
                if((minsTillNews>=0 && minsTillNews<=PauseMinutesBefore))
                {
                   alertstring=mainData[newsIdx][TITLE];
                   GlobalVariableSet(ipiMagic,false);
                   ObjectSetString(0,"LableNews",OBJPROP_TEXT,minsTillNews+" minutes until news for "+mainData[newsIdx][COUNTRY]+": "+mainData[newsIdx][TITLE]);
                   ObjectSetInteger(0,"LableNews",OBJPROP_COLOR,clrRed);
                   if(PauseMinutesBefore!=0 && minsTillNews>=0 && minsTillNews<=PauseMinutesBefore && alertstring!=tmp)
                   {
                   if(AlertOn) { Alert(minsTillNews," minutes until news for "+mainData[newsIdx][COUNTRY],": ",mainData[newsIdx][TITLE]);}
                   if(NotificationOn) { SendNotification(minsTillNews+" minutes until news for "+mainData[newsIdx][COUNTRY]+": "+mainData[newsIdx][TITLE]);}
                   tmp=alertstring;
                   }
                   break;
                }
                
                else 
                   if(minsTillNews<=0 && minsTillNews>=PauseMinutesAfter*-1)
                   {
                      GlobalVariableSet(ipiMagic,false);
                      ObjectSetString(0,"LableNews",OBJPROP_TEXT,minsTillNews+" minutes Since news for "+mainData[newsIdx][COUNTRY]+": "+mainData[newsIdx][TITLE]);
                      ObjectSetInteger(0,"LableNews",OBJPROP_COLOR,clrRed);
                      break;
                   }
                   else
                   {
                      GlobalVariableSet(ipiMagic,true);
                      ObjectSetString(0,"LableNews",OBJPROP_TEXT,"There Is No Upcoming News For "+PauseMinutesBefore+" Minutes Later");
                      ObjectSetInteger(0,"LableNews",OBJPROP_COLOR,clrMediumSeaGreen);
                   }
                
                newsIdx++;
             }
          }     
       }
       return (0);
    }
    //+------------------------------------------------------------------+
    //|                                                                  |
    //+------------------------------------------------------------------+
    void InitNews(string newsUrl)
      {
       if(DoFileDownLoad())
         {
          DownLoadWebPageToFile(newsUrl);
         }
      }
    //+------------------------------------------------------------------+
    //|                                                                  |
    //+------------------------------------------------------------------+
    bool DoFileDownLoad()
      {
       xmlHandle=0;
       int size;
       datetime time=TimeCurrent();
       if(GlobalVariableCheck("Update News File") == false)return(true);
       if((time - GlobalVariableGet("Update News File")) > WebUpdateFreq*60)return(true);
    
       xmlFileName=GetXmlFileName();
       xmlHandle=FileOpen(xmlFileName,FILE_BIN|FILE_READ);
       if(xmlHandle>=0)
         {
          size=FileSize(xmlHandle);
          sData=FileReadString(xmlHandle,size);
          FileClose(xmlHandle);
          return(false);
         }
       return(true);
      }
    //+------------------------------------------------------------------+
    //|                                                                  |
    //+------------------------------------------------------------------+
    string GetXmlFileName()
      {
       int adjustDays=0;
       switch(TimeDayOfWeek(TimeLocal()))
         {
          case 0:adjustDays=0;         break;
          case 1:adjustDays=1;         break;
          case 2:adjustDays=2;         break;
          case 3:adjustDays=3;         break;
          case 4:adjustDays=4;         break;
          case 5:adjustDays=5;         break;
          case 6:adjustDays=6;         break;
         }
       calendardate=TimeLocal() -(adjustDays *86400);
       string fileName=(StringConcatenate(TimeYear(calendardate),"-",
                        PadString(DoubleToStr(TimeMonth(calendardate),0),"0",2),"-",
                        PadString(DoubleToStr(TimeDay(calendardate),0),"0",2),"-News",".xml"));
    
       return(fileName);
      }
    //+------------------------------------------------------------------+
    //|                                                                  |
    //+------------------------------------------------------------------+
    void DownLoadWebPageToFile(string url="http://www.forexfactory.com/ffcal_week_this.xml")
      {
       
       int HttpOpen=InternetOpenW(" ",0," "," ",0);
       int HttpConnect = InternetConnectW(HttpOpen, "", 80, "", "", 3, 0, 1);
       int HttpRequest = InternetOpenUrlW(HttpOpen, url, NULL, 0, 0, 0);
       int read[1];
       uchar  Buffer[];
       ArrayResize(Buffer,READURL_BUFFER_SIZE+1);
       string NEWS="";
       xmlFileName=GetXmlFileName();
       xmlHandle=FileOpen(xmlFileName,FILE_BIN|FILE_READ|FILE_WRITE);
       if(xmlHandle>=0) {FileClose(xmlHandle); FileDelete(xmlFileName);}
       xmlHandle=FileOpen(xmlFileName,FILE_BIN|FILE_WRITE);
    
       while(true)
         {
          bool FL=InternetReadFile(HttpRequest,Buffer,READURL_BUFFER_SIZE,read);
          string strThisRead = CharArrayToString(Buffer,0,read[0],CP_UTF8);
          if(read[0]> 0)NEWS = NEWS + strThisRead;
          else
            {
             FileWriteString(xmlHandle,NEWS);
             FileClose(xmlHandle);
             end=StringFind(NEWS,"</weeklyevents>",0);
             if(end==-1) {Alert(Symbol()," ",Period(),", Error: File download incomplete!");}
             else {GlobalVariableSet("Update News File",TimeCurrent());}
             break;
            }
         }
       if(HttpRequest>0) InternetCloseHandle(HttpRequest);
       if(HttpConnect>0) InternetCloseHandle(HttpConnect);
       if(HttpOpen>0) InternetCloseHandle(HttpOpen);
      }
    //-----------------------------------------------------------
    void dpsLoadWebsite(string inURL="https://www.google.com/finance")
    {
       string cookie=NULL,headers;
       char post[],result[];
       int res;
       //--- to enable access to the server, you should add URL "https://www.google.com/finance"
       //--- in the list of allowed URLs (Main Menu->Tools->Options, tab "Expert Advisors"):
       string google_url=inURL;
       //--- Reset the last error code
       ResetLastError();
       //--- Loading a html page from Google Finance
       int timeout=5000; //--- Timeout below 1000 (1 sec.) is not enough for slow Internet connection
       res=WebRequest("GET",google_url,cookie,NULL,timeout,post,0,result,headers);
       //--- Checking errors
       if(res==-1)
         {
          Print("Error in WebRequest. Error code  =",GetLastError());
          //--- Perhaps the URL is not listed, display a message about the necessity to add the address
          MessageBox("Add the address '"+google_url+"' in the list of allowed URLs on tab 'Expert Advisors'","Error",MB_ICONINFORMATION);
         }
       else
         {
          //--- Load successfully
          PrintFormat("The file has been successfully loaded, File size =%d bytes.",ArraySize(result));
          //--- Save the data to a file
          int filehandle=FileOpen("GoogleFinance.htm",FILE_WRITE|FILE_BIN);
          //--- Checking errors
          if(filehandle!=INVALID_HANDLE)
            {
             //--- Save the contents of the result[] array to a file
             FileWriteArray(filehandle,result,0,ArraySize(result));
             //--- Close the file
             FileClose(filehandle);
            }
          else Print("Error in FileOpen. Error code=",GetLastError());
         }
    }
    //+------------------------------------------------------------------+
    //|                                                                  |
    //+------------------------------------------------------------------+
    string PadString(string toBePadded,string paddingChar,int paddingLength)
      {
       while(StringLen(toBePadded)<paddingLength)
         {
          toBePadded=StringConcatenate(paddingChar,toBePadded);
         }
       return (toBePadded);
      }
    //+------------------------------------------------------------------+
    //|                                                                  |
    //+------------------------------------------------------------------+
    bool IsNewsCurrency(string cSymbol,string fSymbol)
      {
       if(USDNews && fSymbol == "USD"){return(true);}
       if(GBPNews && fSymbol == "GBP"){return(true);}
       if(EURNews && fSymbol == "EUR"){return(true);}
       if(CADNews && fSymbol == "CAD"){return(true);}
       if(AUDNews && fSymbol == "AUD"){return(true);}
       if(CHFNews && fSymbol == "CHF"){return(true);}
       if(JPYNews && fSymbol == "JPY"){return(true);}
       if(NZDNews && fSymbol == "NZD"){return(true);}
       if(CNYNews && fSymbol == "CNY"){return(true);}
       return(false);
      }
    //+-----------------------------------------------------------------------------------------------+
    //| Indicator Subroutine For Date/Time    changed by deVries                                      |
    //+-----------------------------------------------------------------------------------------------+ 
    datetime MakeDateTime(string strDate,string strTime) //not string now datetime
      {
       int n1stDash = StringFind(strDate, "-");
       int n2ndDash = StringFind(strDate, "-", n1stDash+1);
       string strMonth=StringSubstr(strDate,0,2);
       string strDay=StringSubstr(strDate,3,2);
       string strYear=StringSubstr(strDate,6,4);
       int nTimeColonPos=StringFind(strTime,":");
       string strHour=StringSubstr(strTime,0,nTimeColonPos);
       string strMinute= StringSubstr(strTime,nTimeColonPos+1,2);
       string strAM_PM = StringSubstr(strTime,StringLen(strTime)-2);
       int nHour24=StrToInteger(strHour);
       if((strAM_PM == "pm" || strAM_PM == "PM") && nHour24 != 12) {nHour24 += 12;}
       if((strAM_PM == "am" || strAM_PM == "AM") && nHour24 == 12) {nHour24 = 0;}
       datetime newsevent=StringToTime(strYear+"."+strMonth+"."+
                                       strDay)+nHour24*3600+(StringToInteger(strMinute)*60);
       return(newsevent);
      }
    //+------------------------------------------------------------------+
    //| Create a text label                                              |
    //+------------------------------------------------------------------+
    bool LabelCreate(const string            name="Label",             // label name
                     const int               x=0,                      // X coordinate
                     const int               y=0,                      // Y coordinate
                     const string            text="Label",             // text
                     const color             clr=clrRed) // priority for mouse click
      {
       ObjectDelete(0,name);
       ResetLastError();
       if(!ObjectCreate(0,name,OBJ_LABEL,0,0,0))
         {
          Print(__FUNCTION__,": failed to create text label! Error code = ",GetLastError());
          return(false);
         }
       ObjectSetInteger(0,name,OBJPROP_XDISTANCE,x);
       ObjectSetInteger(0,name,OBJPROP_YDISTANCE,y);
       ObjectSetInteger(0,name,OBJPROP_CORNER,CORNER_LEFT_UPPER);
       ObjectSetString(0,name,OBJPROP_TEXT,text);
       ObjectSetString(0,name,OBJPROP_FONT,"Segoe UI");
       ObjectSetInteger(0,name,OBJPROP_FONTSIZE,8);
       ObjectSetInteger(0,name,OBJPROP_COLOR,clr);
       ObjectSetInteger(0,name,OBJPROP_BACK,false);
       ObjectSetInteger(0,name,OBJPROP_SELECTABLE,false);
       ObjectSetInteger(0,name,OBJPROP_SELECTED,false);
       ObjectSetInteger(0,name,OBJPROP_HIDDEN,true);
       return(true);
      }
    //+------------------------------------------------------------------+
    //|                                                                  |
    //+------------------------------------------------------------------+
    void  Add_MyComment()
      {
       string name=prefix+"Time";
       LabelCreate(name,30,35,"Time",clrGray);
    //---- 
       name=prefix+"Country";
       LabelCreate(name,160,35,"Country",clrGray);
    //----
       name=prefix+"Impact";
       LabelCreate(name,260,35,"Impact",clrGray);
    //----
       name=prefix+"Forecast";
       LabelCreate(name,360,35,"Forecast",clrGray);
    //----
       name=prefix+"Previous";
       LabelCreate(name,460,35,"Previous",clrGray);
    //----
       name=prefix+"Title";
       LabelCreate(name,560,35,"Title",clrGray);
    //---- 
       name=prefix+"Separator";
       LabelCreate(name,20,35+20,"---------------------------------------------------------------",clrGray);
    //----   
       name=prefix+"Separator2";
       LabelCreate(name,272,35+20,"---------------------------------------------------------------",clrGray);
    //----   
       name=prefix+"Separator3";
       LabelCreate(name,524,35+20,"---------------------------------------------------------------",clrGray);
       
       int size=ArraySize(News);
       string result[];
       ushort u_sep;
       int d;
       color clr;
    //----
       for(i=0; i<size; i++)
         {
          u_sep=StringGetCharacter("'",0);
          d=StringSplit(News[i],u_sep,result);
          if(result[2]=="High"){clr=clrRed;}
          else if(result[2]=="Medium"){clr=clrOrange;}
          else {clr=clrYellow;}
    
          name=prefix+"Time"+(string)i;
          LabelCreate(name,30,35+20*(i+2),result[0],clr);
          //---- 
          name=prefix+"Country"+(string)i;
          LabelCreate(name,160,35+20*(i+2),result[1],clr);
          //----
          name=prefix+"Impact"+(string)i;
          LabelCreate(name,260,35+20*(i+2),result[2],clr);
          //----
          name=prefix+"Forecast"+(string)i;
          LabelCreate(name,360,35+20*(i+2),result[3],clr);
          //----
          name=prefix+"Previous"+(string)i;
          LabelCreate(name,460,35+20*(i+2),result[4],clr);
          //----
          name=prefix+"Title"+(string)i;
          LabelCreate(name,560,35+20*(i+2),result[5],clr);
         }
      }
    //+------------------------------------------------------------------+
    //|                                                                  |
    //+------------------------------------------------------------------+
    void  Del_MyComment()
      {
       for(i=ObjectsTotal()-1;i>=0;i--)
         {
          if(StringFind(ObjectName(i),prefix)>-1)
             ObjectDelete(ObjectName(i));
         }
      }
    //+------------------------------------------------------------------+
    Regards,
    Rogério

  5. #135
    Senior Member
    Join Date
    Jun 2016
    Posts
    258
    Igor see Investing filter.

    // Investing News

    input string NewsURL = "Please add below link to Tools >> Option >> Expert Advisors >> Allow WebRequest for listed URL to download Newsevent";
    input string NewsLink = "http://ec.forexprostools.com/?columns=exc_currency,exc_importance&importance=1, 2,3&calType=week&timeZone=15&lang=1";
    input string NewsInfo = "https://www.google.com/finance";
    input bool NewsCls = true; //Close All in News
    extern int BeforeNewsStop = 30; //Indent before News, minuts
    extern int AfterNewsStop = 30; //Indent after News, minuts
    input bool NewsLight = false; //Enable light news
    input bool NewsMedium = false; //Enable medium news
    input bool NewsHard = true; //Enable hard news
    input bool UseAutoTimeZone=true; //Auto TimeZone Detection
    extern int U_offset = 3; //Your Time Zone, GMT (for news)
    int offset=U_offset;
    datetime gmtime;
    int tz;

    input string NewsSymb = "USD,GBP,EUR,CHF,AUD,NZD,JPY,CAD"; //Currency to display the news (empty: only the current currencies)
    input bool DrawLines = true; //Draw lines on the chart
    input bool Next = false; //Draw only the future of news line
    input bool Signal = false; //Signals on the upcoming news

    // Check news
    //--- News
    if(!IsTesting())
    {
    if(News())
    {
    if(NewsCls && TotalOrdersCount()>0) CloseAllOpened();

    Comment("NEWS TIME...");
    return;
    }
    else if(!News())
    Comment("No News!");
    }


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

    // News Functions


    //+------------------------------------------------------------------+
    //| News Provider
    //+------------------------------------------------------------------+
    bool News()
    {
    bool result=false;

    //--- Detect News
    if(!IsTesting())
    {
    double CheckNews=0;
    if(AfterNewsStop>0)
    {
    if(TimeCurrent()-LastUpd>=Upd){Comment("News Loading...");Print("News Loading...");UpdateNews();LastUpd=TimeCurrent();Co mment("");}
    WindowRedraw();
    //---Draw a line on the chart news--------------------------------------------
    if(DrawLines)
    {
    for(int i=0; i<NomNews && !IsStopped(); i++)
    {
    string Name=StringSubstr(TimeToStr(TimeNews(i),TIME_MINUT ES)+"_"+NewsArr[1][i]+"_"+NewsArr[3][i],0,63);
    if(NewsArr[3][i]!="")if(ObjectFind(Name)==0)continue;
    if(StringFind(str1,NewsArr[1][i])<0)continue;
    if(TimeNews(i)<TimeCurrent() && Next)continue;

    color clrf = clrNONE;
    if(Vhigh && StringFind(NewsArr[2][i],"High")>=0)clrf=highc;
    if(Vmedium && StringFind(NewsArr[2][i],"Moderate")>=0)clrf=mediumc;
    if(Vlow && StringFind(NewsArr[2][i],"Low")>=0)clrf=lowc;

    if(clrf==clrNONE)continue;

    if(NewsArr[3][i]!="")
    {
    ObjectCreate(Name,0,OBJ_VLINE,TimeNews(i),0);
    ObjectSet(Name,OBJPROP_COLOR,clrf);
    ObjectSet(Name,OBJPROP_STYLE,Style);
    ObjectSetInteger(0,Name,OBJPROP_BACK,true);
    }
    }
    }
    //---------------Event Processing------------------------------------
    int i;
    CheckNews=0;
    for(i=0; i<NomNews && !IsStopped(); i++)
    {
    int power=0;
    if(Vhigh && StringFind(NewsArr[2][i],"High")>=0)power=1;
    if(Vmedium && StringFind(NewsArr[2][i],"Moderate")>=0)power=2;
    if(Vlow && StringFind(NewsArr[2][i],"Low")>=0)power=3;
    if(power==0)continue;
    if(TimeCurrent()+MinBefore*60>TimeNews(i) && TimeCurrent()-MinAfter*60<TimeNews(i) && StringFind(str1,NewsArr[1][i])>=0)
    {
    CheckNews=1;
    break;
    }
    else CheckNews=0;

    }
    if(CheckNews==1 && i!=Now && Signal) { Alert("In ",(int)(TimeNews(i)-TimeCurrent())/60," minutes released news ",NewsArr[1][i],"_",NewsArr[3][i]);Now=i;}
    /*** ***/
    }

    if(CheckNews>0)
    result=true; // We are doing here if we are in the framework of the news
    else
    result=false; // We are out of scope of the news release (No News)
    }

    //---
    return(result);
    }



    //////////////////////////////////////////////////////////////////////////////////
    // Download CBOE page source code in a text variable
    // And returns the result
    //////////////////////////////////////////////////////////////////////////////////
    string ReadCBOE()
    {
    string cookie=NULL,
    headers;
    char post[],
    result[];
    string TXT="";
    int res;
    //--- to work with the server, you must add the URL "https://www.google.com/finance"
    //--- the list of allowed URL (Main menu-> Tools-> Settings tab "Advisors"):
    string google_url="http://ec.forexprostools.com/?columns=exc_currency,exc_importance&importance=1, 2,3&calType=week&timeZone=15&lang=1";
    //---
    ResetLastError();
    //--- download html-pages
    int timeout=5000; //--- timeout less than 1,000 (1 sec.) is insufficient at a low speed of the Internet
    res=WebRequest("GET",google_url,cookie,NULL,timeou t,post,0,result,headers);
    //--- error checking
    if(res==-1)
    {
    Comment("WebRequest error, description =",ErrorDescription(GetLastError()));
    MessageBox("You must add the address ' "+google_url+"' in the list of allowed URL tab 'Advisors' "," Error ",MB_ICONINFORMATION);
    //--- You must add the address ' "+ google url"' in the list of allowed URL tab 'Advisors' "," Error "
    }
    else
    {
    //--- successful download
    //PrintFormat("File successfully downloaded, the file size in bytes =%d.",ArraySize(result));
    //--- save the data in the file
    int filehandle=FileOpen("news-log.html",FILE_WRITE|FILE_BIN);
    //--- ïðîâåðêà îøèáêè
    if(filehandle!=INVALID_HANDLE)
    {
    //---save the contents of the array result [] in file
    FileWriteArray(filehandle,result,0,ArraySize(resul t));
    //--- close file
    FileClose(filehandle);

    int filehandle2=FileOpen("news-log.html",FILE_READ|FILE_BIN);
    TXT=FileReadString(filehandle2,ArraySize(result));
    FileClose(filehandle2);
    }
    else
    {
    Comment("Error in FileOpen. Error description =",ErrorDescription(GetLastError()));
    }
    }

    return(TXT);
    }
    //////////////////////////////////////////////////////////////////////////////////
    //| Time News
    //////////////////////////////////////////////////////////////////////////////////
    datetime TimeNews(int nomf)
    {
    string s=NewsArr[0][nomf];
    string time=StringConcatenate(StringSubstr(s,0,4),".",Str ingSubstr(s,5,2),".",StringSubstr(s,8,2)," ",StringSubstr(s,11,2),":",StringSubstr(s,14,4 ));
    return((datetime)(StringToTime(time) + offset*3600));
    }
    //////////////////////////////////////////////////////////////////////////////////
    //| Update News
    //////////////////////////////////////////////////////////////////////////////////
    void UpdateNews()
    {
    string TEXT=ReadCBOE();
    int sh = StringFind(TEXT,"pageStartAt>")+12;
    int sh2= StringFind(TEXT,"</tbody>");
    TEXT=StringSubstr(TEXT,sh,sh2-sh);

    sh=0;
    while(!IsStopped())
    {
    sh = StringFind(TEXT,"event_timestamp",sh)+17;
    sh2= StringFind(TEXT,"onclick",sh)-2;
    if(sh<17 || sh2<0)break;
    NewsArr[0][NomNews]=StringSubstr(TEXT,sh,sh2-sh);

    sh = StringFind(TEXT,"flagCur",sh)+10;
    sh2= sh+3;
    if(sh<10 || sh2<3)break;
    NewsArr[1][NomNews]=StringSubstr(TEXT,sh,sh2-sh);
    if(StringFind(str1,NewsArr[1][NomNews])<0)continue;

    sh = StringFind(TEXT,"title",sh)+7;
    sh2= StringFind(TEXT,"Volatility",sh)-1;
    if(sh<7 || sh2<0)break;
    NewsArr[2][NomNews]=StringSubstr(TEXT,sh,sh2-sh);
    if(StringFind(NewsArr[2][NomNews],"High")>=0 && !Vhigh)continue;
    if(StringFind(NewsArr[2][NomNews],"Moderate")>=0 && !Vmedium)continue;
    if(StringFind(NewsArr[2][NomNews],"Low")>=0 && !Vlow)continue;

    sh=StringFind(TEXT,"left event",sh)+12;
    int sh1=StringFind(TEXT,"Speaks",sh);
    sh2=StringFind(TEXT,"<",sh);
    if(sh<12 || sh2<0)break;
    if(sh1<0 || sh1>sh2)NewsArr[3][NomNews]=StringSubstr(TEXT,sh,sh2-sh);
    else NewsArr[3][NomNews]=StringSubstr(TEXT,sh,sh1-sh);

    NomNews++;
    if(NomNews==300)break;
    }
    }


    Regards,
    Rogério

  6. #136
    Senior Member
    Join Date
    Jun 2016
    Posts
    258
    Hi Igor,
    Here's the EA I'm testing with the Investing.com News Filter
    Check if it is possible to display the calendar in the same EA was done in Dailyfx
    DailyFX Economic Calendar-news_ea.jpg


    Regards,
    Rogério
    Attached Files Attached Files

  7. #137
    igorad
    Guest
    Hi,

    Please check out the Investing.com Economic Calendar indicator in this thread.

    Regards,
    Igor
    Mitch likes this.

  8. #138
    Junior Member
    Join Date
    Aug 2017
    Posts
    1
    cannot bet it to work properly

  9. #139
    Administrator newdigital's Avatar
    Join Date
    Feb 2013
    Posts
    10,477
    Blog Entries
    2957
    Follow newdigital On Twitter Add newdigital on Facebook Add newdigital on Google+ Add newdigital on MySpace
    Add newdigital on Linkedin
    Quote Originally Posted by LordBrandonCharles View Post
    cannot bet it to work properly
    This DailyFX Economic Calendar indicator does not work.
    Please use the following tools:

    News indicator:
    Investing.com Economic Calendar indicator is on this thread.

    NewsTrader EA:
    NewsTrader EA based on the Investing.com calendar instead of the DailyFX calendar is on this thread.
    Premium Trading Forum: subscription, public discussion and latest news
    Trading Forum wiki || MQL5 channel for the forum
    Trading blogs || My blog

  10. #140
    Junior Member
    Join Date
    Aug 2017
    Posts
    1
    Your submission could not be processed because the token has expired.

    Please push the back button and reload the previous window.
    Newdigital World

Page 14 of 15 FirstFirst ... 4 12 13 14 15 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •