Monday, December 27, 2010

Online Trading Live Day Trading Tips for Jan 8

OrderSend Error 130 — What to Do?

OrderSend Error 130 — What to Do?

The expert advisors that work on one broker can stop working on another; the problem with them often lies in OrderSend Error 130. If you see Error 130 in the Log of your MetaTrader platform when your expert advisor should be opening a position, then that means that the stop-loss or take-profit levels are set to close to the current market price. In the MQL documentation this error is called ERR_INVALID_STOPS («Invalid stops»). Some Forex broker set the minimum distance between the current price and the stop-loss/take-profit levels to prevent scalping or abusing the quote delays. That’s not a real problem for the majority of the expert advisors that don’t use scalping. To prevent this error from occurring, you need to change the expert’s code.

First, you might want to know what’s the minimum stoplevel is set in your broker’s MetaTrader server. Adding this line of code will output the current minimum stoplevel for the currency pair of the chart, where you run the EA:
Print(MarketInfo(Symbol(), MODE_STOPLEVEL));

You shouldn’t be using stop-loss or take-profit level, which are closer than MarketInfo(Symbol(), MODE_STOPLEVEL) to the current market price. If your EA calculates stops and take-profits dynamically, this is what I suggest you to do:

  1. Declare a global variable for the minimum StopLevel; e.g.:
    int StopLevel;
  2. In the init() function of your expert advisor define the minimum StopLevel:
    StopLevel = MarketInfo(Symbol(), MODE_STOPLEVEL) + MarketInfo(Symbol(), MODE_SPREAD);
    Note, that adding a spread difference is also required.
  3. The next time your stop-loss or take-profit is calculated, just check them to be not less than StopLevel:
    if (StopLoss < stoploss =" StopLevel;" takeprofit =" StopLevel;
  4. Don’t forget to refresh the current market rates with RefreshRates() before adding the stop-loss/take-profits levels to the actual market rates.

That should help in the majority of the cases. At least, for me such handling of the OrderSend Error 130 has always worked.

Open Market Forex Rates

Date
Remittance Symbol Buying Selling Charts
US Dollar DD USD-DD 85.6 86.2
US Dollar TT USD-TT 85.6 86.2

Open Market Forex Rates

Currency Symbol Buying Selling Charts
Australian Dollar AUD 85.6 86.6
Bahrain Dinar BHD 226.7 226.8
Canadian Dollar CAD 84.6 85.6
China Yuan CNY 12.95 13
Danish Krone DKK 15.1 15.2
Euro EUR 112.2 114.2
Hong Kong Dollar HKD 10.9 11
Indian Rupee INR 1.8 1.9
Japanese Yen JPY 1.03 1.04
Kuwaiti Dinar KWD 301.9 302.1
Malaysian Ringgit MYR 27.3 27.4
NewZealand $ NZD 62.8 63.8
Norwegians Krone NOK 14.3 14.4
Omani Riyal OMR 221.9 222.1
Qatari Riyal QAR 23.6 23.7
Saudi Riyal SAR 22.78 22.95
Singapore Dollar SGD 65.6 66.5
Swedish Korona SEK 12.6 12.8
Swiss Franc CHF 87 87.2
Thai Bhat THB 2.9 2.95
U.A.E Dirham AED 23.28 23.48
UK Pound Sterling GBP 132.2 134
US Dollar USD 85.7 86