[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 701

 
IgorM:


your dog in passing parameters to the function, if you pass it as SaveDataIND(double TempIND[])

double TempIND[ ] is actually a new array for the function, but without the right to change parameters, try SaveDataIND(double & TempIND[])

No, it's not!!! Looks like the dog ate a piece of meat after all... Thank you, Igor.
 

Is it possible to make it possible to pass in a function which indicator to use, so that in the string

TempIND[j]=iAD(NULL,PERIOD_M5,j);     

not a specific indicator but passed as a function parameter?

 
Well, make a switch or something and write out your possible indictors by assigning indices to them.
 
Mathemat:
Well, make a switch or something and write out your possible indictors by assigning indices to them.
Thanks, Alexey, that thought came to me first... I thought maybe someone would suggest something more extreme... :)
 
artmedia70:

Is it possible to make it possible to pass in a function which indicator to use, so that in the string

not a specific indicator but passed as a function parameter?



But what's the point? Such actions are not usually performed - usually the data are sent to the function, and the calling function prepares the data/array

it seems that your construction ArrayResize(TempIND,nBars); is not correct, at least in other programming languages, the compiler would not miss it since you have double TempIND[50]; - i.e. the array is declared as static and should be dynamic (i.e. without dimensions) - double TempIND[];

ZS: and confusion with the names in the variables in the function - do not forget that if there is a global variable (global in the body of the EA), the variable declared within the function with the same name will be completely different:

int my_int = 100;

///////////
int my_func(){

int my_int = 123;
Print("my_func my_int = ",my_int);
return(0);
}

int start(){
Print("start_func my_int = ",my_int);
return(0);
}
this is usually called the scope of variables - rename what is in the function its name i.e. void SaveDataIND(double myTempIND[], int nBars) - less confusion will be
 
artmedia70:

Where is Lot initialized?

Then only after checking for lots either change Lots_New as written before, or assign it value = Lot;



Thank you! It's all working!
 
IgorM:


But what is the point? Such actions are not usually performed - the data are usually sent to the function, and the calling function prepares the data/array

You seem to have the wrong ArrayResize(TempIND,nBars); construction, at least in other programming languages the compiler would not miss it because you have double TempIND[50]; - i.e. the array is declared as static, while it should be dynamic (i.e. without dimensionality) - double TempIND[];

ZS: and confusion with the names in the variables in the function - do not forget that if there is a global variable (global in the body of the EA), the variable declared within the function with the same name will be completely different:

this is usually called scope of variables - rename things in function their names, i.e. void SaveDataIND(double myTempIND[], int nBars) - less confusion will be

1. So, Igor, should I write my own absolutely identical function for each indicator?

2. Thanks, I fixed it just in case...

3. it doesn't confuse me - I can see which array is being used and where, it's somehow easier for me to reverse it, but when I have a lot of names, I'll definitely get confused... Although... I should probably get used to spelling it right...

 
cyclik33:

Thank you! It's all working!
You're welcome, come back... :)
 
T-G 13.07.2010 22:56 am Correction | delete
artmedia70:
Check the opening of a new candle. If new, you open, if old, you don't...
what is the best way to do it?
 
T-G:
T-G 13.07.2010 22:56 amended | delete
artmedia70:
Check for the opening of a new candle. If new, you open, if old, you don't...
What's the best way to do it?

static int time = Time[0];

if (time < Time[0]){

// old candle

} else {

// new candle

time = Time[0];

}

Reason: