Previous Day's Highest Volume Line for ThinkorSwim

BenTen

BenTen

Administrative
Staff
VIP
I modified the script that @korygill created here and replaced the A/D (Advanced Decline) line with volume. This indicator will plot the previous day's highest volume as a line on the current trading day.

Not sure how useful this is. I thought I'd share it for anyone using volume as a tool to help them trade.



thinkScript Code

Code:
# Previous Day's Highest Volume Line
# Based on the existing script of Kory Gill (@korygill) for BenTen at usethinkscript.com
#

declare lower;
declare once_per_bar;

input OpenTime = 0930;

def bn = BarNumber();
def nan = double.NaN;
def sft = SecondsFromTime(Opentime);

def vol = volume;
def hVal;
def lVal;

if bn == 1 then
{
    hVal = nan;
    lVal = nan;
}
else if bn == 2 then
{
    hVal = vol;
    lVal = vol;
}
else
{
    if sft == 0 then
    {
        hVal = vol;
        lVal = vol;
    }
    else
    {
        hVal = Max(hVal[1], vol);
lVal = Min(lVal[1], vol);
    }
}

def pdh = if sft[-1] == 0 then hVal else pdh[1];
def pdl = if sft[-1] == 0 then lVal else pdl[1];

plot ppdh = pdh;
plot ppdl = pdl;
ppdh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ppdl.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ppdh.SetDefaultColor(GetColor(1));
ppdl.SetDefaultColor(GetColor(0));

plot pvol = vol;

def IsUp = close > open;
def IsDown = close < open;

pvol.AssignValueColor(if vol > pdh and isDown then color.red else if vol > pdh and isup then color.green else color.gray);
 

Similar threads

Top