OK here is the next challenge.
When is it best to use the crossed function as opposed to the before-after way to know if lines crossed. Here is what I mean:
When is it best to use this:
As opposed to this........
When is it best to use the crossed function as opposed to the before-after way to know if lines crossed. Here is what I mean:
When is it best to use this:
Inserted Code
if ( (Short_ema_shift2 < Long_ema_shift2) && (Short_ema_shift1 > Long_ema_shift1) ) // Short EMA crossed Long EMA upwards { ticket=OrderSend(........) }
Inserted Code
int Crossed (double line1 , double line2) // Declaring the Crossed function { static int last_direction = 0; static int current_direction = 0; if(line1>line2)current_direction = 1; if(line1<line2)current_direction = 2; if(current_direction != last_direction) { last_direction = current_direction; return (last_direction); } else { return (0); } } //--- //--- int isCrossed1 = Crossed (line1, line2); if (isCrossed1 == 1) { cross1=1; } else if (isCrossed1 == 2) { cross1=2; } else { cross1=0; } // if (cross1==1) { ticket=OrderSend(........)