Grid EA with Order expiration

MQL4 Asesores Expertos

Trabajo finalizado

Plazo de ejecución 6 días

Tarea técnica

I have a grid order EA with code. I need EA to close pending orders after 5 minutes. So if orders with magic number 1 open at 00:00, pending orders with magic number 1 are delete at 00:005


See code below


//+------------------------------------------------------------------+

//--External variables

extern int    MagicNumber       = 1;//Magic number

extern string EaComment         = "Grid_Template";//Order comment

extern double StaticLot         = 0.01;//Static lots size

extern bool   MM                = false;//Money Management

extern int    Risk              = 2;//Risk %

extern double TakeProfit        = 20.;//Take Profit in pips

extern double StopLoss          = 10.;//Stop loss in pips

extern double PriceDistance     = 15.;//Distance from price in pips

extern double GridStep          = 15.;//Step between grid orders in pips

extern int    GridOrders        = 2;//Amount of grid orders

extern int    PendingExpiration = 15;//Pending expiration after xx minutes

//--Internal variables

double PriceB,PriceS,StopB,StopS,

       TakeB,TakeS,_points,PT,Lots;

int LotDigits;

datetime _e = 0;

int Ticket  = 0;

//--

int OnInit()

  {

//--Determine digits

   _points=MarketInfo(Symbol(),MODE_POINT);

//--

   if(Digits==5 || Digits==3)

      PT = _points*10;

   else

      PT = _points;

//--

   return(INIT_SUCCEEDED);

  }

//--

void OnDeinit(const int reason)

  {


  }

//--

void OnTick()

  {

//If trade allowed and no positions exists by any chart - open a new set of grid orders

   if(IsTradeAllowed() && !IsTradeContextBusy())

     {

      if(PosSelect()==0)

        {

         GridPos(PriceDistance,TakeProfit,StopLoss);//Place grid

        }

      return;

     }

  }

///////////////////////////////////////////////////////////

//Grid order send function

void GridPos(double _Dist,double _Take,double _Stop)

  {

   int i;

   _e=TimeCurrent()+PendingExpiration*60;

//--

   for(i=0; i<GridOrders; i++)

     {

      PriceB = NormalizeDouble(Ask+(_Dist*PT)+(i*GridStep*PT),Digits);

      TakeB  = PriceB + _Take * PT;

      StopB  = PriceB - _Stop * PT;

      Ticket=OrderSend(Symbol(),OP_BUYSTOP,LotSize(),PriceB,3,StopB,TakeB,EaComment,MagicNumber,_e,Green);

      //--

      PriceS = NormalizeDouble(Bid-(_Dist*PT)-(i*GridStep*PT),Digits);

      TakeS  = PriceS - _Take * PT;

      StopS  = PriceS + _Stop * PT;

      Ticket=OrderSend(Symbol(),OP_SELLSTOP,LotSize(),PriceS,3,StopS,TakeS,EaComment,MagicNumber,_e,Red);

     }

   if(Ticket<1)

     {

      Print("Order send error - errcode: ",GetLastError());

      return;

     }

   else

     {

      Print("Grid placed successfully!");

     }

   return;

  }

//////////////////////////////////////////////////////////

//PositionSelector - Determines open positions

int PosSelect()

  {

   int posi=0;

   for(int k = OrdersTotal() - 1; k >= 0; k--)

     {

      if(!OrderSelect(k, SELECT_BY_POS))

        {

         Print("Order pos selection failed - errcode: ",GetLastError());

        }

      if(OrderSymbol()!=Symbol()&&OrderMagicNumber()!=MagicNumber)

        {

         continue;

        }

      if(OrderCloseTime() == 0 && OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)

        {

         if(OrderType() == OP_BUY)

            posi = 1; //Long position

         if(OrderType() == OP_SELL)

            posi = -1; //Short positon

         if(OrderType() == OP_BUYSTOP)

            posi = 1; //Pending Long position

         if(OrderType() == OP_SELLSTOP)

            posi = -1; //Pending Short positon

        }

     }

   return(posi);

  }

////////////////////////////////////////////////////////////

//Lots size calculation

double LotSize()

  {

   if(MM == true)

     { Lots = MathMin(MathMax((MathRound((AccountFreeMargin()*Risk/1000/100)

       /MarketInfo(Symbol(),MODE_LOTSTEP))*MarketInfo(Symbol(),MODE_LOTSTEP)),

       MarketInfo(Symbol(),MODE_MINLOT)),MarketInfo(Symbol(),MODE_MAXLOT));}

   else

     {

      Lots = MathMin(MathMax((MathRound(StaticLot/MarketInfo(Symbol(),MODE_LOTSTEP))*MarketInfo(Symbol(),MODE_LOTSTEP)),

      MarketInfo(Symbol(),MODE_MINLOT)),MarketInfo(Symbol(),MODE_MAXLOT));

     }


   return(Lots);

  }

//+----------------End of Temi's Trader EA-------------------+

Han respondido

1
Desarrollador 1
Evaluación
(16)
Proyectos
20
0%
Arbitraje
10
0% / 80%
Caducado
6
30%
Libre
2
Desarrollador 2
Evaluación
(33)
Proyectos
35
40%
Arbitraje
11
9% / 91%
Caducado
4
11%
Libre
Ha publicado: 4 ejemplos
3
Desarrollador 3
Evaluación
(251)
Proyectos
400
54%
Arbitraje
9
67% / 22%
Caducado
36
9%
Libre
Ha publicado: 2 ejemplos
4
Desarrollador 4
Evaluación
(443)
Proyectos
570
37%
Arbitraje
106
39% / 33%
Caducado
17
3%
Libre
5
Desarrollador 5
Evaluación
(462)
Proyectos
489
70%
Arbitraje
6
67% / 0%
Caducado
2
0%
Trabaja
6
Desarrollador 6
Evaluación
(322)
Proyectos
499
67%
Arbitraje
5
40% / 0%
Caducado
4
1%
Libre
Ha publicado: 8 ejemplos
7
Desarrollador 7
Evaluación
(75)
Proyectos
124
44%
Arbitraje
14
29% / 50%
Caducado
17
14%
Libre
8
Desarrollador 8
Evaluación
(2676)
Proyectos
3418
68%
Arbitraje
77
48% / 14%
Caducado
343
10%
Trabaja
Ha publicado: 1 ejemplo
9
Desarrollador 9
Evaluación
(515)
Proyectos
554
53%
Arbitraje
13
69% / 15%
Caducado
3
1%
Libre
10
Desarrollador 10
Evaluación
(298)
Proyectos
478
40%
Arbitraje
105
40% / 24%
Caducado
82
17%
Trabajando
Ha publicado: 2 ejemplos
11
Desarrollador 11
Evaluación
(144)
Proyectos
186
41%
Arbitraje
24
58% / 21%
Caducado
13
7%
Libre
12
Desarrollador 12
Evaluación
(11)
Proyectos
16
25%
Arbitraje
1
0% / 100%
Caducado
1
6%
Libre
13
Desarrollador 13
Evaluación
(74)
Proyectos
73
47%
Arbitraje
2
50% / 50%
Caducado
2
3%
Libre
14
Desarrollador 14
Evaluación
(574)
Proyectos
945
47%
Arbitraje
309
58% / 27%
Caducado
125
13%
Libre
15
Desarrollador 15
Evaluación
(45)
Proyectos
91
13%
Arbitraje
34
26% / 59%
Caducado
37
41%
Libre
Solicitudes similares
I want a robot that will monitor the h4 time frame. wait for 10ema to cross below or above 50 ema. look for candles to touch the 10 ema, wait for a break of structure and a reversal to the neckline. the robot must send me notification when the reversal touches the neckline and give visual indication on the chart
Hello, I have an existing XAUUSD market-analysis system called I am looking for an experienced MQL5 developer to perform a technical review and prepare a precise architecture for rebuilding the existing SIGNAL ENGINE / ANALYSIS LOGIC in MQL5. IMPORTANT: This request is ONLY about the signal-analysis engine. I am NOT requesting an Expert Advisor (EA), automated trading system, order execution, or live trading
Hi, I'm looking for an experienced MQL5 developer to build a profitable Expert Advisor for MetaTrader 5. The goal is to get the highest possible return from a small account while keeping the account alive. ACCOUNT - Broker: IC Markets (EU, regulated), MT5, hedging account - Leverage: 1:30 - Deposit: 200 USD - Instruments: Forex and/or XAUUSD, your choice. Please check that the margin for the minimum lot size is
I need a professional MT5 Expert Advisor for multi-symbol trade monitoring and risk management. The EA should focus on trade management rather than generating trading signals. Requirements: Platform: MetaTrader 5 / MQL5 Monitor all open positions on the account Multi-symbol support Display a dashboard showing: Symbol Buy/Sell direction Lot size Entry price Current profit/loss Stop Loss Take Profit Configurable
Hi, I’m looking for an experienced MQL5/MT5 developer to build a complex AI-powered adaptive Expert Advisor for XAUUSD+ on Ultima Markets. I have a detailed 28-section technical specification, and the requirements are fixed. I’m looking for the complete implementation , not a simplified EA or a conventional indicator-based system. The project includes: Genuine AI/ML integration AI-based market regime classification
This may be a weird request but if anyone has an EA that is actually consistently profitable I want to buy a copy from you. Ideally trades a lot, I'm sure theres a coder out there who has made a profitable EA, I want to backtest if you have, I have been trying to code a few on my own with no success as I'm not yet good at coding, lets see what ya got.thanks
I need a simple MetaTrader 5 Expert Advisor based on a MACD crossover. Requirements: Platform: MetaTrader 5 / MQL5 Buy when the MACD main line crosses above the signal line Sell when the MACD main line crosses below the signal line Use completed candles only MACD parameters configurable Fixed lot size configurable Stop Loss configurable Take Profit configurable Maximum one open position per symbol Configurable Magic
I need a simple MT5 Expert Advisor based on Bollinger Bands. Requirements: Platform: MetaTrader 5 / MQL5 Buy when price closes below the lower Bollinger Band Sell when price closes above the upper Bollinger Band Bollinger period configurable, default 20 Deviation configurable, default 2.0 Fixed lot size configurable Stop Loss configurable Take Profit configurable Maximum one open position per symbol Use completed
Platform: MT5 / MQL5 Buy khi RSI < 30 Sell khi RSI > 70 RSI period configurable, default 14 Fixed lot configurable SL/TP configurable Max 1 position per symbol Completed candles only Configurable Magic Number Deliver .mq5 source Compile without errors/warnings No martingale/grid No profitability guarantee
Trading bot ea 30+ USD
yoo i want to make a trading bot i have my strategy in videos and also the rules to if anyone can work it out for me i will be glad welcome your bid and it urget let connect here on mgl5 And if you know you can not do the project without getting paid first please don't bid thanks

Información sobre el proyecto

Presupuesto
50 - 100 USD
Plazo límite de ejecución
de 1 a 10 día(s)