Questions from Beginners MQL5 MT5 MetaTrader 5 - page 930

 
ascerdfg:
Is it possible:

replace with:

Why not? Of course you can.

 
double Open[3];

int Ind_Handle;

int OnInit()
  {
      Ind_Handle=iCustom(_Symbol,_Period,"Pop"); // Pop.ex5
      if(Ind_Handle==INVALID_HANDLE)
        {
         Print(" Не удалось получить хендл индикатора");
         return(INIT_FAILED);
        }
   
   return(INIT_SUCCEEDED);
  }


void OnTick()
  {
 
      CopyBuffer(Ind_Handle,0,1,1,Open);
      Print("Open0 ",Open[0]);
  }

Prints: "Open0 1.797693134862316e+308".

Although I have changed both indicator buffer cell number and index.

I know for sure there is an integer in the indicator. Why does it print like this?

 
ascerdfg:

Prints: "Open0 1.797693134862316e+308".

Although I have changed both indicator buffer cell number and index.

I know for sure there is an integer in the indicator. Why does it print like this?

Either make ArraySetAsSeries true after array declaration or declare array with size 1
 
void OnTick()
  {
     int i;
     double price=.5;
     double Open[];
      ArraySetAsSeries(Open,true);

      Print("Кол-во ",BarsCalculated(Ind_Handle));
      Print("хэндл ",Ind_Handle);
      CopyBuffer(Ind_Handle,0,0,100,Open);
                 
      
    for(i=0; i<100; i++)
    {
        if(Open[i]!=EMPTY_VALUE)
        {
            price=Open[i];
            break;
        }
    }
           
      Print(price);
  }
Doesn't work, writes 0.5 all the time. It appears to buffer all the time with the maximum number.
 
ascerdfg:
Does not help, writes all the time 0.5. It turns out the buffer all the time with the maximum number.

If you want an accurate answer, ask the question correctly: provide the code of the indicator and the code of the Expert Advisor. Now it is not clear WHAT, WHO and WHERE :)

 

Rohr - indicator

rrr - advisor

Files:
Pop.mq5  38 kb
ppp.mq5  4 kb
 
ascerdfg:

Ror - indicator

rrr - EA

Rewrite the indicator - firstly, check for STOP WORDS, secondly, simplify it as much as possible - for example, enter the number equal to the number of the current bar into the indicator buffer.

What we get: array[0]=0.0, array[1]=1.0 and so on. This will VERY, VERY simplify the process of understanding the data reception from the indicator. Third - leave only one indicator buffer.

 

Can you please tell me how to explicitly specify the updated symbol in this function? For example EURUSD.m

//+------------------------------------------------------------------+
//| Refreshes the symbol quotes data                                 |
//+------------------------------------------------------------------+
bool RefreshRates(void)
  {
//--- refresh rates
   if(!m_symbol.RefreshRates())
     {
      Print("RefreshRates error");
      return(false);
     }
//--- protection against the return value of "zero"
   if(m_symbol.Ask()==0 || m_symbol.Bid()==0)
      return(false);
//---
   return(true);
  }
//+------------------------------------------------------------------+
 

Good afternoon!

Do you know how to build an indicator for Market?

I have a file with .mq5 extension and some include files with .mqh extension.

As far as I understand, you can't attach .mqh to the .mqh file via resources, should I really convert everything to one file manually?

What if there is a new version :? It's crazy +)))

Thanks.

 
EgorKim:

Can you please tell me how to explicitly specify the updated symbol in this function? For example EURUSD.m

A follow-up question: "Why do you need to specify the symbol explicitly here?

If you use this function, you must assign a symbol to m_symbol in OnInit:

   if(!m_symbol.Name(Symbol())) // sets symbol name
      return(INIT_FAILED);
   RefreshRates();

In this case, if you run the Expert Advisor on the symbol "EURUSD.m" for m_symbol will be automatically set to "EURUSD.m".

Reason: