|
@@ -0,0 +1,958 @@
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+//| line_level_news_filter.mq5 |
|
|
|
|
|
+//| Copyright 2025, MQL Development |
|
|
|
|
|
+//| https://www.mqldevelopment.com/ |
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+#property library
|
|
|
|
|
+#property copyright "Copyright 2025, MQL Development"
|
|
|
|
|
+#property link "https://www.mqldevelopment.com/"
|
|
|
|
|
+#property version "1.00"
|
|
|
|
|
+#include <Trade\Trade.mqh>
|
|
|
|
|
+CTrade trade;
|
|
|
|
|
+
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+//| My function |
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+// int MyCalculator(int value,int value2) export
|
|
|
|
|
+// {
|
|
|
|
|
+// return(value+value2);
|
|
|
|
|
+// }
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+#import "Wininet.dll"
|
|
|
|
|
+int InternetOpenW(string,int,string,string,int);
|
|
|
|
|
+int InternetConnectW(int,string,int,string,string,int,int,int);
|
|
|
|
|
+int HttpRequestW(int,string,string,int,string,int,string,int);
|
|
|
|
|
+int InternetOpenUrlW(int,string,string,int,int,int);
|
|
|
|
|
+int InternetReadFile(int,uchar &sBuffer[],int,int &OneInt);
|
|
|
|
|
+int InternetCloseHandle(int);
|
|
|
|
|
+bool DeleteUrlCacheEntryW(string);
|
|
|
|
|
+#import
|
|
|
|
|
+
|
|
|
|
|
+#import "kernel32.dll"
|
|
|
|
|
+int GetLastError(void);
|
|
|
|
|
+#import
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+datetime previous_time;
|
|
|
|
|
+datetime expiry=D'2026.10.16 12:30:27';
|
|
|
|
|
+string matchExpert="line_level_ea";
|
|
|
|
|
+string matchExpert2="Line_Level_Ea";
|
|
|
|
|
+string fileName="test1"+MQLInfoString(MQL_PROGRAM_NAME)+Symbol()+IntegerToString(Period())+".xml";
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+//| |
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+enum selectLine
|
|
|
|
|
+ {
|
|
|
|
|
+ LineOnNewsBar =0,
|
|
|
|
|
+ LineOnNewsStop=1
|
|
|
|
|
+ };
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+//| |
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+struct newsEvent
|
|
|
|
|
+ {
|
|
|
|
|
+ string title;
|
|
|
|
|
+ string country;
|
|
|
|
|
+ string date;
|
|
|
|
|
+ string time;
|
|
|
|
|
+ string impact;
|
|
|
|
|
+ newsEvent()
|
|
|
|
|
+ {
|
|
|
|
|
+ title="";
|
|
|
|
|
+ country="";
|
|
|
|
|
+ date="";
|
|
|
|
|
+ time="";
|
|
|
|
|
+ impact="";
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+const int newsSize=300;
|
|
|
|
|
+newsEvent ns[300];
|
|
|
|
|
+datetime lastNews;
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+//| |
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+void initiateNews() export
|
|
|
|
|
+ {
|
|
|
|
|
+ lastNews=TimeCurrent();
|
|
|
|
|
+ updateNews(); //change here
|
|
|
|
|
+ fillNewsStruct();
|
|
|
|
|
+ Print("The Symbol is:",Symbol()," and timeperiod:",Period()," and file name is:"+fileName);
|
|
|
|
|
+ }
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+//| |
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+//int OnInit()
|
|
|
|
|
+// {
|
|
|
|
|
+////---
|
|
|
|
|
+// bool check = MQLInfoInteger(MQL_DLLS_ALLOWED);
|
|
|
|
|
+// Print("DLL: ",check);
|
|
|
|
|
+// Alert("Enable");
|
|
|
|
|
+// return(INIT_SUCCEEDED);
|
|
|
|
|
+// }
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+//| |
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+int returnNewsStatus(bool highFlag=true
|
|
|
|
|
+ ,int high_impact_value=60//Stop Trade before high News (min)
|
|
|
|
|
+ ,int end_impact_value=15 //Stop Trade after high News (min)
|
|
|
|
|
+
|
|
|
|
|
+ ,bool show_high_line=true//Show verticle Line when high news comes
|
|
|
|
|
+ ,bool mediumFlag=true
|
|
|
|
|
+ ,int medium_impact_high=60//Stop Trade before medium News (min)
|
|
|
|
|
+ ,int medium_impact_low=15 //Stop Trade after medium News (min)
|
|
|
|
|
+
|
|
|
|
|
+ ,bool show_medium_line=true//Show verticle Line when medium news comes
|
|
|
|
|
+ ,bool lowFlag=true
|
|
|
|
|
+ ,int low_impact_high=60//Stop Trade before low News (min)
|
|
|
|
|
+ ,int low_impact_low=15 //Stop Trade after low News (min)
|
|
|
|
|
+
|
|
|
|
|
+ ,bool show_low_line=true//Show verticle Line when low news comes
|
|
|
|
|
+ ,string symbol=""
|
|
|
|
|
+ ,string expertname=""
|
|
|
|
|
+ ,int gmt=2
|
|
|
|
|
+ ,selectLine sl=0
|
|
|
|
|
+ ,string extraSymbol=""
|
|
|
|
|
+ ) export
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+//| |
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+ {
|
|
|
|
|
+ int newsStatus=0;
|
|
|
|
|
+//Print("TImeCurrent:"+TimeCurrent()+"expiry:"+expiry);
|
|
|
|
|
+//"Trend Gridder(22)" || expertname=="TG NEWS" || expertname=="TG News"
|
|
|
|
|
+//"tylergabor"
|
|
|
|
|
+//(( expertname=="TG NEWS" || expertname=="TG News" || expertname=="Bandit" || expertname=="BANDIT" || expertname=="bandit" || expertname=="TG NEWS" || expertname=="TG News" || expertname=="C-Storm" || expertname=="C-STORM" || expertname=="c-storm" || (expertname=="C-StormV1.1" || (StringFind(chkexpert,"tyler")!=-1) || (StringFind(chkexpert,"hullincash")!=-1) ||(StringFind(chkexpert,"pk5000")!=-1) )))// && TimeCurrent()<expiry)
|
|
|
|
|
+
|
|
|
|
|
+ string chkexpert=expertname;
|
|
|
|
|
+// Print("chkexpert ",chkexpert);
|
|
|
|
|
+// StringToLower(chkexpe/rt);
|
|
|
|
|
+
|
|
|
|
|
+ if(Validate())
|
|
|
|
|
+ {
|
|
|
|
|
+ if(TimeDayMQL4(TimeCurrent())!=TimeDayMQL4(lastNews))
|
|
|
|
|
+ {
|
|
|
|
|
+ updateNews(); // change here
|
|
|
|
|
+ fillNewsStruct();
|
|
|
|
|
+ lastNews=TimeCurrent();
|
|
|
|
|
+ Print("News Function is calling and updating by "+symbol);
|
|
|
|
|
+ }
|
|
|
|
|
+ int index=0;
|
|
|
|
|
+ string sym=symbol;
|
|
|
|
|
+ string metals=sym;
|
|
|
|
|
+ StringToLower(metals);
|
|
|
|
|
+ StringToLower(extraSymbol);
|
|
|
|
|
+ //Print("---------------------Metals:"+metals+ " and symbol:"+ns[index].country," and extraSymbol:",extraSymbol);
|
|
|
|
|
+ //Print("checking metal:"+(StringFind("Nymex-J",sym,0)!=-1) +" and metal is:"+sym );
|
|
|
|
|
+ //Print("country:"+ns[index].country+" and check "+StringFind("JPYAUD",ns[index].country,0)!=-1))
|
|
|
|
|
+ //Start working here
|
|
|
|
|
+ while(index<newsSize)
|
|
|
|
|
+ {
|
|
|
|
|
+ // Print("Inside the currency:"+index+ " currency"+ns[index].country+ " and curent demanding symbol:"+metals + "nstime:"+ns[index].time);
|
|
|
|
|
+
|
|
|
|
|
+ if((StringFind(sym,ns[index].country,0)!=-1) || ((metals=="wticrude." || metals=="usoil" || metals=="crude" || metals=="crude" || metals=="usousd" || metals=="wticousd" || (StringFind(metals,"nymex",0)!=-1) || (StringFind(metals,"WTICrude",0)!=-1) || (StringFind(metals,extraSymbol,0)!=-1)) &&((StringFind("USD",ns[index].country,0)!=-1) || (StringFind("CAD",ns[index].country,0)!=-1))))
|
|
|
|
|
+ {
|
|
|
|
|
+ // Print("Inside the currency:"+index+ " currency"+ns[index].country+ " and curent demanding symbol:"+metals + "nstime:"+ns[index].time);
|
|
|
|
|
+
|
|
|
|
|
+ // int low_time;
|
|
|
|
|
+ // int high_time;
|
|
|
|
|
+ datetime ulow_time,uhigh_time;
|
|
|
|
|
+
|
|
|
|
|
+ // int time_in_seconds;
|
|
|
|
|
+ datetime utime_in_seconds;
|
|
|
|
|
+ //this is the current broker time
|
|
|
|
|
+ // time_in_seconds=(TimeHour(iTime(symbol,0,0))*60*60)+(TimeMinute(iTime(symbol,0,0))*60);
|
|
|
|
|
+ // Print("nsDate:"+ns[index].date);
|
|
|
|
|
+ utime_in_seconds=TimeCurrent();
|
|
|
|
|
+
|
|
|
|
|
+ string chngdt=changeDateFormate(ns[index].date);
|
|
|
|
|
+ // string Date1=TimeToStr(TimeCurrent(),TIME_DATE);
|
|
|
|
|
+
|
|
|
|
|
+ datetime updatedDateTime=StringToTime(chngdt+" 00:00:00");
|
|
|
|
|
+ updatedDateTime+=NsTimeInSeconds(ns[index].time);
|
|
|
|
|
+
|
|
|
|
|
+ // Print("updateTime1+nsTime:"+updatedDateTime+ "currency:"+ns[index].country);
|
|
|
|
|
+
|
|
|
|
|
+ // string updatedTime=TimeToStr(updatedDateTime,TIME_MINUTES);
|
|
|
|
|
+ updatedDateTime+=((gmt)*3600);
|
|
|
|
|
+
|
|
|
|
|
+ // Print("updateTime 2 +nsTime:"+updatedDateTime+ "currency:"+ns[index].country);
|
|
|
|
|
+ // string Today1=TimeToStr(updatedDateTime,TIME_DATE);
|
|
|
|
|
+
|
|
|
|
|
+ // string times=Time24Conversion(ns[index].time);
|
|
|
|
|
+ datetime temp2;
|
|
|
|
|
+ temp2=updatedDateTime;
|
|
|
|
|
+ // Print("chngDate:"+chngdt);
|
|
|
|
|
+ // Print("Time in Seconds:"+time_in_seconds);
|
|
|
|
|
+ // Print("temp2:"+temp2);
|
|
|
|
|
+ // Print("------------Index:"+index+" updated Date Time:"+updatedDateTime);
|
|
|
|
|
+
|
|
|
|
|
+ if(ns[index].impact=="High" && highFlag)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ // low_time=NsTimeInSeconds(ns[index].time)-(high_impact_value*60);
|
|
|
|
|
+ //high_time=NsTimeInSeconds(ns[index].time)+(end_impact_value*60);
|
|
|
|
|
+ ulow_time=updatedDateTime-(high_impact_value*60);
|
|
|
|
|
+ uhigh_time=updatedDateTime+(end_impact_value*60);
|
|
|
|
|
+ // Print("High least:"+low_time+" high highest:"+high_time);
|
|
|
|
|
+ // Print("Date1:"+Date1+" today1:"+Today1);
|
|
|
|
|
+ // if(Date1==Today1 && (time_in_seconds>=low_time && time_in_seconds<=high_time))
|
|
|
|
|
+ // Print("------------Index:"+index+" updated Date Time:"+updatedDateTime);
|
|
|
|
|
+
|
|
|
|
|
+ // Print("----------HighNews dateTime:"+utime_in_seconds+" lowOfNews:"+ulow_time+" highOfnews:"+uhigh_time);
|
|
|
|
|
+ if(utime_in_seconds>=ulow_time && utime_in_seconds<=uhigh_time)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ //flag=true;
|
|
|
|
|
+ newsStatus=1;
|
|
|
|
|
+ if(temp2!=previous_time)
|
|
|
|
|
+ {
|
|
|
|
|
+ if(show_high_line==true)
|
|
|
|
|
+ {
|
|
|
|
|
+ Print("Inside high alert");
|
|
|
|
|
+ datetime lineTime=TimeCurrent();
|
|
|
|
|
+ if(sl==0)
|
|
|
|
|
+ lineTime=updatedDateTime;
|
|
|
|
|
+
|
|
|
|
|
+ ObjectCreate(0,"VLine"+TimeToString(lineTime),OBJ_VLINE,0,lineTime,0);
|
|
|
|
|
+ ObjectSetInteger(0,"VLine"+TimeToString(lineTime),OBJPROP_STYLE,STYLE_DOT);
|
|
|
|
|
+ ObjectSetInteger(0,"VLine"+TimeToString(lineTime),OBJPROP_COLOR,clrRed);
|
|
|
|
|
+ ObjectSetInteger(0,"VLine"+TimeToString(lineTime),OBJPROP_WIDTH,1);
|
|
|
|
|
+ }
|
|
|
|
|
+ previous_time=temp2;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //medium impact
|
|
|
|
|
+ else
|
|
|
|
|
+ if(ns[index].impact=="Medium" && mediumFlag)
|
|
|
|
|
+ {
|
|
|
|
|
+ // low_time=NsTimeInSeconds(ns[index].time)-(medium_impact_high*60);
|
|
|
|
|
+ // high_time=NsTimeInSeconds(ns[index].time)+(medium_impact_high*60);
|
|
|
|
|
+ ulow_time=updatedDateTime-(medium_impact_high*60);
|
|
|
|
|
+ uhigh_time=updatedDateTime+(medium_impact_low*60);
|
|
|
|
|
+
|
|
|
|
|
+ // Print("medium least:"+low_time+" medium highest:"+high_time);
|
|
|
|
|
+ // if(Date1==Today1 && (time_in_seconds>=low_time && time_in_seconds<=high_time))
|
|
|
|
|
+
|
|
|
|
|
+ // Print("----------MediumNews dateTime:"+utime_in_seconds+" lowOfNews:"+ulow_time+" highOfnews:"+uhigh_time);
|
|
|
|
|
+
|
|
|
|
|
+ if(utime_in_seconds>=ulow_time && utime_in_seconds<=uhigh_time)
|
|
|
|
|
+
|
|
|
|
|
+ {
|
|
|
|
|
+ //StopTrading(); //Close Current Orders Buy/Sell
|
|
|
|
|
+ // flag=true;
|
|
|
|
|
+ // Print("Inside high alert");
|
|
|
|
|
+ newsStatus=2;
|
|
|
|
|
+ if(temp2!=previous_time)
|
|
|
|
|
+ {
|
|
|
|
|
+ if(show_medium_line==true)
|
|
|
|
|
+ {
|
|
|
|
|
+ datetime lineTime=TimeCurrent();
|
|
|
|
|
+ if(sl==0)
|
|
|
|
|
+ lineTime=updatedDateTime;
|
|
|
|
|
+
|
|
|
|
|
+ ObjectCreate(0,"VLine"+TimeToString(lineTime),OBJ_VLINE,0,lineTime,0);
|
|
|
|
|
+ ObjectSetInteger(0,"VLine"+TimeToString(lineTime),OBJPROP_STYLE,STYLE_DOT);
|
|
|
|
|
+
|
|
|
|
|
+ ObjectSetInteger(0,"VLine"+TimeToString(lineTime),OBJPROP_COLOR,clrGreen);
|
|
|
|
|
+ ObjectSetInteger(0,"VLine"+TimeToString(lineTime),OBJPROP_WIDTH,1);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ previous_time=temp2;
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ if(ns[index].impact=="Low" && lowFlag)
|
|
|
|
|
+ {
|
|
|
|
|
+ /// low_time=NsTimeInSeconds(ns[index].time)-(low_impact_high*60);
|
|
|
|
|
+ // high_time=NsTimeInSeconds(ns[index].time)+(low_impact_high*60);
|
|
|
|
|
+ //Print("low least:"+low_time+" low highest:"+high_time);
|
|
|
|
|
+ // Print("In low impact and currency is:"+ns[index].country);
|
|
|
|
|
+ ulow_time=updatedDateTime-(low_impact_high*60);
|
|
|
|
|
+ uhigh_time=(updatedDateTime)+(low_impact_low*60);
|
|
|
|
|
+
|
|
|
|
|
+ // if(Date1==Today1 && (time_in_seconds>=low_time && time_in_seconds<=high_time))
|
|
|
|
|
+
|
|
|
|
|
+ // Print("-------Low news Now dateTime:"+utime_in_seconds+" lowOfNews:"+ulow_time+" highOfnews:"+uhigh_time);//+" low time in min:"+low_impact_low);
|
|
|
|
|
+
|
|
|
|
|
+ if(utime_in_seconds>=ulow_time && utime_in_seconds<=uhigh_time)
|
|
|
|
|
+
|
|
|
|
|
+ {
|
|
|
|
|
+ //StopTrading(); //Close Current Orders Buy/Sell
|
|
|
|
|
+ // flag=true;
|
|
|
|
|
+ // Print("Inside high alert");
|
|
|
|
|
+ // Print("updateDateTime:"+updatedDateTime);
|
|
|
|
|
+ newsStatus=3;
|
|
|
|
|
+ // Print("Temp2"+temp2);
|
|
|
|
|
+ if(temp2!=previous_time)
|
|
|
|
|
+ {
|
|
|
|
|
+ if(show_low_line==true)
|
|
|
|
|
+ {
|
|
|
|
|
+ datetime lineTime=TimeCurrent();
|
|
|
|
|
+ if(sl==0)
|
|
|
|
|
+ lineTime=updatedDateTime;
|
|
|
|
|
+
|
|
|
|
|
+ // Print("s1:"+sl+ " lineTime:"+lineTime );
|
|
|
|
|
+ // Print("nsDate:"+ns[index].date+" nstime:"+ns[index].time+ "Sym:"+ns[index].country );
|
|
|
|
|
+ ObjectCreate(0,"VLine"+TimeToString(lineTime),OBJ_VLINE,0,lineTime,0);
|
|
|
|
|
+ ObjectSetInteger(0,"VLine"+TimeToString(lineTime),OBJPROP_STYLE,STYLE_DOT);
|
|
|
|
|
+
|
|
|
|
|
+ ObjectSetInteger(0,"VLine"+TimeToString(lineTime),OBJPROP_COLOR,clrBlue);
|
|
|
|
|
+ ObjectSetInteger(0,"VLine"+TimeToString(lineTime),OBJPROP_WIDTH,1);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ previous_time=temp2;
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ //
|
|
|
|
|
+ }//Close Country Symbol if
|
|
|
|
|
+ index++;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ // Print("exprtName:"+chkexpert+"stringfind:"+IntegerToString((StringFind(chkexpert,"FX Ekspert Ghost Trader"))));
|
|
|
|
|
+ Print("Validation Error");
|
|
|
|
|
+ }
|
|
|
|
|
+ return newsStatus;
|
|
|
|
|
+ }
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+//| |
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+string AlphaNumeric(string istr)
|
|
|
|
|
+ {
|
|
|
|
|
+ string other="Aa";
|
|
|
|
|
+ string ostr = "";
|
|
|
|
|
+ for(int i=0; i<StringLen(istr); i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ string s=StringSubstr(istr,i,1);
|
|
|
|
|
+ if((s>="A" && s<="Z" && StringFind(other,"A")>=0)
|
|
|
|
|
+ || (s >= "a" && s <= "z" && StringFind(other,"a") >= 0)
|
|
|
|
|
+ || (s >= "0" && s <= "9" && StringFind(other,"1") >= 0)
|
|
|
|
|
+ || (s==":")
|
|
|
|
|
+ || (s=="-")
|
|
|
|
|
+ || (s=="0")
|
|
|
|
|
+ || (s=="1")
|
|
|
|
|
+ || (s=="2")
|
|
|
|
|
+ || (s=="3")
|
|
|
|
|
+ || (s=="4")
|
|
|
|
|
+ || (s=="5")
|
|
|
|
|
+ || (s=="6")
|
|
|
|
|
+ || (s=="7")
|
|
|
|
|
+ || (s=="8")
|
|
|
|
|
+ || (s=="9")
|
|
|
|
|
+ || StringFind(other,s)>=0)
|
|
|
|
|
+ ostr=ostr+s;
|
|
|
|
|
+ }
|
|
|
|
|
+ return(ostr);
|
|
|
|
|
+ }
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+//| ChartEvent function |
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+void fillNewsStruct()
|
|
|
|
|
+ {
|
|
|
|
|
+ int file_handle=FileOpen(fileName,FILE_READ|FILE_ANSI);
|
|
|
|
|
+
|
|
|
|
|
+ if(file_handle!=INVALID_HANDLE)
|
|
|
|
|
+ {
|
|
|
|
|
+ PrintFormat("%s file is available for reading",fileName);
|
|
|
|
|
+ //PrintFormat("File path: %s\\Files\\",TerminalInfoString(TERMINAL_DATA_PATH));
|
|
|
|
|
+ //--- additional variables
|
|
|
|
|
+ int str_size;
|
|
|
|
|
+ string str ;
|
|
|
|
|
+ //--- read data from the file
|
|
|
|
|
+ int n=0;
|
|
|
|
|
+ Print("n:",n);
|
|
|
|
|
+ while(!FileIsEnding(file_handle))
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ // Print("n:",n);
|
|
|
|
|
+ //--- find out how many symbols are used for writing the time
|
|
|
|
|
+
|
|
|
|
|
+ str_size=FileReadInteger(file_handle,INT_VALUE);
|
|
|
|
|
+ Print("size:",str_size);
|
|
|
|
|
+
|
|
|
|
|
+ //--- read the string
|
|
|
|
|
+ str=FileReadString(file_handle,str_size);
|
|
|
|
|
+ Print("Printing what is inside the n :",str);
|
|
|
|
|
+
|
|
|
|
|
+ if(StringFind(str,"<title>",0)!=-1)
|
|
|
|
|
+ {
|
|
|
|
|
+ StringReplace(str,"<title>","");
|
|
|
|
|
+ StringReplace(str,"</title>","");
|
|
|
|
|
+ str=AlphaNumeric(str);
|
|
|
|
|
+ ns[n].title=str;
|
|
|
|
|
+ //Print("title ",ns[n].title);
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ if(StringFind(str,"<country>",0)!=-1)
|
|
|
|
|
+ {
|
|
|
|
|
+ StringReplace(str,"<country>","");
|
|
|
|
|
+ StringReplace(str,"</country>","");
|
|
|
|
|
+ str=AlphaNumeric(str);
|
|
|
|
|
+ ns[n].country=str;
|
|
|
|
|
+ //Print("country ",ns[n].country);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ if(StringFind(str,"<date>",0)!=-1)
|
|
|
|
|
+ {
|
|
|
|
|
+ StringReplace(str,"<date>","");
|
|
|
|
|
+ StringReplace(str,"</date>","");
|
|
|
|
|
+ StringReplace(str,"CDATA","");
|
|
|
|
|
+ str=AlphaNumeric(str);
|
|
|
|
|
+ ns[n].date=str;
|
|
|
|
|
+ // Print("date ",ns[n].date);
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ if(StringFind(str,"<time>",0)!=-1)
|
|
|
|
|
+ {
|
|
|
|
|
+ StringReplace(str,"<time>","");
|
|
|
|
|
+ StringReplace(str,"</time>","");
|
|
|
|
|
+ StringReplace(str,"CDATA","");
|
|
|
|
|
+ str=AlphaNumeric(str);
|
|
|
|
|
+ ns[n].time=str;
|
|
|
|
|
+ // Print("time ",ns[n].time);
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ if(StringFind(str,"<impact>",0)!=-1)
|
|
|
|
|
+ {
|
|
|
|
|
+ StringReplace(str,"<impact>","");
|
|
|
|
|
+ StringReplace(str,"</impact>","");
|
|
|
|
|
+ StringReplace(str,"CDATA","");
|
|
|
|
|
+ str=AlphaNumeric(str);
|
|
|
|
|
+ ns[n].impact=str;
|
|
|
|
|
+ // Print("impact ",ns[n].impact);
|
|
|
|
|
+
|
|
|
|
|
+ n++;
|
|
|
|
|
+ }
|
|
|
|
|
+ //--- print the string
|
|
|
|
|
+ // PrintFormat(str);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ //--- close the file
|
|
|
|
|
+ FileClose(file_handle);
|
|
|
|
|
+ PrintFormat("Data is read, %s file is closed",fileName);
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ PrintFormat("Failed to open %s file, Error code = %d",fileName,GetLastError());
|
|
|
|
|
+ }
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+//| |
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+void updateNews()
|
|
|
|
|
+ {
|
|
|
|
|
+ string cookie=NULL,strNews;
|
|
|
|
|
+ string reqheaders="User-Agent: Mozilla/4.0\r\n";
|
|
|
|
|
+ char post[],result[];
|
|
|
|
|
+ int res;
|
|
|
|
|
+//http://www.forexfactory.com/ffcal_week_this.xml
|
|
|
|
|
+ string url="https://cdn-nfs.faireconomy.media/ff_calendar_thisweek.xml";
|
|
|
|
|
+ url="https://nfs.faireconomy.media/ff_calendar_thisweek.xml";
|
|
|
|
|
+ ResetLastError();
|
|
|
|
|
+ int timeout=5000;
|
|
|
|
|
+//res=WebRequest("GET",url,reqheaders,timeout,post,result,headers);
|
|
|
|
|
+ res=InternetGetFile(url,strNews);
|
|
|
|
|
+
|
|
|
|
|
+ StringToCharArray(strNews,result);
|
|
|
|
|
+ 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 '"+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(fileName,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());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+//| |
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+//| |
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+int NsTimeInSeconds(string str)
|
|
|
|
|
+ {
|
|
|
|
|
+ int temp=0;
|
|
|
|
|
+ datetime temp0=StringToTime(str);
|
|
|
|
|
+ int _hour=TimeHourMQL4(temp0);
|
|
|
|
|
+ int _minute=TimeMinuteMQL4(temp0);
|
|
|
|
|
+ if(str[StringLen(str)-2]=='p' && _hour!=12)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ _hour=_hour+12;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ if((str[StringLen(str)-2]=='a') && _hour==12)
|
|
|
|
|
+ _hour=0;
|
|
|
|
|
+ temp=temp+(_hour*3600);
|
|
|
|
|
+ temp=temp+(_minute*60);
|
|
|
|
|
+ return temp;
|
|
|
|
|
+ }
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+//| |
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+//| |
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+string Time24Conversion(string time)
|
|
|
|
|
+ {
|
|
|
|
|
+ string hour,t_mode,min;
|
|
|
|
|
+ int count=0;
|
|
|
|
|
+ bool fl=false;
|
|
|
|
|
+ for(int i=0; i<StringLen(time); i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ if(count==0 && (StringSubstr(time,i,1)!=":"))
|
|
|
|
|
+ hour=hour+StringSubstr(time,i,1);
|
|
|
|
|
+ else
|
|
|
|
|
+ if(StringSubstr(time,i,1)==":")
|
|
|
|
|
+ {
|
|
|
|
|
+ count++;
|
|
|
|
|
+ i++;
|
|
|
|
|
+ }
|
|
|
|
|
+ if(count==1 && (StringSubstr(time,i,1)!="a" && StringSubstr(time,i,1)!="p" && StringSubstr(time,i,1)!="m"))
|
|
|
|
|
+ min=min+StringSubstr(time,i,1);
|
|
|
|
|
+ if(StringSubstr(time,i,1)=="a")
|
|
|
|
|
+ t_mode="a";
|
|
|
|
|
+ else
|
|
|
|
|
+ if(StringSubstr(time,i,1)=="p")
|
|
|
|
|
+ t_mode="p";
|
|
|
|
|
+ }
|
|
|
|
|
+ long h=StringToInteger(hour);
|
|
|
|
|
+ if(t_mode=="p")
|
|
|
|
|
+ h=h+12;
|
|
|
|
|
+ string final_time=IntegerToString(h)+":"+min;
|
|
|
|
|
+ return final_time;
|
|
|
|
|
+ }
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+//| |
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+string changeDateFormate(string date)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ string str[],result="";
|
|
|
|
|
+ StringSplit(date,'-',str);
|
|
|
|
|
+// Print("Str0:"+str[0]+" str1:"+str[1]+" str2:"+str[2]);
|
|
|
|
|
+ result=str[2]+"."+str[0]+"."+str[1];
|
|
|
|
|
+// Print("result:"+result);
|
|
|
|
|
+ return result;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+//| |
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+datetime NsDate(string str)
|
|
|
|
|
+ {
|
|
|
|
|
+ string month=StringSubstr(str,0,2);
|
|
|
|
|
+ string day=StringSubstr(str,3,2);
|
|
|
|
|
+ string year = StringSubstr(str,6,4);
|
|
|
|
|
+ string date = year+"."+month+"."+day;
|
|
|
|
|
+ datetime date_time=StringToTime(date);
|
|
|
|
|
+ return date_time;
|
|
|
|
|
+ }
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+//| |
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+datetime NsDateTime(string date,string time)
|
|
|
|
|
+ {
|
|
|
|
|
+ datetime t1 = NsDate(date);
|
|
|
|
|
+ datetime t2 = NsTimeInSeconds(time);
|
|
|
|
|
+ datetime t3 = t1+t2;
|
|
|
|
|
+ return t3;
|
|
|
|
|
+ }
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+//| |
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+bool Validate() export
|
|
|
|
|
+ {
|
|
|
|
|
+// if(MQLInfoString(MQL_PROGRAM_NAME)=="AProxAlert")
|
|
|
|
|
+
|
|
|
|
|
+ string chkexpert=MQLInfoString(MQL_PROGRAM_NAME);
|
|
|
|
|
+//Print("Calling Expert: ",chkexpert);
|
|
|
|
|
+ StringToLower(chkexpert);
|
|
|
|
|
+ if((StringFind(chkexpert,matchExpert)!=-1) || chkexpert=="news" || (StringFind(chkexpert,matchExpert2)!=-1))
|
|
|
|
|
+ {
|
|
|
|
|
+ // Print("Calling Expert: ",chkexpert);
|
|
|
|
|
+ //string content;
|
|
|
|
|
+ // string request="http://www.verifymysystem.com/";
|
|
|
|
|
+ // InternetGetFile(request,content);
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+//+ Main function which returns Windows error code +
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+int InternetGetFile(string url,string &content)
|
|
|
|
|
+ {
|
|
|
|
|
+//--- Init
|
|
|
|
|
+ content=NULL;
|
|
|
|
|
+
|
|
|
|
|
+//--- Create connection
|
|
|
|
|
+ int httpconnect=0;
|
|
|
|
|
+ int httprequest=0;
|
|
|
|
|
+ int httpopen=Wininet::InternetOpenW("InternetGetFileMQL",0," "," ",0);
|
|
|
|
|
+ int e=kernel32::GetLastError();
|
|
|
|
|
+ if(e==0)
|
|
|
|
|
+ {
|
|
|
|
|
+ bool flag=Wininet::DeleteUrlCacheEntryW(url);
|
|
|
|
|
+ httprequest=Wininet::InternetOpenUrlW(httpopen,url,NULL,0,16|10,0);
|
|
|
|
|
+ e=kernel32::GetLastError();
|
|
|
|
|
+ if(e==0)
|
|
|
|
|
+ {
|
|
|
|
|
+ //--- Define buffers
|
|
|
|
|
+ uchar ch[512];
|
|
|
|
|
+ string temp="";
|
|
|
|
|
+
|
|
|
|
|
+ //--- Retrieve data from file
|
|
|
|
|
+ int cnt=0;
|
|
|
|
|
+ while(Wininet::InternetReadFile(httprequest,ch,512,cnt))
|
|
|
|
|
+ {
|
|
|
|
|
+ //e=kernel32::GetLastError();
|
|
|
|
|
+ if(cnt<=0)
|
|
|
|
|
+ break;
|
|
|
|
|
+ temp=temp+CharArrayToString(ch,0,cnt);
|
|
|
|
|
+ }
|
|
|
|
|
+ //--- Store result
|
|
|
|
|
+ content=temp;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+//--- Close connection
|
|
|
|
|
+ if(httprequest>0)
|
|
|
|
|
+ InternetCloseHandle(httprequest);
|
|
|
|
|
+ if(httpopen>0)
|
|
|
|
|
+ InternetCloseHandle(httpopen);
|
|
|
|
|
+
|
|
|
|
|
+//--- Get out and return error code
|
|
|
|
|
+ return(e);
|
|
|
|
|
+ }
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+//+ Macro function which returns content directly +
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+string InternetGetFile(string url)
|
|
|
|
|
+ {
|
|
|
|
|
+ string content=NULL;
|
|
|
|
|
+ int e=InternetGetFile(url,content);
|
|
|
|
|
+ return content;
|
|
|
|
|
+ }
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+void closeTrades(ENUM_POSITION_TYPE type,int magic)
|
|
|
|
|
+ {
|
|
|
|
|
+ Print("in close trade function : ",PositionsTotal());
|
|
|
|
|
+ for(int i=PositionsTotal()-1; i>=0; i--)
|
|
|
|
|
+ {
|
|
|
|
|
+ ulong ticket = PositionGetTicket(i);
|
|
|
|
|
+ string symbol=PositionGetSymbol(i);
|
|
|
|
|
+ Print("ticket ",ticket," Symbol : ",symbol);
|
|
|
|
|
+
|
|
|
|
|
+ if(PositionSelectByTicket(ticket))
|
|
|
|
|
+ {
|
|
|
|
|
+ Print("1");
|
|
|
|
|
+ if(PositionGetString(POSITION_SYMBOL)==symbol && PositionGetInteger(POSITION_MAGIC) == magic && PositionGetInteger(POSITION_TYPE)==type)
|
|
|
|
|
+ {
|
|
|
|
|
+ Print("2");
|
|
|
|
|
+ if((PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY)||(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_SELL))
|
|
|
|
|
+ {
|
|
|
|
|
+ if(!trade.PositionClose(ticket))
|
|
|
|
|
+ {
|
|
|
|
|
+ Print("Problem in closing order buy", GetLastError());
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ Print("Buy Order closed");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+int orderCount(ENUM_POSITION_TYPE type,int magic_no)
|
|
|
|
|
+ {
|
|
|
|
|
+ int count=0;
|
|
|
|
|
+ for(int i=0; i<PositionsTotal(); i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ ulong ticket = PositionGetTicket(i);
|
|
|
|
|
+ PositionSelectByTicket(ticket);
|
|
|
|
|
+ if(PositionGetInteger(POSITION_MAGIC)== magic_no && PositionGetSymbol(POSITION_SYMBOL)==Symbol() && PositionGetInteger(POSITION_TYPE) == type)
|
|
|
|
|
+ {
|
|
|
|
|
+ count++;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+// Print("Order count" + count);
|
|
|
|
|
+ return count;
|
|
|
|
|
+ }
|
|
|
|
|
+//+-----------
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+void deleteFileNews()export
|
|
|
|
|
+ {
|
|
|
|
|
+ if(FileIsExist(fileName))
|
|
|
|
|
+ if(FileDelete(fileName))
|
|
|
|
|
+ {
|
|
|
|
|
+ Print("File:"+fileName+" deleted");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+string returnUpCommingNews(bool highFlag=true,
|
|
|
|
|
+ int high_impact_value=60//Stop Trade before high News (min)
|
|
|
|
|
+ ,int end_impact_value=15 //Stop Trade after high News (min)
|
|
|
|
|
+
|
|
|
|
|
+ ,bool mediumFlag=true
|
|
|
|
|
+ ,int medium_impact_high=60//Stop Trade before medium News (min)
|
|
|
|
|
+ ,int medium_impact_low=15 //Stop Trade after medium News (min)
|
|
|
|
|
+ ,bool lowFlag=true
|
|
|
|
|
+ ,int low_impact_high=60//Stop Trade before low News (min)
|
|
|
|
|
+ ,int low_impact_low=15 //Stop Trade after low News (min)
|
|
|
|
|
+
|
|
|
|
|
+ ,string symbol=""
|
|
|
|
|
+ ,string expertname=""
|
|
|
|
|
+ ,int gmt=2
|
|
|
|
|
+
|
|
|
|
|
+ ) export
|
|
|
|
|
+ {
|
|
|
|
|
+ int newsStatus=0;
|
|
|
|
|
+ string content="No News";
|
|
|
|
|
+//Print("TImeCurrent:"+TimeCurrent()+"expiry:"+expiry);
|
|
|
|
|
+//"Trend Gridder(22)" || expertname=="TG NEWS" || expertname=="TG News"
|
|
|
|
|
+//"tylergabor"
|
|
|
|
|
+//(( expertname=="TG NEWS" || expertname=="TG News" || expertname=="Bandit" || expertname=="BANDIT" || expertname=="bandit" || expertname=="TG NEWS" || expertname=="TG News" || expertname=="C-Storm" || expertname=="C-STORM" || expertname=="c-storm" || (expertname=="C-StormV1.1" || (StringFind(chkexpert,"tyler")!=-1) || (StringFind(chkexpert,"hullincash")!=-1) ||(StringFind(chkexpert,"pk5000")!=-1) )))// && TimeCurrent()<expiry)
|
|
|
|
|
+
|
|
|
|
|
+// string chkexpert=expertname;
|
|
|
|
|
+// StringToLower(chkexpert);
|
|
|
|
|
+ if(Validate())
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ if(TimeDayMQL4(TimeCurrent())!=TimeDayMQL4(lastNews))
|
|
|
|
|
+ {
|
|
|
|
|
+ //updateNews();
|
|
|
|
|
+ fillNewsStruct();
|
|
|
|
|
+ lastNews=TimeCurrent();
|
|
|
|
|
+ Print("News Function is calling and updating by "+symbol);
|
|
|
|
|
+ }
|
|
|
|
|
+ int index=0;
|
|
|
|
|
+ string sym=symbol;
|
|
|
|
|
+ string metals=sym;
|
|
|
|
|
+ StringToLower(metals);
|
|
|
|
|
+ // StringToLower(extraSymbol);
|
|
|
|
|
+ //Print("---------------------Metals:"+metals+ " and symbol:"+ns[index].country," and extraSymbol:",extraSymbol);
|
|
|
|
|
+ //Print("checking metal:"+(StringFind("Nymex-J",sym,0)!=-1) +" and metal is:"+sym );
|
|
|
|
|
+ //Print("country:"+ns[index].country+" and check "+StringFind("JPYAUD",ns[index].country,0)!=-1))
|
|
|
|
|
+ //Start working here
|
|
|
|
|
+ while(index<newsSize)
|
|
|
|
|
+ {
|
|
|
|
|
+ Print("Inside the currency:",index, " currency:",ns[index].country," and curent demanding symbol:",metals, " nstime:",ns[index].time);
|
|
|
|
|
+
|
|
|
|
|
+ if((StringFind(sym,ns[index].country,0)!=-1))// || ((metals=="wticrude." || metals=="usoil" || metals=="crude" || metals=="crude" || metals=="usousd" || metals=="wticousd" || (StringFind(metals,"nymex",0)!=-1) || (StringFind(metals,"WTICrude",0)!=-1) || (StringFind(metals,extraSymbol,0)!=-1)) &&((StringFind("USD",ns[index].country,0)!=-1) || (StringFind("CAD",ns[index].country,0)!=-1))))
|
|
|
|
|
+ {
|
|
|
|
|
+ Print("Inside the currency:",index, " currency",ns[index].country, " and curent demanding symbol:",metals, "nstime:",ns[index].time);
|
|
|
|
|
+
|
|
|
|
|
+ // int low_time;
|
|
|
|
|
+ // int high_time;
|
|
|
|
|
+ datetime ulow_time,uhigh_time;
|
|
|
|
|
+
|
|
|
|
|
+ // int time_in_seconds;
|
|
|
|
|
+ datetime utime_in_seconds;
|
|
|
|
|
+ //this is the current broker time
|
|
|
|
|
+ // time_in_seconds=(TimeHour(iTime(symbol,0,0))*60*60)+(TimeMinute(iTime(symbol,0,0))*60);
|
|
|
|
|
+ // Print("nsDate:"+ns[index].date);
|
|
|
|
|
+ utime_in_seconds=TimeCurrent();
|
|
|
|
|
+
|
|
|
|
|
+ string chngdt=changeDateFormate(ns[index].date);
|
|
|
|
|
+ // string Date1=TimeToString(TimeCurrent(),TIME_DATE);
|
|
|
|
|
+
|
|
|
|
|
+ datetime updatedDateTime=StringToTime(chngdt+" 00:00:00");
|
|
|
|
|
+ updatedDateTime+=NsTimeInSeconds(ns[index].time);
|
|
|
|
|
+
|
|
|
|
|
+ // Print("updateTime1+nsTime:"+updatedDateTime+ "currency:"+ns[index].country);
|
|
|
|
|
+
|
|
|
|
|
+ // string updatedTime=TimeToString(updatedDateTime,TIME_MINUTES);
|
|
|
|
|
+ updatedDateTime+=((gmt)*3600);
|
|
|
|
|
+
|
|
|
|
|
+ // Print("updateTime 2 +nsTime:"+updatedDateTime+ "currency:"+ns[index].country);
|
|
|
|
|
+ // string Today1=TimeToString(updatedDateTime,TIME_DATE);
|
|
|
|
|
+
|
|
|
|
|
+ // string times=Time24Conversion(ns[index].time);
|
|
|
|
|
+ datetime temp2;
|
|
|
|
|
+ temp2=updatedDateTime;
|
|
|
|
|
+ // Print("chngDate:"+chngdt);
|
|
|
|
|
+ // Print("Time in Seconds:"+time_in_seconds);
|
|
|
|
|
+ // Print("temp2:"+temp2);
|
|
|
|
|
+ Print("------------Index:",index," updated Date Time:",updatedDateTime);
|
|
|
|
|
+
|
|
|
|
|
+ if(ns[index].impact=="High" && highFlag)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ // low_time=NsTimeInSeconds(ns[index].time)-(high_impact_value*60);
|
|
|
|
|
+ //high_time=NsTimeInSeconds(ns[index].time)+(end_impact_value*60);
|
|
|
|
|
+ ulow_time=updatedDateTime-(high_impact_value*60);
|
|
|
|
|
+ uhigh_time=updatedDateTime+(end_impact_value*60);
|
|
|
|
|
+ // Print("High least:"+low_time+" high highest:"+high_time);
|
|
|
|
|
+ // Print("Date1:"+Date1+" today1:"+Today1);
|
|
|
|
|
+ // if(Date1==Today1 && (time_in_seconds>=low_time && time_in_seconds<=high_time))
|
|
|
|
|
+ // Print("------------Index:"+index+" updated Date Time:"+updatedDateTime);
|
|
|
|
|
+
|
|
|
|
|
+ // Print("----------HighNews dateTime:"+utime_in_seconds+" lowOfNews:"+ulow_time+" highOfnews:"+uhigh_time);
|
|
|
|
|
+ if(utime_in_seconds>=ulow_time && utime_in_seconds<=uhigh_time)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ //flag=true;
|
|
|
|
|
+ newsStatus=1;
|
|
|
|
|
+ if(temp2!=previous_time)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ Print("Inside high alert");
|
|
|
|
|
+
|
|
|
|
|
+ content=ns[index].title;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ previous_time=temp2;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //medium impact
|
|
|
|
|
+ else
|
|
|
|
|
+ if(ns[index].impact=="Medium" && mediumFlag)
|
|
|
|
|
+ {
|
|
|
|
|
+ // low_time=NsTimeInSeconds(ns[index].time)-(medium_impact_high*60);
|
|
|
|
|
+ // high_time=NsTimeInSeconds(ns[index].time)+(medium_impact_high*60);
|
|
|
|
|
+ ulow_time=updatedDateTime-(medium_impact_high*60);
|
|
|
|
|
+ uhigh_time=updatedDateTime+(medium_impact_low*60);
|
|
|
|
|
+
|
|
|
|
|
+ // Print("medium least:"+low_time+" medium highest:"+high_time);
|
|
|
|
|
+ // if(Date1==Today1 && (time_in_seconds>=low_time && time_in_seconds<=high_time))
|
|
|
|
|
+
|
|
|
|
|
+ // Print("----------MediumNews dateTime:"+utime_in_seconds+" lowOfNews:"+ulow_time+" highOfnews:"+uhigh_time);
|
|
|
|
|
+
|
|
|
|
|
+ if(utime_in_seconds>=ulow_time && utime_in_seconds<=uhigh_time)
|
|
|
|
|
+
|
|
|
|
|
+ {
|
|
|
|
|
+ //StopTrading(); //Close Current Orders Buy/Sell
|
|
|
|
|
+ // flag=true;
|
|
|
|
|
+ // Print("Inside high alert");
|
|
|
|
|
+ newsStatus=2;
|
|
|
|
|
+ if(temp2!=previous_time)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ content=ns[index].title;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ previous_time=temp2;
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ if(ns[index].impact=="Low" && lowFlag)
|
|
|
|
|
+ {
|
|
|
|
|
+ /// low_time=NsTimeInSeconds(ns[index].time)-(low_impact_high*60);
|
|
|
|
|
+ // high_time=NsTimeInSeconds(ns[index].time)+(low_impact_high*60);
|
|
|
|
|
+ //Print("low least:"+low_time+" low highest:"+high_time);
|
|
|
|
|
+ // Print("In low impact and currency is:"+ns[index].country);
|
|
|
|
|
+ ulow_time=updatedDateTime-(low_impact_high*60);
|
|
|
|
|
+ uhigh_time=(updatedDateTime)+(low_impact_low*60);
|
|
|
|
|
+
|
|
|
|
|
+ // if(Date1==Today1 && (time_in_seconds>=low_time && time_in_seconds<=high_time))
|
|
|
|
|
+
|
|
|
|
|
+ // Print("-------Low news Now dateTime:"+utime_in_seconds+" lowOfNews:"+ulow_time+" highOfnews:"+uhigh_time);//+" low time in min:"+low_impact_low);
|
|
|
|
|
+
|
|
|
|
|
+ if(utime_in_seconds>=ulow_time && utime_in_seconds<=uhigh_time)
|
|
|
|
|
+
|
|
|
|
|
+ {
|
|
|
|
|
+ //StopTrading(); //Close Current Orders Buy/Sell
|
|
|
|
|
+ // flag=true;
|
|
|
|
|
+ // Print("Inside high alert");
|
|
|
|
|
+ // Print("updateDateTime:"+updatedDateTime);
|
|
|
|
|
+ newsStatus=3;
|
|
|
|
|
+ // Print("Temp2"+temp2);
|
|
|
|
|
+ if(temp2!=previous_time)
|
|
|
|
|
+ {
|
|
|
|
|
+ content=ns[index].title;
|
|
|
|
|
+
|
|
|
|
|
+ previous_time=temp2;
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ //
|
|
|
|
|
+ }//Close Country Symbol if
|
|
|
|
|
+ index++;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ // Print("exprtName:"+chkexpert+"stringfind:"+IntegerToString((StringFind(chkexpert,"FX Ekspert Ghost Trader"))));
|
|
|
|
|
+ Print("Validation Error");
|
|
|
|
|
+ }
|
|
|
|
|
+ return content;
|
|
|
|
|
+ }
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+int TimeDayMQL4(datetime date)
|
|
|
|
|
+ {
|
|
|
|
|
+ MqlDateTime tm;
|
|
|
|
|
+ TimeToStruct(date,tm);
|
|
|
|
|
+ return(tm.day);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+//| |
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+int TimeHourMQL4(datetime date)
|
|
|
|
|
+ {
|
|
|
|
|
+ MqlDateTime tm;
|
|
|
|
|
+ TimeToStruct(date,tm);
|
|
|
|
|
+ return(tm.hour);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+//| |
|
|
|
|
|
+//+------------------------------------------------------------------+
|
|
|
|
|
+int TimeMinuteMQL4(datetime date)
|
|
|
|
|
+ {
|
|
|
|
|
+ MqlDateTime tm;
|
|
|
|
|
+ TimeToStruct(date,tm);
|
|
|
|
|
+ return(tm.min);
|
|
|
|
|
+ }
|
|
|
|
|
+//+------------------------------------------------------------------+
|