View Single Post
  #4 (permalink)  
Old 09-24-2007, 05:33 AM
eight10 eight10 is offline
Newbie
 

Join Date: Jul 2007
Posts: 14
Default

Well those lines of a Billion > < == %% || statements makes its almost impossible to comprehend what is going on. I also prefer to make seperate functions to control the program, instead of lumping everything in the start().

for instance you could do something like

Code:
int stochCross(double stoch1, double stoch2)
{
   static int direction = 0;
   static int new_direction = 0;
   
   if(stoch 1> stoch2)
       direciton = 1;
   if(stoch 1 < stoch 2)
       direciton = -1;

   if(direction != new_direction)
   {
        new_direction = direction;
        return(new_direction);
    }
return(0);
}

From there in start just reference:
signal = stochCross(stoch1, stoch2);
then from there something like
if(signal == 1)
placeorder;
etc.
makes for less messy code, and code that people can read. Also eliminates the need for current_stoch and previous_stoch.
Reply With Quote