help with this simple EA, i dont know why it is not working

 

hi

i want to make this simple EA which will simply do reverse trade of the movement in the daily candle, so suppose the daily candle has moved 100 pips then it will do revrese for 10 pip TP

the following code i tried to make, it is not working...can you help?

extern int MagicNumber = 33333;
double lots=0.1;
extern double TP = 500.0;     // Pip-sensitive
extern double SL = 500.0; 
extern int Slippage = 5;
extern int body=60;
extern int diff=15;
int cnt,total;


int init()
  {
   return(0);
  }

int deinit()
  {
   return(0);
  }
int start()
  {
  // GlobalVariableSet("uplevel", High + Point);
 //  GlobalVariableSet("dnlevel", Low - Point);
 double open=iOpen(Symbol(),0,0);
 double close=iClose(Symbol(),0,0);
 double low=iLow(Symbol(),0,0);
 double high=iHigh(Symbol(),0,0);

   
      if(OrdersTotal()<1)
      {    
         if(open*Point>Bid+body) //for white candle means for bearish candle
            { Print("1111111111111111111111");
            if(low*Point+diff<=Bid)
               { Print("222222222222222222");
               if(isGoodTime(_startPeriod1,_endPeriod1))
                  {Print("33333333333333333");
                  OrderSend(Symbol(),OP_BUY,lots,Ask,Slippage,0,0,"",MagicNumber,0,Navy);
                  }
               }
            }
         if(Bid>open*Point+body) //for black candle means for bullish candle
            { 
            if(Bid+diff<=high*Point)
               { Print("44444444444444444444444444444");
               if(isGoodTime(_startPeriod1,_endPeriod1))
                  {Print("5555555555555");
                  OrderSend(Symbol(),OP_SELL,lots,Bid,Slippage,0,0,"",MagicNumber,0,Red);
                  }
               }
            }
      return(0);
      } //if orderstotal loop is closed here
      
      for(cnt=0;cnt<total;cnt++) // cycle through all orders
     {
         if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES))
          if (OrderType()<=OP_SELL)                // check for opened position 
           if (OrderSymbol()==Symbol())            // check for symbol
            if (OrderMagicNumber() == MagicNumber) // check for MagicNumber
              {
                  if(OrderType()==OP_BUY)   // long position is opened
                     {
                     OrderModify(OrderTicket(),OrderOpenPrice(),Ask-SL*Point,Ask+TP*Point,0,Green);
                     return(0);
                     }
                        
                  else // go to short position
                     {
                     OrderModify(OrderTicket(),OrderOpenPrice(),Bid+SL*Point,Bid-TP*Point,0,Red);
                     return(0);
                     }
              }  
             
     }
    
 }

there i have used print to check if it is entering the if loops, and it is not entering any loop, perhaps a little bit of change is needed i guess....

 

First of all, why use

 double open=iOpen(Symbol(),0,0);
 double close=iClose(Symbol(),0,0);
 double low=iLow(Symbol(),0,0);
 double high=iHigh(Symbol(),0,0);

Much simpler to use

double open=Open[0];
//---etc

Will this ever be true?

if(open*Point>Bid+body)

Maybe with EURUSD this will equate to

if(1.35000*0.00001>1.35000 + 60)
//----or
if(0.0000135 > 61.35)

I haven't looked any further into your code, but this is obviously not what is intended

 
GumRai thanks a lot, it solved the problem!
Reason: