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

 
Mihail Matkovskij #:

Explaining. "Calling yourself an expert" means that you know what I don't know. I wondered if I'd really missed something and you'd added to my message. But alas, you didn't say anything new. And it wasn't you who "called yourself an expert in plain language"!

"Chevoi"?! Not only do you allow yourself to address everyone in a familiar manner. You call everyone "you", and you allow yourself to call the person you are talking to by a name other than their full name, without knowing them personally. You also write nonsense like that to me. Rostik (I'm addressing you the same way), who brought you up? Don't you think it's too much?!...

It's you who's having a seizure judging by the posts above... I just resent your upbringing! I thought you had some sense.

I didn't call myself an expert, much less write that I know something you don't know!

I'm not an expert in the field and my relation to MQL4 is amateurish.

Regarding the familiarity, maybe I'm wrong, but given the lack of complaints and my age nothing can change.

As for the huffing, you've already started a lot of clarifications in this thread.

 
Порт-моне тв #:

HOW? Like the three EMAs? I haven't seen that before.

As an example:

         Label1Buffer[i]=iMA(Symbol_1,_Period,1,0,MODE_SMA,PRICE_CLOSE,i);
         Label2Buffer[i]=iMA(Symbol_2,_Period,1,0,MODE_SMA,PRICE_CLOSE,i);
         Label3Buffer[i]=iMA(Symbol_3,_Period,1,0,MODE_SMA,PRICE_CLOSE,i);
         Label4Buffer[i]=(Label1Buffer[i]+Label2Buffer[i]+Label3Buffer[i])/3;
 

Tretyakov Rostyslav #:

As for the familiarity, I may be wrong, but given the lack of complaints and my age, nothing can change.

Well personally, I didn't complain as I don't suffer from megalomania. You can call me "you" if you want. But think about how it looks from the outside... I called you "you" from the beginning until I realized it was useless... I don't think anyone else cares how you address them either. Just like you don't care about your culture of communication...

As for theseizure, you have already started to identify relationships in this thread many times.

If I want to have an argument with someone, it won't be here, not on this site and not on this forum! Here I`m communicating only on the questions of programming and trading. I've already said that many times. Come to think of it, who is figuring things out? What kind of "attacks" are these? Is it instead of arguments on MQL?!
 
Mihail Matkovskij #:



Nadobranch. Don't be unhappy.
 
Good afternoon, I am still interested in the community's opinion on my question in the separate thread next to me. Is it true that the MT4 tester does not work because it does not calculate profits correctly?
 

Good afternoon!!!!

Interested in your opinion on the following question:

Here are parts of the grid EA code

//+----------------------------------------------------------------------------+
//| Калькуляция сетки ордеров                                                  |
//+----------------------------------------------------------------------------+
double CalculiteProfit()
  {
   double oProfit = 0;
   for(int i = OrdersTotal()-1; i>=0; i--)
     {
      if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
        {
         if(OrderSymbol() == Symbol() && OrderMagicNumber() == Magic)
           {
            if(OrderType() == OP_BUY || OrderType() == OP_SELL)
              {
               oProfit += OrderProfit();
              }
           }
        }
     }
   return(oProfit + GetOrderSwap() + GetOrderCommission());
  }
//-------------------------------------------------------------------+  Команда на закрытие сетки ордеров
   if((CountTrade(0) > 1 && CalculiteProfit() >= 0 && OrderGroupCloseSignal()==0)||(CountTrade(1) > 1 && CalculiteProfit() >= 0 && OrderGroupCloseSignal()==1))
     {
      ClosseAll();
     }
//+----------------------------------------------------------------------------+
//| Закрытие сетки ордеров при заданной команде                                |
//+----------------------------------------------------------------------------+
void ClosseAll()
  {
   for(int i = OrdersTotal()-1; i>=0; i--)
     {
      if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
        {
         if(OrderSymbol() == Symbol() && OrderMagicNumber() == Magic)
           {
            if(OrderType() == OP_BUY)
              {
               if(!OrderClose(OrderTicket(), OrderLots(), Bid, slip))
                  Print("Не удалось закрыть ордера на покупку!");
              }
            if(OrderType() == OP_SELL)
              {
               if(!OrderClose(OrderTicket(), OrderLots(), Ask, slip))
                  Print("Не удалось закрыть ордер на продажу!");
              }
           }
        }
     }
  }

The logic of these pieces of code is opening a grid of orders, the orders are not principally averaged in the broker's terminal, the averaging is done on a user's computer.

There is a constant calculation of the open grid of orders if the profit of the whole grid of orders is greater than zero and there is a certain signal from the indicator, the whole grid of orders closes.

The Expert Advisor works flawlessly on a demo account, and works flawlessly in the real account tester, but on a real account, miracles happen: all of the grid closes only those orders that have a profit. There are no errors in the log.

The question is whether someone has faced with such a situation in what the incorrectness of the code or in the kitchen of the broker????

 
EVGENII SHELIPOV #:

The question is whether anyone has encountered such a situation in what is the issue of incorrect code or in the broker's kitchen????

Keep track of not only the closing error but which orders were selected to close, it will become clearer where the bug is.

 
EVGENII SHELIPOV #:

Good afternoon!!!!


Post the code for OnTick()
 
EVGENII SHELIPOV real account tester, but on the real account miracles happen: only orders with profit are closed out of the whole grid.
//+----------------------------------------------------------------------------+
//| Закрытие сетки ордеров при заданной команде                                |
//+----------------------------------------------------------------------------+
void ClosseAll()
  {
   for(int i = OrdersTotal()-1; i>=0; i--)
     {
      if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
        {
         if(OrderSymbol() == Symbol() && OrderMagicNumber() == Magic)
           {
            if(OrderType() == OP_BUY)
              {
               if(!OrderClose(OrderTicket(), OrderLots(), Bid, slip))
                  Print("Не удалось закрыть ордера на покупку!");
              }
            if(OrderType() == OP_SELL)
              {
               if(!OrderClose(OrderTicket(), OrderLots(), Ask, slip))
                  Print("Не удалось закрыть ордер на продажу!");
              }
           }
        }
     }
  }

We can see in the code that orders are closed by the symbol and by a bridge. But we don't see any profit being taken into account. What prevents losing positions from closing? Probably better to ask the broker.

 
Mihail Matkovskij #:

In the code, you can see that orders are closed by the symbol and by the meigic. But no profit is taken into account. What prevents unprofitable positions from closing...? Probably, it is better to ask the broker.

What do you think, if I add profit calculation condition > 0 to the function of closing all orders, will it change?

I have this condition in my command to close orders

Reason: