OPEN-SOURCE SCRIPT
Volumetric Compressed MA

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®
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.
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.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
One does not simply win every trade.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
One does not simply win every trade.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.