Double vs FLOAT - unclear MathFloor error - page 5

 
Rounding may be incorrect if the number to be rounded is tailed, in which case normalisation must be done to the required accuracy before rounding
 
Taras Slobodyanik:
Rounding can be wrong if the number to be rounded is tailed, in this case you should normalize to the right accuracy before rounding.

I'm sure normalisation is necessary, who's to say I haven't done it :-)

And, of course, the data was tailed, so Mathfloor was "going the wrong way".

 
Vladislav Andruschenko:

I'm sure normalisation is necessary, who's to say I haven't done it :-)

And, of course, the data was tailed, so Mathfloor was "going the wrong way".

your code has no normalization before rounding)

It's there everywhere, but at the end you round off an un-normalized number.

 
Taras Slobodyanik:

you have no normalisation before rounding)

There is everywhere, but at the end you' re rounding an un-normalized number.

I tried hundreds of variants of the code, I threw one of the variants here, but as it turned out, the problem was not in the rounding - but in the output of data in the print and comment.

 
Vladislav Andruschenko:

It's understandable that normalisation is necessary.

Normalisation is an expensive operation and NormalizeDouble and MathFloor are not needed at all for this task.
 
fxsaber:
Normalize is an expensive operation and for this task NormalizeDouble and MathFloor are not needed at all.

are needed, and I think a recommendation for MathFloor and MathCeil should be added to the Handbook - "recommend normalising values before performing rounding".

ps. I came across this feature once myself.

 
Taras Slobodyanik:

are needed, and I think a recommendation for MathFloor and MathCeil should be added to the Handbook - "recommend normalising values before performing rounding".

ps. I came across this feature myself once.

I stumbled upon it long time ago.

But even normalization does not give the result you expect.

 
Then why does it work without normalisation and MathFloor?

Forum on trading, automated trading systems and trading strategy testing

Double vs FLOAT - unclear MathFloor error

fxsaber, 2017.02.26 08:53

#define ALPHA 0.1

int DoubleToInt( const double Num )
{
  return((int)(Num + ALPHA));
}

void OnStart()
{
  double NewPrice = DoubleToInt((Ask + Bid) / (2 * Point)) * Point;

  Print(NewPrice);
}
 
fxsaber:
Then why does it work without normalisation and MathFloor?
Does it meet the requirement that if the spread is odd then the price should be closer to the bid?
After all, I used MathFloor for exactly that.
 
Vladislav Andruschenko:
Does it meet the requirement that if the spread is odd, the price should be closer to the bid?
Yes.
Reason: