Code Library / Volume Analysis

MQL5 Volume Indicator

Detect volume spikes, climax bars, and dry-up periods.

Language: MQL5 · Category: Volume Analysis · Tags: volume, MQL5, indicator, volume spike, analysis

Source code

enum VOL {NORMAL,SPIKE,CLIMAX,DRYUP};
VOL AnalyzeVol(int avgP,double spikeMult) {
   long v[]; CopyTickVolume(_Symbol,PERIOD_CURRENT,0,avgP+1,v);
   double avg=0; for(int i=1;i<=avgP;i++) avg+=(double)v[i]; avg/=avgP;
   double ratio=avg>0?(double)v[0]/avg:1;
   if(ratio>=spikeMult*2) return CLIMAX;
   if(ratio>=spikeMult) return SPIKE;
   if(ratio<=0.5) return DRYUP;
   return NORMAL;
}

How to use this snippet

This is a building block, not a finished trading system. Paste it into your own MQL5 project, compile it, and test it on a demo account with your broker's real spreads before relying on it. If MetaEditor reports errors, the compilation error fixer can help.

Related snippets