Questions from Beginners MQL4 MT4 MetaTrader 4 - page 20

 
Vitalie Postolache:
Once again. OrderSelect must come first when working with an order. Then everything else.
Thanks for the reply ... Are you saying that the line if(OrderSelect(i=0;i<accTotal;i++)==true) is not written correctly or in the wrong code place?
 
bablusut:
Thanks for the reply ... Are you saying that the line if(OrderSelect(i=0;i<accTotal;i++)==true) is not written correctly, or in the wrong place in the code? ...
I've added details there.
 

Renat Akhtyamov:
по ссылке пройдите, она у Вас в посте выделена.

I've already looked at it. It doesn't have the necessary information. 10-digit value in the empty buffer and price value when there is a signal... How does mql4 code denote the absence or presence of a value in the buffer? (I've used it more than once, but forgot ...)

if( iCustom(NULL,t, "T...c",1,b) != .......).....

 

atik441:уже смотрел. нет там нужной информации .в пустом буфере 10и значное значение  а при наличии сигнала - значение цены... и как в коде mql4 обозначается отсутствие или наличие значения в буфере ? (пользовался не раз ,да забыл ...) 

if( iCustom(NULL,t, "T...c",1,b) != EMPTY_VALUE).....
 
Vitalie Postolache:
if( iCustom(NULL,t, "T...c",1,b) != EMPTY_VALUE).....What we need... Thanks for the reminder !
 

Help to understand. Is it possible to execute orders sequentially if two differently directed

open trades firstly triggers the TP of any of the trades, and then only SL, although in the process of trading the SL level

any of the trades was passed first?

 
ganri:

Help to understand. Is it possible to execute orders sequentially if two differently directed

open trades firstly triggers the TP of any of the trades, and then only SL, although in the process of trading the SL level

any of the trades was passed first?

analyse asc/bid
 
Vitalie Postolache:

Once again. OrderSelect must come first when working with an order. And then everything else.

If we are working in a loop of order evaluation, then the order of actions is

1. Checking if(OrderSelect())

2. Checking if it is the right order, we usually check for the symbol and magic number, and then check the type if(OrderSymbol()==_Symbol && OrderMagicNumber()==Magic && OrderType()<2) - in this case only market orders placed for the current symbol and with the specified magic number are processed

Processing of other data like OrderComment(), OrderProfit(), etc.

It would look something like this:

for(int i=OrdersHistoryTotal()-1; i>=0; i--) //перебираем историю торгов
{
      if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)) //если ордер выбран то работаем дальше, иначе смысла нет
      {
         if(OrderSymbol()==_Symbol && OrderMagicNumber()==Magic && OrderType()<2) //Если ордер тот, что нам нужен (эту проверку можно и опустить, если нужно обработать все ордера в истории)
         {
            if(StringFind(OrderComment(),"[tp]",0)>-1) //если найден признак закрытия профитом
            Print("Order #",OrderTicket()," profit: ", OrderTakeProfit());
            if(StringFind(OrderComment(),"[sl]",0)>-1) //если найден признак закрытия стоплосс
            Print("Order #",OrderTicket()," loss: "OrderTakeProfit());
         }
      }
}

Thank you for your reply ... So, to search for orders in the trading history, we use the functionOrdersHistoryTotal which, after discarding everything we don't need, looks like this

for(int i=OrdersHistoryTotal()-1; i>=0; i--) // - here is the question, what does "accTotal" meanin the function template, which we have discarded? and why did you take "i--" and not "i++" as in the template?
- The second functionOrderComment returns the comment of the selected order, if it is selected by the previous functionOrdersHistoryTotal, takes the form

if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)) //- where "i", this is "i>=0" from the previous function, and "SELECT_BY_TICKET" was replaced with "SELECT_BY_POS" and "MODE_HISTORY" was added- why?

- The third line is definition, we don't actually need to check the necessary order since we only have market orders closed by TP and SL in this history (we might have a closed pending order, but it will be rare), all other order parameters are not important to us. The only important thing is the amount of closed orders in the history will constantly increase, is it possible to make our recalculation take certain amount of the last orders, for example, 5-10, and not all of them?

- The last four lines are quite clear, the only question is about the PlaySound function, the code of which should be inserted after each"Print("..." line in thefollowing form:

bool PlaySound(

string // filename

);

... Or is it also converted somehow?

 
bablusut:

Read about loops, how they are limited and how they work, and in general, it would be nice to read a textbook on C++ for beginners, C++ is very similar to MQL, the only difference is in trading functions.

And you should also read MQL tutorial and help in compiler. The articles on forum are on the upper border of the window with blue background. You can't just retell and explain the whole course on the forum.

Учебник по MQL4
Учебник по MQL4
  • book.mql4.com
Учебник по MQL4
 
Vitalie Postolache:

Read about loops, how they are limited and how they work, and in general, it would be nice to read a textbook on C++ for beginners, C++ is very similar to MQL, the only difference is in trading functions.

And you should also read MQL tutorial and help in compiler. The articles on forum are on the upper border of the window with blue background. You can't just retell and explain the whole course on the forum.

Thank youVitalie Postolache for your help and advice, and it's too late for me to read all textbooks at my sixth birthday - I won't be able to study that much, I should have done it earlier but I didn't have time. I'm really boring you here, sorry, I won't bother you anymore.
Reason: