why did metatrader delete my orders - page 2

 
Darian Fernández:
metatrader after a few hours deletes my pending orders, why it happens, how to fix it

but this is normal behaviour from most brokers. to stop this from happening you have to do 1 of 2 things, a) monitor your open pending trades, and open more if you need new ones, or b) you might be able to modify the line of code when opening the pending trade to extend the expiry time longer.

 

Ok. This is the code

***

Descubra las nuevas posibilidades de MetaTrader 5 con la comunidad y los servicios MQL5
Descubra las nuevas posibilidades de MetaTrader 5 con la comunidad y los servicios MQL5
  • www.mql5.com
MQL5 es un lenguaje built-in de estrategias comerciales para el terminal MetaTrader 5. Este lenguaje permite escribir sus propios sistemas automáticos de trading, indicadores técnicos, scripts y bibliotecas de funciones.
 
Darian Fernández #:

Ok. This is the code

***

Please insert the code correctly: when editing a message, press the button        Codeand paste your code into the pop-up window.

 
//+------------------------------------------------------------------+
//|                                                   ExpertMAMA.mq5 |
//|                   Copyright 2009-2017, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "2009-2017, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Include                                                          |
//+------------------------------------------------------------------+
#include <Expert\Expert.mqh>
#include <Expert\Signal\SignalMA.mqh>
#include <Expert\Trailing\TrailingMA.mqh>
#include <Expert\Money\MoneyNone.mqh>
//+------------------------------------------------------------------+
//| Inputs                                                           |
//+------------------------------------------------------------------+
//--- inputs for expert
input string             Inp_Expert_Title       ="ExpertMAMA";
int                      Expert_MagicNumber     =12003;
bool                     Expert_EveryTick       =false;
//--- inputs for signal
input int                Inp_Signal_MA_Period   =12;
input int                Inp_Signal_MA_Shift    =6;
input ENUM_MA_METHOD     Inp_Signal_MA_Method   =MODE_SMA;
input ENUM_APPLIED_PRICE Inp_Signal_MA_Applied  =PRICE_CLOSE;
//--- inputs for trailing
input int                Inp_Trailing_MA_Period =12;
input int                Inp_Trailing_MA_Shift  =0;
input ENUM_MA_METHOD     Inp_Trailing_MA_Method =MODE_SMA;
input ENUM_APPLIED_PRICE Inp_Trailing_MA_Applied=PRICE_CLOSE;
//+------------------------------------------------------------------+
//| Global expert object                                             |
//+------------------------------------------------------------------+
CExpert ExtExpert;
//+------------------------------------------------------------------+
//| Initialization function of the expert                            |
//+------------------------------------------------------------------+
int OnInit(void)
  {
//--- Initializing expert
   if(!ExtExpert.Init(Symbol(),Period(),Expert_EveryTick,Expert_MagicNumber))
     {
      //--- failed
      printf(__FUNCTION__+": error initializing expert");
      ExtExpert.Deinit();
      return(-1);
     }
//--- Creation of signal object
   CSignalMA *signal=new CSignalMA;
   if(signal==NULL)
     {
      //--- failed
      printf(__FUNCTION__+": error creating signal");
      ExtExpert.Deinit();
      return(-2);
     }
//--- Add signal to expert (will be deleted automatically))
   if(!ExtExpert.InitSignal(signal))
     {
      //--- failed
      printf(__FUNCTION__+": error initializing signal");
      ExtExpert.Deinit();
      return(-3);
     }
//--- Set signal parameters
   signal.PeriodMA(Inp_Signal_MA_Period);
   signal.Shift(Inp_Signal_MA_Shift);
   signal.Method(Inp_Signal_MA_Method);
   signal.Applied(Inp_Signal_MA_Applied);
//--- Check signal parameters
   if(!signal.ValidationSettings())
     {
      //--- failed
      printf(__FUNCTION__+": error signal parameters");
      ExtExpert.Deinit();
      return(-4);
     }
//--- Creation of trailing object
   CTrailingMA *trailing=new CTrailingMA;
   if(trailing==NULL)
     {
      //--- failed
      printf(__FUNCTION__+": error creating trailing");
      ExtExpert.Deinit();
      return(-5);
     }
//--- Add trailing to expert (will be deleted automatically))
   if(!ExtExpert.InitTrailing(trailing))
     {
      //--- failed
      printf(__FUNCTION__+": error initializing trailing");
      ExtExpert.Deinit();
      return(-6);
     }
//--- Set trailing parameters
   trailing.Period(Inp_Trailing_MA_Period);
   trailing.Shift(Inp_Trailing_MA_Shift);
   trailing.Method(Inp_Trailing_MA_Method);
   trailing.Applied(Inp_Trailing_MA_Applied);
//--- Check trailing parameters
   if(!trailing.ValidationSettings())
     {
      //--- failed
      printf(__FUNCTION__+": error trailing parameters");
      ExtExpert.Deinit();
      return(-7);
     }
//--- Creation of money object
   CMoneyNone *money=new CMoneyNone;
   if(money==NULL)
     {
      //--- failed
      printf(__FUNCTION__+": error creating money");
      ExtExpert.Deinit();
      return(-8);
     }
//--- Add money to expert (will be deleted automatically))
   if(!ExtExpert.InitMoney(money))
     {
      //--- failed
      printf(__FUNCTION__+": error initializing money");
      ExtExpert.Deinit();
      return(-9);
     }
//--- Set money parameters
//--- Check money parameters
   if(!money.ValidationSettings())
     {
      //--- failed
      printf(__FUNCTION__+": error money parameters");
      ExtExpert.Deinit();
      return(-10);
     }
//--- Tuning of all necessary indicators
   if(!ExtExpert.InitIndicators())
     {
      //--- failed
      printf(__FUNCTION__+": error initializing indicators");
      ExtExpert.Deinit();
      return(-11);
     }
//--- succeed
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Deinitialization function of the expert                          |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   ExtExpert.Deinit();
  }
//+------------------------------------------------------------------+
//| Function-event handler "tick"                                    |
//+------------------------------------------------------------------+
void OnTick(void)
  {
   ExtExpert.OnTick();
  }
//+------------------------------------------------------------------+
//| Function-event handler "trade"                                   |
//+------------------------------------------------------------------+
void OnTrade(void)
  {
   ExtExpert.OnTrade();
  }
//+------------------------------------------------------------------+
//| Function-event handler "timer"                                   |
//+------------------------------------------------------------------+
void OnTimer(void)
  {
   ExtExpert.OnTimer();
  }
//+------------------------------------------------------------------+
 
Darian Fernández # :

This EA does not place pending orders. This advisor can only open a position.

 
Hello, could give me the contact of someone from the help system who can really solve my punctual problem, which is that the pending orders are deleted after a while is very rare, if they gave me the contact of that person I would appreciate it