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

 
Vitaly Muzichenko:

limit - the number of bars on the chart, so that when you scroll through the history, the indicator will be displayed until the end of the history.


Thank you very much! :)

 

Hello, could you tell me how to write the parameter - apply to - Median Price in the indicator, in this case Moveng

I will describe the problem, the indicator has an array[][] it records data to calculate the MA - the data was recorded at HL/2 prices, not the default

 

Hello, I'm trying to write a CDecisionForest class object into a bin file (it's from the Alglib library), but I can't figure out how. I tried using FileWriteStruct, but the compiler gives an error on my class argument:

'df' - structures containing objects are not allowed

Is it actually possible to write it or should I disassemble the object, write it in parts and then reassemble it?
 
Vitaly Muzichenko:

limit - number of bars on the chart, so that when you scroll through the history, the indicator will be displayed until the end of the history.


Dear Sir, please explain.

I have not succeeded using the information on your link.

When I declare limit value by myself - "Array out of range" window pops up.

Debugger points to strings with arrays in the for loop.

for(int i=0; i<limit; i++) {
    RSI[i] = iRSI(Symbol(),TimeFrame,14,PRICE_CLOSE,i);
  }

for(int i=0; i<limit; i++) {
    BandsMn[i]=iBandsOnArray(RSI,0,BB_Period,BB_Dev,0,MODE_MAIN,i);
    BandsUp[i]=iBandsOnArray(RSI,0,BB_Period,BB_Dev,0,MODE_UPPER,i);
    BandsDn[i]=iBandsOnArray(RSI,0,BB_Period,BB_Dev,0,MODE_LOWER,i);
  }

Maybe there's a simpler way to make it all?
I don't need the drawing.

Only values on current and previous bars.

 
Ras al Ghul:

Dear Sir, could you please explain?

Using the information on your link, I have not achieved success.

When declaring limit value by myself - "Array out of range" window pops up.

Debugger points to strings with arrays in the for loop.

Maybe it can be done in a simpler way?
I do not need drawing.

Only values on the current and previous bars.

How do you calculate the limit?

Actually, the limit is calculated in the reverse calculation of the indicator - from the beginning of the history to its end (to the current data):

   if(rates_total<нужное_количество_баров_для_верного_расчёта) return(0);
   int limit=rates_total-prev_calculated;
   if(limit>1) {
      limit=rates_total-нужное_количество_баров_для_верного_расчёта-1;
      // здесь, при необходимости очистки мусора в буферах, их инициализация пустыми значениями
      }
   //---
   for(int i=limit; i>=0; i--) {
      // тут цикл просчёта индикатора
      }
The concept"necessary_number of_bars_for_the_fidelity_calculation" means the minimum number of bars, on which the indicator will be correctly calculated. For a 2X2 fractal there are six bars - two on the left, one in the centre, two on the right and one far right which should be completely formed for the fractal not to be re-calculated.
 

Hello, could you please tell me how to increase the size of a one-dimensional array in an indicator

Provided it has a buffer index to call

And the size of the array exceeds the number of bars

 

Stuck, it seems to me, in such a simple place. What about global int chekcount=0; int count=0; in case I want to run several counter() functions in parallel?

void OnTimer()
  {
Print("counter(10)= ",counter(10));
Print("counter(14)= ",counter(14)); // !!!
  }

int chekcount=0; //???
int count=0; //???

int counter(int Pause=10)
  {
   count++;
   if(count>=chekcount+Pause)
      chekcount=count;

   return(chekcount);
  }

 
Nauris Zukas:

Stuck, it seems to me, in such a simple place. What to do with global int chekcount=0; int count=0; if I want to run several counter() functions in parallel?

Just use a class, or make copies of functions with different names.

 
Vitaly Muzichenko:

Only use a class, or make copies of functions with different names.

So it's not that simple... Thank you!

 

Can someone rewrite this function using a class, if it's not difficult ?

void OnTimer()
  {
Print("counter(10)= ",counter(10));
Print("counter(14)= ",counter(14)); // !!!
  }

int chekcount=0; //???
int count=0; //???
int counter(int Pause=10)
  {
   count++;
   if(count>=chekcount+Pause)
      chekcount=count;
   return(chekcount);
  }
Reason: