Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 817

 

I had an idea to draw an indicator from the file data.

I took an example from the textbook. Reworked the script to suit my needs:

int start()                            // Спец. функция start
  {
//--------------------------------------------------------------- 2 --
   int Handle,                         // Файловый описатель
       shift,Text;                            // Стиль вертикальной линии
   string File_Name="News.csv",        // Имя файла
          Obj_Name,                    // Bмя объекта
          Instr,                       // Название валюты
          One,Two,                     // 1я и 2я чать названия инстр.
          Str_DtTm;                    // Дата и время события(строка)
   datetime Dat_DtTm;                  // Дата и время события(дата)
//--------------------------------------------------------------- 3 --
   Handle=FileOpen(File_Name,FILE_CSV|FILE_READ,";");// Открытие файла
   if(Handle<0)                        // Неудача при открытии файла
     {
      if(GetLastError()==4103)         // Если файла не существует,..
         Alert("Нет файла с именем ",File_Name);//.. извещаем трейдера 
      else                             // При любой другой ошибке..
         Alert("Ошибка при открытии файла ",File_Name);//..такое сообщ
      PlaySound("Bzrrr.wav");          // Звуковое сопровождение
      return(0);                          // Выход из start()      
     }
//--------------------------------------------------------------- 4 --
   while(FileIsEnding(Handle)==false)// До тех пор, пока файловый ..
     {                                // ..указатель не в конце файла
      //--------------------------------------------------------- 5 --
      Str_DtTm =FileReadString(Handle);// Дата и время события(дата)
      Text     =FileReadString(Handle);// Текст описания события
      //--------------------------------------------------------- 6 --
      Dat_DtTm =StrToTime(Str_DtTm);   // Преобразование типа данных
      //--------------------------------------------------------- 7 --
      shift=iBarShift(NULL,0,Dat_DtTm);
      Alert("Время=",TimeToString(Time[shift]),"Text=",Text); 
      if(FileIsEnding(Handle)==true)   // Файловый указатель в конце
      break;                        // Выход из чтения и рисования
     }
//--------------------------------------------------------------- 8 --
   FileClose( Handle );                // Закрываем файл
   return(0);                             // Выход из start()
  }
//--------------------------------------------------------------- 9 --

The "Alert" line can be removed.

The logic is to get the date in the indicator and compare it to the file and assign the value to the buffer in case of coincidence.

But I think that if we start search for each bar from the beginning of the file, where the data is already taken into account, it will be quite expensive.

The question is how to fix the processed file lines in the indicator and start search after them?

 
Forexman77:

There is a large file with dates in this form "20141231". To convert the string todatetime formatyou need"YYYY.MM.DD"dots between the year, month and number.

How can this be done?

string sdt="20141231"
string dt=StringSubstr(sdt,0,4)+"."+StringSubstr(sdt,4,2)+"."+StringSubstr(sdt,6,2)
 
vicmos:

Thank you, I've already sorted it out. Converted the file where it was originally separated by commas. Changed the commas to dots and then added a second column, all with "uniCSVed".

Now I'll know how to do it programmatically.

Now I face another titanic task: how to fulfil indicator with these data? I have made a script. It works correctly.

But in the indicator, in order not to have brakes, I need somehow to remember the line in which in the last iteration of the data was obtained.

 
Forexman77:

Thank you, I've already sorted it out. Converted the file where it was originally separated by commas. Changed the commas to dots and then added a second column, all with "uniCSVed".

Now I'll know how to do it programmatically.

Now I face another titanic task: how to fulfil indicator with these data? I have made a script. It works correctly.

But in the indicator, in order not to have brakes, I need somehow to remember the line in which in the last iteration of the data was obtained.

Probably, it is possible with FileTell(Returns current position of file pointer of corresponding open file) and FileSeek(Moves position of file pointer by specified number of bytes relatively to specified position).
 
evillive:
It is probably possible with FileTell (Returns current position of the file pointer of the corresponding open file) and FileSeek (Moves the position of the file pointer by the specified number of bytes relative to the specified position).

Thank you! I also paid attention to these functions. There isalsoFileIsLineEnding. I will think further on how to do it.

 
lexdemon:
How do we define Ticket_first_order?

Assign the value of OrderTicket() to a variable. For example: int Ticket= OrderTicket(). And then use this value in OrderSelect.

OrderSelect(Ticket,SELECT_BY_TICKET); .

We can do it in another way. We will not define the ticket, we just find the order by trying (SELECT_BY_POS).

We will get it:

 string Symb=Symbol();

for(i=0;i<=OrdersTotal() ;i++)

   if(OrderSelect(i,SELECT_BY_POS)==true)

 {

   if(OrderSymbol()!=Symb)continue;

   if(OrderType()==OP_BUY)

     {

   break;

     }

   }

}

 

  if(OrderOpenPrice()+10*Point<=Ask)

 OrderSend(Symbol(),OP_BUY,Lot,Ask,10,Ask-SL*Point,Ask+TP*Point,NULL,Magic,0,Green);

 

 
CJIeCaPb:

Assign the value of OrderTicket() to a variable. For example: int Ticket= OrderTicket(). And then use this value in OrderSelect.

OrderSelect(Ticket,SELECT_BY_TICKET); .

We can do it another way. Let's not define a ticket, but just find the order by brute force method (SELECT_BY_POS).

It will work out:

The brute force method is closer to the truth
 

Since this is a topic for beginner's questions, I'll ask mine...

1. Is there a software API for downloading quotes? Ideally a get/post request.

2. If there is no such thing for broad access, what are the easiest platforms to parse and can provide real-time access to quotes once per second.

3. You can write automation on anything, of course. But I would still like to know which languages and tools are the most convenient and popular?

 
For example, here https://iqoption.com/us/options/turbo (if anyone is logged in there) is a very good real-time graph. Ideally I would like to parse it, but FireBug doesn't show where the script goes to get the quotes. There is a dot on the chart every second.
 
I am programming 3D graphics in C++ and DirectX, decided to try to program an EA here at Alpari Limited MT4, but I don't understand where is the .exe file