Errors, bugs, questions - page 31

 
Urain:
It can, but sometimes it works, although when I set 3, the short name shows 3 values and I only want one of the main buffer.

Then maybe like this:

#property indicator_buffers 3
#property indicator_plots   1
   SetIndexBuffer(0,LRma,INDICATOR_DATA);
   SetIndexBuffer(1,L,INDICATOR_CALCULATIONS);
   SetIndexBuffer(2,S,INDICATOR_CALCULATIONS);

Only one value is displayed on the graph.

 
DC2008:

Then maybe it goes like this:

The chart shows only one value.

This is how it turns out that the short name of the indicator shows 3 numbers, while the buffer for drawing one, it stores all that you need to know,

The problem is that in 4 you can just request the value of the wave on the desired bar and here I have to download the entire buffer and store it somewhere

This storage is not necessary for the indicator needs. But I don't know how to receive the value of the wave.

 
DC2008:

Then maybe like this:

Only one value is displayed on the graph.

Also glitchy ....
 
Interesting:

It's not about initialisation there. It's not even about those two lines that Mashek calls.

Even if we assume that the SYMBOL parameter is really needed (personally I doubt it), work with buffers is lame, and I'm not even speaking about the calculator block...

I see that the indicator displays the value of the linear regression angle of the wrong instrument on which it is running,

and the one prescribed in the input, so hopefully you will hide the checker.

Now, on the other hand, tell me intelligently what you see as incongruous in what happens in calculate?

I do not claim that it is all right (as just learning five and naturally steamed, as many).

The first thing that comes to my mind is that the length of history on different pairs is different and therefore glitches,

But the developers assured me that the terminal will load all the necessary data by itself.

 
Urain:

The problem is that in 4 you can just request the value of the waveform on the required bar and here you have to load the whole buffer,

the problem is that in 4 you can simply request the value of the wave on the needed bar, but here you have to download the entire buffer and store it somewhere

I have to load the whole buffer, but it won't be necessary for the indicator needs. I don't know how to get it in another way.

I can get them right, or nearly right. For all other buffers we may work out (series is not used, what is strange). But what's going on in the calculator is a big question...
 
Urain:

I see that the indicator displays the value of the linear regression angle of the wrong instrument on which it is running,

but the one that's prescribed in the intuition, so hopefully you'll hide the checker.

Now, in the cold, reasonably tell me what you see absurdity in what happens in calculate?

I do not claim that it is all right (as just learning five and naturally steamed, as many).

The first thing that comes to my mind is that the length of history at different pairs of different and therefore glitches,

The developers assured us that the terminal will load all the necessary data by itself.


What is there to argue about? We take the hat of the calculator and see what we see there, and this is what we see:

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[])

After that, there's the control of the bars...

   int count=rates_total-prev_calculated;
   if(count==0)count=1;
If you do not know the password, you will get a warning. So tell me, where is the logic?
 

I've rewritten the calculate like this:

  {
//---
   int count=rates_total-prev_calculated;
   if(count>_Bars())count=_Bars()-1;
   if(count==0)count=1;
   if(CopyBuffer(Lwma,0,0,count,L)!=-1)
     {
      if(CopyBuffer(Sma,0,0,count,S)!=-1)
        {
         for(int i=0;i<count;i++)
            LRma[i]=(L[i]-S[i])*6*iPoint*iiMA;
        }
     }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
int _Bars(){return(Bars(symbol,_Period));}
The error messages are gone, but it still doesn't work properly.
 

This is where we racked our brains over a similar turkey. Look what came out of it

 
Urain:

I've rewritten the calculate like this:

error records disappeared but it still does not work as it should.

The only right way is very simple.

You write a 100% working indicator, and it's done classically without the "Symbol" parameter, i.e. it's calculated using the current symbol and period.

After that such BASIC calculator is called in Expert Advisor (if mechanical operation is provided) or calculator (if it is necessary to display information on graph of NON-CALCULATED INSTRUMENT).

PS

Otherwise, if the calculator or a separate function has to do an additional calculation, and then link the results to the current graph data...

 
Urain:

I've rewritten the calculate like this:

The error messages are gone, but it still doesn't work properly.

That's probably better:

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_plots   1
//--- plot LRma
#property indicator_label1  "LRma"
#property indicator_type1   DRAW_LINE
#property indicator_color1  Red
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
input string             symbol      ="EURJPY";
input int                MA_Period   =25;          // период MA
input int                MA_shift    =0;           // сдвиг индикатора
input ENUM_APPLIED_PRICE price       =PRICE_OPEN;  // тип цены 
//--- indicator buffers
double  LRma[],L[],S[],iPoint,iiMA;

int Lwma,Sma;// Хендлы машек
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,LRma,INDICATOR_DATA);
   ArraySetAsSeries(L,true);
   ArraySetAsSeries(S,true);
   ArraySetAsSeries(LRma,true);
   Lwma=iMA(symbol,0,MA_Period+1,MA_shift,MODE_LWMA,price);
   Sma=iMA(symbol,0,MA_Period+1,MA_shift,MODE_SMA,price);
   iPoint=1.0/SymbolInfoDouble(symbol,SYMBOL_POINT);
   iiMA=1.0/MA_Period;
   IndicatorSetString(INDICATOR_SHORTNAME,"LRma_symbol_"+symbol);
//---
   return(0);
  }
//+------------------------------------------------------------------+
//| 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 count=rates_total-prev_calculated;
   if(count>1)count=(int)SeriesInfoInteger(symbol,0,SERIES_BARS_COUNT);
   if(count==0)count=1;
   if(CopyBuffer(Lwma,0,0,count,L)!=-1)
     {
      if(CopyBuffer(Sma,0,0,count,S)!=-1)
        {
         for(int i=0;i<MathMin(ArraySize(LRma),ArraySize(L));i++)
            LRma[i]=(L[i]-S[i])*6*iPoint*iiMA;
        }
     }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

It seems to work correctly.

Reason: