[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 104

 
kilnart: how do you spell it right?

try it like this:

if(Digits==5){
   if(Close[2]-Open[1]>=10*Point);// цена больше на 10 пп в 5-ти знаке
}
if(Digits==4){
   if(Close[2]-Open[1]>=Point);// цена больше на 1 пп в 4-х знаке
}

//или так ...

switch(Digits){
   case 5: if(Close[2]-Open[1]>=10*Point);// цена больше на 10 пп в 5-ти знаке
   case 4: if(Close[2]-Open[1]>=Point);// цена больше на 1 пп в 4-х знаке
}
 
sergeev:
What exactly is not working?


the position does not open.
 
IgorM:

Try it this way:


Either I don't understand anything, or you misunderstood the problem.

there is a Close[2] price of 1.34529 and an Open[1] price of 1.34530

I have a condition to open the position.

Close[2] >= Open[1]

Since 10 - 20 pips (in 5 digits) do not play a big role, I need to put it into the program,

If the Close price is 1.34529 and the Open price is 1.34530, the position can still be opened.

 
kilnart:

the position does not open.

???

then what does the price condition have to do with it?

look at the code next. there's another mistake.

 
The price that satisfies the condition goes on the chart, and the position is opened.
 
I'll double-check the code and let you know.
 
kilnart:


Either I don't understand, or you've misunderstood the task.

......

10 - 20 ppts (in 5 digits) does not play a big role, you need to put it in the program

apparently you wrote your previous post first and then only wondered what you wanted to hear in response....

really, 10-20pts in 5 digits doesn't matter much, I showed how to correctly compare variables like double, I suspect your problem is not in making the right condition. Try formulating a clear unambiguous question first to get an unambiguous answer

 
IgorM:

apparently you wrote your previous post first and then only wondered what you wanted to hear in reply....

really, 10-20 pp in 5 digits is not a big deal, I showed how to correctly compare variables of type double, I suspect that your problem is not in making the right condition. Try formulating a clear unambiguous question first to get an unambiguous answer


Except, imho, it's wrong to compare doubles like that. For example, four digits, prices 1.00014 and 1.00016 are equivalent to 1.0001 and 1.0002, but 1.00016 to 1.00014 < Point
 
220Volt: Except, imho, it's wrong to compare doble like that. For example, four digits, prices 1.00014 and 1.00016, equivalent to 1.0001 and 1.0002, but 1.00016 - 1.00014 < Point

You mix up comparing doubles and rounding, you need a clear statement of the question: either round a 5-digit into a 4-digit and then do the analysis in the 4-digit, or just properly compare two doubles.

If you compare two double's then that part of the code I cited will work correctly for both 4 and 5 digits:

switch(Digits){
   case 5: if(1.00014-1.00016>=10*Point); условие= false, -0.00002 меньше 0.00001*10   // цена больше на 10 пп в 5-ти знаке
   case 4: if(1.0001-1.0002>=Point); условие= false, -0.0001 меньше 0.0001          // цена больше на 1 пп в 4-х знаке
}

check it out: https://www.mql5.com/ru/articles/1561 and https://www.mql5.com/ru/forum/101433

SZZ: I made a mistake in my code: case should be closed by break, i.e. like this:

switch(Digits){
   case 5: if(Close[2]-Open[1]>=10*Point);// цена больше на 10 пп в 5-ти знаке
           break;
   case 4: if(Close[2]-Open[1]>=Point);// цена больше на 1 пп в 4-х знаке
           break;
}
 
IgorM:

You mix up comparing doubles and rounding, you need a clear statement of the question: either round a 5-digit into a 4-digit and then do the analysis in the 4-digit, or just properly compare two doubles.

If you compare two double's then that part of the code I cited will work correctly for both 4 and 5 digits:

check it out: https://www.mql5.com/ru/articles/1561 and https://www.mql5.com/ru/forum/101433

ZS: I made a mistake in my code: case should be closed with break, i.e. like this:


Although you're probably right, it probably doesn't matter to the author. I count every pip, so I look at such situations from my own point of view.