Expert Advisor doesn`t trade !!!! - page 2

 

What I see in your code is that nothing is done if there are already order(s) open. So it is inefficient to do the calculations unnecessarily. OrdersTotal() should be the first check and bypass the calculation code if there are open order(s).

It would be better to loop through open orders and check for magic number and symbol 

Note that by just using OrdersTotal() as a check, any manually opened trades or by another EA will not allow orders to be placed. It is better to check for open orders with magic number and symbol.

//--- input parameters
input double   takeprofit=0.1;
input double   stoploss= 0.1;
input double   LotSize = 0.01;
double point=Point;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   if(Digits==3 || Digits==5) point*=10;

   return (INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   if(OrdersTotal()<1)
     {
      int ticket;

      int MyHigh=iHighest(Symbol(),0,MODE_HIGH,30,1);
      double price_highest=High[MyHigh];
      if(price_highest<0)
         Print("Error :",GetLastError());
      int MyLow=iLowest(Symbol(),0,MODE_LOW,30,1);
      double price_lowest=Low[MyLow];
      if(price_lowest<0)
         Print(" Error :",GetLastError());

      if(price_highest<Ask)
        {
         ticket=OrderSend(Symbol(),OP_BUY,LotSize,Ask,5,Ask-(stoploss*point),Ask+(takeprofit*point),NULL,0,0,Green);
         if(ticket<0)
            Print(" Error sending Buy order :",GetLastError());
        }
      if(Bid<price_lowest)
        {
         ticket=OrderSend(Symbol(),OP_SELL,LotSize,Bid,5,Bid+(stoploss*point),Bid-(takeprofit*point),NULL,0,0,Red);
         if(ticket<0)
            Print(" Error sendig Sell order number :",GetLastError());
        }
     }
   return;
  }
//+------------------------------------------------------------------+

 Why use variables for Ask and Bid when you can just use Ask and Bid? If you have a lot of code, you can use RefreshRates() to make sure that they are current.

Why use the bools UpBreakThrough and DownBreakThrough when you can just test the condition and go straight to the code?

I would avoid using variable names such as point as it is too easy to mistakenly type Point. 

input double   takeprofit=0.1;
input double   stoploss= 0.1;

 Check your calculations for TP and SL, they will not be calculating as you want

Reason: