Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 593

 
I've got it.
 

As an option, thank you. Although I still don't understand why this is happening given the normalisation.

Another possible solution - if anyone needs it - I converted the double to int. Since I have the required accuracy known in advance.

 

Hello. The if statement line in the EA does not execute

Alert("sell_stop_open= ", sell_stop_open, " Middle= ", Middle);

if (sell_stop_open != Middle)

{

Alert ("sell_stop_open= Middle");

L=L2;

int ticket3=OrderSend(Symb, OP_SELLSTOP, L, Middle, 2, Maximum+4*Point,Minimum_30, Com, Magic);

}

When Alert message appears before if I see values sell_stop_open=1.3080, Middle =1.3080, but if is not executed.

Can you please tell me what can cause such an error?

 
Garik27p:

Hello. The if statement line in the EA does not execute

Alert("sell_stop_open= ", sell_stop_open, " Middle= ", Middle);

if (sell_stop_open != Middle)

{

Alert ("sell_stop_open= Middle");

L=L2;

int ticket3=OrderSend(Symb, OP_SELLSTOP, L, Middle, 2, Maximum+4*Point,Minimum_30, Com, Magic);

}

When Alert message appears before if I see values sell_stop_open=1.3080, Middle =1.3080, but if is not executed.

Can you please tell me what can cause such an error?


Otherwise.
if (sell_stop_open == Middle)
 
r772ra:

Otherwise.
I've tried it that way too. But when it works on the tester, sometimes it does, sometimes it doesn't.
 
Desead:

As an option, thank you. Although I still don't understand why this is happening given the normalisation.

Another possible solution - if anyone needs it - I converted the double to int. Since I have the required accuracy known in advance.

Double numbers have their own peculiarities, so when converting them to a text value, DoubleToString (a function from the new MQL4 language) or DoubleToStr (a function from the old language) is used. These functions convert a numeric value into a text string containing the character representation of the number in the specified precision format.

I recommend that you read "Peculiarities of working with double-type numbers in MQL4". Well and on a forum it is possible to search more detailed info.

P./S.: I do not think, that variant of translation double in int, when it is necessary to see double - is the suitable decision.

 
Garik27p:
I've tried it that way too. But when it works on the tester, sometimes it does, sometimes it doesn't.

Here, the answer.
 
r772ra:
Right there, the answer.


Thank you!!!
 
Desead:
P./S.: Just in case, I'll mention that there is a partial answer to your question in "Note" of the NormalizeDouble help too.

I myself used to forget to enter DoubleToS... ...and then wondered at the many numbers after the dot. :)

 
DiPach:
P./S.: Just in case, I'll mention that there is a partial answer to your question in "Note" of the NormalizeDouble help too.

I myself used to forget to enter DoubleToS... ...and then wondered at the many numbers after the dot. :)


It's written in the Help :) Who would have thought I would have gone there because it's a known function and there's no sense to read it in the Help. Thank you for the answer.
Reason: