Big Tick Volume Indicator (skiping data and reseting)

To add comments, please log in or register
zuazo
87
zuazo  

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_plots   1
#property indicator_type1   DRAW_LINE
#property indicator_color1  Purple
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1

input double         BigVolume = 1000;     

double               Buffer1[];
double               preco;


int OnInit()
  {

SetIndexBuffer(0,Buffer1,INDICATOR_DATA);
ArrayInitialize(Buffer1,EMPTY_VALUE);
preco  = 0;

   return(INIT_SUCCEEDED);
  }

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

   MqlTick tick_array[];
   ArraySetAsSeries(tick_array,true);
   ArraySize(tick_array);
  
if(CopyTicks(_Symbol,tick_array,COPY_TICKS_ALL)!=-1)
     {
     
     MqlTick tick; 
 
   if(SymbolInfoTick(Symbol(),tick)) 
     {     
    
      if(tick.volume >= BigVolume ){
      preco = tick.last;
      }
       
      }
      
     }
                      

Buffer1[rates_total-1] = preco;

   return(rates_total);
  }

Hi everyone

 

This indicator that I built is a line that shows the price that a tick occurred with a volume greater than the one configured in the input.

 

There are two problems with it:

1 - Sometimes it skips a tickvolume that should be plotted.

2 - Sometimes it resets and erases everything that was plotted before.

 

How can I save this data so that it is not lost and how can I ensure it does not skip any tick?

To add comments, please log in or register