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

 
Oleh Fedorov:

Hello.

Isn't anyone going to say anything about the Bilder post?

Maybe it makes sense to put it in a new thread, so that more people will see it? If so, please ask the moderators to post it... Or create one yourself?

Yes, create a separate topic. Just try to choose the right section of the forum in which to create the topic.

 

A word of advice, please, elementary. Arrays.

I'm studying and don't understand.

double tick[2,2];

void OnTick()
  {
  tick[1,1] = Ask;
  tick[1,2] = NormalizeDouble(tick[1,1]*100*_Point,_Digits);
  OrderSend(Symbol(),OP_BUYSTOP,0.01,tick[1,2],3,0,0,"bs2",0,0,clrBlue); 
}

I don't get errors during compilation, but when I run it in the terminal it gives me a critical error.

Why when the comment oftick[1,1] value is printed, it rounds the number to 4 decimal places.

Why is it not only unable to correctly calculatetick[1,2] value but also refuses to copy data oftick[1,1] cell(tick[1,2]=tick[1,1];).

And lastly, why, when creating an order, if instead of price value I cite a cell of array where this price is storedtick[1,2], it considers this variable as 2 values at once. (there is a slippage value skipping in the hints)

 
Gilmor:

A word of advice, please, elementary. Arrays.

I'm studying and don't understand.

I don't get errors during compilation, but I get a critical error when I run it in the terminal.

Why when the comment oftick[1,1] value is printed, it rounds the number to 4 decimal places.

Why is it not only unable to correctly calculatetick[1,2] value but also refuses to copy data oftick[1,1] cell(tick[1,2]=tick[1,1];).

And lastly, why, when creating an order, if instead of price value I cite a cell of array where this price is storedtick[1,2], it considers this variable as 2 values at once. (there is a slippage value skipping in the hints)

Because in the OrderSend function parameters, like in all other functions, the comma plays a role. As soon as a comma appears in the text, it is treated as a separator for incoming values. Make tick[1][2]

 
Alexey Viktorov:

Because in the OrderSend function parameters, like in all other functions, the comma plays a role. As soon as a comma appears in the text, it is treated as a separator for incoming values. Make tick[1][2]

Thank you. Maybe you can answer the other questions too? :)
 
Gilmor:
Thank you. Maybe you can answer some other questions too? :)

Can you answer the question meat(2.55=367.12)

 
Alexey Viktorov:

Can you answer the question meat(2.55=367.12)

Got it.

double tick[2,2];

void OnTick()
  {
  tick[1,1] = Ask;
  tick[1,2] = NormalizeDouble(tick[1,1]*100*_Point,_Digits);
  }
double tick[2,2];

Created an array of 2 cells top row, 2 cells bottom row.

void OnTick()
  {
  tick[1,1] = Ask;
 Comment (tick[1,1])

Result. The price on the chart is 0.84478, but the comment at the top shows 0.8448 ???? Why did it round to 4 decimal places?

double tick[2,2];

void OnTick()
  {
  tick[1,1] = Ask;
  tick[1,2] = tick[1,1];
  }

Following the logic of writing to a cell, I copy the data of cell 1 of the array, to cell 2 of the same array. The result is a critical error.

Why?

double tick[2,2];

void OnTick()
  {
  tick[1,1] = Ask;
  tick[1,2] = NormalizeDouble(tick[1,1]*100*_Point,_Digits);
  }

We want to add to cell 2 of the array the value of the future price for the pending order. In other words, we want to add 100 points to the Ask price and then specify this cell of the array in the price parameter when placing the order. But when executing this command, we get the same error again.


Why?

 
Gilmor:

Following the logic of writing to a cell, I copy the data from cell 1 of the array, to cell 2 of the same array. The result is a critical error.

Why?

because you don't understand what arrays are, if you've read the help, and it didn't work, let's "on our fingers"

it's an array declaration

double tick[2,2];

which tells the compiler to reserve "4 memory cells" --> 2x2

and access to the lowest element has index 0, i.e. in your case, the arraytick[2,2], will only have these array elements

tick[0,0]tick[0,1]

tick[1,0]tick[1,1]

there are 4 elements in the array, right? .... but the youngest index of the array has number 0, and not as you would like (or as you got used to during verbal calculation) from number 1


and, consequently, the most senior element of the array will have the number: array size minus 1

if you have exceeded the array dimensions, you will get a critical error of execution - your screenshot, i.e. for arraytick[2,2] there is no such an array element with numbertick[2,2]

 

Well, at least I'll admit to being a beginner :)

Thank you.

Well, the "on your fingers" thing is a habit. "On your fingers," it's easier to understand. And if I explained it to someone who is a total zero in this language, I would have to use my toes to clarify it =))

 
Gilmor:

Well, at least I'll admit to being a beginner :)

Thank you.

Well, the "on your fingers" thing is a habit. "On your fingers," it's easier to understand. And if I explained it to someone who is a zero in this language, I would have to use my toes to clarify it =))

A beginner is not a shame, the more the branch is thematic - for beginners, and this is one of the few forums where you can get a quick answer to your question ;)

well, in addition, read the beginning of the helphttps://docs.mql4.com/ru/basis/variables

 
Igor Makanu:

it's no shame for a newbie, especially as this is one of the few forums where you can get a quick answer to your question ;)

and on top of that, read the beginning of the helphttps://docs.mql4.com/ru/basis/variables

Thank you.
Reason: