Questions from Beginners MQL5 MT5 MetaTrader 5 - page 284

 
barabashkakvn:
The sequence number in "Market Watch" or the current price?

The sequence number in Market Watch.

I understand how to get a string description of a symbol with SymbolInfoString, but I can't find the number anywhere (:

 
Crucian:

A serial number in the Market Review.

First

int  SymbolsTotal(
   bool  selected      // true – только символы в MarketWatch
   );

then

string  SymbolName(
   int   pos,          // номер в списке
   bool  selected      // true – только символы в MarketWatch
   );

and once SymbolName==Your symbol, you will know its pos.

 
barabashkakvn:

First

then

and once SymbolName==Your symbol, you will know its pos.

Thank you!

But for some reason it doesn't work, pos always = 0. Maybe I'm doing something wrong, I'll figure it out in the morning :).

 
Crucian:

Thank you!

But for some reason it's not working, ros always = 0. Maybe I'm doing something wrong, I'll figure it out in the morning :).

In SymbolName you pass pos and check on output strung parameter.
 
Crucian:

Thank you!

But for some reason it's not working, ros always = 0. Maybe I'm doing something wrong, I'll figure it out in the morning :).

//+------------------------------------------------------------------+
   int PositionsSymbolInList(string sy) {
      for(int i=0; i<SymbolsTotal(false); i++) {
         string symbol_name=SymbolName(i,false);
         if(sy==symbol_name) return i;
         }
      return -1;
   }
//+------------------------------------------------------------------+
 
Crucian:

Thank you!

But for some reason it doesn't work, ros always = 0. Maybe I'm doing something wrong, I'll figure it out in the morning :).

//+------------------------------------------------------------------+
int IndexSymbolInMarketWatch(string sy)
  {
   for(int i=SymbolsTotal(true)-1; i>=0; i--)
     {
      if(SymbolName(i,true)==sy)
         return (i);
     }
   return (-1);
  }
//+------------------------------------------------------------------+
 
artmedia70:

Thank you your code works, but the code paladin800 does not (.

But, there is no sequence in the numbers. For example EUR=21 , GBP=28, CHF=36, JPY=40, EUR/JPY=16. Should it be like this?

 
Crucian:

Thank you your code works, but the code paladin800 does not (.

But, there is no sequence in the numbers. For example EUR=21 , GBP=28, CHF=36, JPY=40, EUR/JPY=16. Is it supposed to be like this?

SymbolsTotal(false)

It is a search in the list of available symbols, if true, then only those selected in Market Watch.

The order in which they are placed in the list of available symbols is the order in which the indexes are returned. Whereas, if you take from list in MarketWatch (if true), then indexes depend on sorting of symbols (they can be dragged and dropped with mouse) in Market Watch, which is not always convenient - there is dependence on "naughty pens of user".

 

One more question.

When compiling the MetaEditor, it started displaying a warning:

Return value of'OrderSend' should be checked Bollinger_Bands_strategy_4.mq5 690 7

I check result after sending request:

           OrderSend(mrequest,mresult);
            if(mresult.retcode==10009 || mresult.retcode==10008)
              { 
             
               Print("Set pending order SellStop"  );
               ModificationPosition=0;
            }else
              {
               Print(ResultRetcodeDescription(mresult.retcode));
               return;
              }

Or is this not enough? What does MetaEditor want?

 
Crucian:

One more question.

When compiling MetaEditor has started to display a warning:

return value of 'OrderSend' should be checked Bollinger_Bands_strategy_4.mq5 690 7
(The return value of "OrderSend" should be checked)

I check the result after sending a query:

Or is that not enough? What does MetaEditor want?

if(OrderSend(...))

Or

bool res=OrderSend(...);

No, my mistake. I'm already asleep. That's me out of habit from my functions of classes... Although it's for mql4, as in Five - dunno... :)

int ticket=OrderSend()