Questions from Beginners MQL5 MT5 MetaTrader 5 - page 991

 
kopeyka2:

That's exactly what I thought. The issue of misunderstanding is the word "parameters". So I started looking at ALL the variables that are involved in the handle --> CopyBuffer

1) My question from the beginning was to switch the timeframe SCREEN to save the handle data. As it is in MT4.

And in fact it turns out so:

ALWAYS and on ALL timeframes gives the same value of 10

Having got nothing here I moved on.

2) And I quote:"Gets the data of the specified buffer of the specified indicator in the specified amount into the buffer array".

That is, by settingthe count by hand we should have an INTERVAL with the values . And there they are! BUT!!!!!! Only when the handle period corresponds to

PERIOD_H1timeframe on the monitor screen. All values are transmitted clearly. But moving to another timeframe, there is NO data on the screen.

They are NOT transmitted in any way!!!! And my question was exactly that. And the number of bars is not so important here if they are NOT there!!!!


I looked at the proposed indicatorMTF_LRMA.mq5 but it's the same. It switches to another timeframe on the screen and the data goes by the screen timeframe. I need it on a handheld.

For example: iClose(NULL, PERIOD_H1, 5); on all timeframes it will give the same value - 10 bars on H1.

So far all examples were on CopyBuffer count correction. But the array is empty.


You are wrong. Handle gives data at any timeframe. I'll give you an example in about 10 hours. I can't do it on my mobile phone.
 
Artyom Trishkin:
You are wrong. Handle gives data at any timeframe. I will give you an example in about 10 hours. I will not be able to do it from my mobile.

OK. Thanks for the reply.


Corrected myself.

Напррмер: iClose(NULL, PERIOD_H1, 5); на всех таймфреймах будут давать одно и тоже значение : Закрытие на 5 баре по Н1. 

I thought it may be like this

MqlParam params[]; 
//--- create iMA("EURUSD",PERIOD_M15,8,0,MODE_EMA,PRICE_CLOSE); 
   ArrayResize(params,4); 
//--- set ma_period 
   params[0].type         =TYPE_INT; 
   params[0].integer_value=0; 
//--- set ma_shift 
   params[1].type         =TYPE_INT; 
   params[1].integer_value=0; 
//--- set ma_method 
   params[2].type         =TYPE_INT; 
   params[2].integer_value=MODE_EMA; 
//--- set applied_price 
   params[3].type         =TYPE_INT; 
   params[3].integer_value=PRICE_CLOSE; 
//--- create MA 
   h_MA=IndicatorCreate("EURUSD",PERIOD_M15,IND_MA,4,params); 
//--- release indicators (first h_MACD) 
   
  if(h_MA==INVALID_HANDLE)
     {
      Print("The iMA (",string(PERIOD_M15),") object was not created: Error ",GetLastError());
      return INIT_FAILED;
     }
//---
   return(INIT_SUCCEEDED);

But if you change my mind, I will wait for the first method to get the value of the technical indicator (iMA). But I still do not understand.

 
kopeyka2:

OK. Thanks for the reply.


Corrected myself.

I thought it may be like this

But if you change my mind, I will wait for the first method to get the value of the technical indicator (iMA). But I don't understand it now...

I showed above that the number of bars on different TFs is different, and therefore different number of bars to copy, depending on the TF where the indicator should be calculated. You should check the number of bars, calculated by BarsCalculated() and use it as a basis.

//+------------------------------------------------------------------+
//| 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[])
  {
   if(rates_total==prev_calculated) return(rates_total);
//---
   int    i;
   double diff;
//--- check for rates count
   if(rates_total<=ExtPeriodRSI)
      return(0);
//---
   if(TF!=PERIOD_CURRENT)
   {
      if(handle==INVALID_HANDLE)
        {
         handle=iCustom(Symbol(),TF,ind_name,Variant,RSIPeriod,Levl_Up,Levl_Down,PERIOD_CURRENT);
         return(0);
        }
      else
        {
         int bars_calculated=BarsCalculated(handle);
                  //Print("Начнем расчет - " , bars_calculated);
         if(bars_calculated<=0) return(0);
         if(Bars(Symbol(),TF)!=bars_calculated)
           {
            for(i=rates_total-prev_calculated-1;i>=0;i--)
              {
               Delta[i]=0.0;   
              }
            return(prev_calculated);
           } 
        }
 
Aleksey Vyazmikin:

I have shown above that the number of bars on different TFs is different, and therefore you should request different number of bars to copy, depending on TF, which should be calculated by the indicator. You should check the number of bars, calculated by indicator via BarsCalculated() and use it as a base, here is a piece of example for MTF

Thank you. I will try it. But as indicated earlier, the array is empty altogether. I've been doing handwritten sdigs on the array. It's all empty.
 
kopeyka2:
Thank you. I'll give it a try. But as pointed out earlier, the array is empty altogether. I've been doing handwritten sdigs on the array. It's all empty.
Are you ignoring that we have to wait for data loading from another timeframe? I gave you examples. The data in the shown indicator is taken only from higher timeframes. If we set lower or equal to the current timeframe, the data is taken from the current one. All this is in the code, but you have not bothered to look into it. But you are making a statement.
 
Artyom Trishkin:
Are you ignoring that you have to wait for data to load from a different timeframe? I have given you examples. The data in the shown indicator is taken only from higher timeframes. If we set lower or equal to the current timeframe, the data is taken from the current one. It all is in the code, but you haven't reviewed it. But you are making a statement.
I did not just look, I took apart your indicator to pieces. I had the idea of data delay from the very beginning. And immediately, from the first viewing, I saw your Timer. I'll look in that direction.
 
kopeyka2:
Not only did I look, but I took your indicator apart piece by piece. Here was the idea about the data delay from the very beginning. And immediately, from the first viewing, I saw your Timer. I'll look in that direction.
The last cycle with the data conversion to the current timeframe commented, and in any graphical buffer pass the data from the calculated buffers MAshek, and you'll see on the chart what you want to see.
 

for now

other (non-native) timeframe


 
kopeyka2:

for now

other (non-native) timeframe


Have you deliberately commented out the return string in case the data is not received? Why? If you unscrew the wheels and say that the motor hums, the steering wheel turns, but the car doesn't go, and therefore it's out of order, that's kind of harsh.
 
kopeyka2:
I'll try. I will try it. But as I pointed out before, the array is empty at all. I used my hands to make readings of the array. It's all empty.

Earlier I gave you a piece of code of your indicator with print, did you try to copy it? Nothing appears in the log, no errors or numbers?