Val_Bands Indicator For MT5
The Val_Bands Indicator For MT5 uses the Bollinger band formula and draws important colored histogram bars that tell the traders about the direction of the major trend. Red color bars forming in the indicator window shows the bears are dominating the market. On the contrary, green color bars show the strength of the bulls. If you spot the yellow color bars, you need to wait for the reversal. You also notice the three moving average bands in the indicator window since it tells you about the overbought and oversold condition of the market. When the green bars trades above the yellow line, it means the market is in the overbought region. Similarly, if the green bars trade the above the yellow line it means the market is in the oversold region. Learn to use this tool in the demo account so that you don’t have become confused by seeing the readings in the real market.
Installing the Val_Bands Indicator For MT5
After you downloaded the indicator via the form above you need to unzip the zip-file. Then you need to copy the file val_bands.mq5 into the folder MQL5\Indicators of your MT5 installation. After that please restart MT5 and then you will be able to see the indicator in the list of indicators.
Parameters of the Val_Bands Indicator For MT5
The Val_Bands Indicator For MT5 has 2 parameters to configure.
input int BandsPeriod=14; // Calculation period
input double BandsDeviations=1.0; // Standard deviation size
Buffers of the Val_Bands Indicator For MT5
The Val_Bands Indicator For MT5 provides 5 buffers.
SetIndexBuffer(0,ValBuffer,INDICATOR_DATA);
SetIndexBuffer(1,ColorValBuffer,INDICATOR_COLOR_INDEX);
SetIndexBuffer(2,MaBuffer,INDICATOR_DATA);
SetIndexBuffer(3,UpBuffer,INDICATOR_DATA);
SetIndexBuffer(4,DownBuffer,INDICATOR_DATA);
Main Parts Of The Code
int OnCalculate(const int rates_total, // number of bars in history at the current tick
const int prev_calculated,// number of bars calculated at previous call
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[])
{
//---- checking the number of bars to be enough for the calculation
if(BarsCalculated(HMA_Handle) lt rates_total
|| BarsCalculated(LMA_Handle) lt rates_total
|| rates_total lt min_rates_total)
return(RESET);
//---- declarations of local variables
int to_copy,limit,bar,k;
double HMA[],LMA[];
double sum,oldval,newres,deviation;
//---- calculations of the necessary amount of data to be copied
//---- and the limit starting index for the bars recalculation loop
if(prev_calculated gt rates_total || prev_calculated lt =0)// checking for the first start of the indicator calculation
{
to_copy=rates_total; // calculated number of all bars
limit=rates_total-min_rates_total-1; // starting index for calculation of all bars
}
else
{
limit=rates_total-prev_calculated; // starting index for calculation of new bars
to_copy=limit+1; // calculated number of new bars only
}
//--- copy newly appeared data in the arrays
if(CopyBuffer(HMA_Handle,0,0,to_copy,HMA) lt =0) return(RESET);
if(CopyBuffer(LMA_Handle,0,0,to_copy,LMA) lt =0) return(RESET);
//---- indexing elements in arrays as timeseries
ArraySetAsSeries(HMA,true);
ArraySetAsSeries(LMA,true);
ArraySetAsSeries(high,true);
ArraySetAsSeries(low,true);
//---- first indicator calculation loop
for(bar=limit; bar gt =0 && !IsStopped(); bar--)
{
ValBuffer[bar]=(high[bar]-low[bar])/_Point;
MaBuffer[bar]=(HMA[bar]-LMA[bar])/_Point;
}
//---- the second indicator calculation loop
for(bar=limit; bar gt =0 && !IsStopped(); bar--)
{
sum=0.0;
k=bar+BandsPeriod-1;
oldval=MaBuffer[bar];
while(k gt =bar)
{
newres=ValBuffer[k]-oldval;
sum+=newres*newres;
k--;
}
deviation=BandsDeviations*MathSqrt(sum/BandsPeriod);
UpBuffer[bar]=oldval+deviation;
DownBuffer[bar]=oldval-deviation;
ColorValBuffer[bar]=0;
if(ValBuffer[bar] gt UpBuffer[bar]) ColorValBuffer[bar]=3;
else if(ValBuffer[bar] gt MaBuffer[bar]) ColorValBuffer[bar]=2;
else if(ValBuffer[bar] gt DownBuffer[bar]) ColorValBuffer[bar]=1;
}
//----
return(rates_total);
}
//+------------------------------------------------------------------+