Downloading...
OPEN-SOURCE SCRIPT

Volumetric Compressed MA

343
VCMA uses the compressor and weighted stdev functions originally translated to pine by @gorx1. Compressor is usually used in audio to avoid clipping of certain frequencies. The original idea is actually pretty simple:

Pine Script®
ma(simple string smt, float src, simple int len) => switch smt 'RMA' => ta.rma(src, len) 'SMA' => ta.sma(src, len) 'EMA' => ta.ema(src, len) 'WMA' => ta.wma(src, len) 'HMA' => ta.hma(src, len) 'LSMA' => ta.linreg(src, len, 0) => na compressor(float in_1, simple int len, simple int thresh_dn_m, simple int thresh_up_m) => data = math.log(math.abs(in_1)) loc = ta.wma(data, len) dev = wstdev(data, len) thresh_dn = loc + dev * thresh_dn_m thresh_up = loc + dev * thresh_up_m math.exp(math.min(math.max(data, thresh_up), thresh_dn)) - math.exp(thresh_up) compressed_out = compressor(volume, len_window, up_thresh, down_thresh) comp_ma = ma(ma_type, close * compressed_out, len_ml) / ma(ma_type, compressed_out, len_ml) vwma = ma(ma_type, close, len_window)


We get the ratio of the compressed volume calculation and plot it with the base MA. Base MA's length is determined by window size input compared to ML length that is used for compressed version.

This provides us another possible confirmation indicator that can be used to take advantage of volume ranges. Autmated crossover alerts are also added. A reminder is that this kind of indicators should not be used on it's own for trading but rather should be used as a confirmation along with your trend detection and main entry indicators to provide additional confluence.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.