Indicators: Better Volume

 

Better Volume:

Easy and visual way to check abnormal changes in Volume.

Better Volume

Author: Minions Labs

 
need help in getting better volume to work...it opens a separate window but displays nothing.
 

Works Well. 

Thank you for sharing it.

Just attaching an idea . I am not a coder and not sure if it's feasible.

Another indicator prints text and when you find time, please do update it.

 

Just to express thank to you.

It is working well.

Files:
 

Did anyone fix the indicator displaying blank?

I am getting the same thing.

I believe i have fixed it. I think it is an issue with our broker and supplying VOLUME_REAL data for derived instruments.

I changed the if statements to default to VOLUME_TICK, and this got the indicator to work.

 
thanks. good indicator, this will best to add arrow and alert when hit certain horizontal level, ex:1000
 
hrhsii:

Did anyone fix the indicator displaying blank?

I am getting the same thing.

I believe i have fixed it. I think it is an issue with our broker and supplying VOLUME_REAL data for derived instruments.

I changed the if statements to default to VOLUME_TICK, and this got the indicator to work.

Thanks for the easy solution. :) 

 
hrhsii:

Did anyone fix the indicator displaying blank?

I am getting the same thing.

I believe i have fixed it. I think it is an issue with our broker and supplying VOLUME_REAL data for derived instruments.

I changed the if statements to default to VOLUME_TICK, and this got the indicator to work.

Thanks for the info. I have attached the fixed mq5 file if anyone needs it (note: you have to click "Go to discussion" link to see the attachment)

Files:
 

Good morning, would it be possible to have it for MT4?
I had it on my old PC but it was stolen and in the backup I made some things were left out due to my carelessness.
Thank you.

Auto-translation applied by moderator
 

Custom, now you can watch volatility on bars SYMBOL_PRICE_VOLATILITY

Auto-translation applied by moderator

//+-------------------------------------------------------------------------------------+
//|                                                            Minions.BetterVolume.mq5 |
//| (CC) Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License|
//|                                                          http://www.MinionsLabs.com |
//+-------------------------------------------------------------------------------------+


//+------------------------------------------------------------------+
//| Descriptors                                                      |
//+------------------------------------------------------------------+
#property copyright   "www.MinionsLabs.com"
#property link        "http://www.MinionsLabs.com"
#property version     "1.0"
#property description "Minions in the quest for explaining Volume in a better way."
#property description " "
#property description "(CC) Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License"


//+------------------------------------------------------------------+
//| Indicator Settings                                               |
//+------------------------------------------------------------------+
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_plots   1

#property indicator_label1  "Better Volume"
#property indicator_type1   DRAW_COLOR_HISTOGRAM
#property indicator_color1  C'20,20,20', clrLime, clrRed
#property indicator_style1  STYLE_SOLID
#property indicator_width1  4



//+------------------------------------------------------------------+
//| INPUT Parameters                                                 |
//+------------------------------------------------------------------+
input ENUM_SYMBOL_INFO_DOUBLE inpAppliedVolume  = SYMBOL_VOLUME_MAX; // Volume Type
input int                 inpBarsToAnalyze  =  20;         // N past bars to analyze



//+------------------------------------------------------------------+
//| Global Variables                                                 |
//+------------------------------------------------------------------+
double bufferVolume[];
double bufferColors[];

// safe check & clean all Input Parameters... just in case this indicator is called via iCustom()...
ENUM_SYMBOL_INFO_DOUBLE  paramAppliedVolume = (inpAppliedVolume == NULL ? SYMBOL_VOLUME_MAX : (ENUM_SYMBOL_INFO_DOUBLE)inpAppliedVolume);
int                  paramBarsToAnalyze = (inpBarsToAnalyze == NULL ? 20 : (int)inpBarsToAnalyze);



//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void OnInit() {
    SetIndexBuffer( 0, bufferVolume, INDICATOR_DATA );
    SetIndexBuffer( 1, bufferColors, INDICATOR_COLOR_INDEX );

    IndicatorSetString(INDICATOR_SHORTNAME,"Minions.BetterVolume ("+EnumToString(inpAppliedVolume)+", Period:"+(string)paramBarsToAnalyze+")");
    IndicatorSetInteger(INDICATOR_DIGITS,0);
}



//+------------------------------------------------------------------+
//|  Volume Calculation...                                           |
//+------------------------------------------------------------------+
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   start=prev_calculated-1;
    long  SMA;

    if (rates_total<2)  {  return(0);  }     // check for rates total

    if (start<1) {  start=1;  }              // correct position

    // calculates the volumes histogram...
    for(int i=start; i<rates_total && !IsStopped(); i++) {

        bufferVolume[i] = (double)(paramAppliedVolume==SYMBOL_VOLUME_MAX  ?  volume[i]  :  tick_volume[i]);     // calculates the indicator...

        if(paramAppliedVolume==SYMBOL_VOLUME_MAX) {
            SMA = SMAOnArray(volume, paramBarsToAnalyze, i );
        } else {
            SMA = SMAOnArray(tick_volume, paramBarsToAnalyze, i );
        }
        
        // change candle colors accordingly...
        if      (open[i]<close[i] && bufferVolume[i]>SMA) {  bufferColors[i]=1.0;  } 
        else if (open[i]>close[i] && bufferVolume[i]>SMA) {  bufferColors[i]=2.0;  }
        else                                              {  bufferColors[i]=0.0;  }
    
    }

    return(rates_total);
  }





//+------------------------------------------------------------------+
//| Calculates a SMA over an indicator array...                      |
//+------------------------------------------------------------------+
long SMAOnArray( const long &array[], int period, int position ) {
    long sum = 0;

    if (position-period <= 0)  {  return false;  }

    for (int i = position-period+1; i<=position; i++) {
        sum += array[i];
    }

    return sum / period;
}
//+------------------------------------------------------------------+
 
@__zeus__ #: Custom, now you can watch volatility on bars SYMBOL_PRICE_VOLATILITY

Auto-translation applied by moderator

On the English forum, please write in English. Either use the automatic translation tool, or post in one of the other language forums.
Reason: