You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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.
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.
TzumanI 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.
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.
TzumanThe 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
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
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 :
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