Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 402

 
Link_x:

Oops.

I meant OrderSelect.


Once again, while browsing through the pages of the tutorial, I came across a misunderstanding of how to use the OrderSelect() function. Decided to ask.
KimIV functions are difficult to grasp, but consider every detail (even though it's irrational).
Ooh, about the PC, TV, phone example - very good example. Now I've been thinking about the structure of my TV and I've come to the conclusion that I know very well how my TV is set up (it was three years ago when my parents caught me taking the TV apart that I first got access to the Internet).

Igor's code and logic is very easy to understand. A lot of unnecessary stuff for universality, but still. Show me what you do not understand and I will tell you.

OrderSelect() - selects the order. This is the first thing you should do when working with orders.

 
artmedia70:

Igor's code and logic is very easy to understand. A lot of unnecessary stuff for universality, but still. Show me what you don't understand and I will tell you.

OrderSelect() - selects the order. This is the first thing to do when working with orders.



That's great! "Here we go!" :)

"Brick number one".
My idea of the meanings of the components:
int GetTypeLastClosePos(string sy="", int mn=-1) {                            // Обозначение пользовательской функции, строковой переменной, а так же числовой переменной.
  datetime t;                                                                 // Установление переменной, связанной со временем. 
  int      i, k=OrdersHistoryTotal(), r=-1;                                   // Обозначение числовой переменной, переменной, использующей исторические все данные, утверждение значения r.
  if (sy=="0") sy=Symbol();                                                   //  Если строковая переменная равняется "0", то она имеет случайное значение.
  for (i=0; i<k; i++) {                                                       // Начало  выяснения типа позиции, при обстоятельствах: i < K, а так будет всегда.
   if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) {                         // Поиск ордера из истории закрытых ордеров с "билетом" i, точным номером позиции. Если ордер найден, то
      if ((OrderSymbol()==sy || sy=="") && (mn<0 || OrderMagicNumber()==mn)){ // задается инструмент, по которому был открыт ордер как sy и его уникальный номер как mn. Это еще не все.
        if (OrderType()==OP_BUY || OrderType()==OP_SELL) {                    // Тип ордера определяется как покупка или продажа заданного значения sy инструмента.
          if (t<OrderCloseTime()) {                                           // Если время закрытия ордера определено, тогда определяются две переменные:
            t=OrderCloseTime();                                               // переменная t в качестве  времени закрытия идентифицированного ордера,
            r=OrderType();                                                    //  переменная r в качестве типа определенного ордера.
          }                                                                   //  Хватит.
        }                                                                     // Достаточно.
      }                                                                       // Полно, я доволен!
    }                                                                         // Остановись!
  }                                                                           // Стой, ****!
  return(r);                                                                  // Остановка дейст вия функции с выводом значения переменной r.
}                                                                             // Конец. 
.
In this code, I couldn't find a variable giving the value of the type of the last, closed order.

It's clear to me how to do the parsing of functions of Igor, who is revered in local circles.
May I place my understanding of these components, and you, as intelligent programmers, will correct my understanding of these functions? ><
 
artmedia70:

Igor 1 has very accessible code and logic. A lot of 2 - unnecessary for universality, but still. Show me what you 3 - don't understand there, and I'll tell you.

4 - OrderSelect() - selects an order. This is the first thing to do when working with orders.


Point by point answer, sorry.
1 - programming genius?
2 - to be fair, nothing is superfluous except feces and other decay products (frank opinion, ready to start debating, but in another thread :) ).
3 - it all makes sense now. :)
4 - so true. I know. I got a bit "wrong" and typed with the "OrderSend" function.

Thank you for contributing to the "Function-Brick parsing" template. :)
 
Sepulca:


Yes to the broker of course)))

The terminal doesn't care.... Will give you the last known data...


There are only four functions to the server. Opening, modifying and closing (deleting) an order
 
Link_x:
Point by point answer, sorry.
1 - programming genius?
2 - to be fair, nothing is superfluous except feces and other decay products (frank opinion, ready to start debating, but in another thread :) ).
3 - it all makes sense now. :)
4 - so true. I know. I got a bit "wrong" and typed with the "OrderSend" function.

Thank you for contributing to the "Function-Brick parsing" template. :)

First of all we have to get acquainted with the concept - function. And then you can move on to the question of what they do and how to use them.
 
To recap!
Before you think about your inability to understand the code, you should "try to take the TV apart".
О-у, насчет примера с ПК, телевизором, телефоном - очень хороший пример. 
Сейчас порассуждал о строении своего телевизора и пришел к выводу, 
что хорошо знаю, как устроен мой телевизор (года три назад "горел желанием" его разобрать, 
именно в тот момент, когда мои родители застали меня за разбиранием телевизора, 
я впервые получил доступ в интернет). 
 
Link_x:

Perfect! "Here we go! :)

"Brick number one".
My representation of the constituent values:
.
In this code, I couldn't find the variable giving the value of the type of the last, closed order.

It's clear to me how to make the analysis of functions of Igor, who is revered in this circles.
May I post my understanding of these components, and you, as intelligent programmers, correct my understanding of these functions? ><

The order type in the variable r. In the last operator, the value of this variable is assigned to the function itself, which means you don't need this variable in principle. The type of the last closed order is the value of the function, for example, you can see this value, if you display it on the screen using the Comment() operator

Comment("Typ=",GetTypeLastClosePos("", -1);

or in the journal using the Print() operator

Print("Typ=",GetTypeLastClosePos("", -1);
 
evillive:

Replace MA variables with indicator variables in EA code (all three sets):

then replace the MA call lines with the J2JMA call:


evillive, tried replacing as you said, but apparently even this requires more knowledge, compiling gives "53 error(s), 18 warning(s)", result attached. evillive, can i ask you to do these replacements if you have time.
 
khorosh:

The order type in the variable r. In the last statement, the value of this variable is assigned to the function itself, which means you don't need this variable in principle. The type of the last closed order is the value of the function, for example, you can see this value, if you display it on the screen using the Comment() operator

or into the journal using the Print() operator


Here's an example of a practical use of a custom function:
GetTypeLastClosePos

.
Thank you.
So you have to apply the name of the function to use it, and the variable "r" itself is set to determine the value of that function!
Here's a little discovery for me! ^^
Thanks again, Yuri. :)


For the final clarification, this is possible:

if(GetTypeLastClosePos == OP_BUY)
?


 
Link_x:

And if you are going to take the function apart, you should not have cut off the function's header, there is important information there.

Returns the type of the last position opened or -1 - this means that if there are no closed positions, then when the function is called, its value will be equal to -1

sy - name of the instrument (currency pair)

mn - magic number. If we set -1, the function will return the type of the last closed order no matter what magic number

//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 19.02.2008                                                     |
//|  Описание : Возвращает тип последней открытой позиции или -1               |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    sy - наименование инструмента   (""   - любой символ,                   |
//|                                     NULL - текущий символ)                 |
//|    mn - MagicNumber                (-1   - любой магик)                    |
//+----------------------------------------------------------------------------+