How to create line every tick at mql5 indicator. Shifting the values ​​of the buffers from one candle to another

 

Hello

The indicator only reads the value for candle 0 and the value for candle 1 only

If I change this line:

for (int j = i+1; j > 0; j--)

And make it :

for (int j = i+2; j > 0; j--)

The data for the indicator values ​​becomes completely wrong

My question is how do I make the indicator receive data other than the data for the current candle and the previous candle?

Or what leads to my inability to increase the number of updated candles?

The purpose of the indicator is to draw a line when the price moves either up or down and updates the values ​​

for example:

It draws the line at the close level of the current candle

And if a new movement occurs, it draws a new line with the new price on the current candle and then transfers the previous value to the previous candle

It does that well with only two candles, but what I want is for it to do that with more than two candles without changing the output values

Waiting for your solutions

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_plots 1

#property indicator_type1 DRAW_LINE
#property indicator_color1 clrBlue
#property indicator_label1 "Close Values"

input double Pips=0.1;
double Start_Point;
double MyPoint;
double CloseAllBuffer[];
//+------------------------------------------------------------------+
void OnInit()
  {
   MyPoint = Point();if(Digits() == 1 || Digits() == 2 || Digits() == 3 || Digits() == 4 || Digits() == 5 || Digits() == 6 || Digits() == 7){MyPoint *= 10;}
   SetIndexBuffer(0,CloseAllBuffer,INDICATOR_DATA);
  }
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const int begin,
                const double &close[])
{      
   int limit = rates_total - prev_calculated;

   ArraySetAsSeries(CloseAllBuffer, true);
   ArraySetAsSeries(close, true);

   if (prev_calculated == 0)
   {
      ArrayInitialize(CloseAllBuffer, close[0]);
   }
   else limit++;
  
for(int i = limit-1; i >= 0; i--)
     {
      if (i >= MathMin(1000000-1, rates_total-1-50)) continue;
      
   for (int j = i+1; j > 0; j--)
   {
   CloseAllBuffer[j] = CloseAllBuffer[j-1];
   }
if (((close[0] >= Start_Point + (Pips * MyPoint))||(close[0] <= Start_Point - (Pips * MyPoint))))
{
   CloseAllBuffer[0] = close[0];
   Start_Point = close[0];
}
   }
   return (rates_total);
   }​ 
 
Your topic has been moved to the section: Technical Indicators
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
 


In the normal conditions //for (int j = i+1; j > 0; j--)


you see Moving average(period 1) is matched with my indicator.



In the other condition //for (int j = i+2; j > 0; j--)


you see Moving average(period 1) is not matched with my indicator.


look at values.

 
Fernando Carreiro #:
Your topic has been moved to the section: Technical Indicators
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893

Thank you


can you help me in that topic?

 
I need help about this topic
 
Can a new line be drawn in candle -1? I mean, can a new line be drawn whenever the price moves regardless of the time like the Renko idea?
 
After reviewing the problem, it turned out that whenever the price moves by a tick, instead of drawing a moving average with a close value of candle 0, it draws a moving average with the same value as the move.