Indicators: Volume Average percent

 

Volume Average percent:

In capital markets, volume, or trading volume, is the amount (total number) of a security (or a given set of securities, or an entire market) that was traded during a given period of time. In the context of a single stock trading on a stock exchange, the volume is commonly reported as the number of shares that changed hands during a given day. The transactions are measured on stocks, bonds, options contracts, futures contracts and commodities. The average volume of a security over a longer period of time is the total amount traded in that period, divided by the length of the period. Therefore, the unit of measurement for average volume is shares per unit of time, typically per trading day.

Trading volume is usually higher when the price of a security is changing. News about a company's financial status, products, or plans, whether positive or negative, will usually result in a temporary increase in the trade volume of its stock. Shifts in trade volume can make observed price movements more significant. Higher volume for a stock is an indicator of higher liquidity in the market. For institutional investors who wish to sell a large number of shares of a certain stock, lower liquidity will force them to sell the stock slowly over a longer period of time, to avoid losses due to slippage.

This version is a sort of normalized version - since it shows Volume as a percent compared to the Average Volume over a chosen period.

With MetaTrader 5 now you can chose if the volume used is going to be tick volumes or real volumes. Percentage breakouts compared to average volume are marked with different colors.

Author: Mladen Rakic

 

This looks fantastic. Hey Mladen can it be done for MT4?

Please consider if possible.

 
Hi, can you please explain in more detail your color change logic?  I checked the code but couldn't spot it, sorry.
 
Kmt501 #:
Hi, can you please explain in more detail your color change logic?  I checked the code but couldn't spot it, sorry.

 MAYBE

THIS IS COLOR

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+

  {
   if(Bars(_Symbol,_Period)<rates_total) return(-1);
   int i=(int)MathMax(prev_calculated-1,0); for(; i<rates_total && !_StopFlag; i++)
     {
      double _volume=double((inpVolumeType==vol_ticks) ? tick_volume[i]: volume[i]);
      double _avg = iCustomMa(inpAverageMethod,_volume,inpAveragePeriod,i,rates_total);
      average[i]  = 100;
      val[i]      = (_avg!=0) ? 100*_volume/_avg : 0;
      valc[i]     = 0;
      if(i>0 && close[i] > close[i-1])  valc[i] = (_volume > _avg*(1+inpBreakoutPercent*0.01)) ? 3 : 1;<<<<THIS IS COLOR



      if(i>0 && close[i] < close[i-1])  valc[i] = (_volume > _avg*(1+inpBreakoutPercent*0.01)) ? 4 : 2;<<<<THIS IS COLOR



     }
   return(i);
  }
 
Kmt501 #:
Hi, can you please explain in more detail your color change logic?  I checked the code but couldn't spot it, sorry.
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void OnInit()
  {
//---- indicator buffers mapping
   SetIndexBuffer(0,val,INDICATOR_DATA);
   SetIndexBuffer(1,valc,INDICATOR_COLOR_INDEX);  <<<<THIS IS COLOR

   SetIndexBuffer(2,average,INDICATOR_DATA);
   string _avgNames[]={"SMA","EMA","SMMA","LWMA"};
   IndicatorSetString(INDICATOR_SHORTNAME,"Volume "+_avgNames[inpAverageMethod]+" average percent ("+(string)inpAveragePeriod+")");
  }
 
Hello
"Yes" and "No"
"Yes" is what allows you to define a type of buffer to manage the color.
But it is given in a SetIndexBuffer function 
SetIndexBuffer(1,valc,INDICATOR_COLOR_INDEX);
which makes the link with a property, the "1"

So "no" is also given by 

#property indicator_label1  "Volume average percent"
#property indicator_type1   DRAW_COLOR_HISTOGRAM
#property indicator_color1  clrDarkGray,clrYellowGreen,clrOrange,clrGreen,clrRed

After it is the code that makes the color

      if(i>0 && close[i] > close[i-1])  valc[i] = (_volume > _avg*(1+inpBreakoutPercent*0.01)) ? 3 : 1;
      if(i>0 && close[i] < close[i-1])  valc[i] = (_volume > _avg*(1+inpBreakoutPercent*0.01)) ? 4 : 2;
 
I send you a PM
 

Automated-Trading:

Volume Average percent:

Author: Mladen Rakic

Hello Mladen Rakic
Can you design a trading robot for me?

I want you to design a trading robot by combining the "Volume Average percent" indicator and the :RSI" indicator.

If you want to cooperate, I will go into the details of the robot design.
Thank
Mladen Rakic
Mladen Rakic
  • 2023.03.06
  • www.mql5.com
Trader's profile
Reason: