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

 
A variable, not a quote. There is a count in a string variable, and the double is converted to a string variable with the specified accuracy. This is of course strong.
 
By the way, this is on the subject of a quote in five digits coming in with more than five decimal places. I wanted to do an automatic check, turns out it's not that easy in this language. In the meantime, I checked it manually with a printer. There are no more than five decimal places, how often does that happen? Maybe it was on terminal 4?
 
OK, there's a systematic ignoring of messages. We should start a thread again.
 
pribludilsa #:
Okay, there's a systematic ignoring of messages. We should start a thread again.

there have already been topics on this subject. Into a string and the number of strings to count. You really have to count the number of digits before the decimal point first. You can convert it to an integer. And it's just as awkward to string))))

 
Alexey Viktorov #:

In the mt4 tester it is not possible to open orders on other pairs, everything else is available without problems.

Thank you, it is indeed possible to get indicator values from another instrument in the tester.
Alexander #:

Check the availability of quotes on AUDUSD, on the correct TF

That was exactly the problem. The matter is that I was testing on a day off (Sunday) and "downloaded" a quote archive for the required symbol (AUDUSD), but it turned out that they just couldn't be downloaded on the day off, because my forex dealer's servers were unavailable on that day off. And today on Monday the downloading of the quote archive and the testing was successful.
MakarFX #:
I'm sorry, I was wrong, I didn't know it myself.
That's ok, your replies in private messages were much more valuable.

It's really nice to have people answering and helping each other out here. Not all answers can be found in the documentation)
 
Valeriy Yastremskiy #:

there have already been topics on this subject. Into a string and the number of strings to count. You really have to count the number of digits before the decimal point first. You can convert it to an integer. And it's a bit tricky to bring)))) to a string, too.

Yes, I wanted to do that too, only conversion of double to string is done with specified accuracy, if accuracy is not specified, 8 digits by default.

 
Valeriy Yastremskiy #:

there have already been topics on this subject. Into a string and the number of strings to count. You really have to count the number of digits before the decimal point first. You can convert it to an integer. And it's just as awkward to string))))

The integer conversion, yes, that's probably the only one. It occurred to me too, but it seemed too complicated to do some sort of multiplication cycle or division by 10. I haven't thought it through yet.
 
MakarFX #:
//+----------------------------------------------------------------------------+
//| Модификация ордеров                           |
//+----------------------------------------------------------------------------+
void ModifyOrders(int otype)
{
 double
   BuyPriceMax = 0, BuyPriceMin = 0, BuyPriceMaxLot = 0, BuyPriceMinLot = 0, 
   SelPriceMin = 0, SelPriceMax = 0, SelPriceMinLot = 0, SelPriceMaxLot = 0;

   int
   BuyPriceMaxTic = 0, BuyPriceMinTic = 0, SelPriceMaxTic = 0, SelPriceMinTic = 0;

   double
   op = 0, lt = 0, order_lots = 0;

   int
   tk = 0, b = 0, s = 0;
   price = 0;tp = 0;

   for(int i = OrdersTotal() - 1; i >= 0; i--)
      if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
         if(OrderMagicNumber() == Magic)
            if(OrderSymbol() == Symbol() &&  OrderType() == otype)
              {
               op = NormalizeDouble(OrderOpenPrice(), Digits());
               lt = NormalizeDouble(OrderLots(), 2);
               tk = OrderTicket();
               if(otype == OP_BUY)
                 {
                  b++;
                  if(op > BuyPriceMax || BuyPriceMax == 0)
                    {
                     BuyPriceMax    = op;
                     BuyPriceMaxLot = lt;
                     BuyPriceMaxTic = tk;
                    }
                  if(op < BuyPriceMin || BuyPriceMin == 0)
                    {
                     BuyPriceMin    = op;
                     BuyPriceMinLot = lt;
                     BuyPriceMinTic = tk;
                    }
                 }
               
               if(otype == OP_SELL)
                 {
                  s++;
                  if(op > SelPriceMax || SelPriceMax == 0)
                    {
                     SelPriceMax    = op;
                     SelPriceMaxLot = lt;
                     SelPriceMaxTic = tk;
                    }
                  if(op < SelPriceMin || SelPriceMin == 0)
                    {
                     SelPriceMin    = op;
                     SelPriceMinLot = lt;
                     SelPriceMinTic = tk;
                    }
                 }
               if (otype == OP_BUY || otype == OP_SELL) 
                  {
                   price += OrderOpenPrice() * OrderLots();
                   order_lots += OrderLots();
                  }
              }
//*************************************************************//
double   AwerageBuyPrice = 0, AwerageSelPrice = 0, avg_price = 0;
      if(b >= 2 && Drawdown >= DrawdownClosingMinMaxOrder)
         AwerageBuyPrice = NormalizeDouble((BuyPriceMax*BuyPriceMaxLot + BuyPriceMin*BuyPriceMinLot)/
         (BuyPriceMaxLot + BuyPriceMinLot) + TakeProfitMinMaxOrder* Point(), Digits());
      if(s >= 2 && Drawdown >= DrawdownClosingMinMaxOrder)
         AwerageSelPrice = NormalizeDouble((SelPriceMax * SelPriceMaxLot + SelPriceMin * SelPriceMinLot)/ 
         (SelPriceMaxLot + SelPriceMinLot) - TakeProfitMinMaxOrder* Point(), Digits());
      if (Drawdown < DrawdownClosingMinMaxOrder) 
         avg_price = NormalizeDouble(price / order_lots, Digits);
//*************************************************************//
   for(int i = OrdersTotal() - 1; i >= 0; i--)
      if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
         if(OrderMagicNumber() == Magic)
            if(OrderSymbol() == Symbol())
              {
               op  = NormalizeDouble(OrderOpenPrice(), Digits());
               tp = NormalizeDouble(OrderTakeProfit(), Digits());
               lt  = NormalizeDouble(OrderLots(), 2);
               tk  = OrderTicket();

                  if(otype == OP_BUY && b >= 2 && Drawdown >= DrawdownClosingMinMaxOrder)
                    {
                     if(tk == BuyPriceMaxTic || tk == BuyPriceMinTic)
                        if(Bid < AwerageBuyPrice && tp != AwerageBuyPrice)
                           if(!OrderModify(tk, op, OrderStopLoss(), AwerageBuyPrice, 0, clrRed))
                              Print("OrderModify error #", GetLastError());

                     if(tk != BuyPriceMaxTic && tk != BuyPriceMinTic && tp != 0)
                        if(!OrderModify(tk, op, 0, 0, 0, clrRed))
                           Print("OrderModify error #", GetLastError());
                    }
                  if(otype == OP_SELL && s >= 2  && Drawdown >= DrawdownClosingMinMaxOrder)
                    {
                     if(tk == SelPriceMaxTic || tk == SelPriceMinTic)
                        if(Ask > AwerageSelPrice && tp != AwerageSelPrice)
                           if(!OrderModify(tk, op, OrderStopLoss(), AwerageSelPrice, 0, clrRed))
                              Print("OrderModify error #", GetLastError());

                     if(tk != SelPriceMaxTic && tk != SelPriceMinTic && tp != 0)
                        if(!OrderModify(tk, op, 0, 0, 0, clrRed))
                           Print("OrderModify error #", GetLastError());
                    }
                 if (Drawdown < DrawdownClosingMinMaxOrder)    
                 if (otype == OP_BUY) tp = NormalizeDouble (avg_price + TakeProfitGroupOrder*Point, Digits);
                 if (otype == OP_SELL) tp = NormalizeDouble (avg_price - TakeProfitGroupOrder*Point, Digits); 
                    {
                    if(OrderModify(OrderTicket(), OrderOpenPrice(), 0, tp, 0))
                      Print("Ордера успешно модифицированы!");
                      else Print("Ошибка модификации ордеров!");
                    } 
             } 
}
 
Valeriy Yastremskiy #:

Is there anything I don't know? Also it is not possible to get bar data from other instruments by tester time, it will be received by current time. That's why I can't test multicurrency even just in the calculation part in 4ka.

I always thought that MT4 tester fully emulates the environment of one instrument, and MT5 the entire environment that is available.

Or is it not so?

Valery, pay attention to the line

  sd = (int)MarketInfo("EURJPY", MODE_DIGITS);

in my code... I've been using the hex functions for a long time, but here's a similar function

SymbolInfoInteger("EURJPY", SYMBOL_DIGITS);

gave a stackey 0.

So, think about where the bug is... And since mt4 refuses to support it, you can assume it will never be fixed...

Everything else has to be checked. I haven't bothered with it for so long that I don't even want to remember.

 

Alexey Viktorov #:

I have been using Friday functions for a long time

Can you suggest where I can learn MQL5 (in Russian)?

Reason: