I want to ask about trading condition

 
 // check if lines have crossed
   if( Close[0]> Open[0]&& Close[1]> Open[1]  ) siCurrentDirection = 1; //up
    if( Close[0]< Open[0]&& Close[1]< Open[1] ) siCurrentDirection = 2; //down
I want to Order Buy went have double Green Bar and Sell went have two Red Bar i write this but it not run
 
phipho:
I want to Order Buy went have double Green Bar and Sell went have two Red Bar i write this but it not run
Close[0]  is equal to Bid and is a moving target . . .  why not check bars 1 & 2 when a new bar is formed ?  this will be just after what was bar 0 closed.
 
how i can write code bar. I don't know wrtie it
 
phipho:
how i can write code bar. I don't know wrtie it
Use the Search box at the top right of this page . . .
 
if( Bars == Green && Bars......  ) siCurrentDirection = 1; //up
     if( Bars == Red && Bars......  )  siCurrentDirection = 2; //down
 
RaptorUK:
Sử dụng hộp tìm kiếm ở phía trên bên phải của trang này. . .


my english is bad. I can't find this hicc Can you help me =.="
 
phipho:

my english is bad. I can't find this hicc Can you help me =.="
Though, it's good that you are learning mql4 programming and trying to create your own EA, how about subscribing to MQL5 signal for MT4 here https://www.mql5.com/en/signals/mt4
 
phi.nuts:
Though, it's good that you are learning mql4 programming and trying to create your own EA, how about subscribing to MQL5 signal for MT4 here https://www.mql5.com/en/signals/mt4

i try to write this. I don't  know your mean what about your link
 
int CheckForCross(){
   static int siLastDirection = 0;
   static int siCurrentDirection = 0;  
   bool bear, bull, neutral, Candle1,Candle2;
   if(Close[1]<Open[1])Candle1= bear;
   if(Close[1]>Open[1])Candle1= bull;
   if(Close[1]==Open[1])Candle1= neutral;
   if(Close[2]<Open[2])Candle2= bear;
   if(Close[2]>Open[2])Candle2= bull;
   if(Close[2]==Open[2])Candle2= neutral;
      
   // check if lines have crossed
   if( Candle1==bull && Candle2==bull) siCurrentDirection = 1; //up
    if( Candle1==bear && Candle2==bear) siCurrentDirection = 2; //down
    return(0);

   if(siCurrentDirection != siLastDirection){
      // they have so return the new signal
      siLastDirection = siCurrentDirection;
      return (siLastDirection);
   }
   
   // no cross
   return(0);
} 
it not work what my mistake
 
phipho:
it not work what my mistake
What is the value of bull,  bear ?  do you know what a variable is ? 
 
int CheckForCross(){
   static int siLastDirection = 0;
   static int siCurrentDirection = 0;  
   bool bear1, bull1,bear2, bull2, neutral, Candle1,Candle2;
 bear1=(Close[1]<Open[1]);
 bull1=  (Close[1]>Open[1]);
 bear2=(Close[2]<Open[2]);
 bull2=  (Close[2]>Open[2]);
   // check if lines have crossed
   if( Candle1==bull1 && Candle2==bull2) siCurrentDirection = 1; //up
    if( Candle1==bear1 && Candle2==bear2) siCurrentDirection = 2; //down
    return(0);
i repair it . but if i write this it will like first code 
Reason: