Questions from Beginners MQL5 MT5 MetaTrader 5 - page 825

 
Aleksey Rodionov:


Have you read the documentation? Instead of %G, the decimal point is used. That is, AccountInfoDouble(ACCOUNT_BALANCE) Accordingly, if this is removed, it will not be printed.
Документация по MQL5: Общие функции / PrintFormat
Документация по MQL5: Общие функции / PrintFormat
  • www.mql5.com
Количество, порядок и тип параметров должны точно соответствовать составу спецификаторов, в противном случае результат печати неопределён. Вместо функции PrintFormat() можно использовать функцию Если за строкой формата следуют еще параметры, то эта строка должна содержать спецификации формата, определяющие формат вывода этих параметров...
 

Good afternoon!

Help me solve this problem, or advise where it has already been solved: I open positions under different conditions - buy on conditions 1, 2, 3, sell on condition 4,5. How to write in code, so that BAY, open on condition 1 (buy1) is closed on condition 6, buy2 and buy3 on condition 7, sell4 on condition 8 and sell5 on condition 9? For some reason all baiys close at 7 and all sells at 9. I am struggling with this for the third day. I am in trouble for the third day. Thank you.

 
novichok2018:

Good afternoon!

Help me solve this problem, or advise where it has already been solved: I open a position under different conditions - buy on conditions 1, 2, 3, sell on condition 4,5. How to write in code, so that BAY, open on condition 1 (buy1) is closed on condition 6, buy2 and buy3 on condition 7, sell4 on condition 8 and sell5 on condition 9? For some reason, all baiys close at 7 and all sells at 9. I am struggling with this for the third day. Thank you.

For magic number 1 set magic number +1, for magic number 2 +2 and so on. That way you can then see if this position has been opened by condition 1 or by condition 2...

 
Vladimir Karputov:

Set magic number +1 for condition 1, magic number +2 for condition 2 and so on. That way you can then see if this position has been opened for condition 1 or for condition 2...

THANK YOU! So far everything is working out.

 
2018/02/08 00:25:21 Completed #69381 panFX
 
 
fxsaber:

Miracles. Just had your answer, now it's gone.

Please repeat the second option.

 
#include <MT4Orders.mqh>

int CountProfit( const string Symb, const long MagicNumber = 0 )
{
  int Count=0;
 
  for (int i = OrdersHistoryTotal() - 1; i >= 0; i--)
    if (OrderSelect(i ,SELECT_BY_POS, MODE_HISTORY) &&
        (OrderMagicNumber() == MagicNumber) &&
        (OrderType() <= OP_SELL) && (OrderSymbol() == Symb))
    {
      if (OrderProfit() < 0)
        break;
        
      Count++;
    }

 return(Count);
}

int CountProfit( const string Symb, const long MagicNumber = 0 )
{
  int Count=0;
  ulong Ticket;
 
  if (HistorySelect(0, LONG_MAX))
    for (int i = HistoryDealsTotal() - 1; i >= 0; i--)
      if ((bool)(Ticket = HistoryDealGetTicket(i)) &&
          (HistoryDealGetInteger(Ticket, DEAL_ENTRY) == DEAL_ENTRY_OUT) &&
          (HistoryDealGetInteger(Ticket, DEAL_MAGIC) == MagicNumber) &&
          (HistoryDealGetString(Ticket, DEAL_SYMBOL) == Symb))
      {
        if (HistoryDealGetDouble(Ticket, DEAL_PROFIT) < 0)
          break;
          
        Count++;
      }

 return(Count);
}
 
Comments not related to this topic have been moved to "Questions from MQL4 MT4 MetaTrader 4 beginners".
 
Vladimir Karputov:
Comments not relevant to this topic have been moved toMQL4 MT4 MetaTrader 4 Beginner's Questions.

Oh my! And who's going to answer me there if the last post was February 5? And #8284 is also kind of on MT4.