Basic OrderSend Error 130

wloa

Trader
Jun 23, 2022
1
0
5
67
I'm trying again to post here. I must have done something wrong with my first attempt, because it disappeared as soon as I posted it. So if I'm unwittingly violating some rule please let me know what it is so I can fix it!

I'm struggling to understand how OrderSend actually functions. Here's a basic test script I set up tostudy how it works.

MQL4:
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
//---
   Print("Current Ask: ", Ask);
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   if ( Ask > 1.044 && Ask < 1.045 ) {
      int ticket=OrderSend(Symbol(),OP_BUY,.1,Ask,2,Bid-15*Point,Bid+15*Point);
      if(ticket<0) {
         Print("OrderSend failed with error #",GetLastError(), " Ask: ", Ask);
      }
   }        
 
  }

Running this code in the Tester for a one day span against EURUSD results in the following journal entries:

0 13:56:17.185 TestGenerator: current spread 9 used
2 13:56:17.185 2022.06.16 00:00:00 TestOrder test started
0 13:56:17.185 2022.06.16 00:00:00 TestOrder EURUSD,H1: Current Ask: 1.0445
3 13:56:17.185 2022.06.16 00:00:00 TestOrder EURUSD,H1: OrderSend error 130
0 13:56:17.185 2022.06.16 00:00:00 TestOrder EURUSD,H1: OrderSend failed with error #130 Ask: 1.0445
3 13:56:17.517 2022.06.16 04:00:00 TestOrder EURUSD,H1: OrderSend error 130
0 13:56:17.517 2022.06.16 04:00:00 TestOrder EURUSD,H1: OrderSend failed with error #130 Ask: 1.0446
3 13:56:17.618 2022.06.16 05:00:00 TestOrder EURUSD,H1: OrderSend error 130
0 13:56:17.618 2022.06.16 05:00:00 TestOrder EURUSD,H1: OrderSend failed with error #130 Ask: 1.0444
0 13:56:19.580 EURUSD,H1: 25 tick events (24 bars, 1048 bar states) processed in 0:00:02.390 (total time 0:00:04.390)

Why do I keep getting Error #130? I know it's a stop limit error, but I'm not grasping why I'm getting it with this code.