Daily Pivots based EA won't enter trades

 

Hey guys, 

I wanted to build a really simple EA based on MT4's built-in Pivot Points indicator that would sell if prices reach resistance levels and buy if they reach support levels. I have not used the iCustom function a lot and so that might be why it does not work although I am not sure since the S & R levels seem to appear fine when I try to backtest the EA. The problem is that the EA won't enter any trades even if the conditions are met.

Here is what I have as a foundation for the strategy:

void OnTick()
  {
  double Resistance3 = iCustom(Symbol(),0,"Pivot Points - Daily (Shifted)",5,0,0);
  double Resistance2 = iCustom(Symbol(),0,"Pivot Points - Daily (Shifted)",5,1,0);
  double Resistance1 = iCustom(Symbol(),0,"Pivot Points - Daily (Shifted)",5,2,0);
  double Pivot = iCustom(Symbol(),0,"Pivot Points - Daily (Shifted)",5,3,0);
  double Support1= iCustom(Symbol(),0,"Pivot Points - Daily (Shifted)",5,4,0);
  double Support2= iCustom(Symbol(),0,"Pivot Points - Daily (Shifted)",5,5,0);
  double Support3= iCustom(Symbol(),0,"Pivot Points - Daily (Shifted)",5,6,0);
  
  
  if(OrdersTotal() == 0)
  { 
   if(Close[1] <= Support1 || Close[1] <= Support2 || Close[1] <= Support3)
   {
    OrderSend(Symbol(),OP_BUY,LotSize,Ask,3,OrderOpenPrice()-Pips*SL,OrderOpenPrice()+Pips*TP,NULL,0,0,Green);
   }
   
   if(Close[1] >= Resistance1 || Close[1] >= Resistance2 || Close[1] >= Resistance3)
   {
    OrderSend(Symbol(),OP_SELL,LotSize,Bid,3,OrderOpenPrice()+Pips*SL,OrderOpenPrice()-Pips*TP,NULL,0,0,Red);
   }
  }
   
  }

Any ideas as to why it can't trade?


Thanks a lot!

 
  1.  if(OrdersTotal() == 0)
    Using OrdersTotal directly and/or no Magic number filtering on your OrderSelect loop means your code is incompatible with every EA (including itself on other charts and manual trading.)
              Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 and MetaTrader 4 - MQL4 programming forum

  2.     OrderSend(Symbol(),OP_BUY,LotSize,Ask,3,OrderOpenPrice()-Pips*SL,OrderOpenPrice()+Pips*TP,NULL,0,0,Green);
    Check your return codes for errors and report them.
              What are Function return values ? How do I use them ? - MQL4 and MetaTrader 4 - MQL4 programming forum
              Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles

  3. You can not use any Trade Functions until you select an order.
Reason: