!HELP! My first ever EA

 
//+------------------------------------------------------------------+
//|                                               HedgeHog_10_v1.mq4 |
//|                                                 Matthew Williams |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Matthew Williams"

#include <stdlib.mqh>

#define MAGIC  1234
#define IDENT  "HedgeHog_10_v1"

extern double  lots           = 0.1;
extern double  stop_loss      = 20000;   // (8 pips) optimise 50-2000
extern double  take_profit    = 100;  // (75 pips) optimise 50-2000


int start()
  {
    
      
    if (OrdersTotal()<2){ 
   if (Hour()==00 && Minute()==05) {
         OrderSend("EURUSD", OP_SELL, lots ,Bid, 3, Bid + stop_loss * Point, Ask - take_profit * Point, IDENT, MAGIC, 0, Red);
         OrderSend("EURUSD", OP_BUY, lots ,Ask, 3, Ask - stop_loss * Point, Bid  + take_profit * Point, IDENT, MAGIC, 0, Blue);
         Alert (GetLastError());
    if (OrdersTotal()<4){ 
   if (Hour()==00 && Minute()==05) {     
         OrderSend("GBPUSD", OP_SELL, lots ,Bid, 3, Bid + stop_loss * Point, Ask - take_profit * Point, IDENT, MAGIC, 0, Red);
         OrderSend("GBPUSD", OP_BUY, lots ,Ask, 3, Ask - stop_loss * Point, Bid  + take_profit * Point, IDENT, MAGIC, 0, Blue);
         Alert (GetLastError());
    if (OrdersTotal()<6){ 
   if (Hour()==00 && Minute()==05) {
         OrderSend("AUDUSD", OP_SELL, lots ,Bid, 3, Bid + stop_loss * Point, Ask - take_profit * Point, IDENT, MAGIC, 0, Red);
         OrderSend("AUDUSD", OP_BUY, lots ,Ask, 3, Ask - stop_loss * Point, Bid  + take_profit * Point, IDENT, MAGIC, 0, Blue);
         Alert (GetLastError());
    if (OrdersTotal()<8){ 
   if (Hour()==00 && Minute()==06) {     
          OrderSend("EURJPY", OP_SELL, lots ,Bid, 3, Bid + stop_loss * Point, Ask - take_profit * Point, IDENT, MAGIC, 0, Red);
          OrderSend("EURJPY", OP_BUY, lots ,Ask, 3, Ask - stop_loss * Point, Bid  + take_profit * Point, IDENT, MAGIC, 0, Blue);
          Alert (GetLastError());
    if (OrdersTotal()<10){ 
   if (Hour()==00 && Minute()==06) {       
          OrderSend("NZDUSD", OP_SELL, lots ,Bid, 3, Bid + stop_loss * Point, Ask - take_profit * Point, IDENT, MAGIC, 0, Red);
          OrderSend("NZDUSD", OP_BUY, lots ,Ask, 3, Ask - stop_loss * Point, Bid  + take_profit * Point, IDENT, MAGIC, 0, Blue);
          Alert (GetLastError());
    if (OrdersTotal()<12){ 
   if (Hour()==00 && Minute()==06) {      
          OrderSend("USDCHF", OP_SELL, lots ,Bid, 3, Bid + stop_loss * Point, Ask - take_profit * Point, IDENT, MAGIC, 0, Red);
          OrderSend("USDCHF", OP_BUY, lots ,Ask, 3, Ask - stop_loss * Point, Bid  + take_profit * Point, IDENT, MAGIC, 0, Blue);
          Alert (GetLastError());
   } 
   return(0);
}}}}

This is my first ever EA, Im getting alot of 130,129 and 4107 errors. Im trying to put in 12 orders at a specified time. I tried some really basic code but I dont think the server can handle it, keeps saying "Trade Context Busy". Is there a better way to put this many trades in at once ? Or putting them in one at a time as quickly as pos ?

Would really appreciate any ideas.

MW

 

add someting like this

int ticket;

ticket = OrderSend(.....);
if (ticket > -1)
   {
   //go to the second
   }

also u can check

if (IsTradeAllowed())

for error 130

https://www.mql5.com/en/forum/129818

https://www.mql5.com/en/forum/129818

 
qjol:

add someting like this

also u can check

for error 130

https://www.mql5.com/en/forum/129818

https://www.mql5.com/en/forum/129818

Thank You for the speedy reply, will give it a go.