Learning and writing together in MQL5 - page 38

 

I found this to be a natural declaration, but the compiler is swearing. It warns in the following way

'Type' - undeclared identifier orderni.mq5 213 18

'Type' - some operator expected ordernir.mq5 213 18

'POSITION_TYPE' - expression has no effect ordernir.mq5 213 4

I'm not an expert in English, but it's not clear either way. Efficiency of expression... ???? Yes and what's the point?

 
Dimka-novitsek:

I found this to be a natural declaration, but the compiler is swearing. It is cursed in the following way

'Type' - undeclared identifier ordernir.mq5 213 18

'Type' - some operator expected ordernii.mq5 213 18

POSITION_TYPE' - expression has no effect ordernir.mq5 213 4

I'm not an expert of English, but I don't understand it anyway.

POSITION_TYPE is just an identifier. Look at what type this identifier is.
 

THANK YOU!!! I'll have a look.

Super!!! It's an int!!!

 
Dimka-novitsek:

'POSITION_TYPE' - expression has no effect orderni.mq5 213 4

Translation: "expression has no effect".
 
Dimka-novitsek:

I found this to be a natural declaration, but the compiler is swearing. It was cursed in the following way

'Type' - undeclared identifier orderni.mq5 213 18

'Type' - some operator expected ordernir.mq5 213 18

'POSITION_TYPE' - expression has no effect ordernir.mq5 213 4

I'm not an expert in English, but it's not clear either way.

ENUM_POSITION_TYPE Type
 
notused:

Great!!! It doesn't swear like that, it swears differently already!
 
'PositionGetInteger' - no one of the overloads can be applied to the function call order.mq5 214 13 In short, not the function, but the call. Or rather what I feed into it.
bool  PositionGetInteger(
   ENUM_POSITION_PROPERTY_INTEGER  property_id,     // идентификатор свойства
   long&                           long_var         // сюда примем значение свойства
   );
I have
Bull =PositionGetInteger(POSITION_TYPE,Type);
????????????
 
Dimka-novitsek:

THANK YOU!!! I'll have a look.

Super!!! It's an int!!!

No, it's not int. You look in the Reference book to see what type corresponds to the specified identifier.
 
Dimka-novitsek:
'PositionGetInteger' - no one of the overloads can be applied to the function call order.mq5 214 13 In short, it's not the function but the call. Or rather what I feed into it.

You still don't read the documentation. You don't even try to copy it.

What's that got to do with it? Can't find it? It doesn't work?

//--- будем искать позицию по символу графика, на котором работает эксперт
   string symbol=Symbol();
//--- попробуем получить позицию
   bool selected=PositionSelect(symbol);
   if(selected) // если позиция выбрана
     {
      long pos_id            =PositionGetInteger(POSITION_IDENTIFIER);
      double price           =PositionGetDouble(POSITION_PRICE_OPEN);
      ENUM_POSITION_TYPE type=(ENUM_POSITION_TYPE)PositionGetInteger(POSITION_TYPE);
      long pos_magic         =PositionGetInteger(POSITION_MAGIC);
      string comment         =PositionGetString(POSITION_COMMENT);
      PrintFormat("Позиция #%d по %s: POSITION_MAGIC=%d, цена=%G, тип=%s, комментарий=%s",
                  pos_id, symbol, pos_magic, price,EnumToString(type), comment);
     }
   else        // если выбрать позицию не удалось
     {
      PrintFormat("Не удалось выбрать позицию по символу %s. Ошибка",symbol,GetLastError());
     }
  }

https://www.mql5.com/ru/articles/211

Ордерa, позиции и сделки в MetaTrader 5
Ордерa, позиции и сделки в MetaTrader 5
  • 2011.01.05
  • MetaQuotes Software Corp.
  • www.mql5.com
Надежный торговый робот не может быть создан без понимания механизмов работы торговой системы MetaTrader 5. Клиентский терминал получает от торгового сервера информацию о позициях, ордерах и сделках. Чтобы правильно обработать эти данные средствами MQL5 необходимо хорошо представлять как происходит взаимодействие mql5-программы и среды исполнения терминала.
 
Dimka-novitsek:
'PositionGetInteger' - no one of the overloads can be applied to the function call order.mq5 214 13 In short, not the function, but the call. Or rather what I feed into it. I have ????????????

ENUM_POSITION_TYPE Type=(ENUM_POSITION_TYPE)PositionGetInteger(POSITION_TYPE);