How to modify this indicator from MT4 to PTMC indicator
//+------------------------------------------------------------------+
//| Volume_Profile4.mq4 |
//| Copyright © 2005, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"
//---- indicator settings
#property indicator_separate_window
//#property indicator_minimum 0
#property indicator_buffers 4
#property indicator_color1 clrBlack
#property indicator_color2 clrGreen
#property indicator_color3 clrRed
#property indicator_color4 clrSilver
#property indicator_width2 2
#property indicator_width3 2
#property indicator_width4 1
#property indicator_style4 STYLE_DOT
//---- indicator buffers
double ExtVolumesBuffer[];
double ExtVolumesUpBuffer[];
double ExtVolumesDownBuffer[];
double ExtVolumesAvarageBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicator buffers mapping
SetIndexBuffer(0,ExtVolumesBuffer);
SetIndexBuffer(1,ExtVolumesUpBuffer);
SetIndexBuffer(2,ExtVolumesDownBuffer);
SetIndexBuffer(3,ExtVolumesAvarageBuffer);
//---- drawing settings
SetIndexStyle(0,DRAW_NONE);
SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexStyle(2,DRAW_HISTOGRAM);
SetIndexStyle(3,DRAW_LINE);
//---- sets default precision format for indicators visualization
//IndicatorDigits(0);
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("Volume_Profile4");
SetIndexLabel(0,"Volume_Profile4");
SetIndexLabel(1,NULL);
SetIndexLabel(2,NULL);
SetIndexLabel(3,NULL);
//---- sets drawing line empty value
SetIndexEmptyValue(1,0.0);
SetIndexEmptyValue(2,0.0);
SetIndexEmptyValue(3,0.0);
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Volumes |
//+------------------------------------------------------------------+
int start()
{
int i,nLimit,nCountedBars;
//---- bars count that does not changed after last indicator launch.
nCountedBars=IndicatorCounted();
//---- last counted bar will be recounted
if(nCountedBars>0) nCountedBars--;
nLimit=Bars-nCountedBars;
//----
double VolumeTotal=0, AverageVolume=0;
for(i=nLimit-1; i>=0; i--))
{
double dVolume=Volume[i];
if(i==Bars-1 || dVolume>Volume[i+1] )
{
ExtVolumesBuffer[i]=dVolume;
ExtVolumesUpBuffer[i]=dVolume;
ExtVolumesDownBuffer[i]=0.0;
}
else
{
ExtVolumesBuffer[i]=dVolume;
ExtVolumesUpBuffer[i]=0.0;
ExtVolumesDownBuffer[i]=dVolume;
}
ExtVolumesAvarageBuffer[i]=SmaVolumeHr(Bars-1,i);
}
//----
for(i=Bars-1; i>=0; i--)
{
VolumeTotal=VolumeTotal+=ExtVolumesBuffer[i];
}
//------Average Level
AverageVolume=VolumeTotal/(Bars-1);
SetLevelStyle(STYLE_DOT,1,clrSilver);
SetLevelValue(0,AverageVolume);
//------Average Level
return(0);
}
//----------------------------------------------------
double SmaVolumeHr(int length, int iShift)
{
int iLimit = Bars-1,
hr = TimeHour(Time[iShift]);
double sum = 0;
int nSum = 0;
for (iShift=0; iShift < iLimit; iShift++)
{
if ( hr == TimeHour(Time[iShift]) )
{
sum+= Volume[iShift];
nSum++;
if (nSum == length) break;
}
}
if (nSum == 0) nSum=1;
return(sum/nSum);
}
//+------------------------------------------------------------------+