Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1272

 
Alexey Viktorov:

Depends on what the purpose of catching the update is. How about just overfilling the array?

What does it matter what the purpose is? The question is why such an obvious event is so hard to catch, given that there's an awful lot of other less used and needed properties. In this case, the goal is notification (alert).

 
leonerd:

What difference does it make what the target is? The question is why such an obvious event is so hard to catch, even though there are a lot of other less used and needed properties. In this case, the goal is notification (alert).

So it's this obvious event that's highlighted in the transaction type. Try Trishkin's library in 58 articles. Maybe it has a simple option.

 
в 58 ми статьях

Well thank you ))

I suspect he keeps his register the same way.

Изменение открытого ордера. К данным изменениям относятся не только явные изменения со стороны клиентского терминала или торгового сервера, но также и изменение его состояния при выставлении (например, переход из состояния ORDER_STATE_STARTED toORDER_STATE_PLACED or fromORDER_STATE_PLACED toORDER_STATE_PARTIAL, etc.).


It would be enough for me to know that this is not the first ORDER_STATE_PLACED on a particular order ticket.

It turns out that two TRADE_TRANSACTION_ORDER_UPDATE come when the first order is placed. Here, and the third one would already fit me as a change, which in my case is only a price change. Or the secondORDER_STATE_PLACED.

Документация по MQL5: Константы, перечисления и структуры / Торговые константы / Свойства ордеров
Документация по MQL5: Константы, перечисления и структуры / Торговые константы / Свойства ордеров
  • www.mql5.com
Приказы на проведение торговых операций оформляются ордерами. Каждый ордер имеет множество свойств для чтения, информацию по ним можно получать с помощью функций Идентификатор позиции, который ставится на ордере при его исполнении. Каждый исполненный ордер порождает сделку, которая открывает новую или изменяет уже существующую позицию...
 
You should also checkORDER_TIME_SETUP. Is it new every time?
 
Followed the MT4 example "STRINGS: ASCII CHARACTERS TABLE AND USE"

//+------------------------------------------------------------------+
//| StringLowerCase |
//+------------------------------------------------------------------+
string StringLowerCase(string str)
  {
   string s = str;
   int lenght = StringLen(str) - 1, symbol;
   while(lenght >= 0)
     {
      symbol = StringGetChar(s, lenght);
      if((symbol > 64 && symbol < 91) || (symbol > 191 && symbol < 224))
         s = StringSetChar(s, lenght, symbol + 32);// тут possible loss of data due to type conversion
      else
         if(symbol > -65 && symbol < -32)
            s = StringSetChar(s, lenght, symbol + 288);// тут possible loss of data due to type conversion
      lenght--;
     }
   return(s);
  }
//+------------------------------------------------------------------+
//| StringUpperCase |
//+------------------------------------------------------------------+
string StringUpperCase(string str)
  {
   string s = str;
   int lenght = StringLen(str) - 1, symbol;
   while(lenght >= 0)
     {
      symbol = StringGetChar(s, lenght);
      if((symbol > 96 && symbol < 123) || (symbol > 223 && symbol < 256))
         s = StringSetChar(s, lenght, symbol - 32);// тут possible loss of data due to type conversion
      else
         if(symbol > -33 && symbol < 0)
            s = StringSetChar(s, lenght, symbol + 224);// тут possible loss of data due to type conversion
      lenght--;
     }
   return(s);
  }

If you don't mind, please help me fix it...
Документация по MQL5: Основы языка / Типы данных / Приведение типов
Документация по MQL5: Основы языка / Типы данных / Приведение типов
  • www.mql5.com
Приведение типов - Типы данных - Основы языка - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
SGarnov:
I did the example from MT4 "STRINGS: ASCII CHARACTERS TABLE AND HIS USE"


If you don't mind, please help me fix it...

StringSetChart() bool returns a bool. And you're assigning it to a string variable... If that's the question.

 
Custom symbols can be created without using the MT5 menu, just by putting the right files in the right folders?
 

Hello. I've written a function that checks the conditions for entering a position.

The problem is that if the condition (highlighted in yellow) is not met - the function does not terminate but moves on to the next condition. Thus, the signal does not work correctly.

What should be done to make the function stop working when one of the conditions is not met - immediately after the incorrect condition?

bool BuySignal_new()
{
   double Sig_Up[];                 // динамический массив для хранения значений индикатора на покупку для каждого бара
   double Sig_Down[];               // динамический массив для хранения значений индикатора на продажу для каждого бара
   ArraySetAsSeries (Sig_Up,true);   // устанавливаем индексацию как в таймсерии ( т.е. 5,4,3,2,1,0) в динамич. массиве для индикатора
   ArraySetAsSeries (Sig_Down,true); // устанавливаем индексацию как в таймсерии ( т.е. 5,4,3,2,1,0) в динамич. массиве для индикатора
   ResetLastError();
   double close = NormalizeDouble(iClose(_Symbol,_Period,1),Digits());
   double close_1 = NormalizeDouble(iClose(_Symbol,_Period,0),Digits());
   double Bid=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_BID),Digits());
if(CopyBuffer(Handle_stepma_line,0,1,5,Sig_Up)==5 && CopyBuffer(Handle_stepma_line,1,1,4,Sig_Down)==4 )
  {
   Print("Данные скопированы. Ошибок нет.");
   
  } 
else
    {
     Print("Ошибка копирования. Нет данных");
     return(false);
    }

if (Sig_Up[1] < Sig_Down[1] && Sig_Up[0] > Sig_Down[0])
  {
   Print("условие 1 - ок");
  }
else
    {
    Print("условие 1 НЕ выполненно");
    return(false);
    }
if (close < Sig_Up[1]&& Bid > Sig_Up[0])
  { 
   Print ("условие 2 - ок");
   return(true);
  }   
else
    {
    Print("условие 2 НЕ выполненно");
    return(false);
    }   
 
Sergey:

What should be done, so that if one of the function conditions is not fulfilled - the whole function will terminate, immediately after the incorrect condition?

Remove branching by else, you can try it that way:

   if(CopyBuffer(Handle_stepma_line, 0, 1, 5, Sig_Up) != 5)
   {
      Print("Ошибка копирования. Нет данных");
      return(false);
   }

   if(CopyBuffer(Handle_stepma_line, 1, 1, 4, Sig_Down) != 4)
   {
      Print("Ошибка копирования. Нет данных");
      return(false);
   }


   if(!(Sig_Up[1] < Sig_Down[1] && Sig_Up[0] > Sig_Down[0]))
   {
      Print("условие 1 НЕ выполненно");
      return(false);
   }

   if (!(close < Sig_Up[1] && Bid > Sig_Up[0]))
   {
      Print("условие 2 НЕ выполненно");
      return(false);
   }
//--- если дошли сюда, то все условия выполнены
   return(true);
 
Igor Makanu:

remove the branching by the other, you can try it that way:

Thanks, I'll give it a try.

Reason: