Need help with EA OrderSend Error 130

 

I don't know what's going on here. 


I'm trying to do an OrderSend for a pending order here is all the details.

1. Current Price: $2022


OrderSend("XAUUSD", 5, 0.1, 2035, 3, 0, 0 , "Trade", 0, 0, 3937500);


Full code here for ordersend:

   if (order.type == "Buy"){
      if(current_ask>order.entry)
      {
         orderType = OP_BUYLIMIT;
      }else{
         orderType = OP_BUYSTOP;
      }
      ticket = OrderSend(Symbol(), orderType, lotSize, order.entry, 3, 0, 0, "Trade", magic, tenMinutesLater, clrGreen);
   }else{
      if(current_bid>order.entry)
      {
         orderType = OP_SELLLIMIT;
      }else{
         orderType = OP_SELLSTOP;
      }
      ticket = OrderSend(Symbol(), orderType, lotSize, order.entry, 3, 0, 0, "Trade", magic, tenMinutesLater, clrCrimson);
   }

Not setting a SL or TP just trying to do an entry. 


A google search mentioned StopLevel so I checked stoplevel

StopLevel = 200


I did a check before the OrderSend

   int StopLevel = (int)MarketInfo(Symbol(), MODE_STOPLEVEL);
   double current_ask=MarketInfo(Symbol(),MODE_ASK);
   double current_bid=MarketInfo(Symbol(),MODE_BID);
   double minDistanceSL = StopLevel * Point;
   Print("StopLevel: ", StopLevel, " points");
   Print("Minimum Entry Price for Buy: ", NormalizeDouble(current_ask + minDistanceSL, Digits));
   Print("Minimum Entry Price for Sell: ", NormalizeDouble(current_bid - minDistanceSL, Digits));

It returned back the following in Journal 

Minimum Entry Price for Sell: 2020.04
Minimum Entry Price for Buy: 2024.34
Basic Principles - Trading Operations - MetaTrader 5 Help
  • www.metatrader5.com
Before you proceed to study the trade functions of the platform, you must have a clear understanding of the basic terms: order, deal and position...
 
Kodyisking: 1. Current Price: $2022

OrderSend("XAUUSD", 5, 0.1, 2035, 3, 0, 0 , "Trade", 0, 0, 3937500);
  1. Don't hard code constants (5), use the proper enumeration (OP_SELLSTOP).
  2. You can't put a sell stop above the market.
              Example of a buy limit and a buy stop? - General - MQL5 programming forum #1 (2020)
 
William Roeder #:
  1. Don't hard code constants (5), use the proper enumeration (OP_SELLSTOP).
  2. You can't put a sell stop above the market.
              Example of a buy limit and a buy stop? - General - MQL5 programming forum #1 (2020)

Check out the full code section in the thread, I only showed the constant as an example. 

 
Kodyisking #:

Check out the full code section in the thread, I only showed the constant as an example. 

You chose to concentrate on his (correctly) criticism of your code snippet,

And totally ignored the fact that he solved your problem, and didn't even thanked him.

Don't be ungrateful.

 
AMI289 #:

You chose to concentrate on his (correctly) criticism of your code snippet,

And totally ignored the fact that he solved your problem, and didn't even thanked him.

Don't be ungrateful.

That isn't the problem lol.


The OrderSend is 100% an example that doesn't exist or anything. The full code snippet is the problem. 

 

You left out relevant code that could be the source of the problem.

For example- where and when do you set the 'order.entry' variable? What value does it holds at the time of the OrderSend function?

 
Kodyisking #:

That isn't the problem lol.


The OrderSend is 100% an example that doesn't exist or anything. The full code snippet is the problem. 

did you check out William suggestion at number 2?