Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1354

 
Aleksey Verbin:

Hello, I have a problem.

I have hieroglyphs instead of Russian letters.I tried changing the regional settings, but it didn't help. Do you know any working methods?

Where?
 

Good evening everyone!

I have a situation in my EA. The Expert Advisor does not determine whether a trade is in a symbol or not.

I do not know how to fix it, because I want it to analyze deals for a certain symbol. I want it to be more accurate! I cannot find this function ((!)

I tried to write such a function:

if(OrderSymbol() != "EURUSD")

{

......

}

 
михаил мосинзов:

Good evening everyone!

I have a situation in my EA. The Expert Advisor does not determine whether a trade is in a symbol or not.

I do not know how to fix it, because I want it to analyze deals for a certain symbol. I want it to be more accurate! I cannot find this function ((!)

I tried to write such a function:

if(OrderSymbol() != "EURUSD")

{

......

}

//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 06.03.2008                                                     |
//|  Описание : Возвращает флаг существования позиций                          |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    sy - наименование инструмента   (""   - любой символ,                   |
//|                                     NULL - текущий символ)                 |
//|    op - операция                   (-1   - любая позиция)                  |
//|    mn - MagicNumber                (-1   - любой магик)                    |
//|    ot - время открытия             ( 0   - любое время открытия)           |
//+----------------------------------------------------------------------------+
bool ExistPositions(string sy="", int op=-1, int mn=-1, datetime ot=0) {
  int i, k=OrdersTotal();
 
  if (sy=="0") sy=Symbol();
  for (i=0; i<k; i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      if (OrderSymbol()==sy || sy=="") {
        if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
          if (op<0 || OrderType()==op) {
            if (mn<0 || OrderMagicNumber()==mn) {
              if (ot<=OrderOpenTime()) return(True);
            }
          }
        }
      }
    }
  }
  return(False);
}
 
михаил мосинзов:

Good evening everyone!

I have a situation in my EA. The Expert Advisor does not determine whether a trade is in a symbol or not.

I do not know how to fix it, because I want it to analyze deals for a certain symbol. I want it to be more accurate! I cannot find this function ((!)

I tried to write such a function:

if(OrderSymbol() != "EURUSD")

{

......

}

check in loop each order against magic and symbol

... What language did you write your EA in, MQL4 or MQL5?

 
How resource intensive is the function
 Sleep() 

in services want to run once per hour ? is this the right solution or is it better to do something else?

 

Why doesn't the terminal account for all ticks?

datetime st = 0;
int tics = 0;

//---------------------------------------------------------

ArraySetAsSeries(time,true);
   ArraySetAsSeries(tick_volume,true);
   
   if(prev_calculated == 0) st = time[0];
   
   else if(time[0] != st)
     {
      tics++;
      Alert("T - ",tics," TV - ",tick_volume[0]);
     };


It's just that I wrote a big canvas of calculations and it's important for me to know how many ticks are calculated / missed

* THIS IS IMPORTANT, as this is a scalper strategy

 
BillionerClub:
How resource intensive is the function

in services want to run once per hour ? is this the right solution or is it better to do something else ?

Better as follows

if(TimeMinute(time[i])==0)
 

Good day everyone! I asked somewhere above, do I have to remove the check for a new bar in order for the EA to be executed by ticks? I was told that everything should be checked by ticks for real trade. In this regard, I have the following question. If the real trade will be executed by ticks, the orders are opened in this way now.

void OnTick()
{
//--- АО БАЙ--

   /*УСЛОВИЕ 1*/
   if(flag_screen1==en_vbIkl_screen1 &&flag_screen2==en_vbIkl_screen2)
   { // НАЧАЛО УСЛОВИЕ 1
   if(ao_buy!=EMPTY_VALUE && count_orders_market_buy ==0)
   {
    if(OrderSend(Symbol(),OP_BUY,lot,Ask,slippages,Bid-sl,Bid+tp ,comment_ao_market_buy)) Print("Buy Open"); // ОТКРЫВАЕМ БАЙ ОРДЕР
   }
   } // КОНЕЦ УСЛОВИЕ1


}

It turns out that if something goes wrong, my Expert Advisor will pound the server at every tick and my account will be simply disconnected from auto-trading because I cannot understand it well. What kind of check should I do and how should I do it, so if I make an error or something bad happens, my EA will not pound the server and I will not get banned for such things? Please tell me what the essence of this check and how it works in words, and then the code with comments please send. P / S please do not pass by knowledgeable people, and the same to help brotherly grail dopilivit ;-) Oh_o))))))))

 
DanilaMactep:

Good day everyone! I asked somewhere above, do I have to remove the check for a new bar in order for the EA to be executed on ticks? I was told that everything should be checked by ticks for real trade. In this regard, I have the following question. If the real trade will be executed by ticks, the orders are opened in this way now.

It turns out that if something goes wrong, my Expert Advisor will pound the server at every tick and my account will be simply disconnected from auto-trading because I cannot understand it well. What kind of check should I do and how should I do it, so if I make an error or something bad happens, my EA will not pound the server and I will not get banned for such things? Please tell me what the essence of this check and how it works in words, and then the code with comments please send. P / S please do not pass by knowledgeable people, and the same to help brotherly grail dopilivit ;-) Oh_o))))))))

First, determine how many orders you need to open when the condition

how it is calculated

count_orders_market_buy 
 
DanilaMactep:

I asked somewhere above, is it necessary to remove the check for a new bar in order for everything to be executed on ticks?

No, it does not. As you have done for the demo, so use it. Make sure that your EA properly sends trading orders and correctly responds to the server error codes.

Reason: