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
First, you might want to know whats the minimum stoplevel is set in your brokers 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:
You shouldnt be using
- Declare a global variable for the minimum StopLevel; e.g.:
- 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.
- The next time your
stop-lossor take-profitis calculated, just check them to be not less than StopLevel:
if (StopLoss < StopLevel) StopLoss = StopLevel;
if (TakeProfit < StopLevel) TakeProfit = StopLevel;
- Dont forget to refresh the current market rates with RefreshRates() before adding the
stop-loss/ take-profitslevels 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.
Update 2011-12-15: Some brokers (ECN ones) don’t allow expert advisors to set