Error 130 - invalid stop. Why? - page 4

 

Error 130

There are two possible problems that cause and Error 130.

If your broker is an ECN, then setting the Stop Loss and Take Profit on an OrderSend is not permitted. The OrderSend must have zeroes for these two variables. After placing the order, immediately process an OrderModify to set the SL and TP. Be sure to check for order send errors before executing the Order Modify.

The other problem is that since the broker does not support the order stoplevel, you must "estimate" it somehow. One way is to use the manual order modify and see how many pips off the price it takes to enable the modify button. Another way is to perform a recursive loop while the error code 130 is valid and add one pip to your "stop level" until the error ceases. Remember this number as you should use it to initialize the stop level for the next order modify.

Another possible problem is if you are setting and then modifying dynamic stops. In this scenario, the error code 130 indicates that you are trying to set too tight a stop. The solution is that the price has just about reached the stop level and you should close the order instead of trying to adjust the stop level.

Hope this helps, I had an awful time with 130's myself.

Tzuman

 

Hi Tzuman,

Thanks for the reply. I added the order modify function to the code:

...

pivot=((iHigh(NULL,0,1)+iLow(NULL,0,1)+iClose(NULL,0,1))/3); //calculates the pivot point of previous candle

if (Ask<pivot)

{

OrderSend(Symbol(),OP_BUY,0.04,Ask,3,0,0); //buy at ask (now works!)

OrderModify(OrderTicket(),OrderOpenPrice(),Ask-iATR(NULL,0,1,1),pivot,0,Blue);

Alert (Symbol(),": ",GetLastError());

The good news is that the Ordersend now works.The bad news is that OrderModify gives Error 4051, and stoploss and takeprofit levels are still set to 0.

Tzuman:

The other problem is that since the broker does not support the order stoplevel, you must "estimate" it somehow. One way is to use the manual order modify and see how many pips off the price it takes to enable the modify button. Another way is to perform a recursive loop while the error code 130 is valid and add one pip to your "stop level" until the error ceases. Remember this number as you should use it to initialize the stop level for the next order modify.

Tzuman

I tried the manual modify on the opened order, and the stop loss/tp modify button gets enabled at price level, ie. there's no minimum stoploss limit.

Tzuman:

Another possible problem is if you are setting and then modifying dynamic stops. In this scenario, the error code 130 indicates that you are trying to set too tight a stop. The solution is that the price has just about reached the stop level and you should close the order instead of trying to adjust the stop level.

Hope this helps, I had an awful time with 130's myself.

Tzuman

The stop level was quite a few pips away, and there's no minimum stop loss so I'm not sure if this is the problem.

I use a 6-digit broker (1.23456), does this affect the programming somehow? I used Alert to tell me the Bid and Ask prices and they're displayed in 5-digits (1.2345), including the iATR and calculated pivot. Maybe this is messing up the code? Any advice would be appreciated. Thanks.

 

...

Use MarketInfo(Symbol(),MODE_STOPLEVEL) and you will get the minimal stop loss level (in points) so you do not have to guess (since it is broker and symbol dependent) Just make sure that when you compare the value you take into account that those are points and not pips and you should not have problem

Error 4051 means that you are trying to call a function with wrong parameter value.

 

Merry Christmas!

There are some brokers, my broker FXCM, that have not implemented the MarketInfo(Symbol(),MODE_STOPLEVEL). It always returns a zero, although the OrderModify screen does not enable the accept button indicating that the value is present. In this case, a way of estimating the StopLevel value must be devised.

 

...

Yeah. It seems that they are preferring their own trading platform to metatrader platform and then metatrader does not work as the it does on the rest of the brokers. Oh well, nothing is perfect ... In any case, minimal stop level of 0 is impossible, so the code can "know" that something is wrong then . Manually guessing the minimal stop level can prove to be near to impossible task in some cases

Tzuman:
There are some brokers, my broker FXCM, that have not implemented the MarketInfo(Symbol(),MODE_STOPLEVEL). It always returns a zero, although the OrderModify screen does not enable the accept button indicating that the value is present. In this case, a way of estimating the StopLevel value must be devised.
 

Error 130

From the Metatrader documentation:

"double NormalizeDouble( double value, int digits)

Rounds the floating point value to the given precision. Returns normalized value of the double type.

The calculated StopLoss and TakeProfit values, as well as open price of pending orders must be normalized with a precision the value of which is stored in the pre-defined variable of Digits."

You should set a variable = your stoplevel normalized to 5 digits

double sl=NormalizeDouble(Ask-iATR(NULL,0,1,1),5);

do the same for your pivot and also check your OrderModify parameters closely, you are probably either missing one or one is the wrong type, a double where an int should be.

here's one I use that works

bool TicketMod = OrderModify(argTicket,OrderOpenPrice(),Ticket[etStopLoss],Ticket[etTakeProfit],0);

I normalize stop loss and take profit during the return from their respective functions.

 

Hedge ea with error 130

This expert work good in backtest but when it work in my account on IBFX , it not open any trades at all and give me error 130

I don't have any mql background.

So pls can you fix this problem and resent the ea back here.

the ea called; HedgeLot_StrategyV2.mq4

at this link

http://www.forexmt4.com/mt_yahoo/HedgeLot_StrategyV2.mq4

thanks in advance

 

...

ibfx does not allow placing stop loss and / r take profit along with order opening

The EA should first open an order with take profit and stop loss set to 0 and, once when the order is opened, it should modify those as required

wowos:
This expert work good in backtest but when it work in my account on IBFX , it not open any trades at all and give me error 130

I don't have any mql background.

So pls can you fix this problem and resent the ea back here.

the ea called; HedgeLot_StrategyV2.mq4

at this link

http://www.forexmt4.com/mt_yahoo/HedgeLot_StrategyV2.mq4

thanks in advance
 

...

Speaking of IBFX :

Multi-asset online trading platform company TradeStation - which itself was just recently acquired for $411 million by Japan's Monex Group - has expanded its FX presence in the US with the acquisition of IBFX for $17 million. IBFX is the fourth-largest US-based retail Forex firm, following FXCM, Oanda and Gain Capital (Forex.com).

The folks at Monex were kind enough to give us details of the acquisition, including:

  • Deal size of $17 million.
  • IBFX has daily volume of about 93 billion Yen ($1.2 billion), or about $25 billion monthly (and TradeStation is now doing about $8 billion monthly).
  • IBFX's had LTM Revenues of about $21 million, and a net loss of $3 million (following a net loss of $8 million in 2010).
  • IBFX has 27,000 funded accounts (IBFX's latest CFTC filing showed about 11,000 US accounts), and holds about $37 million in client assets.
  • IBFX has 106 employees.
  • CEO Todd Crosland owned 59% of IBFX; Spectrum Equity owned 40% (which cost them about $40 million, so as per above they are taking a large writeoff on the investment).

source : TradeStation acquires IBFX - Forex Industry News

 

Error 131

Hello all,

I am getting the OrderSend Error 131. I am trying to re-code so the lots amount is permissable by my broker. I have added this but I am still getting an error 131. Please could you tell me whether I have written this correctly and if I am going about it the right way? Thanks.

int LotsLong, Remainder;

LotsLong = MathFloor(AccountBalance() * (PositionSize * 0.01)) / ((Ask - SLPriceLong) * PipValue); //Calculate Lots

{

Remainder = LotsLong%10;

{

LotsLong = LotsLong - Remainder;

I did MarketInfo() and it gave me:

2008.07.10 15:13:37 MACD Sample EURUSD, H1: 1000

2008.07.10 15:13:37 MACD Sample EURUSD, H1: 0.01

2008.07.10 15:13:37 MACD Sample EURUSD, H1: 0.01

2008.07.10 15:13:37 MACD Sample EURUSD, H1: 100000