Indicators: Volume Profile

 

Volume Profile:

This is an indicator for showing volume profile on the chart, using simple calculations and very fast execution.

Volume Profile

Author: Mohammad Baset

 
Thank you Mohammad,

This is interesting, especially if it correlates to highs and lows which could help potentially to find SR zones.
I will review the code fully later, but it looks very well organized and simple.

I also wonder if there would be a way to plot this not just with ObjectCreate but in indicator plot array.
 
Tau Vaitkus #:
Thank you Mohammad,

This is interesting, especially if it correlates to highs and lows which could help potentially to find SR zones.
I will review the code fully later, but it looks very well organized and simple.

I also wonder if there would be a way to plot this not just with ObjectCreate but in indicator plot array.

You're welcome

I'm not sure if I properly understand what do you mean by correlation between highs/lows and VP, but as a general rule, it would be better to use volume profile indicators with SR indicators (ZigZag, for example) to know exactly where the start and end of the time range should be placed.

You cannot create a horizontal histogram using the default mql5 drawing styles. Additionally, when plotting the indicator buffers, you may need to call the OnCalculate function and wait for new ticks to see any changes in the plots. In this code, the OnChartEvent function is called, allowing you to see any changes instantly by dragging the vertical lines. 

Drawing Styles - Indicator Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5

Documentation on MQL5: Constants, Enumerations and Structures / Indicator Constants / Drawing Styles
Documentation on MQL5: Constants, Enumerations and Structures / Indicator Constants / Drawing Styles
  • www.mql5.com
Drawing Styles - Indicator Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

Nice indicator

Thank you Mohammad

 
Thanks for good indicator. Could VWAP (Anchored ) price show in this indicator?
 
ekren Clausewitz #:
Thanks for good indicator. Could VWAP (Anchored ) price show in this indicator?

You're welcome. Yes, of course. You can define a condition in the input section to display the VWAP and place the following in the current code:

//---Drawing anchored VWAP
//---Get the current timeframe price data
   if(vwap_condition)
     {
      double cclose[];
      double chigh[];
      double clow[];
      long   cvol[];
      datetime ctime[];
      int cbars=Bars(_Symbol,PERIOD_CURRENT,time_begin,time_finish);

      ArrayResize(cclose,cbars);
      ArrayResize(chigh,cbars);
      ArrayResize(clow,cbars);
      ArrayResize(cvol,cbars);
      ArrayResize(ctime,cbars);

      if(CopyHigh(_Symbol,PERIOD_CURRENT,time_begin,time_finish,chigh)==-1 ||
         CopyLow(_Symbol,PERIOD_CURRENT,time_begin,time_finish,clow)==-1 ||
         CopyClose(_Symbol,PERIOD_CURRENT,time_begin,time_finish,cclose)==-1 ||
         CopyTime(_Symbol,PERIOD_CURRENT,time_begin,time_finish,ctime)==-1 ||
         CopyRealVolume(_Symbol,PERIOD_CURRENT,time_begin,time_finish,cvol)==-1)
         return;
      //---check the applied volume
      if(av==VOLUME_TICK || cvol[0]==0)
         if(CopyTickVolume(_Symbol,PERIOD_CURRENT,time_begin,time_finish,cvol)==-1)
            return;
      //---Calculate VWAP for the range period
      double vwap=0.0;
      double vp=0.0; // sum of (volume * average price)
      long   v=0.0; // sum of volumes
      for(int z=0; z<cbars && !IsStopped(); z++)
        {
         vp+=(cvol[z]*((cclose[z]+chigh[z]+clow[z])/3.0));
         v+=cvol[z];
         vwap=vp/v;
         ArrowCreate("VP prfl "+IntegerToString(z),ctime[z],vwap,pocc);
         vwap=0.0;
        }
     }

I have used obj_arrow to display the VWAP in the code. You can find the 'ArrowCreate' function in the documentation ->  OBJ_ARROW - Object Types - Objects Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5

Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Object Types / OBJ_ARROW
Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Object Types / OBJ_ARROW
  • www.mql5.com
OBJ_ARROW - Object Types - Objects Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
if anything, could you please add a moving POC
 
dinktoan #:
if anything, could you please add a moving POC
Sorry, this is a code for calculating VP by lower time-frames data. I will be happy if you mention any error in the code and I will try to fix it. But the right place for customized indicators is the freelance or market section of the mql5 community. Regards
 
do you this indicator for the MT4 platform
 
Larrydeelf #:
do you this indicator for the MT4 platform

Unfortunately, no. But i think it would be easy to convert it. Just copy/paste the code in mt4 editor and debug it (especially pay attention to the CopyRealVolume function).

 
Pretty good. But would like to know when or where i could get value area for the VP.