Why is ask and bid automatically passed by reference?

 
I was just wondering why ask and bid are automatically passed by reference?
 
What do you mean by "passed by reference"?
 
mfx123:
What do you mean by "passed by reference"?


The value of ask and bid inside the sampleFunction are changing although they are passed by value, from my lessons in c++, the value of inputAsk/inputBid should only be changing if they are passed by reference.

void OnTick()
{
//---
   double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK),_Digits);
   double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_BID),_Digits);
   sampleFunction(Ask,Bid);
//---
  }

        void sampleFunction (double inputAsk, double inputBid){
        Comment("The value of ask is ", inputAsk,
                "The value of bid is ", inputBid );
        }
 
Renz Carillo:


The value of ask and bid inside the sampleFunction are changing although they are passed by value, from my lessons in c++, the value of inputAsk/inputBid should only be changing if they are passed by reference.

You have not passed them by reference, you have just passed the values.

If you change the values of the variables in the function when you return to OnTick() the varaiable values will not have changed.

 
Keith Watford:

You have not passed them by reference, you have just passed the values.

If you change the values of the variables in the function when you return to OnTick() the varaiable values will not have changed.

Then why does variable inputAsk value changed when variable Ask changes, when you're passing by value, only the initial value gets saved isn't it

 
Renz Carillo:

Then why does variable inputAsk value changed when variable Ask changes, when you're passing by value, only the initial value gets saved isn't it

Because you are calling the function every tick and passing new values to the function.

 
Renz Carillo:


The value of ask and bid inside the sampleFunction are changing although they are passed by value, from my lessons in c++, the value of inputAsk/inputBid should only be changing if they are passed by reference.

OnTick is an event-driven function defined by mql4/mql5.  it's called when the chart symbol's ask/bid prices change.

 
Tsungche Kuo:

OnTick is an event-driven function defined by mql4/mql5.  it's called when the chart symbol's ask/bid prices change.

Not relevant to this topic.

Reason: