Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1495

 
Taras Slobodyanik:

if(MathAbs(Bid - Low[1]) >= 0.0004) { action;}

This code is not identical to the code:

if (Bid - Low[1]>=0.0030 && Bid - Low[1]<0.0035) {действие;}




 
PapaYozh:

This code is not the same as the code:

yes, of course.
depends on whether you want to get "out of range" or "in range"?
For that you need to put the required sign (more or less, and equal if needed), plus a tolerance (you can put it in parameters too).

if (MathAbs(Bid - Level) >= 0.0004)
        {
        //цена вышла за пределы Level +/- 4 пункта
        }
if (MathAbs(Bid - Level) <= 0.0004)
        {
        //цена вошла в пределы Level +/- 4 пункта
        }

And the bid should be replaced with the ask to buy.
Thought it was obvious.

ps. If you need exactly0.0030-0.0035, then add this number to the level - shift it to the right side... There's a lot more to guess and change/add.

pps. The question was about the mathematical operation, not about the identity to a formula or the size of a range digit.

 
Taras Slobodyanik:

Yes, of course.
depends on whether you want to get "out of range" or "in range"?
For that you need to put the required sign (more or less, and equal if needed), plus the tolerance (you can also put it in the parameters).

And the bid should be replaced with the ask to buy.
Thought it was obvious.

ps. If you need exactly0.0030-0.0035, then add this number to the level - shift it to the right side... There's a lot more to guess and change/add.

pps. the question was about mathematical operation, not about identity or range digit size.

and traditionally there will be miracles with double, but on every tick... i.e. somewhere along the boundaries it works right, and somewhere it doesn't. unpredictably

 
Maxim Kuznetsov:

and traditionally there will be miracles with double, but already on every tick... that is, somewhere along the boundaries it works correctly, and somewhere not. unpredictably

It won't, there is no comparison to zero, and super-small values won't affect the result.

 
Taras Slobodyanik:

will not, there is no comparison to zero, and ultra-small values will not affect the result in any way.

there is a comparison of two doubles

some Bid Level values will satisfy the MathAbs(Bid-Level)<=double_const condition, and some will suddenly not

and it is not yet clear how Level is calculated. Bid is normalized, and about Level not so sure

 
Taras Slobodyanik:

Learn to read, you liar.

Oh Taras, Taras... Didn't you learn to think at school?

The range from >= 0.0030 to < 0.0035 is in the range of 4 points... If you write precisely, the range is

  • 0.0030
  • 0.0031
  • 0.0032
  • 0.0033
  • 0.0034

Well, ANDREY was a little wrongwhen he said 4 points, not 5. But he is excused, but you are not ... you are trying to teach, but in fact you still have a long time to learn. You don't know if you will learn anything... I doubt it.

You keep on arguing and spouting nonsense...


 
Alexey Viktorov:

Oh Taras, Taras... Didn't they teach you to think at school?

The range from >= 0.0030 to < 0.0035 is in the range of 4 points... If you want to be precise, the range is

  • 0.0030
  • 0.0031
  • 0.0032
  • 0.0033
  • 0.0034

Well, ANDREY was a little wrongwhen he said 4 points, not 5. But he is excused, but you are not ... you are trying to teach, but in fact you still have a long time to learn. You don't know if you will learn anything... I doubt it.

You keep on arguing and spouting nonsense...

Why are you so excited by my posts?)
What are you so hot that you are willing to look for inaccuracies in other users, and turn them out as my mistakes?

Are you offended that you're a Liar?)
I give you permission to apologise to me in private messages, if you're so shy about doing so in front of everyone.

 
Maxim Kuznetsov:

there are two double comparisons

some Bid Level values will satisfy the MathAbs(Bid-Level)<=double_const condition, and some will suddenly not

and it is not yet clear how Level is calculated. Bid is normalized, and about Level - not a fact.

Well, firstly, this "suddenly" is in the source code.
Secondly, it is a range, i.e. it is a set value "from and to", and you can set the range a bit more or less and the "suddenness" will be different.
Thirdly, later one will definitely face the fact that this constant will not work so well on pairs with different digit capacity, and will unambiguously make calculation of this value either before comparison or in the formula.
Fourthly, even normalised decimal values have inaccuracies, and you will never get an exact double. It doesn't depend on whether it's a static variable, dynamic or just calculated. (imho - a given or calculated value is better than a normalised rounded value, because it has more accuracy)

So, again, it doesn't matter at this stage.

 
Taras Slobodyanik:

Why do you get so excited about my posts?)
What are you so hot that you're willing to look for inaccuracies in other users, and turn them out as my mistakes?

Did it get you offended that you're a Liar?)
I give you permission to apologise to me in private messages if you're so embarrassed to do so in front of everyone.

You have completely lost your friendship with your head...

 
Alexey Viktorov:

Oh Taras, Taras... Didn't they teach you to think at school? Is 0.0004 less than 0.0035 ...............

Didn't they teach you to think at school? Is 0.0004 greater than 0 .0035?

You're trying to teach, but you've got a long way to go. You don't know if you'll learn anything... I doubt it.
You keep on arguing and spewing nonsense...

psst. so in fact you're lying again and twisting the obvious)

oops. no apology yet.