Can't fix OrderSend error 130

Apr 29, 2013 at 20:05
Vues 3,537
10 Replies
Membre depuis May 19, 2010   posts 14
Apr 29, 2013 at 20:05
Hi,

I have a EA which is 50% automatic, 50% manual. So I am drawing manually trendlines and this EA is working according to these lines. That EA is not made by me, thats why I need some help with that. I tested this EA for last 6 months on demo account with poitive results, but with small profits. Finally I decided to try it on the real account. I tried Forex.com and Oanda MT4 platforms, but on both of them I got only OrderSend error 130. Of course everybody knows what is this problem about, but I am not so good with coding to fix it. I was wondering if there is somebody who can fix this EA (so it works for real accounts) for me and how much this can cost to me?

Thanks in a advance.
Membre depuis Mar 28, 2011   posts 86
May 02, 2013 at 20:44
tiiniz posted:
Of course everybody knows what is this problem about, but I am not so good with coding to fix it.

Just curious, what's the problem?
Is it Instant Execution vs. Market Execution?
Being Bearish or Bullish Makes No Difference
Membre depuis May 19, 2010   posts 14
May 02, 2013 at 20:54
petays posted:
tiiniz posted:
Of course everybody knows what is this problem about, but I am not so good with coding to fix it.

Just curious, what's the problem?
Is it Instant Execution vs. Market Execution?

Yes, you are right. I got some help from https://www.forex-tsd.com/forum.php forum, so I will try to recode that EA.

It simply has to be coded to work on ECN/STP like brokers. Which means : to open order with stop loss and take profit set to 0 and only when an order is opened modify to to desired stop loss and / or take profit
Membre depuis Mar 28, 2011   posts 86
May 02, 2013 at 21:10
Yeah, fixing that shouldn't be too difficult if you know what you are doing 😀
And some knowledge of programming is not bad if you plan to use a third party EA and have the source code available.

It would be interesting to see that part of your code where the EA checks if price crosses/touches your hand-drawn trendline(s).
I've been toying with similar ideas but calculations in price-time coordinates is not so simple (to me).
But it should be doable with some kind of averaging/approximation to convert time to price in every bar which your trendline goes over.
Then you can compare prices.
Being Bearish or Bullish Makes No Difference
Membre depuis May 19, 2010   posts 14
May 03, 2013 at 16:49
Yes, trying to fix this problem this way:
Original code:
li_ret_44 = OrderSend(Symbol(), OP_BUYLIMIT, a_lots_4, a_price_12, slip, StopLong(ad_20, ai_28), TakeLong(a_price_12, ai_32), a_comment_36, MagicNumber, 0, CLR_NONE);

Edited code:
li_ret_44 = OrderSend(Symbol(), OP_BUYLIMIT, a_lots_4, a_price_12, slip, 0, 0, a_comment_36, MagicNumber, 0, CLR_NONE);
if (li_ret_44>-1)
   OrderModify(li_ret_44,OrderOpenPrice(),StopLong(ad_20, ai_28), TakeLong(a_price_12, ai_32),0,CLR_NONE);

Shortly we gonna see whats happening.
You can take a look how it looks like while traiding by attached picture.

I am still trying to understand this code (its on 15 MS Word pages), so I am not really sure which is which part :D

Fichiers joints:

Membre depuis Mar 28, 2011   posts 86
May 03, 2013 at 17:17
Your fix seems quite workable.
Maybe you should select order first by its ticket before using OrderOpenPrice() function?

Once i reverse-engineered code for one indicator to find out what formulas it was using.
It was not so bad when I started renaming all global variables first and then relevant local variables.
That helped me to have a better understanding of the code.
Luckily most MQL4 code is written quite straight forward manner so it should be easy to understand ;-)
Browsing the code in MetaEditor should help you because you get syntax highlighting that helps a lot.
Best luck!
Being Bearish or Bullish Makes No Difference
Membre depuis May 19, 2010   posts 14
May 03, 2013 at 18:35
Learning more and more with every day :) Now I am reading about SelectOrder function for example.
Do you think its enough with just one line like that? --->

Edited code:

li_ret_44 = OrderSend(Symbol(), OP_BUYLIMIT, a_lots_4, a_price_12, slip, 0, 0, a_comment_36, MagicNumber, 0, CLR_NONE);
OrderSelect(li_ret_44,SELECT_BY_TICKET);
if (li_ret_44>-1)
   OrderModify(li_ret_44,OrderOpenPrice(),StopLong(ad_20, ai_28), TakeLong(a_price_12, ai_32),0,CLR_NONE);

Or should I add new variable for orderselect?
Membre depuis Mar 28, 2011   posts 86
May 03, 2013 at 19:25
int ticket=OrderSend(TradeSymbol,OP_BUY,TradeLot,Ask,TradeSlippage,0,0,TradeComment,TradeMagicNumber,0,Green);
if(ticket>-1)
{
  OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES);
  OrderModify(ticket,OrderOpenPrice(),TradeStopLoss,TradeTakeProfit,0,Green);
}

See more: https://forum.mql4.com/36116
Being Bearish or Bullish Makes No Difference
TheCyclist
forex_trader_28881
Membre depuis Feb 07, 2011   posts 724
May 13, 2013 at 07:40 (édité May 13, 2013 at 08:10)
ERR_INVALID_STOPS 130 Invalid stops.

The problem is on the stops. Make them 0 and it will most likely send.

Now in the case of O and any ECN you can't send orders with stops. Your orders will simply be rejected as is the case here. No point in looking for the problem. There isn't any. Just can't send with stops.

You have to modify them afterwords...!!

Send your oder, wait till it is set, then use ordermodify to add the stops.
Membre depuis Feb 10, 2011   posts 36
May 15, 2013 at 01:49
Did you manage to fix the error?

If not then we might look at it at no cost for you.
Go to https://MetaTraderProgramming.com and ask for a programmer to review it.
Membre depuis May 19, 2010   posts 14
May 20, 2013 at 15:27
Yes, its working ok without any problems til now.
If somebody finds this article, so here you have changes I made.

Original:
li_ret_44 = OrderSend(Symbol(), OP_BUYLIMIT, a_lots_4, a_price_12, slip, StopLong(ad_20, ai_28), TakeLong(a_price_12, ai_32), a_comment_36, MagicNumber, 0, CLR_NONE);

Edited:
li_ret_44 = OrderSend(Symbol(), OP_BUYLIMIT, a_lots_4, a_price_12, slip, 0, 0, a_comment_36, MagicNumber, 0, CLR_NONE);
if(li_ret_44>-1)
{
OrderSelect(li_ret_44,SELECT_BY_TICKET);
         OrderModify(li_ret_44,OrderOpenPrice(),StopLong(ad_20, ai_28), TakeLong(a_price_12, ai_32),0,CLR_NONE);
         }
Se connecter / S’inscrire to comment
You must be connected to Myfxbook in order to leave a comment
*Lutilisation commerciale et le spam ne seront pas tolérés et peuvent entraîner la fermeture du compte.
Conseil : Poster une image/une url YouTube sera automatiquement intégrée dans votre message!
Conseil : Tapez le signe @ pour compléter automatiquement un nom dutilisateur participant à cette discussion.