Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1572

 
   if(PositionGetInteger(POSITION_TYPE_BUY)) //в этих двух условиях мне нужно найти
               iq = iq1;

               else

   if(PositionGetInteger(POSITION_TYPE_SELL))
               iq = iq2;
      if (PositionsTotal()==iq)
      
     {
      int ord_total=OrdersTotal(); //это удаление ордеров
   if(ord_total > 0)
     {
      for(int i=ord_total-1;i>=0;i--)
        {
         ulong ticket=OrderGetTicket(i);
         if(OrderSelect(ticket) && OrderGetString(ORDER_SYMBOL)==Symbol())
           {
            CTrade *trade=new CTrade();
            trade.OrderDelete(ticket);
            delete trade;
           }
        }
     }
   }   

I have several positions of the same type at the same time (either long or short), their number is either iq1 or iq2. I get the error "'PositionGetInteger' - none of the overloads can be applied to the function"? Basically, I need to correctly define the type of any position at the moment and insert it into the condition

 
statist247 'PositionGetInteger' - none of the overloads can be applied to the function"? Basically, I need to correctly define the type of any position at the moment and insert it into the condition

Can you tell me in words what happens when this code is executed?

The clever engine of the forum has highlighted PositionGetInteger() in the description of which there is an answer to your question.

PositionGetInteger

The function returns the requested property of the open position, previously selected using the....................................... function.

Before "before" you should select this order, then determine its type and only then...................

 
statist247 'PositionGetInteger' - none of the overloads can be applied to the function"? Basically, I need to correctly define the type of any position at the moment and insert it into the condition

Can you comment on what is written in these lines?

   if(PositionGetInteger(POSITION_TYPE_BUY)) //в этих двух условиях мне нужно найти
               iq = iq1;

               else

   if(PositionGetInteger(POSITION_TYPE_SELL))
               iq = iq2;
 
You need to hold your finger for a couple of seconds on an empty field. A vertical dotted line will appear on the current bar. Move the chart to the left as needed. Single click on the empty field to reset the vertical line. The indentation will remain
 
What is the best way to implement multi-symbol trading functionality in an EA? I’ve considered using a 2D array or classes. Using classes and creating an object for each symbol pair seems like the better approach, but I’m currently facing memory handling issues. Should I focus on fixing these memory issues or explore a different approach?
 
Aleksandr Slavskii #:
MqlDateTime dtLast, dtCurr; datetime TimeCurr = TimeCurrent(dtCurr); datetime TimeDay = iTime(_Symbol, PERIOD_D1, 0); int Shift = iBarShift(_Symbol, PERIOD_M1, TimeDay); datetime TimeLast = iTime(_Symbol, PERIOD_M1, Shift); TimeToStruct(TimeLast, dtLast); if(dtCurr.hour * 60 + dtCurr.min >= dtLast.hour * 60 + dtLast.min) Print(" TimeCurrent", TimeCurrent(), "; TimeLast ", TimeLast);

Just got to the programme.

It works, but unstable, the problem with access to time different from the time on which the programme is installed.


I will try to replace it with SymbolInfoInteger(Sym_arr[i],SYMBOL_TIME) and compare it with the current time + 5 minutes.

Thanks for your time!

 

How to find out the value of an array from a structure?

struct aIND {
  double RSI;
  double CCI;
  double MACD;
};
aIND Ind[];
---
    {
      ...
      Ind[i].RSI=res;
    }
    Min=ArrayMinimum(Ind[].RSI); // ?
    //Min=ArrayMinimum(Ind_arr); это простой массив - работает
 
Vitaly Muzichenko #:

How to find out the value of an array from a structure?

Why aren't there arrays in the structure?

 
Aleksei Stepanenko #:
You need to hold your finger for a couple of seconds on an empty field. A vertical dotted line will appear on the current bar. Move the chart to the left as needed. Single click on the empty field to reset the vertical line. The indentation will remain
The vertical line does not appear.
Prices disappear on the right side and that's all.
 
Vitaly Muzichenko #:

How to find out the value of an array from a structure?

write your own int ArrayMininum(aIND &[])

or even

template <typename T> int ArrayMiniumu(T const&[],int (*Comapartor)(const T&,const T&))

because only the author of the code knows how exactly arbitrary structures should be compared