icustom buy and sell issue NEED HELP Please!

 

2015.05.07 11:06:32.484 '610589287': order buy 14.00 AUDCAD.bo opening at market sl: 0.00000 tp: 0.00000 failed [Invalid parameters]

thats the error i get but it does open orders sometimes but alot of times it shows that error above 

void OnTick()
  {
   int total=0;
   bool newb=NewBar();
   int tip=-1;
   for(int z=OrdersTotal()-1;z>=0;z--)
      {sel=OrderSelect(z,SELECT_BY_POS);
       if(OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNumber)
         {total++;
         }
      }
      
   
   datetime lastcl=0;   
   for(int z=OrdersHistoryTotal()-1;z>=0;z--)
      {sel=OrderSelect(z,SELECT_BY_POS,MODE_HISTORY);
       if((OrderType()==OP_SELL||OrderType()==OP_BUY)&&OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNumber)
            {
             if(OrderCloseTime()>lastcl)
               {lastcl=OrderOpenTime();
               }
            }
         
      }   
 if(TimeHour(TimeCurrent())>=HourBegin&&TimeHour(TimeCurrent())<HourEnd&&iBarShift(Symbol(),0,lastcl)!=0&&total==0)
   {
      OpenOrder(tip);
   }  
//---
   
  }
//+------------------------------------------------------------------+
bool NewBar()
{
static datetime lastbar = 0;
datetime curbar = Time[0];
if(lastbar!=curbar)
{
lastbar=curbar;
return (true);
}
else return(false);
}

void BuyOrder()
{RefreshRates();
//GetLot();
double ordersize = GetLot();
//for(int z=0;z<ArraySize(Lot);z++)
 //  { 
   //tic=OrderSend (Symbol(),OP_SELL,Lot[z],Close[0],0,0,0,"BO exp:"+string(ExpireSeconds),MagicNumber,0,Red);
   tic=OrderSend (Symbol(),OP_BUY,ordersize,Close[0],0,0,0,"BO exp:"+string(ExpireSeconds),MagicNumber,0,Red);
     if(tic==-1){Print("eror=",GetLastError());return;}
 //  }

}

void SellOrder()
{RefreshRates();
//GetLot();
double ordersize = GetLot();

//for(int z=0;z<ArraySize(Lot);z++)
  // { 
   // tic=OrderSend (Symbol(),OP_BUY,Lot[z],Close[0],0,0,0,"BO exp:"+string(ExpireSeconds),MagicNumber,0,Green);
   tic=OrderSend (Symbol(),OP_SELL,ordersize,Close[0],0,0,0,"BO exp:"+string(ExpireSeconds),MagicNumber,0,Red);
    if(tic==-1){Print("eror=",GetLastError());return;}
 //  }
}

void OpenOrder(int tip)
{


 double arrowup=iCustom(NULL,0,"BB60SEC",0,1);
 double arrowdown=iCustom(NULL,0,"BB60SEC",1,1);
 

  if(arrowup)

  {
       BuyOrder();
       return;
      
  } 

  if(arrowdown)


 { 
       SellOrder();
       return;
      
 } 
       
}

 

i have even tried     if(arrowup!=2147483647) but that does not work at all because then it takes trades but no arrow at all.

Please can some one help me  

Files:
BB60SEC.ex4  9 kb
 

invalid parameters because u use Close[0] in the order send function where you should use Ask or Bid respectively.

when Close[0] does not match actual market prices your order get's rejected.

 
Marco vd Heijden:

invalid parameters because u use Close[0] in the order send function where you should use Ask or Bid respectively.

when Close[0] does not match actual market prices your order get's rejected.

i have tried ask and bid in the replace of close but still does not work at all and this is for binary options ea

thanks marco but do you have any other ideas or can you maybe show me some code?

 

really appreciate ur help 

 

u could try

tic=OrderSend (Symbol(),OP_SELL,ordersize,Close[0],3,0,0,"BO exp:"+string(ExpireSeconds),MagicNumber,0,Red);

Invalid parameter usually refers to prices not matching or slippage and since yours is set to 0 it will reject a lot of orders.

I have to say i am coding forex so i am not all that familiar with binary options.

 
iv tried that still nothing 
 

its hard to understand the logic without knowing what it suppose to do for example why are you pulling orders from historic pool ?

And you are selling and buying both at Close[0] how is that suppose to work?

 
Marco vd Heijden:

its hard to understand the logic without knowing what it suppose to do for example why are you pulling orders from historic pool ?

And you are selling and buying both at Close[0] how is that suppose to work?

maybe he needs pending order instead instant
Reason: