The EOP for schoolchildren. - page 9

 
Dmitry Fedoseev:

If the indicator is calculated from the left to the right, then if some event has occurred, for example, a fractal has formed, we should memorize the index of the bar with this event (to use it for something else). If the indexing is from the right to the left, we should calculate n=Bars-i and remember n, and then do the reverse: i=Bars-n. But if you do index from left to right, you should just save the index and use it, it won't change. Since in more or less complicated indicators this is always needed, left-to-right indexing is a big help for indicator developers.

Yes, I once started to write one indicator in mql4, I wrote 1/3 of it, another 1/3 part was based on results of the first one and the third part on the values of the second third. I faced a big problem when calculating the bar with needed value. But it so happened that the customer has disappeared and I haven't finished writing it. And when indexing on the right the bar number is unchanged, it is enough to write the bar number to the auxiliary array and only this array must be run to construct the second and the third part...

 
Dmitry Fedoseev:

If the indicator is calculated from the left to the right, then if something happens, for example, a fractal is formed, you must store the index of the bar with this event (to use it for something else). If the indexing is from the right to the left, we should calculate n=Bars-i and remember n, and then do the reverse: i=Bars-n. But if you do index from left to right, you should just save the index and use it, it won't change. Since in more or less complicated indicators this is always needed, left-to-right indexing is a big help for indicator developers.

How about. And then the terminal downloads the history and what?
 
Ihor Herasko:

Here's an example.

Thank you, but

  1. Unfortunately, it's all fours.
  2. I would like a clear example of connecting such an indicator without iCustom )))
 
Vladimir Simakov:
Oh, boy. And then the terminal downloads the history and what?

It's no big deal. You just have to forget about the four-way approach

   int counted_bars=IndicatorCounted();
   int i,r,limit;

   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
         limit = Bars-counted_bars;
         if (ArrayRange(working,0) != Bars) ArrayResize(working,Bars);

   //
   //
   //
   //
   //
        
   for(i=limit, r=Bars-i-1; i >= 0; i--,r++)

And do it like this.

if(rates_total-prev_calculated > 1)
 {
  // Если это первый запуск или подгрузилась история пересчитаем весь индикатор.
 }
if(rates_total-prev_calculated >= 0)
 {
  // Пересчитаем только последнее изменение.
 }
 
#include <Indicators/Indicators.mqh>

CiADX adx;

int OnInit()
  {

   if(!adx.Create(Symbol(),Period(),14)){
      return(INIT_FAILED);
   }

   OnTick(); // это только для этого примера, чтобы на выходных сработало

   return(INIT_SUCCEEDED);
  }

void OnTick()
  {
   double buf[];
   
   if(adx.GetData(0,1,0,buf)==-1){
      return;
   }

   Comment(buf[0]);
   
  }
 
Vladimir Simakov:
Oh, yeah. And then the terminal downloaded the history and what?

Where are you from and why are you here? Have you written a single indicator for MT4 or MT5? At least you should know the basics of writing indicators for MetaTrader.

 
Dmitry Fedoseev:

Because they never wrote complex but fast indicators, otherwise left-to-right indexing would have been a very important solution.

If you need a fast indicator for an EA, it's better to put the calculation part directly into the EA.

 
Alexey Volchanskiy:

If you need a quick indicator for the EA, it is more profitable to insert the calculation part directly into the EA.

No way... Tell your girlfriends about it, for the sake of brutality.

 
Dmitry Fedoseev:

Where are you from and why are you here? Have you written a single indicator for MT4 or MT5? You should at least know the basics of writing indicators for MetaTrader.

Dimitri is angry, he hasn't had a hangover yet)))

 
Fixed it a bit. GetData() should be checked for inequality -1.
Reason: