Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1490

 
JRandomTrader #:

And take into account that an order can generate several deals.

So either to pre-select for each order its deals, or to create an array/list (by the number of orders) of structures and fill them by searching deals.

Why complicate your life? If you need to calculate the profit for a certain period, and in the source code this is what is done, then just go through the deals for this period. The IN deal has or may have a commission, the OUT deal may have a swap and profit in addition to the commission. Thus, having summarised everything, we got the desired result.

Another thing is if the task is to collect the profit for each position ID separately into an array.

 
Good day, there was a signal with an open order which was waiting for its movement but the admin sent it to the archive due to inactive trading as he claims...please tell me how to take it out of there now.... thanks.
 

Guys, help me. Earlier, when clicking on the mouse wheel, the cursor crosshair mode was activated in the terminal and MT4 and MT5. Now it has disappeared. How is it customised?

p.s. I have never put any mouse drivers, everything worked automatically....

 
Alexander Mostovnek #:

Guys, help me. Earlier, when clicking on the mouse wheel, the cursor crosshair mode was activated in the terminal and MT4 and MT5. Now it has disappeared. How is it set up?

p.s. I have never put any mouse drivers, everything worked automatically....

It's not gone, it's just less responsive...

I even sinfully thought that the mouse is broken and the button is not being pressed once and twice

 
Maxim Kuznetsov #:

it's not gone, it's just less responsive.

I even thought that the mouse was broken and that the button was slipping.

I don't know. I've tested it many times and it's very responsive. No delays. It's never shown up once.


 
It's become that the wheel pressing is dead..... :)
 

- Doctor, I have a pain here, and here, and here.

- Your finger is broken.)

 
double MinOpenBuy(int a = 1)
   {
   ulong tick = 0;
   datetime time = 0;
   double result=0,lot=0,profit=0,openprice=0,
          NewPrice, OldPrice = DBL_MAX;
   for(int i=OrdersTotal(); i>=0; i--)
   {
      if (a_position.SelectByIndex(i))
      {
         if (a_position.Symbol() == a_symbol.Name() && a_position.Magic() == Magic && a_position.PositionType() == POSITION_TYPE_BUY)
         {
            NewPrice = a_position.PriceOpen();
            if ( NewPrice < OldPrice)
            {
               OldPrice = NewPrice;
               profit = NormalizeDouble(a_position.Commission()+a_position.Swap()+a_position.Profit(),2);
               lot = a_position.Volume(); 
               time = POSITION_TIME; 
               tick = a_position.Ticket(); 
            }
         }
      }
   }
   if(a==1) 
	{result = OldPrice;} else
   if(a==2) 
	{result = profit;} else
   if(a==3) 
	{result = lot;} else
   if(a==4) 
	{result=(double)time;}else
   if(a==5) 
	{result=(double)tick;}else
   {result=0;}
   return(result);
  }
Good day.
Happy Holidays to all.
I need help from professionals.
I wrote this code in MQL4 to search for the order with the lowest opening price and get its data
Now I'm trying to transfer everything to MQL5, but for some reason it doesn't work(
What is the error?
 
Maksim Burov #:
for(int i=OrdersTotal(); i>=0; i--)

I didn't go into the essence of the code, but what immediately caught my eye was the incorrectly set number of orders to be searched. It should be like this:

for(int i=OrdersTotal() - 1; i>=0; i--)

And also in the loop you are looping through orders, but you are looking for position properties. This is also incorrect. I assume that most likely you need to loop through positions:

for(int i=PositionsTotal() - 1; i>=0; i--)

Regards, Vladimir.

 
MrBrooklin #:

I did not go into the essence of the code, but what immediately caught my eye was the incorrectly set number of orders to be searched. It should be like this:

And also in the loop you are looping through orders, but you are looking for position properties. This is also incorrect. I assume that most likely you need to loop through positions:

Regards, Vladimir.

Thank you very much.
I haven't tested all of them yet, but some of them are already working correctly.

Reason: