Error 130

 

I am not certain why I am getting this error... I have found that it is related to my S/L... but it's set to 30.. I've even tried 10...100... I keep getting it.... please help



//Buy
if (Order == SIGNAL_BUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
if(!IsTrade) {
//Check free margin
if (AccountFreeMargin() < (1000 * Lots)) {
Print("We have no money. Free Margin = ", AccountFreeMargin());
return(0);
}

if (UseStopLoss) StopLossLevel = Ask - StopLoss * Point; else StopLossLevel = 0.0;
if (UseTakeProfit) TakeProfitLevel = Ask + TakeProfit * Point; else TakeProfitLevel = 0.0;

Ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, StopLossLevel, TakeProfitLevel, "Buy(#" + MagicNumber + ")", MagicNumber, 0, DodgerBlue);
if(Ticket > 0) {
if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) {
Print("BUY order opened : ", OrderOpenPrice());
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Open Buy");
} else {
Print("Error opening BUY order : ", GetLastError());
}
}
if (EachTickMode) TickCheck = True;
if (!EachTickMode) BarCount = Bars;
return(0);
}
}

 
Skog23:

I am not certain why I am getting this error... I have found that it is related to my S/L... but it's set to 30.. I've even tried 10...100... I keep getting it.... please help

It could be either your s/l or your t/p, or both. Or it could be something else entirely.


If your broker uses 5 digits, then an s/l of 10 is too tight: 1.0 pips. Even 100 (10.0 pips) may not be big enough, depending on the symbol. For example, a quick look on an Alpari demo account shows the minimum stop-level on AUDNZD as 120.


However, the problem may be something entirely different. Your broker may be using something like the Boston Technologies bridge which requires the s/l and t/p to be placed separately from a market order. Try altering the code so that it does an OrderSend() without an s/l or t/p, followed by an OrderModify().

 
jjc:

It could be either your s/l or your t/p, or both. Or it could be something else entirely.


If your broker uses 5 digits, then an s/l of 10 is too tight: 1.0 pips. Even 100 (10.0 pips) may not be big enough, depending on the symbol. For example, a quick look on an Alpari demo account shows the minimum stop-level on AUDNZD as 120.


However, the problem may be something entirely different. Your broker may be using something like the Boston Technologies bridge which requires the s/l and t/p to be placed separately from a market order. Try altering the code so that it does an OrderSend() without an s/l or t/p, followed by an OrderModify().

They do in fact! I didn't think of that... though how would I code that exactly... I am new to MQL

 
Skog23:

They do in fact! I didn't think of that... though how would I code that exactly... I am new to MQL


Something along the lines of the following. The s/l and the t/p in the OrderSend() are left at zero, and are placed afterwards by doing an OrderModify():


   Ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, 0, 0, "Buy(#" + MagicNumber + ")", MagicNumber, 0, DodgerBlue);
   if (Ticket > 0) {
      if (OrderModify(Ticket, OrderOpenPrice(), StopLossLevel, TakeProfitLevel, OrderExpiration())) {
         // Successful
      } else {
         // s/l or t/p failed. Dangerous scenario which needs urgent handling, because there's an unprotected position in the market
      }
   } else {
      Print("Error opening BUY order : ", GetLastError());
   }
 
jjc:


Something along the lines of the following. The s/l and the t/p in the OrderSend() are left at zero, and are placed afterwards by doing an OrderModify():


Sorry for the delay... that worked perfectly, thank you very much!

 

hi guys i have an ea that i have been using for a while now and never had any issues with it but lately i tried using this ea on the spjun10 contract but i always get error 130 even though my stop is more then 50 pips away from the price. here is the error :

2010.05.04 17:25:52 LibOrderReliable_V1_1_4_test SPJUN10,M5: OrderSendReliableMKT v1_1_4:last error: 130:invalid stops
2010.05.04 17:25:52 LibOrderReliable_V1_1_4_test SPJUN10,M5: OrderSendReliableMKT v1_1_4:failed trade: OP_BUY SPJUN10@1169.75000000 tp@1194.75000000 sl@1119.75000000 slippage:100
2010.05.04 17:25:52 LibOrderReliable_V1_1_4_test SPJUN10,M5: OrderSendReliableMKT v1_1_4:failed to execute OP_BUY/OP_SELL, after 0 retries
2010.05.04 17:25:52 LibOrderReliable_V1_1_4_test SPJUN10,M5: OrderSendReliableMKT v1_1_4:non-retryable error: 130:invalid stops
2010.05.04 17:25:52 LibOrderReliable_V1_1_4_test SPJUN10,M5: OrderSendReliableMKT v1_1_4: attempted OP_BUY 0.10000000 lots @1169.75000000 sl:1119.75000000 tp:1194.75000000 slippage:100


can anyone help me i have tried multiple stops and take profit and the only way i got it to trade was to put no sl and tp just a trailing stop.

any insight would help.

 
Open the order without Stop Loss and Take Profit first. Then select the last order and modify with SL and TP. Following is the simple code to fix that Error 130 bug.

OrderSend(Symbol(),OP_SELL,Lots,Bid,5,0,0,"Reverse",255,0,CLR_NONE);
OrderSelect(SELECT_BY_POS, MODE_TRADES);
if(OrderType()==OP_SELL && OrderSymbol()== Symbol()&& OrderComment()== "Reverse")
{
OrderModify(OrderTicket(),5,OrderOpenPrice()+(200*Point),OrderOpenPrice()-(500*Point),0,CLR_NONE);
}
Reason: