Hey everyone! This is my formal greeting/required newbie question . I’ve been working through the Coders’ Guru guide and it’s making sense, although I wouldn’t say it’s all sticking. Most things I recognize and can put the pieces together, but there is one thing that isn’t clicking. It’s in the “My First EA” section and it goes something like this…
int Crossed (double line1 , double line2)
{
static int last_direction = 0;
static int current_dirction = 0;
if(line1>line2)current_dirction = 1; //up
if(line1<line2)current_dirction = 2; //down
if(current_dirction != last_direction) //changed
{
last_direction = current_dirction;
return (last_direction);
}
else
{
return (0);
This makes sense, basically what I’m taking from it is it tells the program what we see visually, a change in position (or not) of two lines relative to each other. The issue I’m having is that line1 and line2 are not declared anywhere else. The next instance Crossed is used is here…
int isCrossed = Crossed (shortEma,longEma);
What I think is happening is that the first section of code I showed is just a set up for a formula. line1 and line2 are not actually variables, they are placeholders for variables, if that makes sense. It’s more for setting Crossed up as a function, I suppose, and that you must use a double data type. Is that correct? Thank you in advance.