Download MetaTrader 5
To add comments, please log in or register
Do you want to write a technical indicator? Find solution in MQL5 Reference!
iamloving
5
iamloving 2016.08.01 00:35 
I am on OSX 10.11.5, can anyone please confirm if this is a MQL4 bug? on OSX? it always return 130error.
On OSX the MQL4 compiler did not used native objective-C, it might be using Wine? is that the reason i always keep getting 130 error while using OrderSend method?

void OnTick() {

  string symbol   = Symbol();
  int    cmd      = OP_BUY;
  double volume   = 1;
  double price    = Ask;  
  int    slippage = 3;

  double minstoplevel=MarketInfo(Symbol(),MODE_STOPLEVEL); 
  double stoploss     = Bid+1*Point;
  double takeprofit   = Bid+50*Point;
  //double stoploss   = NormalizeDouble(Bid-minstoplevel*Point,Digits);
  //double takeprofit = NormalizeDouble(Bid+minstoplevel*Point,Digits);

  string comment  = "COMMENT";
  int magic_number = 255;

  //SEE: https://docs.mql4.com/trading/ordersend
  int ticket=OrderSend(symbol,              //string  = symbol
                       cmd,                 //int     = operation
                       1,                   //double  = volume
                       Ask,                 //double  = price
                       slippage,            //int     = slippage
                       stoploss,            //double  = stoploss
                       takeprofit,          //double  = take profit
                       comment,             //string  = comment
                       magic_number,        //int     = Magic number
                       TimeCurrent()+7200,  //datetime= duration..
                       clrRed);             //color   = color
  if(ticket < 0) {
    Print("OrderSend failed: ", GetLastError());
  }
  else {
    Print("OrderSend success");
  }
  
}

 


whroeder1
13600
whroeder1 2016.08.01 13:36  
iamloving: can anyone please confirm if this is a MQL4 bug? on OSX? it always return 130error.
  double minstoplevel=MarketInfo(Symbol(),MODE_STOPLEVEL); 
  double stoploss     = Bid+1*Point;
  double takeprofit   = Bid+50*Point;
Not a bug, it's your broken code.
  1. You are buying, so how can the SL be above the market?
  2. Where is your test to make sure that your stops are at least STOPLEVEL away? Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial
/
To add comments, please log in or register