Pending order script returning 129 error

To add comments, please log in or register

I'm very new to scripting in Mql4, but I want to make a script that takes the alert message from my indicator and sets multiple orders with the same stop and different take-profits

But I keep getting a 129 error and I can't figure out why.

Here is the string from my indicator GBPUSD BUY: 4.32 @ 1.335, Stop: 1.333, T1: 1.3361, T2: 1.3372, T3: 1.338, T4: 1.3391, T5: 1.3402 

Here is my script

#property copyright "Copyright © 2008, PRMQuotes Software Corp."
#property show_inputs

#include <stdlib.mqh>
#include <WinUser32.mqh>

double Lots;
double Price; // Asking price that you want to put the pending order at.
double stoploss;  // change this number to change the stoploss
double t1; // change this number to change the takeprofit
double t2;
double t3;
double t4;
double t5;
string Pair;
extern string alertmessage = "Paste alert message";

int ticket = 0; 
int start()
   string to_split = alertmessage;   // A string to split into substrings
   string sep=" ";                   // A separator as a character
   ushort u_sep;                     // The code of the separator character
   string result[];                  // An array to get strings
   //--- Get the separator code
   //--- Split the string to substrings
   int k=StringSplit(to_split,u_sep,result);

   Pair = result[0];
   Lots = result[4];
   Price = NormalizeDouble(result[6],Digits);
   stoploss = NormalizeDouble(result[8],Digits);
   t1 = result[10];
   t2 = result[12];
   t3 = result[14];
   t4 = result[16];
   t5 = result[18];
   if(result[3] == "BUY:")
         ticket = OrderSend(Pair,OP_BUY,Lots,Price,5,stoploss,t1,"",0,0,CLR_NONE);
         ticket = OrderSend(Pair,OP_BUY,Lots,Price,5,stoploss,t2,"",0,0,CLR_NONE);
         ticket = OrderSend(Pair,OP_BUY,Lots,Price,5,stoploss,t3,"",0,0,CLR_NONE);
         ticket = OrderSend(Pair,OP_BUY,Lots,Price,5,stoploss,t4,"",0,0,CLR_NONE);
         ticket = OrderSend(Pair,OP_BUY,Lots,Price,5,stoploss,t5,"",0,0,CLR_NONE);
         printf(GetLastError() );
         printf("Order " + IntegerToString(ticket));
         ticket = OrderSend(Pair,OP_SELLSTOP,Lots,Price,3,stoploss,t1,"",0,0,CLR_NONE);
         ticket = OrderSend(Pair,OP_SELLSTOP,Lots,Price,3,stoploss,t2,"",0,0,CLR_NONE);
         ticket = OrderSend(Pair,OP_SELLSTOP,Lots,Price,3,stoploss,t3,"",0,0,CLR_NONE);
         ticket = OrderSend(Pair,OP_SELLSTOP,Lots,Price,3,stoploss,t4,"",0,0,CLR_NONE);
         ticket = OrderSend(Pair,OP_SELLSTOP,Lots,Price,3,stoploss,t5,"",0,0,CLR_NONE);
         printf("Sell order set");
William Roeder
William Roeder  
  1. mielie007: But I keep getting a 129 error and I can't figure out why
    You can't buy at any price only at the Ask.

  2. Check your return codes for errors (for each call,) report them and you would know why. Don't just silence the compiler, it is trying to help you.
              What are Function return values ? How do I use them ? - MQL4 and MetaTrader 4 - MQL4 programming forum
              Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
To add comments, please log in or register