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

 
Igor Makanu:

MQL help is the same as other languages

and assumes you have at least some basic experience in writing simple codes

that's why the word "// placeholder" most people won't even test it and check it.

ushortfill_symbol='filler'// filler

That's about it.

 
awsomdino:

Does this mean that here and in cases like this, you can leave this field out?

like

(meaning how right it is to use it)

and the second parameter can be omitted.

No, that's not it.

there is such a thing as "the default value" - you should read about it in the help, where the term "function" is explained

but to use" the default value" is simple: if the help in the description of the function has a sign = , then this is the default value, and if you do not write anything yourself at this place, the compiler will use the value written in the help

string  IntegerToString(
   long    number,              // число
   int     str_len=0,           // длина строки на выходе
   ushort  fill_symbol=' '      // заполнитель
   )
 

@Igor Makanu

Thanks, a lot is clear now. Without initial knowledge it's hard to do everything

 
Artyom Trishkin:

A simple moving average with period 14, shift 0, calculated from Close prices on the daily chart of the current symbol. We take the value of the first bar (zero being the current day):

Is there any way to quickly get on the moving averages the price in the middle between the opening and closing with 0 shift, you mean the current bar? Or is it a tricky one, there are no ready-made variables for this function.

 

Good day to all.

When partially closing an order, the alert message "OrderClose (28800839, 0.01) error (method: CloseOrderPartial) - trade is not allowed in the expert properties" appears in the alert window.

However, a correct order part is in fact being closed and the EA is correctly performing both order opening and closing. I did not find such an error in the documentation and neither did the forums. The error translation says that 'the EA is not allowed to trade' but we can see that this is not actually the case and the EA is trading.

Maybe somebody has faced such a problem?

Method code for partial close

//Закрытие ордера на продажу
//NumberOrder = тикет ордера, 0 - закрытие всех ордеров
//ValueClose = объем закрытия ордера
bool CloseOrderSell(int NumberOrder, double ValueClose)
{
   if (NumberOrder == 0)
   {
      for (int i = OrdersTotal() - 1; i >= 0; i--)
         if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
         {
            if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderType() == OP_SELL)
            {
               if(OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, clrMaroon) == false)
               {
                  Print("Ошибка #" + (string)GetLastError() + " закрытия ордера на продажу #" + (string)OrderTicket());    
                  return false;       
               }
               else
               {
                  if (EnableMgs == true)
                     Print("Ордер на продажу #"+ (string)OrderTicket() +" закрыт на " + (string)ValueClose + " лота");
                  return true;            
               }         
            }      
         }
   }
   else
   {
      if (OrderSelect(NumberOrder, SELECT_BY_TICKET) == true)
      {
         ValueClose = NormalizeDouble(ValueClose * OrderLots(), 2);
         if(OrderClose(OrderTicket(), ValueClose, Ask, Slippage, clrMaroon) == false)
         {
            Print("Ошибка #" + (string)GetLastError() + " закрытия ордера на продажу #" + (string)OrderTicket());   
            return false;
         }
         else
         {
            if (EnableMgs == true)
               Print("Ордер на продажу #"+ (string)OrderTicket() +" закрыт на " + (string)ValueClose + " лота");
            return true;
         } 
      }
      else
         Print("Ошибка #" + (string)GetLastError() + " выбора ордера на продажу #" + (string)NumberOrder + " при закрытии ордера");
   }
   return false;
} 
Документация по MQL5: Константы, перечисления и структуры / Состояние окружения / Информация о запущенной MQL5-программе
Документация по MQL5: Константы, перечисления и структуры / Состояние окружения / Информация о запущенной MQL5-программе
  • www.mql5.com
Константы, перечисления и структуры / Состояние окружения / Информация о запущенной MQL5-программе - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Seric29:

Is there any way to quickly get the price in the middle between opening and closing with a 0 shift on slides, you mean the current bar? Or is it a tricky one, there are no ready-made variables for this function.

Are you using it for an owl or for an indicator?
they have different legs, you need different slides)

 
Medvedina:

Good day to all.

When partially closing an order, the alert "OrderClose (28800839, 0.01) error (method: CloseOrderPartial) - trade is not allowed in the expert properties" appears in the alert window.

I think the problem is not in the method but in the closing conditions.

What does it say in the log? Can you take a screenshot?

 
Taras Slobodyanik:

are you looking for an owl or a turkey?
they have different legs, need different glides)

Normal smoothed (there's also Exponential Smoothed Weighted Average and whatever else is out there). I need a simple maybe smoothed moving average, which will bluntly pass through the middle between opening and closing. I realized that there is no such thing, you have to do, because no one would think that a jerk like me would come along and use such simple things in very complicated situations, but it occurred to me to make such complex variables (Simle...).

...that don't know what they're calculating and just redraw the prices. I don't even know if large investors pay attention to averaging (e.g. 200,30,21,14,7). If I don't have one, I will do it later.

 
MakarFX:

I think the problem is not with the method, but with the closing conditions.

What does it say in the logbook? Can I have a screenshot?

Good afternoon.

Thank you for the thought. Indeed, I haven't noticed it but it is not my EA that gets warnings but another one that is working in parallel on the same pair. The strange thing is that the warnings for the second EA have only appeared while working in parallel.

 
Seric29:

A regular smoothed one (there's also Exponential Smoothed Weighted Average and whatever else is out there). I need a simple may be smoothed moving average, which stupidly would pass in the middle between opening and closing.

so yourself add up and divide - (MA1 + MA2 + MA3) / 3 = Average MA

If you count by the buffer, then iMAOnArray