I will write an advisor free of charge - page 169

 

Antonio Simon Del Vecchio Я только что приготовила его и не успела протестировать.

Everything works! Thank you! But, I have no experience in working with such tools, so suddenly, after checking, I realized that I made a mistake and did not specify a request in the ToR: please correct it so that the EA closes only the currency pair (one or more orders) on whose chart it is thrown.
 
torrr #:
Everything is working. Thank you. But, I have no experience in working with this kind of tools, so suddenly, after checking it, I have realised that I have made a mistake and have not specified a request in the ToR: please correct it so that the EA closes only the currency pair (one or more orders) on whose chart it is launched.
Just add a Magic. Regards.
//+------------------------------------------------------------------+
//|                                                     Practica.mq4 |
//|                        Copyright 2022, Antonio Simón Del Vecchio |
//|                    https://www.mql5.com/es/users/simondelvecchio |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, Antonio Simón Del Vecchio"
#property link      "https://www.mql5.com/es/users/simondelvecchio"
#property version   "1.00"
#property strict


input int Magic = 12345;
input int Periodo = 50;


//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   if(OrdersTotal() > 0 && CruceMediaPrecio())
     {
      Cerrar();
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Cerrar()
  {
   double Precio = 0;
   for(int i = OrdersTotal() - 1; i >= 0; i--)
     {
      if(OrderSelect(i, SELECT_BY_POS))
        {
         if(OrderType() == OP_BUY && OrderMagicNumber()== Magic)
            Precio = Bid;
         else
            Precio = Ask;
         if(!OrderClose(OrderTicket(), OrderLots(), Precio, 3, clrNONE))
            Print("Error al cerrar la órden: ", GetLastError());
        }
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool CruceMediaPrecio()
  {
   double Media = iMA(Symbol(), PERIOD_CURRENT, Periodo, 0, MODE_SMA, PRICE_CLOSE, 0);
   double Max = iHigh(Symbol(), PERIOD_CURRENT, 0);
   double Min = iLow(Symbol(), PERIOD_CURRENT, 0);
   if(Max > Media && Min < Media)
     {
      return(true);
     }
   return(false);
  }
//+------------------------------------------------------------------+
 
Antonio Simon Del Vecchio #:

Thanks again! Only I don't understand where to get the magik, as all trades were opened manually (maybe comments when opening orders will do?)

P.S. Found a script that opens orders manually with the ability to set a magik. I think it will work that way.
 
torrr #:

Thanks again. I just don't understand where to get the magik from, as all trades were opened manually (maybe the comments when opening orders will help?).

P.S. I found a script that opens orders manually with the ability to set a magik. I think it will work like this.

I thought the positions were opened by another EA. If you open them manually, this one will work for you.

//+------------------------------------------------------------------+
//|                                                     Practica.mq4 |
//|                        Copyright 2022, Antonio Simón Del Vecchio |
//|                    https://www.mql5.com/es/users/simondelvecchio |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, Antonio Simón Del Vecchio"
#property link      "https://www.mql5.com/es/users/simondelvecchio"
#property version   "1.00"
#property strict

input int Periodo = 50;


//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   if(OrdersTotal() > 0 && CruceMediaPrecio())
     {
      Cerrar();
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Cerrar()
  {
   double Precio = 0;
   for(int i = OrdersTotal() - 1; i >= 0; i--)
     {
      if(OrderSelect(i, SELECT_BY_POS))
        {
         if(OrderType() == OP_BUY && OrderSymbol() == Symbol())
            Precio = Bid;
         else
            Precio = Ask;
         if(!OrderClose(OrderTicket(), OrderLots(), Precio, 3, clrNONE))
            Print("Error al cerrar la órden: ", GetLastError());
        }
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool CruceMediaPrecio()
  {
   double Media = iMA(Symbol(), PERIOD_CURRENT, Periodo, 0, MODE_SMA, PRICE_CLOSE, 0);
   double Max = iHigh(Symbol(), PERIOD_CURRENT, 0);
   double Min = iLow(Symbol(), PERIOD_CURRENT, 0);
   if(Max > Media && Min < Media)
     {
      return(true);
     }
   return(false);
  }
//+------------------------------------------------------------------+
 
Antonio Simon Del Vecchio #:

I thought the positions were opened by another EA. If you are opening them manually, this option will work for you.

Thank you very much! I'll be testing.
 

Greetings to all, a question, I have a complete EA code, however I would like to know if you can add an informative panel where you can report aspects of the moment as, balance, equity, # of open trades, profit of the day, week, month, etc...

Thank you.

 
Hello please write an EA for MT5,

That sells at the upper Bollinger band crossover if the current price is the current high of the current bar. 
Bollinger Bands parameters, timeframe,lot size, takeprofit and StopLoss as manual inputs.

Thanks alot :)
 
Dac coyr # :
Hello please write an EA for MT5,

That sells at the upper Bollinger band crossover if the current price is the current high of the current bar. 
Bollinger Bands parameters, timeframe,lot size, takeprofit and StopLoss as manual inputs.

Thanks alot :)

Take a screenshot of the MetaTrader 5 terminal and put the indicators on the chart, please. And one more request: the background of the chart should be white.

 
Vladimir Karputov #:

Take a screenshot of the MetaTrader 5 terminal and put the indicators on the chart, please. And one more request: the background of the chart should be white.


This is only one indicator, but the sell order will be executed when the price crosses the upper Bollinger band, if the current price corresponds to the highest price of the current / new bar.

This means that a sell order will be opened for each new higher price above the upper Bollinger Bands.
Files:
 
hi . i am new to trading . i want to know to how to use robot in trading ?
Reason: