Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 203

 
Alexey Kozitsyn:
Well... I don't think we need to dig that deep, but the request in a loop is really the first thing that catches your eye.

What if it needs this data one time, or once an hour? Why make a useless loop?

None of us, except for the questioner himself, know what he wants. So we can only advise what he was advised to do - to go and read in a telepathic club his failings in formulating the question. And do not be offended by those who decided to laugh a little.

 
Alexey Kozitsyn:
Trollers:) A better suggestion would be to get the prices in a loop. Accordingly, store in arrays.
Read it at your leisure).
 
You should have just answered that my question was not clear to you. And you "salt and pepper..." Resentment
 
STARIJ:

In my opinion, it is simpler like this

Alert outputs immediately to the screen. This is the end of the table


Have you read the question? You seem to have missed it.
 
Romal001:
You should have just answered that my question was not clear to you. And you "salt, pepper..." Offensive

Read my first reply to you, it was a question to you. If you had answered it clearly, it might have been a different conversation.

What kind of signals were you asking about?

What does this have to do with candle data?

 
#property indicator_chart_window
extern int boom = 1;
//=================================
void fishka(int ma,int mi,double map,double mip) // ф-ция
{
   ObjectCreate("Макс_Мин",OBJ_TRENDBYANGLE,0, Time[ma], map, Time[mi], mip);// Проводим линию
   ObjectSet("Макс_Мин",OBJPROP_RAY,false);     // Выключить свойство бесконечного луча
}

int deinit()
  {

 ObjectsDeleteAll();// Удалим все объекты
  return(0);
  }

void start()
{  
  string Символ = "GBPUSD";
  datetime Первый, Последний;
  int Период=PERIOD_H1;

  Последний = iTime(Символ, Период, 0);// Прежде всего узнаем дату и время последнего бара
 
if(boom){
   Alert("Последний бар на часовом  ",Последний);}
 
  
  MqlDateTime MqlПервый;              // Теперь получить начало суток, обнулив часы
  TimeToStruct(Последний,MqlПервый);  // Для этого преобразуем время последнего бара в структуру
  MqlПервый.hour=0;

  
  Первый=StructToTime(MqlПервый);            // Терерь надо обратно преобразовать во время
if(boom){
  Alert("Первый бар на часовом  ",Первый);}  // Смотрим начало первого бара суток
  
  int НомерПервого=iBarShift(Символ, PERIOD_H1,Первый);// По времени определим номер первого бара суток
if(boom){
   Alert("Первый бар на часовом под номером ",НомерПервого);}

// Можно было просто узнать время начала бара на D1

  // Теперь у нас есть НомерПервого бара, а номер послелнего = 0
  // Найдем на этом интервале номера баров, где макс и мин
  // iHighest и iLowest находят номер бара с макс и мин ценой
 int  БарМакс = iHighest(Символ,  // symbol = инструмента
                Период,           // timeframe = Период
                MODE_HIGH,        // Наибольшая цена бара
                НомерПервого+1,   // Количество баров
                0);               // Начальный бар

int  БарМин  = iLowest(Символ,Период,MODE_LOW,НомерПервого+1,0); // Наименьшая цена бара
                               
if(boom){
  Alert("Максимальный бар = ", БарМакс, "  Минимальный бар = ", БарМин);}
                                                                           

 
double max_price=iHigh(Символ, Период, БарМакс); // iHigh и iLow дают макс и мин цены указанного бара
double min_price=iLow (Символ, Период, БарМин);
   
    fishka(БарМакс,БарМин,max_price,min_price); // ф-ция
 if(boom){
   Alert("Максимум цены = ", max_price, "  Минимум цены = ", min_price);
 
   Alert("Угол = ", ObjectGetDouble(0,"Макс_Мин",OBJPROP_ANGLE));} // Теперь хорошо бы узнать угол               
}

how to put it in a loop to display not just one day but the history, all twisted like a snake does not work, the interest is technical, I'm itching))

 

Please advise how to get a correct and more accurate price for where the two machines intersect


 
missha32:   Please advise how to get a correct and more accurate price where two machines intersect with each other

The intersection is between the bars, and the calculation is based on the bars. Or do you need to be more precise? You can interpolate, but do you have to? The slow Ma has the same value.

 
STARIJ:

Intersection between bars, and the calculation is done on a bar-by-bar basis. Or do you need to be more precise? You could interpolate, but should you? Slow Ma has the same value.

In this figure, MA1(1)>MA2(1) and MA1(2)<=MA2(2) is the fact of crossing. The bar in brackets shows the bar at which MA1 and MA2 are taken
 

MA crossing occurs between bars - caught a clear example

The MA on the bars to the left and right of the crossing is different from the price at the crossing point. I understand that the questioner wants the value at the exact crossing point instead of the value on one of the adjacent bars. This exact value can be obtained using linear interpolation - because the MA between bars is constructed as straight line segments. Or take the coordinates of each MA on the adjacent bars. Construct analytically 2 straight lines and calculate their intersection point. It is possible to calculate by considering 2 similar triangles. A counter question arises - why do we need it? Are the costs commensurate with the value of the result? After all, the intersection points will move if the MA parameters are changed minimally. Most likely, it is required by the head of the course project