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

 
rabanik:    Good ... on a dime ... what does it mean ... "&" whenpassing to a function?

Left click on the picture to enlarge or right click and save

MetaEditor has help for MQL-4 language. It makes sense to read the whole help or at least to run through it

 

Good afternoon.

I have made a button on the screen and want to attach an Offline Chart opening to it. What function can I use to specify the path to the desired Offline Chart?

 
Good afternoon, how can we make the chart update automatically every 10 seconds so that you don't have to press the "Update" button every time?
 
zert: updating the diagram
voidOnTimer() // On timer WindowRedraw(); // Redraw the window
 
LRA:
voidOnTimer() // On timer WindowRedraw(); // Redraw the window
I don't understand where to write it all, can you show me on a screenshot?
 
zert:   where to write
insert into the EA you are using. If there isn't one, you need to write one. Why a new nickname?
 
LRA:

Left click on the picture to enlarge or right click and save

The MetaEditor has help for MQL-4 language. It makes sense to read it all, or at least look through it

Thanks for the reply. I don't understand it to the end. For example, I have the SendOrder(int &Ticket, int Type ,double LT ,double OP=-1 ,int ModeSL=0) function with parameters. Further, if I for example in code try to refer to it in any condition, I get error "parameter passed as reference, variable".

Please, advise what to do? Thank you.

 
rabanik:    if you go to .... error "parameter passed as reference, variable".

If the parameter is without & transfer by value, which is more reliable. The actual parameter is copied and a copy is passed to the function. The changes made to the parameter inside the function remain inside the function. The actual parameter at the place of the function call remains unchanged. And it doesn't matter for the function if a constant or a variable is passed to it, because in any case only a copy of the parameter reaches the function. This is done to increase reliability, to protect the variables from accidental change within a function.

When passing the parameter by reference, the & symbol is specified and it means that the reference, the address of the variable itself, is passed to the function. And the function can change this variable and these changes will affect the value of the variable inside the function which called this function. Well, for a function to change the value of a parameter, it must be a variable, the Translator most likely wrote: parameter passed as reference, variable expected = parameter by reference must be a variable

If in doubt again, I have the SendOrder(int &Ticket, int Type ,double LT ,double OP=-1 ,int ModeSL=0) function instead I'd better write how the function was called. It seems that you pass a number as the first parameter, which makes no sense. In this parameter, your function tries to return the number under which the order has been placed in the broker's database. Clearly this should be a variable. If in doubt, have a look at the function. And the function is TRUE to change the number being passed, it wants a variable in that place.

 

Wouldn't it be easier to understand from an example?

void OnStart()
{
 int a = 5;
 int b = 7;
 int c = f(a, b);
 Print("a = ", a, ": b = ", b": c = ", c);
}

int f(int k, int n)
{
 k += 2;
 return(k+n);
}

//результат a = 5: b = 7: с = 14

The other option

void OnStart()
{
 int a = 5;
 int b = 7;
 int c = f(a, b);
 Print("a = ", a, ": b = ", b": c = ", c);
}

int f(int &k, int n)
{
 k += 2;
 return(k+n);
}

//результат a = 7: b = 7: с = 14

this is the difference.

 
Good day all!!! Let's assume there is a buffer in the indicator that I need to use in the calculation of other indicators. I want to use it in calculation of other indicators. How to make the indicator buffer be present but it doesn't show any icons on the chart? Thank you all!!!!
Reason: