Questions from Beginners MQL5 MT5 MetaTrader 5 - page 663

 
new-rena:

5 quid for an answer?

)

Waiting...

Well, if the question requires individual work and the result is a finished code, anything is possible...
 

Afternoon. The indicator needs to get data from another indicator, when loading the indicator the history is displayed, new values are not updated, please advise what is the error in the loop or somewhere else:

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,   // Количество просчитанных баров
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
   int limit;
   int counted_bars = IndicatorCounted();
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   limit = Bars - counted_bars - 500;
   for (int i=limit; i>=0; i--)
   {
     Buf_1[i]=iCustom(Symbol(), 0,"ATR", 0, i);//При подстановке любого индикатора нет обновления!!!
   }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
 

Such a situation, I'm getting an error - can you help me understand why an error occurs - in MQL5 you can't change the value of user input variable?

'Slippage' - constant cannot be modified Kamikadze_MA-may.mq5 67 7

extern int Slippage    = 10;                       // Проскальзывание

int init()
  {
//3,5 знаков
   if(MarketInfo(Symbol(),MODE_DIGITS)==3 || MarketInfo(Symbol(),MODE_DIGITS)==5)
     {
      Slippage*=10;
     }
   return(INIT_SUCCEEDED);
  }

  }

 
-Aleks-:

Such a situation, I get an error - can you help me understand why the error occurs - in MQL5 you cannot change the value of a variable entered by the user?

'Slippage' - constant cannot be modified Kamikadze_MA-may.mq5 67 7

extern int Slippage    = 10;                       // Проскальзывание

int init()
  {
//3,5 знаков
   if(MarketInfo(Symbol(),MODE_DIGITS)==3 || MarketInfo(Symbol(),MODE_DIGITS)==5)
     {
      Slippage*=10;
     }
   return(INIT_SUCCEEDED);
  }

  }

There is no such a thing in 5

MarketInfo

I don't know about Slippage)

 
new-rena:

This one's not in the 5pc.

MarketInfo

What the hell - why doesn't he put it in the errors...

What kind of analogue should I use?

 
-Aleks-:

Oh, bollocks - why doesn't he put it in error...

What kind of analogue should I use?

This same thread last weekend was about switching to 5-circa.

From my post and back read all the posts on 2-3 pages

https://www.mql5.com/ru/forum/6343/page662#comment_2930149

Вопросы от начинающих
Вопросы от начинающих
  • www.mql5.com
Форум трейдеров MQL5.community
 
new-rena:

The same thread last weekend dealt with the switch to 5k.

From my post and back read all the posts on 2-3 pages

https://www.mql5.com/ru/forum/6343/page662#comment_2930149

Yes, yes, I already opened that article - thanks. Inserted MarketInfoMQL4 function, but the result is negative.... Maybe I put it in the wrong place...

 
-Aleks-:

Yes, I've already opened this article - thank you. I pasted MarketInfoMQL4 function, but the result is negative.... I may have put it in the wrong place...

MarketInfo(Symbol(),MODE_DIGITS) is (int)SymbolInfoInteger(Symbol(),SYMBOL_DIGITS)

You'd better look deeper into the depths of substitution in functions

It will be more elegant and close to MQL5.

Take your time, in short.

You do not need any libraries and alien functions. You should learn to write in pure MQL5.

 
-Aleks-:

Such a situation, I'm getting an error - can you help me understand why an error occurs - in MQL5 you can't change the value of user input variable?

'Slippage' - constant cannot be modified Kamikadze_MA-may.mq5 67 7

extern int Slippage    = 10;                       // Проскальзывание

int init()
  {
//3,5 знаков
   if(MarketInfo(Symbol(),MODE_DIGITS)==3 || MarketInfo(Symbol(),MODE_DIGITS)==5)
     {
      Slippage*=10;
     }
   return(INIT_SUCCEEDED);
  }

  }

Yes, input parameters cannot be modified. To be honest, I don't understand why this value should be changed in accordance with 3/5 digit quotes? You do set this value in the input parameters. Can't you just write 100 (if 3/5 digits) and not bother?
 
new-rena:

MarketInfo(Symbol(),MODE_DIGITS) is (int)SymbolInfoInteger(Symbol(),SYMBOL_DIGITS)

You'd better look deeper into the depths of substitution in functions

It will be more elegant and close to MQL5.

Take your time, in short.

You do not need any libraries and alien functions. You should learn to write in pure MQL5.

By the way, the function from MarketInfoMQL4() leads to an error - how to fix it? (learning two languages will make my brain boil - I need to be able to check how ideas work in the stock market without deep coding)

'(' - name expected Kamikadze_MA-may.mq5 332 17
'::' - name expected Kamikadze_MA-may.mq5 332 17


double MarketInfoMQL4(string symbol,
                      int type)
  {
   switch(type)
     {
      case MODE_LOW:
         return(SymbolInfoDouble(symbol,SYMBOL_LASTLOW));
      case MODE_HIGH:
         return(SymbolInfoDouble(symbol,SYMBOL_LASTHIGH));
      case MODE_TIME:
         return(SymbolInfoInteger(symbol,SYMBOL_TIME));
      case MODE_BID:
        {
         MqlTick last_tick;
         SymbolInfoTick(symbol,last_tick);
         double Bid=last_tick.bid;
         return(Bid);
        }
      case MODE_ASK:
        {
         MqlTick last_tick;
         SymbolInfoTick(symbol,last_tick);
         double Ask=last_tick.ask;
         return(Ask);
        }
      case MODE_POINT:
         return(SymbolInfoDouble(symbol,SYMBOL_POINT));
      case MODE_DIGITS:
         return(SymbolInfoInteger(symbol,SYMBOL_DIGITS));
      case MODE_SPREAD:
         return(SymbolInfoInteger(symbol,SYMBOL_SPREAD));
      case MODE_STOPLEVEL:
         return(SymbolInfoInteger(symbol,SYMBOL_TRADE_STOPS_LEVEL));
      case MODE_LOTSIZE:
         return(SymbolInfoDouble(symbol,SYMBOL_TRADE_CONTRACT_SIZE));
      case MODE_TICKVALUE:
         return(SymbolInfoDouble(symbol,SYMBOL_TRADE_TICK_VALUE));
      case MODE_TICKSIZE:
         return(SymbolInfoDouble(symbol,SYMBOL_TRADE_TICK_SIZE));
      case MODE_SWAPLONG:
         return(SymbolInfoDouble(symbol,SYMBOL_SWAP_LONG));
      case MODE_SWAPSHORT:
         return(SymbolInfoDouble(symbol,SYMBOL_SWAP_SHORT));
      case MODE_STARTING:
         return(0);
      case MODE_EXPIRATION:
         return(0);
      case MODE_TRADEALLOWED:
         return(0);
      case MODE_MINLOT:
         return(SymbolInfoDouble(symbol,SYMBOL_VOLUME_MIN));
      case MODE_LOTSTEP:
         return(SymbolInfoDouble(symbol,SYMBOL_VOLUME_STEP));
      case MODE_MAXLOT:
         return(SymbolInfoDouble(symbol,SYMBOL_VOLUME_MAX));
      case MODE_SWAPTYPE:
         return(SymbolInfoInteger(symbol,SYMBOL_SWAP_MODE));
      case MODE_PROFITCALCMODE:
         return(SymbolInfoInteger(symbol,SYMBOL_TRADE_CALC_MODE));
      case MODE_MARGINCALCMODE:
         return(0);
      case MODE_MARGININIT:
         return(0);
      case MODE_MARGINMAINTENANCE:
         return(0);
      case MODE_MARGINHEDGED:
         return(0);
      case MODE_MARGINREQUIRED:
         return(0);
      case MODE_FREEZELEVEL:
         return(SymbolInfoInteger(symbol,SYMBOL_TRADE_FREEZE_LEVEL));

      default: return(0);
     }
   return(0);
  }