OrderSend - Error Code 130 - OP_BUYLIMIT - page 2

 
Nima:

Thanks for your reply.

But this code has got the same problem. I used your code and just replaced Slippage.Pips with an integer value, same error raised after executing.

For learning purpose, I want to write a simple expert which sends just one instant sell or buy order, and I want to adjust everything according to parameters queried from broker.

Any advice?

Please show your modified code. Did you replace your OrderSend with and OrderSend followed by an OrderModify ? With ECN brokers you must use TP=0 and SL=0 when you send the order and then modify the order to add the TP and SL
 
I'm noob but I'll take a crack at this. I may not have answers but perhaps can ask the right questions.

What is this ?:
NormalizeDouble(StopPrice,Digits)

Should this not be NormalizeDouble(StopPrice*Digits) or (StopPrice*Point) if thats what your trying to do ?

And if you use the code above posted by WHRoeder to adjust for 4/5 digits would you not put it this way ?

And his notes about ECN does not solve this 130 error ?


OrderSend(Symbol(),OP_BUY,Lots,Ask,3*pips2points,Bid-StopLoss*pips2dbl,Bid+TakeProfit*pips2dbl,"Agent86",12345,0,Green);
or some such thing ?

Your code of:

int ticket=OrderSend(Symbol(),OP_BUYLIMIT,0.1,NormalizeDouble(BuyLimitPrice,Digits),5,NormalizeDouble(StopPrice,Digits),NormalizeDouble(TakeProfitPrice,Digits),"LimitTest",0,0,Blue);

Seems to me the slippage of 5 would be .5 on 5 digit broker so this may need to be 50 or more = 5pips depending on the spread.

Or WHRoeder's post for 4/5 digit brokers as he posted above.


I could be way off since I'm noob, so don't take my answer too seriously but at least this is what is seems like to me.
 

Re; NormalizeDouble . . .

NormalizeDouble( double value, int digits) https://docs.mql4.com/convert/NormalizeDouble so NormalizeDouble(StopPrice,Digits) rounds the StopPrice to the value of Digits.

By the way, the NormalizeDounble stuff you are referring to was written by mark1808 on 2010.01.18 14:41 :-) he probably lost interest a while ago .. .

 
Agent86:
What is this ?:
NormalizeDouble(StopPrice,Digits)

NormalizeDouble is never, ever, necessary. Don't use it - it's a crutch. Code correctly and it's unnecessary. There are none in my code. E.G.

double  minGapStop  = MarketInfo(Symbol(), MODE_STOPLEVEL)*Point;
if ((now.close - newSL)*DIR >= minGapStop   // Not too close to market no error 130
&&  (newSL -SL)*DIR >= Point                // no error 1
) { // OK to modify
 

This is what I wrote using WHRoeder's code, I don't know if which part is wrong :


#property copyright ""
#property link      ""

#include <stdlib.mqh>
#include <stderror.mqh>

int     pips2points;    // slippage  3 pips    3=points    30=points
double  pips2dbl;       // Stoploss 15 pips    0.0015      0.00150
int     Digits.pips;    // DoubleToStr(dbl/pips2dbl, Digits.pips)

int init()
  {

   if (Digits == 5 || Digits == 3){    // Adjust for five (5) digit brokers.
      pips2dbl    = Point*10;
      pips2points = 10;
      Digits.pips = 1;
      }
   else {
      pips2dbl    = Point;
      pips2points =  1;
      Digits.pips = 0; 
   }
  
   return(0);
  }
  
int deinit()
  {
   return(0);
  }

int start()
  {
  
   static bool done = false;
   if(!done){
   Alert("Sendig request");   
      int ticketNum = OrderSend(Symbol(),
                           OP_BUY,
                           0.1,
                           Ask, 
                           0,            
                           Ask - 50*pips2dbl,
                           0);
      
      if(ticketNum < 1){
         Alert(GetLastError());
      }else{
         Alert("Done");
      }
      done = true;
   }

   return(0);
  }


It seems WHRoeder's last post is what I'm looking for, I'll give it a try.

And about the broker's type, I don't know about it, how should I find out?

 
RaptorUK:
Please show your modified code. Did you replace your OrderSend with and OrderSend followed by an OrderModify ? With ECN brokers you must use TP=0 and SL=0 when you send the order and then modify the order to add the TP and SL
You need to do this . . .
 
Yes thank you, it worked. So it means this is an ECN broker? How should I know this? How should I check this in EA?
 
Viffer:

I have a similar problem. I have error 130 and I can't track down why. I would really appreciate some pointers.

I've checked the following...

The SL is delivered as a real price rather than pips away.

It's the correct format... a double and it's been normalised.

It's the correct figure.... confirmed by print in the line above the ordersend.

It's an allowable distance ~50pips

It's not the Boston Technologies Bridge refered to in another thread


I get

Alert: SL 1.4255 Bid 1.4201
OrderSend error 130

I have run out of ideas of where to look next... thanks for any help

V


hi there

my broker wont allow any stop or Take profit to be placed when placing the order


so i have it set to 0

and run a take profit and stoploss straight after

if you broker is same just set your order to 0 stop and 0 take profit

and it the tester should be able to place a trade


 
WHRoeder:

NormalizeDouble is never, ever, necessary. Don't use it - it's a crutch. Code correctly and it's unnecessary. There are none in my code. E.G.

Got it thanks,
And RaptureUK, thanks I get this too.
 
I use NormalizeDouble in my code . . but I am calculating prices not just reading them from somewhere else. If you read a price value from a bar it will already be set to the correct precision, if you add a point value to a price from a bar it will also have the correct precision so doesn't need to be Normalized.
Reason: