Can't get my EA to sell

To add comments, please log in or register
tonycunningham
15
tonycunningham  
extern double Lots=0.1;
extern datetime StartDateTime= D'08.10.2012 10:47:33';
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
  
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+

int start()
  {

    int cnt,i;
  
  
   int TotalTrades=0;
  
 if(TimeCurrent()<StartDateTime)  return;
 
  double val1=iCustom(NULL, 0, "CustomAdaptiveIndicator",1,0); 
  double val2=iCustom(NULL, 0, "CustomAdaptiveIndicator",1,1);
  double val3=iCustom(NULL, 0, "CustomAdaptiveIndicator",1,2);
  double val4=iCustom(NULL, 0, "CustomAdaptiveIndicator",1,3);   
   
   for(cnt=0;cnt<OrdersTotal();cnt++)
   {
     OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
     if(OrderMagicNumber()==15926) TotalTrades++;       
   }
   
//----
   if(TotalTrades==0 ) 
   {

      if(val1 > val2 && val2 < val3 && val3 < val4)
         {
         OrderSend(Symbol(),OP_BUYLIMIT,Lots,Ask-3*Point,3,Ask-300*Point,Ask+100*Point,"",15926,0,Blue);
         }

      if(val1 < val2 && val2 > val3 && val3 > val4)
         {
         OrderSend(Symbol(),OP_SELLLIMIT,0.1,Bid+3*Point,3,Bid+300*Point,Bid-100*Point,"",15926,0,Red);
         }      

   }

   return;
  }
//+------------------------------------------------------------------+

I can't figure out what I'm missing here. I can't get this EA to open a sell position.

I've tried putting in a 'return' after each OrderSend, but that didn't work. It opens a buy position just fine when parameters are met.

Any help would be greatly appreciated.

 

Tony 

Simon Gniadkowski
17644
Simon Gniadkowski  
tonycunningham:

I can't figure out what I'm missing here. I can't get this EA to open a sell position.

I've tried putting in a 'return' after each OrderSend, but that didn't work. It opens a buy position just fine when parameters are met.

Any help would be greatly appreciated.

Check that the parameters are actually met for a SELL condition to exist,  PRINT them.

Then check if your OrderSend() is working or not:   What are Function return values ? How do I use them ?

Tjipke de Vries
6542
Tjipke de Vries  
Can you tell what value is val1

what value is val2

why do you have 

OP_BUYLIMIT

and 

OP_SELLLIMIT

placing trades

what is the value  of  stoplevel 

I think we have to explain everything to you it looks like you have no clue what you are doing.....

So show us how will you know what the value is of val1  ,   val2,   ......

To add comments, please log in or register