Hi, is there any experienced trader/programmer teach me how to make a function producing multiple outputs?
I am testing if I can make a function whose output is an array of 3 values. I've looked into everywhere, and I cannot find
anything talking about how a function output multiple values, in the form of an array? or something else?
So I tried this way below. I wish the code produce an output array -- IBinfo[3] = {1,2,3} due to calling "MyFunc".
but my results is that IBinfo[3] = {11,12,13}, which is same as the initial values.
How can I make a function producing multiple outputs? This is fundamental question. If someone shows me the grammar, we don't need to look into the code below.
Thanks a lot! Thanks a lot!
//+------------------------------------------------------------------+
int start()
{
int randominput = 3;
double IBinfo[3]={11,12,13};
IBinfo[3] = MyFunc(randominput);
Print("IBinfo array reads like 3rd?: ", (IBinfo[2]+3) );
Print("IBinfo array reads like 2nd?: ", (IBinfo[1]+2) );
Print("IBinfo array reads like 1st?: ", (IBinfo[0]+1) );
return(0);
}
//+-- function of "MyFunc" -------------------------------------------+
//
double MyFunc(int randomNO)
{
double an_array[3];
for (int i=1; i<=randomNO; i++)
{
an_array[i-1]=i;
return(an_array);
}
//+-- end of MyFunc
I am testing if I can make a function whose output is an array of 3 values. I've looked into everywhere, and I cannot find
anything talking about how a function output multiple values, in the form of an array? or something else?
So I tried this way below. I wish the code produce an output array -- IBinfo[3] = {1,2,3} due to calling "MyFunc".
but my results is that IBinfo[3] = {11,12,13}, which is same as the initial values.
How can I make a function producing multiple outputs? This is fundamental question. If someone shows me the grammar, we don't need to look into the code below.
Thanks a lot! Thanks a lot!
//+------------------------------------------------------------------+
int start()
{
int randominput = 3;
double IBinfo[3]={11,12,13};
IBinfo[3] = MyFunc(randominput);
Print("IBinfo array reads like 3rd?: ", (IBinfo[2]+3) );
Print("IBinfo array reads like 2nd?: ", (IBinfo[1]+2) );
Print("IBinfo array reads like 1st?: ", (IBinfo[0]+1) );
return(0);
}
//+-- function of "MyFunc" -------------------------------------------+
//
double MyFunc(int randomNO)
{
double an_array[3];
for (int i=1; i<=randomNO; i++)
{
an_array[i-1]=i;
return(an_array);
}
//+-- end of MyFunc