# Help with the meaning of an input variable

I'm studying the 2010 ATC Avoitenko's EA,

There's a function called OrderCalcMargin() used in EA,which is defined as below:

bool OrderCalcMargin(string symbol, // Symbol name
double volume, // Lots
double price, // Open price
double& margin) // output value
{
string first = StringSubstr(symbol,0,3);
string second = StringSubstr(symbol,3,3);
string currency = AccountCurrency();
double leverage = AccountLeverage();

double contract = MarketInfo(symbol, MODE_LOTSIZE);

margin = 0.0;

...........

}

I know that is a bool function which return true or false, and the function actually calculate the margin that is needed for trading.

My qusetion is that:

what does the double& mean? can anyone explain for me?

It passes the variable (probably an array) by reference. You can't return an array from a function so if you have a function that modifies an array how do you use it for different arrays ? you pass the array name to the function by reference . . .

OK, in this case the variable being passed is not an array . .

RaptorUK:

It passes the variable (probably an array) by reference. You can't return an array from a function so if you have a function that modifies an array how do you use it for different arrays ? you pass the array name to the function by reference . . .

OK, in this case the variable being passed is not an array . .

first of all, thank you for help!

now i know this thing is called "reference", the same in C++.

My understanding is that:

the variable "margin" is what we need, but the OrderCalcMargin() is defined as "bool", so it can not return a double type variable.

then we use the reference thing to let the function judge T or F, meanwhile, we can "reference" the value of "margin".

is that right?

saji:

the variable "margin" is what we need, but the OrderCalcMargin() is defined as "bool", so it can not return a double type variable.

then we use the reference thing to let the function judge T or F, meanwhile, we can "reference" the value of "margin".

is that right?

Yes I think it is just about right . . . just to add that it also allows the modification of the value of margin without returning that value or having it as a globally defined variable.

RaptorUK:
Yes I think it is just about right . . . just to add that it also allows the modification of the value of margin without returning that value or having it as a globally defined variable.
thank you very much.....