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

 
Hi everyone, please upload to the download if you have any indicators for mt 5 (channel indicator). i really need????
 
frank2020:
Hi everyone, please upload for download if you have any katala-type indicators for mt 5. i really need????

CodeBase to help: https://www.mql5.com/ru/search#!keyword=%D0%BA%D0%D0%B0D0%BD%D0%D0%BB%D1%8B&module=mql5_module_codebase.

 

I need the Expert Advisor to print in the log the size of the loss on all losing orders. I have written a loop in the body of the Start function but it turns out that the same data is printed in the journal several hundreds of times. I understand that the Start function body processes the loop anew with every tick and therefore we get infinite duplication of data. Please advise me how should it be done scientifically? Here is my code:

***

The final goal: if an order is closed by a stop-loss on a long trend, it will automatically open an order in the other direction. I know how to implement it, but the problem is that orders to the other side are opened hundreds of times. Thank you for your reply.

 
Petronet:

I need the Expert Advisor to print in the log the size of the loss on all losing orders. I have written a loop in the body of the Start function, but it turns out that the same data is printed in the journal several hundreds of times.

The final target is: if an order is closed by a stop loss on a long trend, it will automatically open an order in the other direction. I know how to implement it, but the problem is that orders to the other side are opened hundreds of times. Thank you for your feedback.

Size of loss on all losing orders

Print("Closed with a minus:", trade,"/", OrderProfit());

End goal: in case of closing an order at a stop loss

you need to look for the last losing order and you go through all losing orders

 
Petronet:


Pleaseinsert the code correctly: when editing a post, click on Code and paste your code in the pop-up window
MQL5.community - Памятка пользователя
MQL5.community - Памятка пользователя
  • www.mql5.com
Вы недавно зарегистрировались и у вас возникли вопросы: Как вставить картинку в сообщение на форуме, как красиво оформить исходный код MQL5, где находятся ваши Личные сообщения? В этой статье мы подготовили для вас несколько практических советов, которые помогут быстрее освоиться на сайте MQL5.community и позволят в полной мере воспользоваться доступными функциональными возможностями.
 
MakarFX:

Loss on all losing orders

Print("Closed with a minus:", trade,"/", OrderProfit());

End goal: in case of closing an order at a stop loss

you need to look for the last losing order and you go through all losing orders.

Makar, look more carefully...

the Start function body processes the loop anew with every tick and therefore we get infinite duplication of data. Please advise me how should it be done scientifically? Here is my code:

***

The final goal: if an order is closed by a stop-loss on a long trend, it will automatically open an order in the other direction. I know how to implement it, but the problem is that orders to the other side are opened hundreds of times. Thank you for your reply.

If you want to print only once, you better do it as a script. Worked out - fell off...

 
Alexey Viktorov:

Makar, pay attention...

If you only need to print once, it's better to do it as a script. Worked out - fell off...

The amount of loss on all losing orders

I must have got it wrong again

or the amount of loss for each losing order

or the summary loss on all losing orders...


If you need only a single print, you'd better do it as a script

You don't have to, you can do it like this

   for(int pos=0; pos<OrdersHistoryTotal();; pos++)
     {
      if(OrderSelect(pos, SELECT_BY_POS, MODE_HISTORY))
        {
         if((OrderSymbol()==_Symbol))
           {
            if(OrderCloseTime()>=TimeStart)
              {
               if(OrderProfit()<0) cnt+=OrderProfit()+OrderCommission()+OrderSwap();
               Print(cnt); TimeStart=TimeCurrent();
              }
           }
        }
     }
 

Good day!

Does MT5 allow me to comfortably group open positions for each instrument and each direction (BUY/SELL) to see the total position amount, total profit, average price and current unrealized profit

Of course, I would like it to be implemented as in a tree - under the "plus". You may close it if you want, and open it if you want.

 
MakarFX:

If you want to understand the code, go through all the logic of the EA, what it does and under what conditions.

I have made the entire EA very clear to you, even for beginners, if you do not understand it, ask.

If you want to get an EA written, you, as a "law-abiding citizen", should go here

please tell me if I understand correctly,

function://| Count open orders

int CountOrders() - is it necessary only for "start/stop" button?

 
законопослушный гражданин:

Please tell me if I understand correctly,

function://| Count open orders

int CountOrders() - is it needed only for operation of button "start/stop"?

Not only, check the opening condition of the first order, see where CountOrders() is spelled out.

Reason: