Simple Question, No apparent solution. Any insights? Order Send Error 130

 

Hi,

 

Im Having trouble to figure out what is wrong with my function, could anyone take a look and give any insights... here is the function.

And i get the following error:

 

2013.03.14 01:15:16 Test EA EURUSD.arm,M12: OP_BUY SL = 1.2946 TP = 1.297

2013.03.14 01:15:16 Test EA EURUSD.arm,M12: LastError = 130 : invalid stops

 

Thank You in advance. 


extern double TakeProfit     = 160;
extern double StopLoss       = 75;


 if(OrderSignal == OPEN_BUY)
     {
       ErrorCheckOut(OrderSend(Symbol(), OP_BUY, LotsOptimized(), Ask, 3, 
                     NormalizeDouble(Bid - StopLoss*Point, Digits), NormalizeDouble(Ask + TakeProfit*Point,Digits), "", MAGIC, 
                     0, Lime));
     Print("OP_BUY SL = ", NormalizeDouble(Bid - StopLoss*Point, Digits) , " TP = ",  NormalizeDouble(Ask + TakeProfit*Point,Digits));
     }
     
//============================== ??????? ============================
   else     
       if(OrderSignal == OPEN_SELL)
         {
           ErrorCheckOut(OrderSend(Symbol(), OP_SELL, LotsOptimized(), Bid, 3, 
                          NormalizeDouble(Ask + StopLoss*Point,Digits),NormalizeDouble(Bid - TakeProfit*Point,Digits) , "", 
                         MAGIC, 0, DarkOrange));
         Print("OP_SEL SL = ", NormalizeDouble(Ask + StopLoss*Point,Digits), " TP = ",NormalizeDouble(Bid - TakeProfit*Point,Digits) );
         }
 
 

Thank you for the helpful insight. Here is what the function looks like working 100% looks like:

 

 

RefreshRates();
    
  if(ECNBroker){
    if(OrderSignal == OPEN_BUY)
     {
       int ticket = OrderSend(Symbol(), OP_BUY, LotsOptimized(), Ask, 3,0, 0, DoubleToStr(MarketInfo(Symbol(), MODE_SPREAD),1), MAGIC,0, Blue);
            if (ticket > 0)
                {
                OrderSelect (ticket, SELECT_BY_TICKET, MODE_TRADES);
                ErrorCheckOut(OrderModify(ticket,OrderOpenPrice(), OrderOpenPrice() - StopLoss*Point, OrderOpenPrice() + TakeProfit*Point, 0, Blue));
                }
            else ErrorCheckOut(false);
            
    // Print("OP_BUY SL = ", NormalizeDouble(Bid , Digits) , " TP = ",  NormalizeDouble(Ask + TakeProfit*Point,Digits));
     }
     
   else     
       if(OrderSignal == OPEN_SELL)
         {
           ticket = OrderSend(Symbol(), OP_SELL, LotsOptimized(), Bid, 3,0,0 , DoubleToStr(MarketInfo(Symbol(), MODE_SPREAD),1), MAGIC, 0, Red);
               if (ticket > 0)
                {
                OrderSelect (ticket, SELECT_BY_TICKET, MODE_TRADES);
                ErrorCheckOut(OrderModify(ticket,OrderOpenPrice(), OrderOpenPrice() + StopLoss*Point, OrderOpenPrice() - TakeProfit*Point, 0, Red));
                }
            else ErrorCheckOut(false);
            
           
         //Print("OP_SEL SL = ", NormalizeDouble(Ask + StopLoss*Point,Digits), " TP = ",NormalizeDouble(Bid - TakeProfit*Point,Digits) );
         }
    }
    
   //============================== Non ECN BROKERS ============================
   if(!ECNBroker){
   if(OrderSignal == OPEN_BUY)
     {
       ErrorCheckOut(OrderSend(Symbol(), OP_BUY, LotsOptimized(), Ask, 3, 
                     NormalizeDouble(Bid - StopLoss*Point, Digits), NormalizeDouble(Ask + TakeProfit*Point,Digits), DoubleToStr(MarketInfo(Symbol(), MODE_SPREAD),1), MAGIC, 
                     0, Lime));
     //Print("OP_BUY SL = ", NormalizeDouble(Bid - StopLoss*Point, Digits) , " TP = ",  NormalizeDouble(Ask + TakeProfit*Point,Digits));
     }
     

   else     
       if(OrderSignal == OPEN_SELL)
         {
           ErrorCheckOut(OrderSend(Symbol(), OP_SELL, LotsOptimized(), Bid, 3, 
                          NormalizeDouble(Ask + StopLoss*Point,Digits),NormalizeDouble(Bid - TakeProfit*Point,Digits) , DoubleToStr(MarketInfo(Symbol(), MODE_SPREAD),1), 
                         MAGIC, 0, DarkOrange));
         //Print("OP_SEL SL = ", NormalizeDouble(Ask + StopLoss*Point,Digits), " TP = ",NormalizeDouble(Bid - TakeProfit*Point,Digits) );
         }
    }
 
investguy: Thank you for the helpful insight. Here is what the function looks like working 100% looks like:
You're Welcome.