Grid EA with Order expiration

MQL4 Experts

Job finished

Execution time 6 days

Specification

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-------------------+

Responded

1
Developer 1
Rating
(16)
Projects
20
0%
Arbitration
9
0% / 78%
Overdue
6
30%
Free
2
Developer 2
Rating
(33)
Projects
35
40%
Arbitration
11
9% / 91%
Overdue
4
11%
Free
3
Developer 3
Rating
(251)
Projects
400
54%
Arbitration
9
67% / 22%
Overdue
36
9%
Free
4
Developer 4
Rating
(376)
Projects
475
40%
Arbitration
83
36% / 33%
Overdue
13
3%
Loaded
5
Developer 5
Rating
(368)
Projects
398
70%
Arbitration
3
100% / 0%
Overdue
2
1%
Loaded
6
Developer 6
Rating
(298)
Projects
442
64%
Arbitration
5
40% / 0%
Overdue
4
1%
Working
7
Developer 7
Rating
(74)
Projects
121
43%
Arbitration
12
33% / 50%
Overdue
17
14%
Free
8
Developer 8
Rating
(2428)
Projects
3057
66%
Arbitration
77
48% / 14%
Overdue
340
11%
Free
9
Developer 9
Rating
(478)
Projects
507
53%
Arbitration
10
60% / 20%
Overdue
3
1%
Free
10
Developer 10
Rating
(256)
Projects
415
38%
Arbitration
86
44% / 19%
Overdue
70
17%
Busy
11
Developer 11
Rating
(124)
Projects
158
42%
Arbitration
20
60% / 20%
Overdue
8
5%
Free
12
Developer 12
Rating
(11)
Projects
16
25%
Arbitration
0
Overdue
1
6%
Free
13
Developer 13
Rating
(74)
Projects
73
47%
Arbitration
2
50% / 50%
Overdue
2
3%
Free
14
Developer 14
Rating
(563)
Projects
932
47%
Arbitration
302
59% / 25%
Overdue
124
13%
Loaded
15
Developer 15
Rating
(42)
Projects
88
14%
Arbitration
30
30% / 53%
Overdue
36
41%
Working
Similar orders
I want have the possibility to increase lotsize not alone by Lot-multiplier rather I want add a fix-lot increase for excample for 0,05 lot. I want have this for buy / sell and hedge-buy and hedge sell
Hi, I want to make an automated system to take my place in making trading positions and closing it. But I want to ask , can you program it to draw a trend line in a specific chart and several moving averages should be in specific order, and when the price is near the trend line by few pips, we shift to 15 minutes chart and noticing a resistance or support action , then we take the trade ? can we do that
Develop EA to track performance metrics of strategies I would like to develop an EA that will track the performance metrics of the strategies I have running on a terminal, If any of the metrics start to under perform then the EA/Indictor should alert me with a pop up alert that specify's the metric that has triggered the alert. The EA should also display the metrics in a dashboard - please see my example screen shot
I would like to modify the RSI Epert Avisor with a developer. I would like to use the RSI Expert on the inverse mode and the base setting doesnt conatain this strategy mode
Profitable EA HFT 50 - 300 USD
From a long time i am searching for a profitable EA i have lost a lot , and now i have only 300$ to buy a profitable EA , i wish to say with 0 losses but some or most traders they don't want to hear this i am really tired of searching for a programmer to just create me a profitable EA with the least losses or zero losses maybe nearly 1 year i am searching i just need an HFT EA that can work very well on MT4,MT5
I need help fixing my EA for MT5. It’s a very simple EA, and I currently cannot solve an issue where webrequest communicates with OpenAi API without error. Please only apply if you can help solve this issue
p.p1 {margin: 0.0px 0.0px 12.0px 0.0px; font: 14.0px 'Trebuchet MS'; color: #313131} p.p1 {margin: 0.0px 0.0px 12.0px 0.0px; font: 14.0px 'Trebuchet MS'; color: #313131} li.li1 {margin: 0.0px 0.0px 12.0px 0.0px; font: 14.0px 'Trebuchet MS'; color: #313131} ol.ol1 {list-style-type: decimal} I have an EA that open trades when my entry conditions are met. It usually executes one trade per day. I'd like to add an option
у нас есть стратегия, нам нужно написать mql5-код ​​для тестера стратегий МТ5,Цена договорная. Мой контакт @abbosaliyev из Telegram Программист должен знать РУССКИЙ ИЛИ УЗБЕКСКИЙ язык. Задание: разработать тестер, который использует шаблон условий на открытие и проверит весь исторический график на всех доступных таймфреймах. Остальная информация будет предоставлена ​​после согласования цены
a coder is required to add an indicator to existing ea The new indicator will work as 1. option to combine with exiting indicator to open trade 2. it will be used as alternative BE point 3. It can also be used to close order or combine with other to close trade The second Job is telegram bot to get alert fr news trade and others Details when you apply i will test the ea work on live market and all bug is fixed before
Hello, I want to make an EA based on SMC and a developer that is familiar with the concept and full understanding of this. Must have done similar jobs before and be able show it. I only want to work with developer that has good track record and is precise. Further information will be handed when contact is made. Developers that has zero rating will not be considered. Listed price is a base point. The project can also

Project information

Budget
50 - 100 USD
For the developer
45 - 90 USD
Deadline
from 1 to 10 day(s)