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

 
Artyom Trishkin #:
And how easy it is to put together an array and sort by the right criterion. But for 100500 pages we've been crutching at our heels.
Please show me an example in code. I don't know how to stack in an array and then sort as well.
 
Alexey Viktorov #:
After all, it's easier and quicker to check than to wait for an answer from someone else...

My mql skills are too small) I can certainly try, but it will take me a lot of time) so it's better to find out in advance if it's possible than to spend a lot of time and find out that it can't be done)
when I have more free time, it will certainly be easier to try it myself, but for now I would rather ask more experienced people if it can be done.

 
Scarick #:

My mql skills are too small) i can certainly try, but it will take me a lot of time) so it's better to find out beforehand if it is possible to do something, than to spend a lot of time and find out that it cannot be done)
when i have more free time, it will certainly be easier to try, but for now i would rather ask more experienced people if it can be done.

If your skills are not too great, but your logical thinking is working, what can be understood from this question?

Forum on trading, automated trading systems and testing trading strategies.

Any questions from beginners on MQL4 and MQL5, help and discussion on algorithms and codes

Scarick, 2021.11.06 17:01

In other words, if I sign 5 symbols in an indicator, I can work with all 5 symbols through one OnBookEvent()? The only important thing is to filter by which character the change occurred?

then the most reliable thing to do is to check, not wait for a positive answer from someone else. That's why I answered as I did.
 
MakarFX #:
Please show me an example in code. I don't know how to stack in an array and then sort as well.

Look herehttp://www.mql5.com/ru/articles/1404 No sorting there, but stack in an array.

Управление ордерами – это просто
Управление ордерами – это просто
  • www.mql5.com
Статья описывает разнообразные способы контроля открытых позиций и отложенных ордеров и призвана облегчить написание экспертов.
 
MakarFX #:
Show me an example in code, please. I don't know how to stack into an array and then also sort.

bool BubleSort(struct &arr[])

{

for(int i = ArraySize(arr)-1;i>=0;i--)
for(int j = i-1;j>=0;j--) {

if (Compare(arr[i],arr[j])<0 ) Swap(arr[i],arr[j]);

}

}

screw you - go to school... such micro-algorithms are written from memory with one eye closed.

seriously : take an algorithmic course or something...

 
Alexey Viktorov #:

In your case, if skills are not great but logical thinking works, as can be deduced from this question

then the most reliable thing to do is to check rather than wait for a positive answer from someone else. That's why I answered as I did.
Yeah already figured out how to try it with less work. But you can't check it through a tester. I have to wait for working days. But you could have answered directly) I am not asking you to write the code for me, I just asked a question.
 

Maxim Kuznetsov #:

fuck you - go to school... such micro-algorithms are written from memory and drunkenly, with one eye squeezed shut

Seriously, take an algorithmic course or something.

Interesting way of speaking... you shouldn't have bothered

 
MakarFX #:

Interesting way of speaking... you shouldn't have bothered

Normal manner - you are given a sorting algorithm. All right, normal buble-sorting. No one was straining.

And the normal message is really - read about algorithms

Read the literature already.

 

Good day gentlemen programmers!!!!

I will try once again to ask my question, but I have rephrased it a bit.

In a grid EA, we need to find the ticket of the penultimate order. The solution -1 from the ticket of the maximum order does not work in the strategy tester, maybe, but it will not work on a demo or real account, I attached a picture, it will be clear why.

I have written the code for the function that determines the next to last order ticket. This logic is as follows: if we look through all open orders in the grid, we will find the maximal one following it and it will be the necessary order ticket.

However, my programming level is not high enough and there is some error in the code. The result of this function is the minimum ticket. These two functions max ticket and penultimate ticket. The function defining max ticket works without problems.

//+----------------------------------------------------------------------------+
//| Расчет тикета предпоследнего ордера в сетке                                |
//+----------------------------------------------------------------------------+
int GetTicketPenultimateOrder()
  {
   penultimate_ticket = 0;
     {
      for(int cnt = OrdersTotal() - 1; cnt >= 0; cnt--)
        {
         if(OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES))
           {
            if(OrderSymbol() == Symbol() && OrderMagicNumber() == Magic)
              {
               if(OrderType() == OP_BUY || OrderType() == OP_SELL)
                 {
                  if(OrderTicket() > penultimate_ticket && penultimate_ticket != GetTicketMaxOrder())
                     penultimate_ticket = OrderTicket();
                 }
              }
           }
        }
     }
   return(penultimate_ticket);
  }
//+----------------------------------------------------------------------------+
//| Расчет тикета максимального ордера в сетке                                 |
//+----------------------------------------------------------------------------+
int GetTicketMaxOrder()
  {
   max_ticket = 0;
     {
      for(int cnt = OrdersTotal() - 1; cnt >= 0; cnt--)
        {
         if(OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES))
           {
            if(OrderSymbol() == Symbol() && OrderMagicNumber() == Magic)
              {
               if(OrderType() == OP_BUY || OrderType() == OP_SELL)
                 {
                  if(OrderTicket() > max_ticket)
                     max_ticket = OrderTicket();
                 }
              }
           }
        }
     }
   return(max_ticket);
  }

Please advise what the error is. Thank you.

 
Scarick #:
Yes, I have already figured out how to try with less effort. But I cannot verify it with a tester. I have to wait for working days. But you could answer directly) I'm not asking to write the code for me, I just asked a question.

There you go... I didn't mean to offend you. What difference would a positive answer make? After all, you have to write and check only during working hours.

Reason: