//+------------------------------------------------------------------+ //| News calendar week EA.mq4 | //| Copyright 2016, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "vorese" #property link "https://www.mql5.com/ru/users/vorese" #property version "5.1" #property strict #property description "russian(RU):add address 'http://ec.ru.forexprostools.com/'" #property description "in Expert Advisors tab of the Options window" #property description "englich(UK):add address 'http://ec.uk.forexprostools.com/'" #property description "in Expert Advisors tab of the Options window" input bool russian_english=true; //переключение русский/английский календарь input int number_string=30; //количество строк в календаре input color clr_table=clrBlack; input color clr_text=clrMediumSpringGreen; input color clr_border=clrGreen; input color clr_button_off=clrLimeGreen; input color clr_button_on=clrGold; input color clr_backdrop=clrMidnightBlue; input color clr_day_week=clrWhite; input color clr_future=clrLimeGreen; input color clr_better=clrLightGray; input color clr_worse=clrDarkOrange; input color clr_comp=clrYellowGreen; input color clr_past=clrTurquoise; input color clr_empty_string=clrDarkGray; input string table_font="Verdana"; input string text_font="Verdana"; input int table_size=6; input int text_size=7; input int x_distance=5; input int y_distance=2; input string filename_ru="ru-forexprostools-exp"; //имя файла календаря на русском языке input string filename_en="uk-forexprostools-exp"; //имя файла календаря на английскоом языке #define size 400 // макс. количество строк //====================================================================== datetime time_ind[];//время string currency[],//валюта volatility[],//волатильность text_ind[],//текст previous[],//предыдущий forecast[],//прогноз actual[],//факт compliance[];//ожидания datetime time_ind_0[]; string currency_0[], volatility_0[], text_ind_0[], previous_0[], forecast_0[], actual_0[], compliance_0[]; int line_number[size];//индексы строк после фильтр. //===================================================================== bool button_0=false;//X bool button_1=false;//время bool button_2=false;//валюта bool button_3=false;//текст bool button_4=false;//$$$ bool button_5=false;//$$ bool button_6=false;//$ bool button_7=false;//сегодня bool button_8=false;//обновить bool button_9=false;//прокрутка вниз bool button_10=false;//прокрутка вверх bool start_exp=true;//терминал //==================================================================== color col_but0=clr_button_off; color col_but1=clr_button_off; color col_but2=clr_button_off; color col_but3=clr_button_off; color col_but4=clr_button_off; color col_but5=clr_button_off; color col_but6=clr_button_off; color col_but7=clr_button_off; color col_but8=clr_button_off; color col_but9=clr_past; color col_but10=clr_past; //==================================================================== string symb_0=_Symbol; string symb_1=NULL; string symb_2=NULL; string str_update=NULL; string str_err=NULL; int file_size=0;// размер загруженного файла int count=0;//кол-во строк в календаре int displ=0;//счетчик прокрутки календаря int ru_en=0;//флаг переключения русский/английский int time_corr=0;//коррекция времени //=================================================================== string URL=NULL; string str_pfa=NULL; string filename=NULL; string text_butt_1=NULL; string text_butt_2=NULL; string text_butt_3=NULL; string text_butt_7=NULL; string text_butt_8=NULL; //=================================================================== int OnInit() { symb_1=StringSubstr(symb_0,0,3);//1-я валюта в валютной паре symb_2=StringSubstr(symb_0,3,3);//2-я валюта в валютной паре time_corr=TimeGMTOffset(); //=================================================================== if(russian_english) { ru_en=0; URL="http://ec.ru.forexprostools.com/"; // URL="http://ec.ru.forexprostools.com/?columns=exc_flags,exc_currency,exc_importance,exc_actual,exc_forecast,exc_previous&features=datepicker,timezone&countries=25,4,17,39,72,26,10,6,37,97,96,43,56,36,5,61,22,12,89,110,35&calType=week&timeZone=18&lang=7"; filename=filename_ru; str_pfa="предш. прогн. факт. "; text_butt_1="время"; text_butt_2="валюта"; text_butt_3="текст"; text_butt_7="сегодня"; text_butt_8="обновить"; } else { ru_en=1; URL="http://ec.uk.forexprostools.com/"; // URL="http://ec.uk.forexprostools.com/?columns=exc_flags,exc_currency,exc_importance,exc_actual,exc_forecast,exc_previous&features=datepicker,timezone&countries=25,34,32,6,37,72,71,22,17,51,39,14,33,10,35,43,60,38,36,110,11,26,9,12,4,5&calType=week&timeZone=15&lang=51"; filename=filename_en; str_pfa="prev. forecast actual. "; text_butt_1="time"; text_butt_2="currenty"; text_butt_3="text"; text_butt_7="today"; text_butt_8="update"; } //==================================================================== EventSetMillisecondTimer(60);//скорость прокрутки календаря return(INIT_SUCCEEDED); } //==================================================================== void OnDeinit(const int reason) { f_Delete_object(number_string); f_Delete_button(); ObjectDelete("table"); ObjectDelete("time"); ObjectDelete("terminal"); ObjectDelete("error"); //--- destroy timer EventKillTimer(); } //+------------------------------------------------------------------+ //| Timer function | //+------------------------------------------------------------------+ void OnTimer() { ButtonCreate("table",x_distance+123,y_distance+15,143,14,str_pfa,7,clr_table,clr_past,false,clr_button_on); ButtonCreate("time",x_distance+15,y_distance+15,107,14,"local",7,clr_table,clr_past,false,clr_button_on); ButtonCreate("terminal",x_distance+519,y_distance+15,118,14,"terminal",7,clr_table,clr_past,false,clr_button_on); ButtonCreate("error",x_distance+325,y_distance,312,14,str_update,7,clr_table,clr_past,false,clr_button_on); //============ загрузка страницы===================================== if(button_8)//нажата кнопка"обновить" { f_Free();//освободить память f_Resize(size);//установить размер массивов file_size=f_Download(URL,filename,str_err);//загрузка страницы GlobalVariableSet("update_"+(string)ru_en,0);//запомнить время последнего обновления count=f_Parsing(filename);//разбор страницы f_Corrects_day_week(count);// коррекция начала суток в зависимости от часового пояса button_8=false; col_but8=clr_button_off; } if(start_exp) { f_Resize(size); count=f_Parsing(filename); f_Corrects_day_week(count); start_exp=false; } //=====верхняя строка календаря====================================== str_update=str_err+f_Date_time(GlobalVariableTime("update_"+(string)ru_en),5,0); ObjectSetString(0,"time",OBJPROP_TEXT,TimeToString(TimeLocal(),TIME_SECONDS)); //=====кнопки======================================================== ButtonCreate("button0",x_distance,y_distance+15,14,14,"X",10,clr_table,col_but0,button_0,clr_button_on); ButtonCreate("button1",x_distance+267,y_distance+15,37,14,text_butt_1,7,clr_table,col_but1,button_1,clr_button_on); ButtonCreate("button2",x_distance+305,y_distance+15,48,14,text_butt_2,7,clr_table,col_but2,button_2,clr_button_on); ButtonCreate("button3",x_distance+354,y_distance+15,35,14,text_butt_3,7,clr_table,col_but3,button_3,clr_button_on); ButtonCreate("button4",x_distance+390,y_distance+15,25,14," $$$",6,clr_table,col_but4,button_4,clr_button_on); ButtonCreate("button5",x_distance+416,y_distance+15,25,14," $$",6,clr_table,col_but5,button_5,clr_button_on); ButtonCreate("button6",x_distance+442,y_distance+15,25,14," $",6,clr_table,col_but6,button_6,clr_button_on); ButtonCreate("button7",x_distance+468,y_distance+15,50,14,text_butt_7,7,clr_table,col_but7,button_7,clr_button_on); ButtonCreate("button8",x_distance+267,y_distance,57,14,text_butt_8,7,clr_table,col_but8,button_8,clr_button_on); ButtonCreate("button9",x_distance+638,y_distance+15,15,14,CharToString(130),13,clr_border,col_but9,button_9,clr_button_on,"Wingdings 3"); ButtonCreate("button10",x_distance+638,y_distance,15,14,CharToString(129),13,clr_border,col_but10,button_10,clr_button_on,"Wingdings 3"); //=========фильтруем новости========================================== int w=0; int r=0; color color_button=clr_future; color color_compliance=clr_future; color color_text=clrNONE; while(r0) displ--; //прокрутка вверх //==================================================================== int t=0; int u=0; while(t=TimeLocal())//цвет прошедших и будущих новостей { color_button=clr_future;color_text=clr_text; } else { color_button=clr_past;color_text=clr_text; } if(time_ind[u]==0) { color_text=clr_day_week;color_button=clr_empty_string; } if(compliance[u]=="+")color_compliance=clr_better; else { if(compliance[u]=="-")color_compliance=clr_worse; else { if(compliance[u]=="=" && actual[u]!="----")color_compliance=clr_comp; else { color_compliance=color_button; } } } //=================таблица============================================ if(!button_0) { ButtonCreate("date"+(string)(t),x_distance,y_distance+30+11*t,31,11,f_Date_time(time_ind[u],5,5),table_size,clr_table,color_button,false,clr_border,table_font); ButtonCreate("time"+(string)(t),x_distance+30,y_distance+30+11*t,31,11,f_Date_time(time_ind[u],11,5),table_size,clr_table,color_button,false,clr_border,table_font); ButtonCreate("currency"+(string)(t),x_distance+61,y_distance+30+11*t,31,11,currency[u],table_size,clr_table,color_button,false,clr_border,table_font); ButtonCreate("volatility"+(string)(t),x_distance+92,y_distance+30+11*t,31,11,volatility[u],table_size,clr_table,color_button,false,clr_border,table_font); ButtonCreate("previous"+(string)(t),x_distance+123,y_distance+30+11*t,41,11,previous[u],table_size,clr_table,color_button,false,clr_border,table_font); ButtonCreate("forecast"+(string)(t),x_distance+164,y_distance+30+11*t,41,11,forecast[u],table_size,clr_table,color_button,false,clr_border,table_font); ButtonCreate("fact"+(string)(t),x_distance+205,y_distance+30+11*t,41,11,actual[u],table_size,clr_table,color_button,false,clr_border,table_font); ButtonCreate("compliance"+(string)(t),x_distance+246,y_distance+30+11*t,21,11,compliance[u],table_size,clr_table,color_compliance,false,clr_border,table_font); //================текст=============================================== if(!button_3) { RectLabelCreate("LabelCreate"+(string)t,x_distance+267,y_distance+30+11*t,386,12,clr_backdrop,clr_backdrop); f_Label("text"+(string)t,x_distance+270,y_distance+30+11*t,text_ind[u],text_size,color_text,text_font); } } t++; } if(t==w-displ)f_Delete_string(t);//удалить строку в конце таблицы ObjectSetString(0,"terminal",OBJPROP_TEXT,"terminal "+TimeToString(TimeCurrent(),TIME_SECONDS));//время терминала ChartRedraw(); } //+------------------------------------------------------------------+ //| ChartEvent function | //+------------------------------------------------------------------+ void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) { //---------------кнопка "X"-------------------------------------- if(sparam=="button0" && !button_0) { button_0=true; col_but0=clr_button_on; f_Delete_object(number_string); return; } if(sparam=="button0" && button_0) { button_0=false; col_but0=clr_button_off; return; } //-------------кнопка "время"-------------------------------- if(sparam=="button1" && !button_1) { button_1=true; col_but1=clr_button_on; f_Delete_object(number_string); displ=0; return; } if(sparam=="button1" && button_1) { button_1=false; col_but1=clr_button_off; displ=0; return; } //-------------кнопка "валюта"-------------------------------- if(sparam=="button2" && !button_2) { button_2=true; col_but2=clr_button_on; f_Delete_object(number_string); displ=0;return; } if(sparam=="button2" && button_2) { button_2=false; col_but2=clr_button_off; displ=0;return; } //--------------кнопка "текст"---------------------------------- if(sparam=="button3" && !button_3) { button_3=true; col_but3=clr_button_on; f_Delete_text(number_string); return; } if(sparam=="button3" && button_3) { button_3=false; col_but3=clr_button_off; return; } //---------------кнопка "$$$"----------------------------------- if(sparam=="button4" && !button_4) { button_4=true; col_but4=clr_button_on; f_Delete_object(number_string); displ=0; return; } if(sparam=="button4" && button_4) { button_4=false; col_but4=clr_button_off; displ=0;return; } //---------------кнопка "$$"------------------------------------ if(sparam=="button5" && !button_5) { button_5=true; col_but5=clr_button_on; f_Delete_object(number_string); displ=0; return; } if(sparam=="button5" && button_5) { displ=0;button_5=false; col_but5=clr_button_off; return; } //---------------кнопка "$"-------------------------------------- if(sparam=="button6" && !button_6) { button_6=true; col_but6=clr_button_on; f_Delete_object(number_string); displ=0;return; } if(sparam=="button6" && button_6) { displ=0;button_6=false; col_but6=clr_button_off; return; } //---------------кнопка "сегодня"------------------------------------- if(sparam=="button7" && !button_7) { displ=0; button_7=true; col_but7=clr_button_on; f_Delete_object(number_string); return; } if(sparam=="button7" && button_7) { displ=0; button_7=false; col_but7=clr_button_off; return; } //-------------кнопка "обновить"-------------------------------------- if(sparam=="button8" && !button_8) { button_8=true; col_but8=clr_button_on; return; } if(sparam=="button8" && button_8) { button_8=false; return; } //---------------вниз------------------------------------------------- if(sparam=="button9" && !button_9) { button_9=true;col_but9=clr_button_on; button_10=false;col_but10=clr_past; return; } if(sparam=="button9" && button_9) { button_9=false;col_but9=clr_past; return; } //--------------вверх------------------------------------------------- if(sparam=="button10" && !button_10) { button_10=true;col_but10=clr_button_on; button_9=false;col_but9=clr_past; return; } if(sparam=="button10" && button_10) { button_10=false;col_but10=clr_past; return; } } //===============установить размер массивов========================== void f_Resize(int s) { ArrayResize(time_ind_0,s); ArrayResize(currency_0,s); ArrayResize(volatility_0,s); ArrayResize(text_ind_0,s); ArrayResize(previous_0,s); ArrayResize(forecast_0,s); ArrayResize(actual_0,s); ArrayResize(compliance_0,s); ArrayResize(time_ind,s); ArrayResize(currency,s); ArrayResize(volatility,s); ArrayResize(text_ind,s); ArrayResize(previous,s); ArrayResize(forecast,s); ArrayResize(actual,s); ArrayResize(compliance,s); } //===========освободить память======================================= void f_Free() { ArrayFree(time_ind_0); ArrayFree(currency_0); ArrayFree(volatility_0); ArrayFree(text_ind_0); ArrayFree(previous_0); ArrayFree(forecast_0); ArrayFree(actual_0); ArrayFree(compliance_0); ArrayFree(time_ind); ArrayFree(currency); ArrayFree(volatility); ArrayFree(text_ind); ArrayFree(previous); ArrayFree(forecast); ArrayFree(actual); ArrayFree(compliance); } //+------------удалить таблицу----------------------------------------+ void f_Delete_object(int max) { for(int v=0;v0 && time_ind_0[z]>0) { f_Data_transfer(z,shift+1); shift+=2; continue; } f_Data_transfer(z,shift); shift++; } for(int d=0;d0) { if(ru_en==0)//русский/английский text_ind[d]=" "+f_Day_week(time_ind[d+1],ru_en)+(string)TimeDay(time_ind[d+1])+f_Month(time_ind[d+1],ru_en)+(string)TimeYear(time_ind[d+1])+"г."; else text_ind[d]=" "+f_Day_week(time_ind[d+1],ru_en)+f_Month(time_ind[d+1],ru_en)+(string)TimeDay(time_ind[d+1])+". "+(string)TimeYear(time_ind[d+1]); } } } //=========месяц==================================================== string f_Month(datetime time,int offset) { string res=NULL; switch(TimeMonth(time)+offset*12) { case 1: res=" января "; break; case 2: res=" февраля "; break; case 3: res=" марта "; break; case 4: res=" апреля "; break; case 5: res=" мая "; break; case 6: res=" июня "; break; case 7: res=" июля "; break; case 8: res=" августа "; break; case 9: res=" сентября "; break; case 10: res=" октября "; break; case 11: res=" ноября "; break; case 12: res=" декабря "; break; case 13: res=" January "; break; case 14: res=" February "; break; case 15: res=" March "; break; case 16: res=" April "; break; case 17: res=" May "; break; case 18: res=" June "; break; case 19: res=" July "; break; case 20: res=" August "; break; case 21: res=" September "; break; case 22: res=" October "; break; case 23: res=" November "; break; case 24: res=" December "; break; default: res="error"; break; } return(res); } //=========дни недели================================================= string f_Day_week(datetime time,int offset) { string res=NULL; switch(TimeDayOfWeek(time)+offset*7) { case 0: res="Воскресенье. "; break; case 1: res="Понедельник. "; break; case 2: res="Вторник. "; break; case 3: res="Среда. "; break; case 4: res="Четверг. "; break; case 5: res="Пятница. "; break; case 6: res="Суббота. "; break; case 7: res="Sunday. "; break; case 8: res="Monday. "; break; case 9: res="Tuesday. "; break; case 10: res="Wednesday. "; break; case 11: res="Thursday. "; break; case 12: res="Friday. "; break; case 13: res="Saturday. "; break; default: res="error"; break; } return(res); } //=================================================================== void f_Data_transfer(int x0,int x1) { time_ind[x1]=time_ind_0[x0]; text_ind[x1]=text_ind_0[x0]; currency[x1]=currency_0[x0]; volatility[x1]=volatility_0[x0]; previous[x1]=previous_0[x0]; forecast[x1]=forecast_0[x0]; actual[x1]=actual_0[x0]; compliance[x1]=compliance_0[x0]; } //==================позиции подстрок================================= int f_Position(string text_str,int flag) { string tegi[31]= { "","theDay","",">","event_timestamp","","#"); int k=StringSplit(text_string,35,result); if(k<4) { Alert("2#Ошибка при загрузке или чтении файла."); break; } actual_0[counter_news]=StringSubstr(result[0],f_Position(result[0],4)+1,0); forecast_0[counter_news]=StringSubstr(result[1],f_Position(result[1],4)+1,0); previous_0[counter_news]=StringSubstr(result[2],f_Position(result[2],4)+1,0); counter_news++; continue; } } } FileClose(handle);//закрыть файл return(counter_news+day-1);//кол-во строк } //===============кнопки============================================== bool ButtonCreate(const string name="button", // имя кнопки const int x=0, // координата по оси X const int y=0, // координата по оси Y const int width=0, // ширина кнопки const int height=0, // высота кнопки const string text="error", // текст const int font_size=6, // размер шрифта const color clr=clrNONE, // цвет текста const color back_clr=clrNONE, // цвет фона const bool state=false, // нажата/отжата const color border_clr=clrNONE, // цвет границы const string font="Verdana", // шрифт const bool back=false, // на заднем плане const bool selection=false, // выделить для перемещений const bool hidden=false, // скрыт в списке объектов const long z_order=0) // приоритет на нажатие мышью { ResetLastError(); if(ObjectFind(name)==-1) { ObjectCreate(0,name,OBJ_BUTTON,0,0,0); ObjectSetInteger(0,name,OBJPROP_XDISTANCE,x); ObjectSetInteger(0,name,OBJPROP_YDISTANCE,y); ObjectSetInteger(0,name,OBJPROP_XSIZE,width); ObjectSetInteger(0,name,OBJPROP_YSIZE,height); ObjectSetInteger(0,name,OBJPROP_CORNER,CORNER_LEFT_UPPER); ObjectSetString(0,name,OBJPROP_FONT,font); ObjectSetInteger(0,name,OBJPROP_FONTSIZE,font_size); ObjectSetInteger(0,name,OBJPROP_COLOR,clr); ObjectSetInteger(0,name,OBJPROP_BORDER_COLOR,border_clr); ObjectSetInteger(0,name,OBJPROP_BACK,back); ObjectSetInteger(0,name,OBJPROP_SELECTABLE,selection); ObjectSetInteger(0,name,OBJPROP_SELECTED,selection); ObjectSetInteger(0,name,OBJPROP_HIDDEN,hidden); ObjectSetInteger(0,name,OBJPROP_ZORDER,z_order); } ObjectSetString(0,name,OBJPROP_TEXT,text); ObjectSetInteger(0,name,OBJPROP_STATE,state); ObjectSetInteger(0,name,OBJPROP_BGCOLOR,back_clr); return(true); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| Создает текстовую метку | //+------------------------------------------------------------------+ bool f_Label( const string name="Label", // имя метки const int x=0, // координата по оси X const int y=0, // координата по оси Y const string text="error", // текст const int font_size=10, // размер шрифта const color clr=clrRed, // цвет const string font="Verdana", // шрифт const double angle=0.0, // наклон текста const ENUM_ANCHOR_POINT anchor=ANCHOR_LEFT_UPPER, // способ привязки const bool back=false, // на заднем плане const bool selection=false, // выделить для перемещений const bool hidden=true, // скрыт в списке объектов const long chart_ID=0, // ID графика const int sub_window=0, // номер подокна const ENUM_BASE_CORNER corner=CORNER_LEFT_UPPER, // угол графика для привязки const long z_order=0) // приоритет на нажатие мышью { ResetLastError(); if(ObjectFind(name)==-1) { ObjectCreate(chart_ID,name,OBJ_LABEL,sub_window,0,0); ObjectSetInteger(chart_ID,name,OBJPROP_XDISTANCE,x); ObjectSetInteger(chart_ID,name,OBJPROP_YDISTANCE,y); ObjectSetInteger(chart_ID,name,OBJPROP_CORNER,corner); ObjectSetString(chart_ID,name,OBJPROP_FONT,font); ObjectSetInteger(chart_ID,name,OBJPROP_FONTSIZE,font_size); ObjectSetDouble(chart_ID,name,OBJPROP_ANGLE,angle); ObjectSetInteger(chart_ID,name,OBJPROP_ANCHOR,anchor); ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back); ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection); ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection); ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden); ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order); } ObjectSetString(chart_ID,name,OBJPROP_TEXT,text); ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr); return(true); } //+------------------------------------------------------------------+ //| Создает прямоугольную метку | //+------------------------------------------------------------------+ bool RectLabelCreate( const string name="RectLabel", // имя метки const int x=0, // координата по оси X const int y=0, // координата по оси Y const int width=500, // ширина const int height=180, // высота const color back_clr=clrRed, // цвет фона const color clr=clrRed, // цвет плоской границы (Flat) const ENUM_LINE_STYLE style=STYLE_SOLID, // стиль плоской границы const int line_width=1, // толщина плоской границы const bool back=false, // на заднем плане const bool selection=false, // выделить для перемещений const bool hidden=false, // скрыт в списке объектов const long chart_ID=0, // ID графика const int sub_window=0, // номер подокна const ENUM_BASE_CORNER corner=CORNER_LEFT_UPPER, // угол графика для привязки const ENUM_BORDER_TYPE border_lab=BORDER_FLAT, // тип границы const long z_order=0) // приоритет на нажатие мышью { ResetLastError(); if(ObjectFind(name)==-1) { ObjectCreate(chart_ID,name,OBJ_RECTANGLE_LABEL,sub_window,0,0); ObjectSetInteger(chart_ID,name,OBJPROP_XDISTANCE,x); ObjectSetInteger(chart_ID,name,OBJPROP_YDISTANCE,y); ObjectSetInteger(chart_ID,name,OBJPROP_XSIZE,width); ObjectSetInteger(chart_ID,name,OBJPROP_YSIZE,height); ObjectSetInteger(chart_ID,name,OBJPROP_BGCOLOR,back_clr); ObjectSetInteger(chart_ID,name,OBJPROP_BORDER_TYPE,border_lab); ObjectSetInteger(chart_ID,name,OBJPROP_CORNER,corner); ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr); ObjectSetInteger(chart_ID,name,OBJPROP_STYLE,style); ObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,line_width); ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back); ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection); ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection); ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden); ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order); } return(true); } //+-----
","Праздник","Holiday", "Низкая","Low","Умеренная","Moderate","Высокая","High","left","event"," ","Actual_","Forecast_","Previous_", "Лучше","Better","Хуже","Worse ","_forecast"," Line ","Речь","Speech" }; int position=StringFind(text_str,tegi[flag],0); return(position); } //=====читаем файл ================================================== int f_Parsing(string file_name) { string text_string=NULL; int handle=0; int counter_news=1; int day=0;//кол-во дней в календаре bool begin_table=false; handle=FileOpen(file_name,FILE_READ,CP_ACP);// открываем файл для чтения while(!FileIsEnding(handle)) { text_string=FileReadString(handle);//читаем строку из файла if(!begin_table && f_Position(text_string,0)==(-1)) continue; else begin_table=true;//начало таблицы if(f_Position(text_string,1)>=0)break;//конец таблицы if(f_Position(text_string,2)>0) //день недели { day++;continue; } if(f_Position(f_Cyrillic(text_string),9+ru_en)>=0) continue;// праздник if(f_Position(text_string,5)>0) //время { time_ind_0[counter_news]=f_StrTime(StringSubstr(text_string,f_Position(text_string,5)+17,19))-time_corr; continue; } if(f_Position(text_string,6)>0) //"","#");//разделитель "#" int m=StringSplit(text_string,35,text);//Получаем из указанной строки подстроки по заданному разделителю "#" if(m<4) { Alert("1#Ошибка при загрузке или чтении файла."); break; } //валюта. 1-я подстрока currency_0[counter_news]=StringTrimLeft(StringSubstr(text[0],f_Position(text[0],8)+7,0)); //волатильность. 2-я подстрока if(f_Position(f_Cyrillic(text[1]),11+ru_en)>0) volatility_0[counter_news]="$"; if(f_Position(f_Cyrillic(text[1]),13+ru_en)>0) volatility_0[counter_news]="$$"; if(f_Position(f_Cyrillic(text[1]),15+ru_en)>0) volatility_0[counter_news]="$$$"; //текст. 3-я подстрока if(f_Position(f_Cyrillic(text[2]),29+ru_en)>0 || f_Position(f_Cyrillic(text[2]),19)>0) text_ind_0[counter_news]=f_Cyrillic(StringSubstr(text[2],f_Position(text[2],4)+1,f_Position(text[2],19)-f_Position(text[2],4)-1)); else text_ind_0[counter_news]=f_Cyrillic(StringSubstr(text[2],f_Position(text[2],4)+1,0)); continue; } // результат ожидания if(f_Position(text_string,20)>0) { if(f_Position(f_Cyrillic(text_string),23+ru_en)>0)//лучше compliance_0[counter_news]="+"; else { if(f_Position(f_Cyrillic(text_string),25+ru_en)>0)//хуже compliance_0[counter_news]="-"; else { if(f_Position(text_string,27+ru_en)>0)//в соответствии с ожиданиями compliance_0[counter_news]="="; else { compliance_0[counter_news]="?";//нет данных } } } //факт, прогноз, предыдущий string result[]; StringReplace(text_string," ","----"); StringReplace(text_string,"