Learning and writing together in MQL5 - page 37

 
Dimka-novitsek:
Thank you! The current bid and offer price is zero. Deal Ticket . Ticket order. Right, there's Dad.
So what's the retcode? What does it mean?
 

Thanks !!! I'll have a look at the retcode !

THANK YOU!!!! I got it! Nowhere without you.

 

Hello.

I've encountered this problem, which I don't understand at all. Can you explain why in this case NormalizeDouble() does not always work?

   for ( x = .... ) {
      close = tf_rates[x].close;
      close = NormalizeDouble(close, 4 );
   }

I'm adding price and other datato file for current timeframe. About 10% of all entries are strings like:

1971.01.07,00:00,0.5368000000000001,0.5368000000000001,0.5368000000000001,0.5368000000000001,1

The result is independent of the normalization order, I substitute 1, 2, 3, 4, 5, Digits - all the same. Where is the problem?

Документация по MQL5: Файловые операции / FileWrite
Документация по MQL5: Файловые операции / FileWrite
  • www.mql5.com
Файловые операции / FileWrite - Документация по MQL5
 
wtvirtual:

Hello.

I've encountered this problem, which I don't understand at all. Can you explain why in this case NormalizeDouble() does not always work?

I'm adding price and other datato file for current timeframe. About 10% of all entries are strings like:

1971.01.07,00:00,0.5368000000000001,0.5368000000000001,0.5368000000000001,0.5368000000000001,1

The result is independent of the normalization order, I substitute 1, 2, 3, 4, 5, Digits - all the same. Where is the problem?

There is no ambush. This is what some normalised values look like. see the section in the Reference Manual about this function.
 
Yedelkin:
There is no ambush. This is what some normalised values look like. see the section in the Reference Manual about this function.
Well in the Reference Manual there is a note only about output with Print. Let's assume that not only this function, but all the others also "normalize". So, how should we display this value as prices in a pending order?
Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров
Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров
  • www.mql5.com
Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров - Документация по MQL5
 
wtvirtual:
Well in the handbook there is a remark only about the output with Print.

So what function do you use to output these normalised values? :) - Ah, got it. Reading from a file. In the example from the Reference Manual, the Print() function simply prints the number "as it is".

wtvirtual:
Suppose that not only this function, but all others also "normalise". And how should we then send such a value in the form of prices to a pending order?

And that is exactly how it should be presented. What is required for the order? - Normalized prices. So we normalize them and submit. And it's not our problem what these normalized prices look like when they are printed.)

Moreover, if you output "prices for the current timeframe", it means that these very prices with a large number of decimal places are acceptable as normalized prices on the server. ...This is sort of my conclusion, but I cannot find any counter arguments.

 
wtvirtual:

Hello.

I've encountered this problem, which I don't understand at all. Can you explain why in this case NormalizeDouble() does not always work?

I'm adding price and other datato file for current timeframe. About 10% of all entries are strings like:

1971.01.07,00:00,0.5368000000000001,0.5368000000000001,0.5368000000000001,0.5368000000000001,1

The result does not depend on the order of normalization, I substitute 1, 2, 3, 4, 5, Digits - all the same. Where is the problem?

You can explain it this way, try to write down number 1/3 in decimal form - it won't work (not enough paper, paste and life).
Sooner or later you will accept a small inaccuracy and round off the value.
The same thing happens with real numbers written in binary form (as presented by the computer).
If it is not possible to represent the number with a mantissa of 52 bits (e.g. 0.53680) there is a "slight" inaccuracy...
 

Hello, could you please tell me how to correctly declare a variable as a type? Here is a sample function naming convention.

string OrderType() {
string Si=";
POSITION_TYPE Type; bool Bull=false;
Bull =PositionGetInteger(POSITION_TYPE,Type);
if ( Bull ) {
if ( Type==POSITION_TYPE_BUY) Si="OP_BUY";
if ( Type==POSITION_TYPE_SELL) Si="OP_SELL";
return (Si); }

ORDER_TYPE ORType;
Bull =OrderGetInteger(ORDER_TYPE,ORType);
if ( Bull ) {
if ( Type==ORDER_TYPE_BUY_LIMIT ) Si = OP_BUY_LIMIT;
if ( Type==ORDER_TYPE_SELL_LIMIT) Si="OP_SELL_LIMIT";
if ( Type==ORDER_TYPE_BUY_STOP) Si="OP_BUY_STOP";
if ( Type==ORDER_TYPE_SELL_STOP) Si="OP_SELL_STOP";
return (Si); }

}

Maybe there is something wrong with it, for example, I haven't tried to get the values of PositionGetInteger and OrderGetInteger functions in this way.

 
Dimka-novitsek:

Good afternoon! Could you please tell me how to correctly declare a variable as a type? Here's a sample function overlay.

Maybe there is something wrong with it at all, for example, I haven't tried to get the values of PositionGetInteger and OrderGetInteger functions in this way.

Which variable are we talking about?
 
POSITION_TYPE Type Oh my computer is slowing down, it took me almost 40 seconds to put it in!
Reason: