Any suggestions ?
(1) Pass any number of variables into the function by reference.
See the second section of:
(1) Pass any number of variables into the function by reference.
See the second section of:
Thank You Anthony !
I tried this one :
//+------------------------------------------------------------------+ //| Passing parameters by reference | //+------------------------------------------------------------------+ double SecondMethod(int &i,int &j) { double res; //--- i*=2; j/=2; res=i+j; //--- return(res); } //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { //--- int a=14,b=8; Print("a and b before call:",a," ",b); double d=SecondMethod(a,b); Print("a and b after call:",a," ",b); } //+------------------------------------------------------------------+ //--- result of script execution // a and b before call: 14 8 // a and b after call: 28 4
And doesn't work :/
int smma_handle; double temp[2]; int OnInit() { smma_handle=iMA (_Symbol,PERIOD_M5,50,0,MODE_SMMA,PRICE_CLOSE); return(INIT_SUCCEEDED); } void OnTick() { CopyBuffer(smma_handle,0,0,2,temp); Comment(temp[0] + temp[1]); }
Try These :
Thank You (Ευχαριστώ!) for the answer !
The my first code is one external file and I need to calculate 364 MA (Different periods from different Time Frames.
I am search for something faster and lighter . I could calculate 2 times my first code to different strings to get the two latest values from my array.
The reason that I am doing this,is that after the getting of the two latest values from the 364 MA's, I need to send them not directly to my framework, but to a "Check" file, which will do all the comparisons, and after to the Main.
In PHP is so much easier to return array ! I cannot believe at it's so difficult to here.
I found also this from c++ forum
int * getRandom( ) { static int r[10]; // set the seed srand( (unsigned)time( NULL ) ); for (int i = 0; i < 10; ++i) { r[i] = rand(); cout << r[i] << endl; } return r; } // main function to call above defined function. int main () { // a pointer to an int. int *p; p = getRandom(); for ( int i = 0; i < 10; i++ ) { cout << "*(p + " << i << ") : "; cout << *(p + i) << endl; } return 0; }
but it doesn't work :/
Thank You Anthony !
I tried this one :
And doesn't work :/
What do you mean by "And doesn't work."
This is exactly what I would expect of the code you wrote.
//--- result of script execution // a and b before call: 14 8 // a and b after call: 28 4
Thank You (Ευχαριστώ!) for the answer !
The my first code is one external file and I need to calculate 364 MA (Different periods from different Time Frames.
I am search for something faster and lighter . I could calculate 2 times my first code to different strings to get the two latest values from my array.
The reason that I am doing this,is that after the getting of the two latest values from the 364 MA's, I need to send them not directly to my framework, but to a "Check" file, which will do all the comparisons, and after to the Main.
In PHP is so much easier to return array ! I cannot believe at it's so difficult to here.
I found also this from c++ forum
but it doesn't work :/
So , you actually need 182 sets ? (2 for each asset , timeframe ?)
MamRa:
In PHP is so much easier to return array ! I cannot believe at it's so difficult to here.
but it doesn't work :/
- It's not difficult, just pass an array in by reference and modify the array.
- "Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless.
- Your comment shows it did work. You modified two variables in the caller.
- It's not difficult, just pass an array in by reference and modify the array.
- "Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless.
- Your comment shows it did work. You modified two variables in the caller.
Can you help me on my example ?
So , you actually need 182 sets ? (2 for each asset , timeframe ?)
No, I want 360 unique values (for different MA Method, different MA Period and different Time Frame) for each.
So if we calculate the the previous of them, I want 720 values.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello to everyone ! I want to pass multiple values (2 or more) from this array:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
and the way that I am calling this to main is:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Any suggestions ?