Errors, bugs, questions - page 452

 

Thank you!

 
alexvd:

Yes, on the first point I'm clearly confused. Explain what exactly is wrong in the description, that a copy should be returned?

And about concatenation in your case you should have written something like

To clarify. It says"Returns a copy of the string with a changed value of the character at the specified position. " The function prototype is boolStringSetCharacter(...). Obviously, you can't put a string in a bool. If indeed a boolean is returned, then apparently this is a sign of success/error. Normally other documentation pages have a separate Returned Value section , but this page doesn't have one. It should be added, and in the textual description formulate a sentence regarding the semantics of the function, not the return value.


Regarding concatenation, if what you wrote is correct, the StringConcatenate function description should also be changed. The description says that thestring_var parameter is an[in][out] String that will be generated as a result of concatenation. You state that this parameter is only [out].

 
New question. What does it mean when BarsCalculated returns 0. It doesn't seem to be an error, but how can 0 bars be calculated? In fact - nothing has been counted. Isn't it an error?
 
MoneyJinn:

Unfortunately, the problem is that the terminal only publishes orders to close positions with comments in the "Results" tab.

The corresponding order is not added to the list of HistoryDealsTotal().

In the general list of orders HistoryOrdersTotal(), the order is also missing, even if you select a period with some redundancy.

I can assure you that both orders and deals, in the case of closing by 'end of test', are present in history. My multicurrency calculates the profit earned on each symbol. Trades closed in the tester by 'end of test' are corrected in the de-initialization to reflect these trades. Total profit for all symbols coincides with data from the testing report. This is the code;

       if(HistorySelect(0,TimeTradeServer()))   // Поправка для 'end of test'
        {
         int DeelsTotal=HistoryDealsTotal();
         for(int i=0;i<SymbolsNumber;i++)
           {
            ulong ticket=HistoryDealGetTicket(DeelsTotal-1-i);
            string comment=HistoryDealGetString(ticket,DEAL_COMMENT);
            if(comment!="end of test"&&StringSubstr(comment,0,3)!="so ")
               break;
            for(int j=0;j<SymbolsNumber;j++)
              {
               if(HistoryDealGetString(ticket,DEAL_SYMBOL)!=m_expert[j].Name())
                continue;
               m_Profit[j]=m_Profit[j]+HistoryDealGetDouble(ticket,DEAL_PROFIT)+  // Добавим профит закрытой позиции для "end of test" и "so"
                           HistoryDealGetDouble(ticket,DEAL_SWAP)+HistoryDealGetDouble(ticket,DEAL_COMMISSION);
              }
           }
        }
 

Colleagues, is there any way to make SymbolInfoSessionTrade work in the strategy tester?

A trivial entry doesn't work:

void OnTick() {
  datetime from, to;
  if (SymbolInfoSessionTrade(_Symbol, FRIDAY, 0, from, to)) Print("WOW!");
}
Документация по MQL5: Получение рыночной информации / SymbolInfoSessionQuote
Документация по MQL5: Получение рыночной информации / SymbolInfoSessionQuote
  • www.mql5.com
Получение рыночной информации / SymbolInfoSessionQuote - Документация по MQL5
 

One more question, if possible. I'd like to understand the meaning of the new operator. What's the idea behind it? Why not create the object in the usual way? After all, after the end of the block access to the object declared through new will be lost, so why do we need it?

P.S. Honestly, I could not find it in the documentation :)

Документация по MQL5: Основы языка / Операторы / Оператор создания объекта new
Документация по MQL5: Основы языка / Операторы / Оператор создания объекта new
  • www.mql5.com
Основы языка / Операторы / Оператор создания объекта new - Документация по MQL5
 
220Volt:

One more question, if possible. I'd like to understand the meaning of the new operator. What is the idea behind it? Why not create the object in the usual way? After all, after the end of the block access to the object declared through new will be lost, so why do we need it?

Everything passes at some point. Does that mean nothing needs to be done...?


P.S honestly I could not find it in the documentation :)

I believe you... :))
 
Valmars:

Thank you! Figured it out. It is necessary and sufficient to useTimeTradeServer() instead of TimeCurrent().

At the end of trading week there are no fresh quotes and that is why TimeCurrent() is not updated for a long time.

When deinitializing the Expert Advisor, TimeCurrent() shows time 23:00; TimeTradeServer() shows time 23:59, which coincides with the end of the test.

 
MoneyJinn:

Thank you! Figured it out. It is necessary and sufficient to useTimeTradeServer() instead of TimeCurrent().

At the end of trading week there are no fresh quotes and therefore TimeCurrent() is not updated for a long time.

The point is not in quotes but in that 'end of test' deals are executed after the testing period is over. So, neither 'OnTick' nor 'OnTimer' can get them from the history. At least it was like that a year ago, so I moved their checking to 'OnDeinit'.
 
220Volt:

One more question, if possible. I'd like to understand the meaning of the new operator. What's the idea behind it? Why not create the object in the usual way? After all, after the end of the block access to the object declared via new will be lost, so why do we need it at all?

P.S honestly could not find it in documentation :)

Don't create dynamic objects - you won't have to use now and everything else that is associated with these objects (Although you won't be able to do much then).

You want to understand not the meaning of now, but the meaning of working with dynamic objects...

Initialization and deinitialization of dynamically placed objects

Pointers to objects area special case, because declaration of a pointer doesn't require initialization of the object in question. Dynamically placed objects are initialized only at the moment of creating an instance of a class by new operator. Initialization of an object implies a call of the constructor of the corresponding class. If there is no corresponding constructor in a class, its members of simple type will not be automatically initialized; members of string, dynamic array and complex object types will be automatically initialized.

Pointers can be declared locally or globally, and can be initialized with an empty NULL value or with a pointer of the same or a spawned type. Ifnew iscalled on a pointer declared on the local level , thedelete statement for that pointer must be executed before leaving the local level as well .Otherwise, the pointer will be lost and the object cannot be deleted explicitly.

All the objects created by the expression pointer_object=new_ClassName must be destroyed with the delete(pointer_object) operator afterwards.If, for some reason, this variable was not destroyed by the delete operator, the message about it will appear in the Experts' Journal. You can declare multiple variables, and assign to all of them pointers to the same object.

If object being created dynamically has a constructor, this constructor will be called when newoperator is executed . If the object has a destructor, the destructor will be called when thedelete operator is executed.

Thus, dynamically placed objects are created only when they are created using newoperator , and they are guaranteed to be deleted either by delete operator or automatically by MQL5 executing system at the moment of program unloading.The order of declaration of dynamically created objects' pointers does not affect the order of their initialization. The order of initialization and deinitialization is fully controlled by the programmer.