blakecmathis
Well-known member
The lower is comprised of two studies: RelativeVolumeStDev and Freedom of Movement. However, only values above 2 standard deviations are plotted for both studies (bars for volume and wedges for freedom of movement). Ideally, I would like for the these to be absent from the chart and only shown when they overlap such as in the picture below and plotted as a boolean value. So if both signals are generated on the same candle, a simple wedge up would be plotted. And when they do not occur on the same candle, nothing is plotted. Is this possible?
Code:
#Freedom of Movement
declare lower;
declare zerobase;
input length = 60;
input numDev = 2.0;
input allowNegativeValues = no;
def mov = AbsValue(close / close[1] - 1);
def minMov = Lowest(mov, length);
def maxMov = Highest(mov, length);
def nMov = 1 + (mov - minMov) / (maxMov - minMov) * 9;
def vol = (volume - Average(volume, length)) / StDev(volume, length);
def minVol = Lowest(vol, length);
def maxVol = Highest(vol, length);
def nVol = 1 + (vol - minVol) / (maxVol - minVol) * 9;
def vByM = nVol / nMov;
def rawFoM = (vByM - Average(vByM, length)) / StDev(vByM, length);
plot FoM = if rawFoM > numDev then rawFoM else Double.NaN;
plot StDevLevel = numDev;
FoM.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
FoM.SetLineWeight(3);
FoM.DefineColor("Above", GetColor(0));
FoM.DefineColor("Below", GetColor(2));
FoM.AssignValueColor(if FoM >= numDev then FoM.Color("Above") else FoM.Color("Below"));
StDevLevel.SetDefaultColor(GetColor(7));
StDevLevel.SetStyle(Curve.SHORT_DASH);
# End Code
Code:
#Relative Volume Std Dev
declare lower;
declare zerobase;
input length = 60;
input numDev = 2.0;
input allowNegativeValues = no;
def rawRelVol = (volume - Average(volume, length)) / StDev(volume, length);
def RelVol = if allowNegativeValues then rawRelVol else Max(0, rawRelVol);
plot StDevLevel = numDev;
plot RV = if RelVol > numDev then RelVol else Double.NaN;
RV.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
RV.SetLineWeight(3);
RV.DefineColor("Above", GetColor(0));
RV.DefineColor("Below", GetColor(2));
RV.AssignValueColor(if RelVol >= numDev then RV.Color("Above") else RV.Color("Below"));
StDevLevel.SetDefaultColor(GetColor(7));
StDevLevel.SetStyle(Curve.SHORT_DASH);
# End Code
Last edited: