Hi all! I've been tinkering with the code for days, but no luck! The condition doesn't work. The Z variable is always assigned the last value, in this case it equates to Z=1. What do I need to fix to make the conditions work? Who can help?
X = MathFloor(PriceTarget); Y = (PriceTarget - X); { if (0 < Y <= 0.03125) {Z = 0.03125;}
if (0.03126 < Y <= 0.0625) {Z = 0.0625;}
if (0.0625 < Y <= 0.09375) {Z = 0.09375;}
if (0.09375 < Y <= 0.125) {Z = 0.125;}
if (0.125 < Y <= 0.15625) {Z = 0.15625;}
if (0.15625 < Y <= 0.1875) {Z = 0.1875;}
if (0.1875 < Y <= 0.21875) {Z = 0.21875;}
if (0.21875 < Y <= 0.25) {Z = 0.25;}
if (0.25 < Y <= 0.28125) {Z = 0.28125;}
if (0.28125 < Y <= 0.3125) {Z = 0.3125;}
if (0.3125 < Y <= 0.34375) {Z = 0.34375;}
if (0.34375 < Y <= 0.375) {Z = 0.375;}
if (0.375 < Y <= 0.40625) {Z = 0.40625;}
if (0.40625 < Y <= 0.4375) {Z = 0.4375;}
if (0.4375 < Y <= 0.46875) {Z = 0.46875;}
if (0.46875 < Y <= 0.5) {Z = 0.5;}
if (0.5 < Y <= 0.53125) {Z = 0.53125;}
if (0.53125 < Y <= 0.5625) {Z = 0.5625;}
if (0.5625 < Y <= 0.59375) {Z = 0.59375;}
if (0.59375 < Y <= 0.625) {Z = 0.625;}
if (0.625 < Y <= 0.65625) {Z = 0.65625;}
if (0.65625 < Y <= 0.6875) {Z = 0.6875;}
if (0.6875 < Y <= 0.71875) {Z = 0.71875;}
if (0.71875 < Y <= 0.75) {Z = 0.75;}
if (0.75 < Y <= 0.78125) {Z = 0.78125;}
if (0.78125 < Y <= 0.8125) {Z = 0.8125;}
if (0.8125 < Y <= 0.84375) {Z = 0.84375;}
if (0.84375 < Y <= 0.875) {Z = 0.875;}
if (0.875 < Y <= 0.90625) {Z = 0.90625;}
if (0.90625 < Y <= 0.9375) {Z = 0.9375;}
if (0.9375 < Y <= 0.96875) {Z = 0.96875;}
if (0.96875 < Y <= 1) {Z = 1;} } W = X + Z;
Ilya12345:
Hi all! I have been tinkering with the code for days, but with no success! The condition doesn't work. Variable Z is always assigned the last value, in this case it equals Z=1. What do I need to fix to make the conditions work? Can someone help me?
Try this
X = MathFloor(PriceTarget);
Y = (PriceTarget - X);
{
if (0 < Y <= 0.03125)
Z = 0.03125;
else if (0.03126 < Y <= 0.0625)
Z = 0.0625;
else if (0.0625 < Y <= 0.09375)
Z = 0.09375;
else if (0.09375 < Y <= 0.125)
Z = 0.125;
else if (0.125 < Y <= 0.15625)
Z = 0.15625;
else if (0.15625 < Y <= 0.1875)
Z = 0.1875;
else if (0.1875 < Y <= 0.21875)
Z = 0.21875;
else if (0.21875 < Y <= 0.25)
Z = 0.25;
elseif (0.25 < Y <= 0.28125)
Z = 0.28125;
else if (0.28125 < Y <= 0.3125)
Z = 0.3125;
else if (0.3125 < Y <= 0.34375)
Z = 0.34375;
else if (0.34375 < Y <= 0.375)
Z = 0.375;
else if (0.375 < Y <= 0.40625)
Z = 0.40625;
else if (0.40625 < Y <= 0.4375)
Z = 0.4375;
else if (0.4375 < Y <= 0.46875)
Z = 0.46875;
elseif (0.46875 < Y <= 0.5)
Z = 0.5;
else if (0.5 < Y <= 0.53125)
Z = 0.53125;
else if (0.53125 < Y <= 0.5625)
Z = 0.5625;
else if (0.5625 < Y <= 0.59375)
Z = 0.59375;
else if (0.59375 < Y <= 0.625)
Z = 0.625;
else if (0.625 < Y <= 0.65625)
Z = 0.65625;
else if (0.65625 < Y <= 0.6875)
Z = 0.6875;
else if (0.6875 < Y <= 0.71875)
Z = 0.71875;
elseif (0.71875 < Y <= 0.75)
Z = 0.75;
else if (0.75 < Y <= 0.78125)
Z = 0.78125;
else if (0.78125 < Y <= 0.8125)
Z = 0.8125;
else if (0.8125 < Y <= 0.84375)
Z = 0.84375;
else if (0.84375 < Y <= 0.875)
Z = 0.875;
else if (0.875 < Y <= 0.90625)
Z = 0.90625;
else if (0.90625 < Y <= 0.9375)
Z = 0.9375;
else if (0.9375 < Y <= 0.96875)
Z = 0.96875;
else if (0.96875 < Y <= 1)
Z = 1;
}
W = X + Z;
Question 1: it is written that they are stored on the hard disk. Is the access time to them as long as when reading data from a file or as fast as when reading an ordinary variable?
Question 2: It says that global variables can only be of type double, but what if I want to store data of other types, e.g. int or string?
"Not complaining" is sort of not really a mathematical concept.
It is written here:
It says that the global variable is saved on the hard disk and stored for a certain time. While the programme (terminal, indicator, advisor) is running, all variables are in RAM, i.e. the value of the G.P. will only be read from the disk when the programme is launched for the first time.
Temnyj: It says that the global variable is saved on the hard disk and stored for a certain time. While the programme (terminal, indicator, Expert Advisor) is running, all variables are stored in RAM, i.e. the value of G.P. will only be read from the disk when the programme is launched for the first time.
Thank you for the information. What about the second question?
Any variables are lost when you exit the program (restart your computer, etc.). Except for global variables, because they are stored on the hard disk. But they can only be of type double. What to do, if it's necessary to store variables of other types (int or string for example)? What is unclear here?
Any variables will be lost when exiting the program (restarting the computer, etc.). Except for global variables, because they are stored on the hard disk. But they can only be of type double. What to do, if it's necessary to store variables of other types (int or string for example)? What is unclear here?
There are global variables of the current program level and global variables of the terminal level. The former are reset on deinitialisation, the latter are not. You are clearly talking about the latter.
Of course, it would be hard, for example, to hide an array like double from 100 items into such variables. It's better not to use them at all for such purposes.
Use a file to store data of any type. There are no limitations there. And this method is used by everyone at all times.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Hi all! I've been tinkering with the code for days, but no luck! The condition doesn't work. The Z variable is always assigned the last value, in this case it equates to Z=1. What do I need to fix to make the conditions work? Who can help?
X = MathFloor(PriceTarget);
Y = (PriceTarget - X);
{
if (0 < Y <= 0.03125)
{Z = 0.03125;}
if (0.03126 < Y <= 0.0625)
{Z = 0.0625;}
if (0.0625 < Y <= 0.09375)
{Z = 0.09375;}
if (0.09375 < Y <= 0.125)
{Z = 0.125;}
if (0.125 < Y <= 0.15625)
{Z = 0.15625;}
if (0.15625 < Y <= 0.1875)
{Z = 0.1875;}
if (0.1875 < Y <= 0.21875)
{Z = 0.21875;}
if (0.21875 < Y <= 0.25)
{Z = 0.25;}
if (0.25 < Y <= 0.28125)
{Z = 0.28125;}
if (0.28125 < Y <= 0.3125)
{Z = 0.3125;}
if (0.3125 < Y <= 0.34375)
{Z = 0.34375;}
if (0.34375 < Y <= 0.375)
{Z = 0.375;}
if (0.375 < Y <= 0.40625)
{Z = 0.40625;}
if (0.40625 < Y <= 0.4375)
{Z = 0.4375;}
if (0.4375 < Y <= 0.46875)
{Z = 0.46875;}
if (0.46875 < Y <= 0.5)
{Z = 0.5;}
if (0.5 < Y <= 0.53125)
{Z = 0.53125;}
if (0.53125 < Y <= 0.5625)
{Z = 0.5625;}
if (0.5625 < Y <= 0.59375)
{Z = 0.59375;}
if (0.59375 < Y <= 0.625)
{Z = 0.625;}
if (0.625 < Y <= 0.65625)
{Z = 0.65625;}
if (0.65625 < Y <= 0.6875)
{Z = 0.6875;}
if (0.6875 < Y <= 0.71875)
{Z = 0.71875;}
if (0.71875 < Y <= 0.75)
{Z = 0.75;}
if (0.75 < Y <= 0.78125)
{Z = 0.78125;}
if (0.78125 < Y <= 0.8125)
{Z = 0.8125;}
if (0.8125 < Y <= 0.84375)
{Z = 0.84375;}
if (0.84375 < Y <= 0.875)
{Z = 0.875;}
if (0.875 < Y <= 0.90625)
{Z = 0.90625;}
if (0.90625 < Y <= 0.9375)
{Z = 0.9375;}
if (0.9375 < Y <= 0.96875)
{Z = 0.96875;}
if (0.96875 < Y <= 1)
{Z = 1;}
}
W = X + Z;
Hi all! I have been tinkering with the code for days, but with no success! The condition doesn't work. Variable Z is always assigned the last value, in this case it equals Z=1. What do I need to fix to make the conditions work? Can someone help me?
Try this
transferred from
try it like this.
works!!!! real thanks!!! especially for the promptness!
works!!!! real thanks!!! especially for the promptness!
Somewhere like this:
I have two questions about global variables.
Question 1: it is written that they are stored on the hard disk. Is the access time to them as long as when reading data from a file or as fast as when reading an ordinary variable?
Question 2: It says that global variables can only be of type double, but what if I want to store data of other types, e.g. int or string?
1. I can't complain about the speed.
2. where is it written? all types can be global.
"Not complaining" is not really a mathematical concept.
It's written here:
"Not complaining" is sort of not really a mathematical concept.
It is written here:
It says that the global variable is saved on the hard disk and stored for a certain time. While the programme (terminal, indicator, Expert Advisor) is running, all variables are stored in RAM, i.e. the value of G.P. will only be read from the disk when the programme is launched for the first time.
Thank you for the information. What about the second question?
Thank you for the information. What about the second question?
I don't really understand the second question.
You'd better read it here.
I don't really understand the second question.
You might want to read it here
Any variables are lost when you exit the program (restart your computer, etc.). Except for global variables, because they are stored on the hard disk. But they can only be of type double. What to do, if it's necessary to store variables of other types (int or string for example)? What is unclear here?
Any variables will be lost when exiting the program (restarting the computer, etc.). Except for global variables, because they are stored on the hard disk. But they can only be of type double. What to do, if it's necessary to store variables of other types (int or string for example)? What is unclear here?
There are global variables of the current program level and global variables of the terminal level. The former are reset on deinitialisation, the latter are not. You are clearly talking about the latter.
Of course, it would be hard, for example, to hide an array like double from 100 items into such variables. It's better not to use them at all for such purposes.
Use a file to store data of any type. There are no limitations there. And this method is used by everyone at all times.