This indicator is based on Volume . It shows multi colored volume based on your defined ratio with Bar color option
CODE:
CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © Codextent
#indicator(title='Volume Analysis', shorttitle='VolAna')
# Converted and mod by Sam4Cok@Samer800 - 12/2022
declare lower;
input BarColor = yes;
input showVolMA = {Default Histogram, Line, None}; # 'Show Moving Average'
input lengthVolumeMA = 22; # 'Length of MA applied on Volume'
input ratioUltraVolume = 2.4; # 'Ultra Ratio'
input ratioVeryHighVolume = 1.8; # 'Very High Ratio'
input ratioHighVolume = 1.2; # 'High Ratio'
input ratioNormalVolume = 0.8; # 'Normal Ratio'
input ratioLowVolume = 0.4; # 'Low Ratio'
input ratioVeryLowVolume = 0.2; # 'Very Low Ratio'
def na = Double.NaN;
def Style = if showVolMA==showVolMA.Histogram then 1 else
if showVolMA==showVolMA.Line then -1 else 0;
def volStyle = Style;
def raising = close > open;
def v = volume;
script nz {
input data = close;
input repl = 0;
def ret_val = if IsNaN(data) then repl else data;
plot return = ret_val;
}
script nzero {
input data = close;
input repl = 0;
def ret_val = if data <= 0 then repl else data;
plot return = ret_val;
}
#----Colors
DefineGlobalColor("UltHigh" , Color.GREEN);
DefineGlobalColor("VeryHigh", Color.DARK_GREEN);
DefineGlobalColor("High" , Color.LIGHT_GREEN);
DefineGlobalColor("Normal" , Color.WHITE);
DefineGlobalColor("Low" , Color.GRAY);
DefineGlobalColor("VLow" , Color.DARK_GRAY);
DefineGlobalColor("UltLow" , Color.RED);
DefineGlobalColor("VeryLow" , Color.DARK_RED);
DefineGlobalColor("lHigh" , Color.PINK);
DefineGlobalColor("ma" , CreateColor(54,58,69));
#// Volume MA
def volumeMA;
volumeMA = nzero(volumeMA[1],v) + (v - nz(volumeMA[1])) / lengthVolumeMA;
#// Ratio
def ultraHighVolumeMin = volumeMA * ratioUltraVolume;
def veryHighVolumeMin = volumeMA * ratioVeryHighVolume;
def highVolumeMin = volumeMA * ratioHighVolume;
def normalVolumeMin = volumeMA * ratioNormalVolume;
def lowVolumeMin = volumeMA * ratioLowVolume;
def veryLowVolumeMin = volumeMA * ratioVeryLowVolume;
#// Ratio check
def volUltraHigh = if v >= ultraHighVolumeMin then 1 else 0;
def volVeryHigh = if v >= veryHighVolumeMin and v < ultraHighVolumeMin then 1 else 0;
def volHigh = if v >= highVolumeMin and v < veryHighVolumeMin then 1 else 0;
def volNormal = if v >= normalVolumeMin and v < highVolumeMin then 1 else 0;
def volLow = if v >= lowVolumeMin and v < normalVolumeMin then 1 else 0;
def volVeryLow = if v < lowVolumeMin then 1 else 0;
#//Plot
def palette = if volUltraHigh then 3 else if volVeryHigh then 2 else if volHigh then 1 else
if volNormal then 0 else if volLow then -1 else -2;
plot VolHist = if raising then v else v * -1;#, color=palette, style=plot.style_columns, title='Volume')
VolHist.SetLineWeight(2);
VolHist.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
VolHist.AssignValueColor(if raising then
if palette==3 then GlobalColor("UltHigh") else
if palette==2 then GlobalColor("VeryHigh") else
if palette==1 then GlobalColor("High") else
if palette==0 then GlobalColor("Normal") else
if palette==-1 then GlobalColor("Low") else GlobalColor("VLow") else
if palette>2 then GlobalColor("UltLow") else
if palette>1 then GlobalColor("VeryLow") else
if palette>0 then GlobalColor("lHigh") else
if palette>-1 then GlobalColor("Normal") else
if palette>-2 then GlobalColor("Low") else GlobalColor("VLow"));
plot VolMa = if Style!=0 then volumeMA else na; #'Volume MA'
VolMa.SetDefaultColor(GlobalColor("ma"));
VolMa.SetLineWeight(5);
VolMa.SetPaintingStrategy(if volStyle> 0 then PaintingStrategy.HISTOGRAM else PaintingStrategy.LINE);
plot VolMaLo = if Style!=0 then -volumeMA else na; #'Volume MA'
VolMaLo.SetPaintingStrategy(if volStyle> 0 then PaintingStrategy.HISTOGRAM else PaintingStrategy.LINE);
VolMaLo.SetDefaultColor(GlobalColor("ma"));
VolMaLo.SetLineWeight(5);
AssignPriceColor(if !BarColor then Color.CURRENT else if raising then
if palette==3 then GlobalColor("UltHigh") else
if palette==2 then GlobalColor("VeryHigh") else
if palette==1 then GlobalColor("High") else
if palette==0 then GlobalColor("Normal") else
if palette==-1 then GlobalColor("Low") else GlobalColor("VLow") else
if palette==3 then GlobalColor("UltLow") else
if palette==2 then GlobalColor("VeryLow") else
if palette==1 then GlobalColor("lHigh") else
if palette==0 then GlobalColor("Normal") else
if palette==-1 then GlobalColor("Low") else GlobalColor("VLow"));
#--- END CODE
Last edited by a moderator: