Why do dolls die the power of passivity and the embodied interplay between disability and sex dolls

How to beat Ordersend Error 130 in MetaTrader 4

ordersend-error-130

By popular demand, proven strategies on how to beat every algorithmic trader’s worst nightmare – Error 130

The OrderSend Error 130 appears in MetaTrader 4 when an Expert Advisor can’t execute a marker order as expected. Also known as the Invalid Stop (ERR_INVALID_STOPS) in MQL jargon, the Error 130 happens when the TakeProfit and StopLoss levels are set to close to the current market price.

Where does this error come from? What does it mean for your Expert Advisor? How can you find the part of your code that is causing the error? We tackle all this and more…

Video Tutorial

Alright! Let’s go ahead and send some orders with OrderSend. The video below is available if you prefer watching instead of reading

To start off, a formal definition from our friend, MQL4 Documentation:

ERR_INVALID_STOPS

That’s right! That is all you get from MetaQuotes. And the rest… Go figure!

Ordersend Error 130 is briefly mentioned in other sections of the documentation. However, there is no thorough guide to what “Invalid Stops” actually means and how to deal with this, perhaps, most common problem in Forex programming.

But not a worry! That’s why I have written this article. Let’s get through this together!

The silent killer

So… you launched your expert advisor and… nothing happens. No BUY orders, no SELL orders, no pending orders, not even error messages in the logs…. Just silence. You decide to wait a few hours / days / weeks, and nothing really changes – the charts go up and down, but you don’t see any profit. This can go on forever…

The real reason is simple – you’re actually getting ERR_INVALID_STOPS (which is the correct technical term for the issue), but you can’t see it. That’s because 130 is a silent killer. A cold-blooded murderer of your brain and inner calm ?

There is no way to pick up this error through expert advisor logs or even terminal logs. The only way to catch it is by adding the right failsafe mechanisms into your code. Here’s an example you can adapt to your code:
int ticket;
ticket = OrderSend("EURUSD", OP_BUY, 1.0, Ask, 10, StopLossLevel, TakeProfitLevel, "My 1st Order!");

if(ticket < 0)
<
Alert(“OrderSend Error: “, GetLastError());
>
else
<
Alert(“Order Sent Successfully, Ticket # is: ” + string(ticket));
>
What we are doing here is taking the ticket number and that OrderSend() returns and checking if it is less than zero. If yes, then that is a signal from MetaTrader 4 telling us that there was a problem with the request.

The error code is then printed out onto the screen using Alert() and the built-in GetLastError() function. This code will give a pop-up window like in the image up at the top of this article.

Note: you can use Print() instead of Alert() to redirect the message straight to the EA’s log instead of displaying it on the screen.

Core of Ordersend Error 130

Invalid stops is the real name for the culprit we are dealing with today. So what does invalid stops in MetaTrader 4 actually mean?

As we can see, the issue is always with one (or many) of the prices that your Forex Robot specified in its request to the trade server. Now that we know our enemy – let’s beat it!

1) StopLoss & TakeProfit are prices

There are several possible causes of ERR_INVALID_STOPS, and one of the more frequent ones among beginners is specifying the StopLoss and TakeProfit in pips rather than actual price levels. Like this:
OrderSend(EURUSD, OP_BUY, 0.1, 1.1606, 10, 20, 40);
This person tried to set a StopLoss of 20 pips and a TakeProfit of 40 pips. Big NO-NO….. The correct and only way of specifying your SL and TP is through price levels:
OrderSend(EURUSD, OP_BUY, 0.1, 1.1606, 10, 1.1585, 1.1645);
By the way, here we assumed that the current ASK price is 1.1606 and current BID price is 1.1605 (i. e. 1 pip spread).

2) 4-digits vs 5-digits

Another reason you could be getting ERR_INVALID_STOPS is if you are setting the input parameters of your EA in Pips (4-digit points) when the Robot is anticipating 5-digit points. Let’s look at an example:
extern int StopLoss = 20;
extern int TakeProfit = 40;

OrderSend(EURUSD, OP_BUY, 0.1, Ask, 10, Bid-StopLoss*Point(), Bid+TakeProfit*Point());

This code will work fine on a 4-digit broker, however will fail on a 5-digit broker. The reason is that on a 4-digit broker, Point() equals to 0.0001, whereas on a 5-digit broker Point() equals to 0.00001.

Basically, with no additional adjustments, on a 5-digit broker the EA will be attempting to set the StopLoss and TakeProfit at only 2 and 4 pips away from the Bid price respectively!

That’s why in the case of a 5-digit broker you have to increase your StopLoss and TakeProfit parameters tenfold. Like this:
extern int StopLoss = 200;
extern int TakeProfit = 400;

OrderSend(EURUSD, OP_BUY, 0.1, Ask, 10, Bid-StopLoss*Point(), Bid+TakeProfit*Point());
However, be careful! Some EA’s already have modules that will detect the number of digits after the decimal and will automatically adjust your input parameters for you. In these situations multiplying inputs by 10 can actually lead to erroneous performance.

Note: I plan on posting a separate article where we will discuss how to create our own modules to detect the number of digits after the decimal

3) ECN brokers

ECN accounts have their own specifics. One of them is – when trading through a ECN broker you will not be able to set a StopLoss and/or TakeProfit with your Market Order (BUY or SELL). If you try to do this – you will get Error 130.

However, of course, you do need to set a StopLoss (and maybe TakeProfit) for your order, and this must be done as soon as possible after the order has been executed. Try this code:
int MarketOrderSend(string symbol, int cmd, double volume, double price, int slippage, double stoploss, double takeprofit, string comment, int magic)
<
int ticket;

ticket = OrderSend(symbol, cmd, volume, price, slippage, 0, 0, NULL, magic);
if(ticket <= 0) Alert(“OrderSend Error: “, GetLastError());
else
<
bool res = OrderModify(ticket, 0, stoploss, takeprofit, 0);
if(!res) < Alert(“OrderModify Error: “, GetLastError());
Alert(“IMPORTANT: ORDER #”, ticket, ” HAS NO STOPLOSS AND TAKEPROFIT”);>
>
return(ticket);
>
You can add this function to your code (at the very end) and then use it instead of OrderSend() in your main code. This function adds an extra step in the process of sending a Market Order.

First, it send the request to execute a market order stripping out the StopLoss and TakeProfit. Next, it modifies the newly opened market order by adding the desired SL and TP.

There is, of course, a risk that the order will be executed, but the modification will fail. However, in that case the function will promptly notify the trader that the StopLoss and TakeProfit have not been set.

Feel free to modify this function to suit your needs and trading style.

4) Stop-Levels

Stop-Levels are a mechanism for brokers to protect themselves from certain volatility and liquidity related risks. In simple terms, you will not be able to set your StopLoss or TakeProfit OR any pending order closer than a predetermined number of Pips to the current market price.

To find out what the Stop Level is for a specific currency pair you need to press CTRL+U on your keyboard, select the desired currency pair and click the “Properties” button as shown on the illustration below:

forex-symbol-properties

In this example the Stop Level for AUDUSD is 3 Pips. This means that you will not be able to set the StopLoss for your order closer than 3 Pips to the price at which the order will be opened.

This also means that any pending order will have to be set at least 3 Pips away from the current market price.

If you Robot tries to break these rules and set a StopLoss / TakeProfit or Pending Order within the Stop Level range, then it will get Error 130 “Invalid Stops”. So just be mindful of the Stop Level of the currency where your EA’s are trading – don’t specify excessively small StopLoss and TakeProfit parameters.

It is also worth noting that more exotic currency pairs can have much more significant Stop Levels. Fore example, for AUDNZD the Stop Level with the same broker as in the above example is 20 Pips. For GBPSEK (British Pound vs Swedish Krone) – it’s 100 Pips.

5) Normalization of doubles

With some brokers you will find that for an unknown reason the Ask and Bid prices are passed onto the trader with additional negligible digits after the decimal. For example:

Instead of 1.1606 the broker would give you 1.160600001

Now this phenomenon has no effect on manual trading, moreover since the MT4 terminal is hardwired to display a certain number of digits after the decimal point (either 4 or 5) – you will not be able to notice any difference at all!

However, these ‘negligible’ digits after the decimal can have a dramatic effect on Expert Advisors causing……… that’s right! Our old friend, OrderSend Error 130!

Here’s a strategy that I personally use to protect my Robots from this issue:
void OnTick()
<
//.
OrderSend(EURUSD, OP_BUY, 0.1, ND(Ask), 10, ND(Bid-StopLoss*Point()), ND(Bid+TakeProfit*Point()));

double ND(double val)
<
return(NormalizeDouble(val, Digits));
>
This neat little trick allows you to normalize (in simple terms – Round) any prices that you are inputting into the OrderSend() function. This way you cut off all ‘negligible’ digits after the decimal point.

Conclusion

Today we saw that there may be multiple (at least 5) causes to error 130. Though this is quite a few, the underlying issues are all trivial and can be corrected in a matter of minutes.

Therefore, Error 130 should not be feared! If you have encountered this culprit, it’s just a matter of going through the list above, finding the situation that applies to you and applying the prescribed solution.

Hope you found this article useful!

Let me know if you have any questions by using the comments section below.

Как исправить код ошибки 130 в Steam?

Код ошибки 130 возникает в ситуациях, когда Steam пытается загрузить запрашиваемую пользователем страницу, но по какой-то причине не может получить ее с серверов игровой платформы. Она может произойти как при обращении к странице новостей об обновлении, так и при открытии Магазина. В большинстве случаев причиной является отсутствие доступа в интернет, но также она может возникнуть в результате других сбоев.

Чем вызвана ошибка?

Клиенту не удается подключиться к внешним серверам Steam по следующим причинам:

Перезагрузка клиента

В первую очередь попробуйте перезагрузить клиента, возможно, он был загружен с ошибками. Для этого перейдите в меню Steam и кликните на Выход.

После закрытия, откройте Диспетчер задач, нажатием на Ctrl + Shift + Esc и перейдите на вкладку Процессы. Проверьте, нет ли запущенных процессов Steam. Если обнаружите один из его процессов, дождитесь его завершения. После этого запустите клиента и повторите то действие, которое вызывало сбой при подключении с кодом 130.

Отключение антивируса

Стороннее программное обеспечение, особенно антивирусные программы, часто вмешиваются в работу клиента, в некоторых случаях препятствуют установке соединения с серверами игровой платформы.

Поэтому если столкнулись с кодом ошибки 130 в Steam, временно отключите защиту в реальном времени. Таким образом, можно проверить их причастность к этой проблеме. В некоторых случаях, пользователям удавалось устранить ошибку после полного удаления антивируса и замены его другим.

Переустановка клиента

Ошибку 130 можно устранить путем переустановки Steam, когда все поврежденные файлы текущей установки будут заменены новыми, полностью функциональными.

Полностью закройте клиента кнопкой Выход из меню Steam.

После полного удаления загрузите установщик Стим. Запустите загруженный файл и следуйте инструкциям на экране до завершения установки.

После переустановки проверьте, устранен ли код ошибки 130.

Очистка кэша DNS

Очистка кэша заставит клиента запрашивать IP каждого URL адреса, к котором он пытается подключиться, вместо того, чтобы ссылаться на собственную библиотеку URL-адресов и связанных IP. Таким образом, даже когда компьютер имел неправильные IP, после очистки кэша DNS, приложение будет вынужденно запрашивать их, и сохранять правильные. Это решение эффективно в тех случаях, когда пользователь сталкивается с кодом ошибки 130 на определенных страницах Стим.

Выполните в консоли команду:

После успешного выполнения команды закройте командную строку и перезагрузите компьютер. Повторите то действие, которое вызывало сбой с кодом 130.

Источники:

https://forexboat. com/ordersend-error-130/

https://compuals. ru/error/130-v-steam

Понравилась статья? Поделиться с друзьями:
Добавить комментарий

;-) :| :x :twisted: :smile: :shock: :sad: :roll: :razz: :oops: :o :mrgreen: :lol: :idea: :grin: :evil: :cry: :cool: :arrow: :???: :?: :!: