Volume ima on array for expert advisor

 

hello friens

i try to calculate volume with ima on array but i have a some problem.   if i use long type then error "parameter conversion not allowed".  if i use double type then ea is not work completely

double  volume_ima[];
double  volume[];     ----> if i use long type arrey then  "parameter conversion not allowed"

int start()
{        
        
    Counted_bars = IndicatorCounted();
   if(Counted_bars<0) return(-1);
   if(Counted_bars>0) Counted_bars--;
      int i = Bars-Counted_bars-1;  
      
     ArraySize(volume_ima);  
     ArraySize(volume);
     ArraySetAsSeries( volume,true);  
     ArraySetAsSeries(volume_ima,true);  
     
       for(i=0; i>Counted_bars ; i--)
         {      
          volume[i] = iVolume ("EURUSD", PERIOD_M5 , i);
         }
     for(i=0; i>Counted_bars ; i--)
   {
      volume_ima[i] = iMAOnArray(volume,0,vol_ima_per,0,MODE_SMA,i);      
    }      
       
 

iMAOnArray operates on double arrays

 

What is this supposed to do?

     ArraySize(volume_ima);  
     ArraySize(volume);

 Are these 2 arrays dynamic arrays or buffers?

If they are not buffers, then they need to be sized using ArrayResize

 
GumRai:

iMAOnArray operates on double arrays

 

What is this supposed to do?

 Are these 2 arrays dynamic arrays or buffers?

If they are not buffers, then they need to be sized using ArrayResize. 

hi i just try to everythink

how i can add to expert advisor , volume avarage i try but i cant found healty  

you know Volume need it long format  but how?

volume_ima[i] = iMAOnArray(volume,0,vol_ima_per,0,MODE_SMA,i);   
may you see me example?
 

Personally, I would write an indicator to draw the MA on Volume as it is a simple thing to do as EAs don't have buffers.

Here is my code for the indicator.

//+------------------------------------------------------------------+
//|                                                MA on Volumes.mq4 |
//|                                                           GumRai |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "GumRai"
#property link      ""
#property version   "1.00"
#property strict
#property indicator_separate_window
#property indicator_minimum 0
#property indicator_buffers 2
#property indicator_plots   2
//--- plot Volume
#property indicator_label1  "Volume"
#property indicator_type1   DRAW_HISTOGRAM
#property indicator_color1  clrDeepSkyBlue
#property indicator_style1  STYLE_SOLID
#property indicator_width1  2
//--- plot MA_Volume
#property indicator_label2  "MA on Volume"
#property indicator_type2   DRAW_LINE
#property indicator_color2  clrRed
#property indicator_style2  STYLE_SOLID
#property indicator_width2  1
//--- input parameters
input int                 MA_Period=10;//MA Period
input int                 MAshift = 0;//MA Shift
input ENUM_MA_METHOD      MAMethod=0;//MA Method
//--- indicator buffers
double         VolumeBuffer[];
double         MA_VolumeBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,VolumeBuffer);
   SetIndexBuffer(1,MA_VolumeBuffer);
   IndicatorDigits(0);
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| 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 x, limit;
  if(prev_calculated==0)
     limit = rates_total-1;
  else
     limit=rates_total-prev_calculated+1;
     
  for(x=limit;x>=0;x--)
     VolumeBuffer[x]=(double)Volume[x];
  
  
  if(prev_calculated==0)
     limit = rates_total-1-MA_Period;
  for(x=limit;x>=0;x--)
     MA_VolumeBuffer[x]=iMAOnArray(VolumeBuffer,0,MA_Period,MAshift,MAMethod,x);
  
  
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

 Then simply use an iCustom() call in your EA

 
GumRai:

Personally, I would write an indicator to draw the MA on Volume as it is a simple thing to do as EAs don't have buffers.

Here is my code for the indicator.

 Then simply use an iCustom() call in your EA

 Thank you for your sharing volume ima on array i also search it but now found. 

 ea need more fast process icustom i think more slowly because need it some process .

  check this out more fast sma method when i use expenential method then need more formula

double volume_total,volume_avarage,volume; 

for(int i = vol_ima_per-1, volume_total=0 ; i >= 0; i--)
         {   
         volume = iVolume (Symbol(), PERIOD_M5 , i);
         volume_total = volume_total + volume;
         }

         volume_avarage = volume_total / vol_ima_per;
Reason: