Learning and writing together in MQL5 - page 36

 

Thank you for such comprehensive answers and apologize for my haste and inattention while studying the documentation; the answers were indeed contained in the description of the OnCalculate function.

Apparently I was too quick to force the process of learning and missed studying the OnInit and OnCalculate descriptions.

Yedelkin:

Do these lines answer your question?

MetaDriver:

In this case, these values can't be calculated correctly (not enough history to calculate them), so they're bluntly assigned zero values.

// I would have preferred to assign them corresponding input data, but it doesn't make much difference.

Incorrectly put the question (it's obvious, I wrote the same in the comment to the line, and I understood that null-value assignment is present). To paraphrase

Profi_R:

I put in the printout and see that values other than 0 in ExtLineBuffer are assigned from index limit-1to index rates_total-1, but in the chart the indicator is drawn in the entire space, hmm, then where is the assignment of values(other than zero) to the indicator buffer in the space from 0 to limit-1?

That they can't be calculated and don't make sense is clear from the beginning. I looked, on bar 0 the value of a simple average (indicator) is equal to the maximum price value (not always), at first I thought it was about the number of bars displayed on the chart and stored in the history, I switched this settings option to unlimit, the result has not changed, the indicator on the first (left) limit bars is drawn, and its value is different from 0.
 
Profi_R:

Thank you for such comprehensive answers and I apologize for my haste and inattention while studying the documentation; the answers were indeed contained in the description of the OnCalculate function.

Apparently I was too quick to force the process of learning and missed studying the OnInit and OnCalculate descriptions.

ok.

Paraphrasing

The fact that they can not be calculated and do not make sense is clear from the beginning. I looked, at 0 bar the value of a simple average (indicator), equated to the maximum price value (not always), at first I thought it was about the number of bars displayed on the chart and stored in the history, I switched this setting to "unlimited", the result has not changed, the indicator on the first (left) bars drawn, and its value is different from 0.

I checked it and it looks the same. History in the settings is 100000 bars, I don't want to check for any unlimit, I believe it.)

I have no answer to "how is it possible", it's better to ask developers (e.g. in the "bugs, bugs, questions" branch, that is visited by developers very regularly).

I'm sure no miracles will appear here, most likely the terminal does not display all the history requested and the leftmost available (programmatically) bars are simply left out. :)

 
Profi_R:
The fact that they cannot be calculated and do not make sense is clear from the beginning. I looked, at 0 bar, the value of a simple average (the indicator), equated to the maximum price value (not always), at first I thought it was about the number of bars displayed on the chart and stored in the history, I switched this option to an unlimited, the result has not changed, the indicator on the first (left) bars is drawn, and its value is different from 0.
Did this scientifically: in the line for(i=0;i<limit-1;i++) ExtLineBuffer[i]=0.0; replace zero with one and see where it appears. Compare with previously obtained results.
 
MetaDriver:

I'm sure that no miracles will appear here, most likely the terminal does not quite display all of the requested history and the leftmost available (programmatically) bars are simply left out of the picture. :)

Yes, as it turned out, the entire history depth was calculated (without linking it to a chart), it is just not enough to enable the depth, displayed on the chart, you have to either restart the terminal or open the chart again and only then this option will be effective. This piece of code is now completely clear.
Документация по MQL5: Операции с графиками / ChartOpen
Документация по MQL5: Операции с графиками / ChartOpen
  • www.mql5.com
Операции с графиками / ChartOpen - Документация по MQL5
 

In general, you should start with the articles How to write an indicator in MQL5 and Indicator by indicator in MQL5.

Besides, there is a special branch in the appropriate section of the forum, which is aimed at answering such questions - What you need to know about indicators

 
Rosh:

In general, you should start with the articles How to write an indicator in MQL5 and Indicator by indicator in MQL5.

Besides, there is a special thread in the appropriate section of the forum, which is aimed at answering such questions - What you need to know about indicators

))))) glad to see you in good health, may you forgive my flaming. Thanks, I will take it into account )
 
Good to see you on 5 too :)
 
Good evening, I am investigating the structureof trade request result (MqlTradeResult). Wrote so Prints for this structure respectively between Print(9999999999999999999999);
 OrderSend(request,result);

      int Error=GetLastError(); ResetLastError();
        printf("Error %i ",Error);
      
        Print(i);
        
       Print(999999999999999999); 
        uint re= result.retcode;
         Print( "Код результата операции");
        Print( re);  
      // int re=
       ulong  ru= result.   deal;
        Print( "Тикет сделки, если она совершена");
       Print( ru); 
       
         ru= result.  order;
        Print( "Тикет ордера, если он выставлен");
        Print( ru);
        
         double    rd= result. volume;
         Print( "Объем сделки, подтверждённый брокером"); 
         Print( rd); 
       
          rd= result.  price;  
        Print( "Цена в сделке, подтверждённая брокером");  
       Print( rd);
      
           rd= result. bid;     
       Print( "Текущая рыночная цена предложения (цены реквота)"); 
         Print( rd); 
      
            rd= result. ask;   
        Print( "Текущая рыночная цена спроса (цены реквота)"); 
         Print( rd); 
      
          string    rs= result. comment;  
           Print( "Комментарий брокера к операции (по умолчанию заполняется расшифровкой)"); 
         Print( re);
      
         //    re= result.  request_id;   
       //    Print( "Идентификатор запроса, устанавливается терминалом при отправке "); 
       //  Print( re);
         
          
                   
      Print(999999999999999999); 
For many values the print is written zero, what is that!
 
Dimka-novitsek:
Good evening, I am investigating the structureof trade request result (MqlTradeResult). I have written Print(99999999999999999999) for this structure respectively; For many values Print has written zero, what is that!

Why do we write these lines? Why don't we analyse the result?

uint re= result.retcode;
         Print( "Код результата операции");
         Print( re);  

Regarding zeros: What kind of zeros cause disturbance?

 
Thank you! The current bid and offer price is zero. Deal Ticket . Ticket order. Right, here's the daddy.
Документация по MQL5: Торговые функции / OrderGetTicket
Документация по MQL5: Торговые функции / OrderGetTicket
  • www.mql5.com
Торговые функции / OrderGetTicket - Документация по MQL5
Reason: