Can't fix OrderSend error 130

Apr 29, 2013 at 20:05
3,563 व्यू
10 Replies
तबसे मेंबर है May 19, 2010   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.
तबसे मेंबर है Mar 28, 2011   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
तबसे मेंबर है May 19, 2010   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
तबसे मेंबर है Mar 28, 2011   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
तबसे मेंबर है May 19, 2010   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

अटैचमेंट :

तबसे मेंबर है Mar 28, 2011   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
तबसे मेंबर है May 19, 2010   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?
तबसे मेंबर है Mar 28, 2011   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
तबसे मेंबर है Feb 07, 2011   724 पोस्टों
May 13, 2013 at 07:40 (एडिट हो रहा है 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.
तबसे मेंबर है Feb 10, 2011   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.
तबसे मेंबर है May 19, 2010   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);
         }
You must be connected to Myfxbook in order to leave a comment
*व्यवसायिक इस्तेमाल और स्पैम को ब्रदाश नहीं किया जाएगा, और इसका परिणाम खाता को बन्द करना भी हो सकता है.
टिप: किसी चित्र या यूट्यूब या URL को पोस्ट करने से वे अपने आप आपके पोस्ट में आजाएगा!
टिप: @ चिन्ह को टाइप करें उपभोगता के नाम को अपने आप करने के लिए जो इस चर्चा में भाग ले रहा है.