Errors, bugs, questions - page 313

 

For some reason I cannot get the current account profit in the OnTester function

This is how I get 0

double OnTester()
{
   return(AccountInfoDouble(ACCOUNT_PROFIT));

And this is how I get profit:

double OnTester()
{
   return(AccountInfoDouble(ACCOUNT_BALANCE)-100000);

Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства позиций
Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства позиций
  • www.mql5.com
Стандартные константы, перечисления и структуры / Торговые константы / Свойства позиций - Документация по MQL5
 
stringo:

What are we arguing about? w0 not put

PS There is bound to be a message (perhaps a few lines below)


Glory I agree - all these arguments are so time-consuming, screw them ( arguments ). :)

But so, what's called on the leg - you, I'm sure, know everything perfectly well yourself, but still, if this function is external and declared only through a declaration, there are such modifiers as "const" and "in" and "out". Perhaps there is a flaw in this function. The thing is - if it's a returnable parameter then a warning is given if it's not returned (in case it's returned via "return") and having a second form of function, when the return value is returned via a parameter, a warning should also be given, because it's a returnable value. Otherwise, if the success/failure result was returned via a parameter and the value itself was returned via return, it would be impossible. And success or no success is also ALWAYS returned. In other words - ( http://users.telenet.be/bart.demeyere/C++InOutParameters.html ) here is a solution which has been around for a long time.


But the conversation in general as I noticed nothing about. IMHO, you need to answer such questions, if you do not plan to change anything cardinally in the current implementation something like this :) - "Yes, there is such a problem, it will be solved in the next versions of the program, now we have fixed the code, and we are only fixing errors". No one ( I think even the most inadequate ) will be offended, but just fixing the problem itself is important and necessary.


So whether or not there will be in this version such very ( VERY ) useful modifiers in out and others, they significantly allow to minimize errors.


***

It will take half a day to do all this correspondence. I'm done. :)

 
Erm955:

For some reason I cannot get the current account profit in the OnTester function

This is how I get 0

double OnTester()
{
   return(AccountInfoDouble(ACCOUNT_PROFIT));

And this is how I get profit:

double OnTester()
{
   return(AccountInfoDouble(ACCOUNT_BALANCE)-100000);


Declare a global variable and assign the current balance value to it in OnInit().

In OnTester() calculate the total profit based on the results of all completed transactions:

Профит=ТекущийБбаланс - Начальный баланс

and output it in OnTester().


And what you are trying to get now is the current unfixed profit, which is zero if all positions are closed.

 
Academic:


Glory I agree - all these debates are so time consuming, don't bother with them ( debates ). :)

Will there be in this version such very ( VERY ) useful modifiers in out and others, they allow to minimize errors.

"What are we arguing about?" - is a phrase from my childhood that means "what are we arguing about?

Passing a parameter by reference is exactly what inout means. There are simply implementations that are beyond the compiler's control.

In fact, it is quite easy to analyze the execution flow by entering functions (the example Rashid provided). We deliberately refused this approach. The very reason was that it would increase our compilation time significantly. That's why we chose the simplest way - displaying a warning. Is it better not to produce such a warning? Yes, you should. If you do explicit initialization, there will be no warning.

I also repeat that we have a shortened estimate for logical expressions. It means in your case that if the first ObjectGetDouble returns false (for example, because the object, notice the external to the program, suddenly does not exist), the second ObjectGetDouble will not be called

Документация по MQL5: Основы языка / Типы данных / Ссылки. Модификатор & и ключевое слово this
Документация по MQL5: Основы языка / Типы данных / Ссылки. Модификатор & и ключевое слово this
  • www.mql5.com
Основы языка / Типы данных / Ссылки. Модификатор & и ключевое слово this - Документация по MQL5
 
stringo:

"What are we arguing about?" - is a phrase from my childhood that means "what are we arguing about?

Passing a parameter by reference is exactly what inout means. There are simply implementations that are beyond the compiler's control.

In fact, it is quite easy to analyze the execution flow by entering functions (the example Rashid provided). We deliberately refused this approach. The very reason was that it would increase our compilation time significantly. That's why we chose the simplest way - displaying a warning. Is it better not to produce such a warning? Yes, you should. If you do explicit initialization, there will be no warning.

I also repeat that we have a shortened estimate for logical expressions. It means in your case that if the first ObjectGetDouble returns false (for example, because the object, notice the external to the program, suddenly doesn't exist), the second ObjectGetDouble will not be called


Right, it won't be called - this is standard behaviour in C code.

Modifiers in and out can be in addition to references. And by default they are always in and out for references. But I can pass a reference with in modifier, which means that this function's parameter is always input and writing into it is not possible even if it is passed by reference. Have you read ? http://users.telenet.be/bart.demeyere/C++InOutParameters.html


in: parameter will be read (warning when not read in every branch*)
(in: parameter will be read (warning when nowhere read)
out: parameter will be written to (warning when not written to in every branch*)
(out): parameter can be written to (warning when nowhere written to)
in without out: parameter cannot be written to
out without in: parameter cannot be read before it is written to.
*in every branch: in all possible normal flows through the function (both branches in an if statement, all branches in a case statement,... ), but not when an exception is thrown. This is the same constraint as for a return statement, to have no undefined behaviour.


And above all, introducing the keywords in and out, can help us find some problems already at compile time. And don't we all want to find errors as soon as possible

 

There is a const modifier. Passing a constant reference explicitly implies an in parameter without any out. We definitely will not introduce additional entities in, out, inout

 
stringo:

There is a const modifier. Passing a constant reference explicitly assumes the parameter in without any out. We definitely will not introduce additional entities in, out, inout

If you won't, you won't. But you must realize that you will not get a decent optimization then. And if there had been OUT in that example, the warning would not have been generated. But all in vain - IMHO - it will take you three minutes but there are much fewer errors. And if you don't want to use it, don't use it. Then everything is as it always is. Just like now. :)


How do you make only OUT without IN? Which means something is always returned, you know, like a function return?

 

Developers.

1. I take it that the spread on the major pairs has been hammered since May 1993, about 930 weekly bars at the current time?

And in the deep history the bars were built on the basis of days.

Therefore, the Expert Advisor may be tested starting exactly from May 1993 (if we use a TF not less than D1)?

Can we look deeper than May 9, 1993 on GBPUSD (like it is implemented on EURUSD)?
 

Hello.

Can you please explain why when creating a "Graphic Tag" object manually, it doesn't have the specified bmp file for on/off states?

Here's the code:

ObjectCreate(....);

.......

ObjectSetString(0, "ColorLabel", OBJPROP_BMPFILE, 0, "Images\on.bmp");
ObjectSetString(0, "ColorLabel", OBJPROP_BMPFILE, 1, "Images\off.bmp");

The label is created completely correctly, in the specified position, with specified colours, etc., but "Images\on.bmp" and "Images\off.bmp" are not specified. If in the MT5 gui
click on the list of objects and set these files for the marker manually, they will be set. But why doesn't ObjectSetString do that?

What do you think?

Документация по MQL5: Стандартные константы, перечисления и структуры / Константы объектов / Типы объектов
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы объектов / Типы объектов
  • www.mql5.com
Стандартные константы, перечисления и структуры / Константы объектов / Типы объектов - Документация по MQL5
 
MathX:

What do you think?

Try

ObjectSetString(0, "ColorLabel", OBJPROP_BMPFILE, 0, "\\Images\\on.bmp");
ObjectSetString(0, "ColorLabel", OBJPROP_BMPFILE, 1, "\\Images\\off.bmp");


Changes to the certificate will be coming soon.