Anna Coulling Volume Price Analysis For ThinkOrSwim

Trying to debug an anomaly in this script where a cyan bar(up3) is being printed even though its not exceeding the volAvg.
Code:
def up3 = if IR_BODYG and (Vol > VolAvg) then 1 else 0;
anna4.jpg


Any ideas?
I found the source of this bug - the color assignment doesn't have a case where it handles doji candles, so it falls through to coloring them as GetColor(1). On a dark chart, GetColor(1) is COLOR.CYAN, which is the same color used for UP3.

The below code colors them YELLOW instead and also has a mod to allow for user selectable average type and length to use for volume. The original indicator was using a 12 period exponential average.

Ruby:
AddLabel(yes, "Day_volume: " + volume (period = "DAY" ), Color.LIGHT_GRAY);
AddLabel(yes, "volume: " + volume, Color.white);

declare lower;
declare zerobase;

input averageType = averagetype.Exponential;
input averageLength = 12;

plot Vol = volume;
plot VolAvg = MovingAverage(averageType,volume,averageLength);
VolAvg .SetPaintingStrategy(PaintingStrategy.squared_HISTOGRAM);
VolAvg .SetDefaultColor(Color.GRAY);
def BODY_RANGE = max(oPEN,cLOSE) - min(oPEN,cLOSE);
plot IR_BODY = if BODY_RANGE < BODY_RANGE[1] and volume > volume[1] then 1 else 0 ;
def IR_BODYG  = if IR_BODY and close>open then 1 else 0;
def IR_BODYR  = if IR_BODY and close<open then 1 else 0;

Vol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Vol.SetLineWeight(3);
Vol.DefineColor("Up", Color.green);
Vol.DefineColor("Down", Color.red);
Vol.DefineColor("Up2", Color.light_green);
Vol.DefineColor("Down2", Color.dark_ORANGE );
Vol.DefineColor("Up3", Color.cyan);
Vol.DefineColor("Up4", Color.blue);
Vol.DefineColor("Down3", Color.mAGENTA );
Vol.DefineColor("Down4", Color.plum );


Vol.AssignValueColor(
if close > open and IR_BODYG and Vol >VolAvg  then Vol.color("Up3") else if

close > open and IR_BODYG  then Vol.color("Up4")

else if close < open and IR_BODYR and Vol >VolAvg then Vol.color("Down3")

else if close < open and IR_BODYR then Vol.color("Down4")

else if close > open and Vol >VolAvg  then Vol.color("Up")

else if close < open and Vol >VolAvg then Vol.color("Down")

else if close > open then Vol.color("Up2")

else if close < open then Vol.color("Down2")

else color.yellow);



input paintBars = yes;

DefineGlobalColor("CAM_UP", Color.GREEN);
DefineGlobalColor("CAM_UP2", Color.liGHT_GREEN);
DefineGlobalColor("CAM_UP3", Color.cyan);
DefineGlobalColor("CAM_UP4", Color.blue);

DefineGlobalColor("CAM_DN", Color.RED);
DefineGlobalColor("CAM_DN2", Color.darK_ORANGE );
DefineGlobalColor("CAM_DN3", Color.mAGENTA );
DefineGlobalColor("CAM_DN4", Color.plum );
AssignPriceColor(if !paintBars then Color.CURRENT

else if close > open and IR_BODYG and Vol >VolAvg then GlobalColor("CAM_UP3")
else if close < open and IR_BODYR and Vol >VolAvg then GlobalColor("CAM_DN3")

else if close > open and IR_BODYG then GlobalColor("CAM_UP4")
else if close < open and IR_BODYR then GlobalColor("CAM_DN4")

else if close > open and Vol >VolAvg then GlobalColor("CAM_UP")
else if close < open and Vol >VolAvg then GlobalColor("CAM_DN")

else if close > open then GlobalColor("CAM_UP2")
else if close < open then GlobalColor("CAM_DN2")

else Color.CURRENT);

 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

@bigboss Thank you for catching that!
Here is the latest mods to that script which includes options for either bull/bear signals or reversal signals(based off all cyan or magenta bars that exceed vol avg and followed by opposing volume to the bar prior).
The way buy/sell volume is calculated has been changed as well.

Update: Latest version 3.0 posted here(see script notes for update details).

Code:
# Original script by Cwparker23
# Mods/additions by Tidan
# Updates:
#    Further reduced redundancy
#    Reconfigured reversal signals to include magenta bars and set default mode to reversal
#    Restructured how bull/bear volume bars are recognized
#    Added option to use original buy/sell volume calculation or new method
#    Removed bull/bear option and signals
# v3


#hint: The indicator finds irregular bodies based on candle size and volume, it colors price to indicate irregular bodies below volume average (blue bullish and plum bearish) and indicate irregular bodies above-average volume (cyan bullish and magenta bearish). Also colors price with above-average volume (green bullish and red bearish) and below-average volume (light green bullish and orange bearish). \n As confirmation watch TMO(trueMomentumOsc), it should be above zero for entering short and below zero for entering long.\n\n<b>Note: </b>To view aggregations higher than daily comment out the two "AddLabel" lines by prefixing them with a "#" sign.


input showReversalSignals = yes;
input reversalFilter = yes;
input showLabels = no;
input paintBars = no;
input volAvgLength = 12; #default 12
input volAvgType = averageType.exponential; #default exponential
input useOriginalVolCalc = no;

def revSig = showReversalSignals;
def revFil = reversalFilter;


####
# new method to determine buying/selling volume
#def buying = Round(volume * (close - low) / (high - low), 0);
#def selling = Round(volume * (high - close) / (high - low), 0);

def buying;
def selling;
if useOriginalVolCalc
{
    buying = if close > open then 1 else 0;
    selling = if close < open then 1 else 0;
}
else
{
    buying = Round(volume * (close - low) / (high - low), 0);
    selling = Round(volume * (high - close) / (high - low), 0);
}
####

# Note: to view on time frames higher than Daily comment out these two AddLabel lines
AddLabel(showLabels, "Day_volume: " + volume (period = "DAY" ), Color.LIGHT_GRAY);
AddLabel(showLabels, "volume: " + volume, Color.white);

declare lower;
declare zerobase;

plot Vol = volume;
plot VolAvg = movingAverage(volAvgType,volume,volAvgLength);
VolAvg .SetPaintingStrategy(PaintingStrategy.squared_HISTOGRAM);
VolAvg .SetDefaultColor(Color.GRAY);
def BODY_RANGE = max(open,close) - min(open,close);
def IR_BODY = if (BODY_RANGE < BODY_RANGE[1]) and (volume > volume[1]) then 1 else 0 ;
def IR_BODYG  = if IR_BODY and buying > selling then 1 else 0;
def IR_BODYR  = if IR_BODY and buying < selling then 1 else 0;

####
# new method to determine vol bar properties
def up3 = if IR_BODYG and (Vol > VolAvg) then 1 else 0;
def up4 = if IR_BODYG then 1 else 0;
def down3 = if IR_BODYR and (Vol > VolAvg) then 1 else 0;
def down4 = if IR_BODYR then 1 else 0;
def up = if (buying > selling) and (Vol > VolAvg)  then 1 else 0;
def down = if (buying < selling) and (Vol > VolAvg) then 1 else 0;
def up2 = if (buying > selling) then 1 else 0;
def down2 = if (buying < selling) then 1 else 0;
####

Vol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Vol.SetLineWeight(3);
Vol.DefineColor("Up", Color.green);
Vol.DefineColor("Down", Color.red);
Vol.DefineColor("Up2", Color.light_green);
Vol.DefineColor("Down2", Color.dark_ORANGE );
Vol.DefineColor("Up3", Color.cyan);
Vol.DefineColor("Up4", Color.blue);
Vol.DefineColor("Down3", Color.mAGENTA );
Vol.DefineColor("Down4", Color.plum );

Vol.AssignValueColor(
    if up3 then Vol.color("Up3")
    else if up4  then Vol.color("Up4")
    else if down3 then Vol.color("Down3")
    else if down4 then Vol.color("Down4")
    else if up  then Vol.color("Up")
    else if down then Vol.color("Down")
    else if up2 then Vol.color("Up2")
    else if down2 then Vol.color("Down2")
    else color.white);




DefineGlobalColor("CAM_UP", Color.GREEN);
DefineGlobalColor("CAM_UP2", Color.liGHT_GREEN);
DefineGlobalColor("CAM_UP3", Color.cyan);
DefineGlobalColor("CAM_UP4", Color.blue);
DefineGlobalColor("CAM_DN", Color.RED);
DefineGlobalColor("CAM_DN2", Color.darK_ORANGE );
DefineGlobalColor("CAM_DN3", Color.mAGENTA );
DefineGlobalColor("CAM_DN4", Color.plum );

AssignPriceColor(
    if !paintBars then Color.CURRENT
    else if up3 then GlobalColor("CAM_UP3")
    else if down3 then GlobalColor("CAM_DN3")
    else if up4 then GlobalColor("CAM_UP4")
    else if down4 then GlobalColor("CAM_DN4")
    else if up then GlobalColor("CAM_UP")
    else if down then GlobalColor("CAM_DN")
    else if up2 then GlobalColor("CAM_UP2")
    else if down2 then GlobalColor("CAM_DN2")
    else Color.CURRENT);



# reversal signal set up
def pastUp = if up[2] or up2[2] or up3[2] or up4[2] then 1 else 0;
def pastDn = if down[2] or down2[2] or down3[2] or down4[2] then 1 else 0;
def currUp = if up or up2 or up3 or up4 then 1 else 0;
def currDn = if down or down2 or down3 or down4 then 1 else 0;
def trigger = if (pastUp and currUp) or (pastDn and currDn) then 0 else 1;

# cyan reversal
addVerticalLine(revSig and revFil and up3[1] and trigger,"",if(currUp) then color.light_green else if (currDn) then color.dark_orange else color.gray,curve.short_dash);
addVerticalLine(revSig and !revFil and up3[1],"",if(currUp) then color.light_green else if (currDn) then color.dark_orange else color.gray,curve.short_dash);
# magenta reversal
addVerticalLine(revSig and revFil and down3[1] and trigger,"",if(currUp) then color.light_green else if (currDn) then color.dark_orange else color.gray,curve.short_dash);
addVerticalLine(revSig and !revFil and down3[1],"",if(currUp) then color.light_green else if (currDn) then color.dark_orange else color.gray,curve.short_dash);

# end of script
 
Last edited by a moderator:
I love to see how everyone is finding different ways to use the indicator and it's drawbacks and fixes. Keep up the great work!
 
@bigboss Thank you for catching that!
Here is the latest mods to that script which includes options for either bull/bear signals or reversal signals(based off all cyan or magenta bars that exceed vol avg and followed by opposing volume to the bar prior).
The way buy/sell volume is calculated has been changed as well.


Code:
# Original script by Cwparker23
# Mods/additions by Tidan
# Updates:
#    Further reduced redundancy
#    Reconfigured reversal signals to include magenta bars and set default mode to reversal
#    Restructured how bull/bear volume bars are recognized
# v2.5


#hint: The indicator finds irregular bodies based on candle size and volume, it colors price to indicate irregular bodies below volume average (blue bullish and plum bearish) and indicate irregular bodies above-average volume (cyan bullish and magenta bearish). Also colors price with above-average volume (green bullish and red bearish) and below-average volume (light green bullish and orange bearish). \n As confirmation watch TMO(trueMomentumOsc), it should be above zero for entering short and below zero for entering long.

input showBullBearSignals = no;
input bullBearMultiplier = 2;
input allowBullBearOpposingVolume = yes;
input showReversalSignals = yes;
input reversalFilter = yes;
input showLabels = no;
input paintBars = no;
input volAvgLength = 12; #default 12
input volAvgType = averageType.exponential; #default exponential
def bbSig = showBullBearSignals;
def bbMultiplier = bullBearMultiplier;
def bbOppVol = allowBullBearOpposingVolume;
def revSig = showReversalSignals;
def revFil = reversalFilter;


####
# new method to determine buying/selling volume
def buying = Round(volume * (close - low) / (high - low), 0);
def selling = Round(volume * (high - close) / (high - low), 0);
####


AddLabel(showLabels, "Day_volume: " + volume (period = "DAY" ), Color.LIGHT_GRAY);
AddLabel(showLabels, "volume: " + volume, Color.white);

declare lower;
declare zerobase;

plot Vol = volume;
#plot VolAvg = expAverage(volume);
plot VolAvg = movingAverage(volAvgType,volume,volAvgLength);
VolAvg .SetPaintingStrategy(PaintingStrategy.squared_HISTOGRAM);
VolAvg .SetDefaultColor(Color.GRAY);
def BODY_RANGE = max(open,close) - min(open,close);
def IR_BODY = if (BODY_RANGE < BODY_RANGE[1]) and (volume > volume[1]) then 1 else 0 ;
def IR_BODYG  = if IR_BODY and buying > selling then 1 else 0;
def IR_BODYR  = if IR_BODY and buying < selling then 1 else 0;

####
def up3 = if IR_BODYG and (Vol > VolAvg) then 1 else 0;
def up4 = if IR_BODYG then 1 else 0;
def down3 = if IR_BODYR and (Vol > VolAvg) then 1 else 0;
def down4 = if IR_BODYR then 1 else 0;
def up = if (buying > selling) and (Vol > VolAvg)  then 1 else 0;
def down = if (buying < selling) and (Vol > VolAvg) then 1 else 0;
def up2 = if (buying > selling) then 1 else 0;
def down2 = if (buying < selling) then 1 else 0;
####

Vol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Vol.SetLineWeight(3);
Vol.DefineColor("Up", Color.green);
Vol.DefineColor("Down", Color.red);
Vol.DefineColor("Up2", Color.light_green);
Vol.DefineColor("Down2", Color.dark_ORANGE );
Vol.DefineColor("Up3", Color.cyan);
Vol.DefineColor("Up4", Color.blue);
Vol.DefineColor("Down3", Color.mAGENTA );
Vol.DefineColor("Down4", Color.plum );

Vol.AssignValueColor(
    if up3 then Vol.color("Up3")
    else if up4  then Vol.color("Up4")
    else if down3 then Vol.color("Down3")
    else if down4 then Vol.color("Down4")
    else if up  then Vol.color("Up")
    else if down then Vol.color("Down")
    else if up2 then Vol.color("Up2")
    else if down2 then Vol.color("Down2")
    else color.white);




DefineGlobalColor("CAM_UP", Color.GREEN);
DefineGlobalColor("CAM_UP2", Color.liGHT_GREEN);
DefineGlobalColor("CAM_UP3", Color.cyan);
DefineGlobalColor("CAM_UP4", Color.blue);
DefineGlobalColor("CAM_DN", Color.RED);
DefineGlobalColor("CAM_DN2", Color.darK_ORANGE );
DefineGlobalColor("CAM_DN3", Color.mAGENTA );
DefineGlobalColor("CAM_DN4", Color.plum );

AssignPriceColor(
    if !paintBars then Color.CURRENT
    else if up3 then GlobalColor("CAM_UP3")
    else if down3 then GlobalColor("CAM_DN3")
    else if up4 then GlobalColor("CAM_UP4")
    else if down4 then GlobalColor("CAM_DN4")
    else if up then GlobalColor("CAM_UP")
    else if down then GlobalColor("CAM_DN")
    else if up2 then GlobalColor("CAM_UP2")
    else if down2 then GlobalColor("CAM_DN2")
    else Color.CURRENT);


def bull =
    if bbSig and up3[1] and vol[1] >= (volAvg[1] * bbMultiplier) and (up3 or up4 or up or up2) then yes
    else if bbSig and bbOppVol and down3[1] and (vol[1] >= (volAvg[1] * bbMultiplier)) and (up3 or up4 or up or up2) then yes
    else double.nan;
def bear =
    if bbSig and down3[1] and vol[1] >= (volAvg[1] * bbMultiplier) and (down3 or down4 or down or down2) then yes
    else if bbSig and bbOppVol and up3[1] and (vol[1] >= (volAvg[1] * bbMultiplier)) and (down3 or down4 or down or down2) then yes
    else double.nan;

addVerticalLine(bull,"bull",color.green,curve.short_dash);
addverticalLine(bear,"bear",color.red,curve.short_dash);

# reversal signals
def pastUp = if up[2] or up2[2] or up3[2] or up4[2] then 1 else 0;
def pastDn = if down[2] or down2[2] or down3[2] or down4[2] then 1 else 0;
def currUp = if up or up2 or up3 or up4 then 1 else 0;
def currDn = if down or down2 or down3 or down4 then 1 else 0;
def trigger = if (pastUp and currUp) or (pastDn and currDn) then 0 else 1;

# cyan reversal
addVerticalLine(revSig and revFil and up3[1] and trigger,"",if(currUp) then color.light_green else if (currDn) then color.dark_orange else color.gray,curve.short_dash);
addVerticalLine(revSig and !revFil and up3[1],"",if(currUp) then color.light_green else if (currDn) then color.dark_orange else color.gray,curve.short_dash);
# magenta reversal
addVerticalLine(revSig and revFil and down3[1] and trigger,"",if(currUp) then color.light_green else if (currDn) then color.dark_orange else color.gray,curve.short_dash);
addVerticalLine(revSig and !revFil and down3[1],"",if(currUp) then color.light_green else if (currDn) then color.dark_orange else color.gray,curve.short_dash);

# end of script


anna5.png
this will not change the candle color last time like the Parker did?
 
this will not change the candle color last time like the Parker did?
@bigboss Thank you for catching that!
Here is the latest mods to that script which includes options for either bull/bear signals or reversal signals(based off all cyan or magenta bars that exceed vol avg and followed by opposing volume to the bar prior).
The way buy/sell volume is calculated has been changed as well.


Code:
# Original script by Cwparker23
# Mods/additions by Tidan
# Updates:
#    Further reduced redundancy
#    Reconfigured reversal signals to include magenta bars and set default mode to reversal
#    Restructured how bull/bear volume bars are recognized
# v2.5


#hint: The indicator finds irregular bodies based on candle size and volume, it colors price to indicate irregular bodies below volume average (blue bullish and plum bearish) and indicate irregular bodies above-average volume (cyan bullish and magenta bearish). Also colors price with above-average volume (green bullish and red bearish) and below-average volume (light green bullish and orange bearish). \n As confirmation watch TMO(trueMomentumOsc), it should be above zero for entering short and below zero for entering long.

input showBullBearSignals = no;
input bullBearMultiplier = 2;
input allowBullBearOpposingVolume = yes;
input showReversalSignals = yes;
input reversalFilter = yes;
input showLabels = no;
input paintBars = no;
input volAvgLength = 12; #default 12
input volAvgType = averageType.exponential; #default exponential
def bbSig = showBullBearSignals;
def bbMultiplier = bullBearMultiplier;
def bbOppVol = allowBullBearOpposingVolume;
def revSig = showReversalSignals;
def revFil = reversalFilter;


####
# new method to determine buying/selling volume
def buying = Round(volume * (close - low) / (high - low), 0);
def selling = Round(volume * (high - close) / (high - low), 0);
####


AddLabel(showLabels, "Day_volume: " + volume (period = "DAY" ), Color.LIGHT_GRAY);
AddLabel(showLabels, "volume: " + volume, Color.white);

declare lower;
declare zerobase;

plot Vol = volume;
#plot VolAvg = expAverage(volume);
plot VolAvg = movingAverage(volAvgType,volume,volAvgLength);
VolAvg .SetPaintingStrategy(PaintingStrategy.squared_HISTOGRAM);
VolAvg .SetDefaultColor(Color.GRAY);
def BODY_RANGE = max(open,close) - min(open,close);
def IR_BODY = if (BODY_RANGE < BODY_RANGE[1]) and (volume > volume[1]) then 1 else 0 ;
def IR_BODYG  = if IR_BODY and buying > selling then 1 else 0;
def IR_BODYR  = if IR_BODY and buying < selling then 1 else 0;

####
def up3 = if IR_BODYG and (Vol > VolAvg) then 1 else 0;
def up4 = if IR_BODYG then 1 else 0;
def down3 = if IR_BODYR and (Vol > VolAvg) then 1 else 0;
def down4 = if IR_BODYR then 1 else 0;
def up = if (buying > selling) and (Vol > VolAvg)  then 1 else 0;
def down = if (buying < selling) and (Vol > VolAvg) then 1 else 0;
def up2 = if (buying > selling) then 1 else 0;
def down2 = if (buying < selling) then 1 else 0;
####

Vol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Vol.SetLineWeight(3);
Vol.DefineColor("Up", Color.green);
Vol.DefineColor("Down", Color.red);
Vol.DefineColor("Up2", Color.light_green);
Vol.DefineColor("Down2", Color.dark_ORANGE );
Vol.DefineColor("Up3", Color.cyan);
Vol.DefineColor("Up4", Color.blue);
Vol.DefineColor("Down3", Color.mAGENTA );
Vol.DefineColor("Down4", Color.plum );

Vol.AssignValueColor(
    if up3 then Vol.color("Up3")
    else if up4  then Vol.color("Up4")
    else if down3 then Vol.color("Down3")
    else if down4 then Vol.color("Down4")
    else if up  then Vol.color("Up")
    else if down then Vol.color("Down")
    else if up2 then Vol.color("Up2")
    else if down2 then Vol.color("Down2")
    else color.white);




DefineGlobalColor("CAM_UP", Color.GREEN);
DefineGlobalColor("CAM_UP2", Color.liGHT_GREEN);
DefineGlobalColor("CAM_UP3", Color.cyan);
DefineGlobalColor("CAM_UP4", Color.blue);
DefineGlobalColor("CAM_DN", Color.RED);
DefineGlobalColor("CAM_DN2", Color.darK_ORANGE );
DefineGlobalColor("CAM_DN3", Color.mAGENTA );
DefineGlobalColor("CAM_DN4", Color.plum );

AssignPriceColor(
    if !paintBars then Color.CURRENT
    else if up3 then GlobalColor("CAM_UP3")
    else if down3 then GlobalColor("CAM_DN3")
    else if up4 then GlobalColor("CAM_UP4")
    else if down4 then GlobalColor("CAM_DN4")
    else if up then GlobalColor("CAM_UP")
    else if down then GlobalColor("CAM_DN")
    else if up2 then GlobalColor("CAM_UP2")
    else if down2 then GlobalColor("CAM_DN2")
    else Color.CURRENT);


def bull =
    if bbSig and up3[1] and vol[1] >= (volAvg[1] * bbMultiplier) and (up3 or up4 or up or up2) then yes
    else if bbSig and bbOppVol and down3[1] and (vol[1] >= (volAvg[1] * bbMultiplier)) and (up3 or up4 or up or up2) then yes
    else double.nan;
def bear =
    if bbSig and down3[1] and vol[1] >= (volAvg[1] * bbMultiplier) and (down3 or down4 or down or down2) then yes
    else if bbSig and bbOppVol and up3[1] and (vol[1] >= (volAvg[1] * bbMultiplier)) and (down3 or down4 or down or down2) then yes
    else double.nan;

addVerticalLine(bull,"bull",color.green,curve.short_dash);
addverticalLine(bear,"bear",color.red,curve.short_dash);

# reversal signals
def pastUp = if up[2] or up2[2] or up3[2] or up4[2] then 1 else 0;
def pastDn = if down[2] or down2[2] or down3[2] or down4[2] then 1 else 0;
def currUp = if up or up2 or up3 or up4 then 1 else 0;
def currDn = if down or down2 or down3 or down4 then 1 else 0;
def trigger = if (pastUp and currUp) or (pastDn and currDn) then 0 else 1;

# cyan reversal
addVerticalLine(revSig and revFil and up3[1] and trigger,"",if(currUp) then color.light_green else if (currDn) then color.dark_orange else color.gray,curve.short_dash);
addVerticalLine(revSig and !revFil and up3[1],"",if(currUp) then color.light_green else if (currDn) then color.dark_orange else color.gray,curve.short_dash);
# magenta reversal
addVerticalLine(revSig and revFil and down3[1] and trigger,"",if(currUp) then color.light_green else if (currDn) then color.dark_orange else color.gray,curve.short_dash);
addVerticalLine(revSig and !revFil and down3[1],"",if(currUp) then color.light_green else if (currDn) then color.dark_orange else color.gray,curve.short_dash);

# end of script


anna5.png
sorry I found the input option
 
I think this is a great study. I’m wondering why I would prefer an exponential moving average for average volume rather than a simple moving average. Any thoughts or reasons that you would prefer one over the other for average volume?
 
While I understand the key code, Im struggling to get the difference between lets say, cyan and dark green (both above avg vol bullish), magenta and red (above average volume bearish), orange and plum (below avg volume, bearish), etc...Any help? @Tidan @charlie2598 @Cwparker23
 
While I understand the key code, Im struggling to get the difference between lets say, cyan and dark green (both above avg vol bullish), magenta and red (above average volume bearish), orange and plum (below avg volume, bearish), etc...Any help? @Tidan @charlie2598 @Cwparker23
You can click the question mark next to the study after you add it to TOS or you can read the #hint comments in the source code.
The colors change relative to candle size and volume.
 
I created this indicator after reading Anna Coulling book on volume price analysis. https://www.amazon.com/Complete-Gui...t=&hvlocphy=9051671&hvtargid=pla-432422856366

The indicator finds irregular bodies based on candle size and volume it colors price to indicate irregular bodies below volume average (blue bullish and plum bearish) and indicate bodies above-average volume (cyan bullish ad magenta bearish). Also colors price with above-average volume (green bullish and red bearish) and below-average volume (light green bullish and orange bearish).

Here is the link to the indicator: https://tos.mx/uSOXiHe Click here for --> Easiest way to load shared links

Here are some other indicators I created: https://www.youtube.com/channel/UCX4CpcAoeGoFCFeOIzWlLqA
Hello, For this Anna Indicator, is there a way to put this on a weekly or monthly candle chart? Thansk!
 
Hello, thats what I tried to do. maybe there is a newer version that lets you do that?
It works fine on everything from the 1d/1min to the 1y/1day time frame for me. Not sure why it wouldn't be the same for you. Can you post a screen shot of the issue you're having?
 
It works fine on everything from the 1d/1min to the 1y/1day time frame for me. Not sure why it wouldn't be the same for you. Can you post a screen shot of the issue you're having? Not sure how to post a snip shot but the indicator is blank. Only on the weekly and monthly charts. Not sure whats different but maybe you have a different version than i do?


It works fine on everything from the 1d/1min to the 1y/1day time frame for me. Not sure why it wouldn't be the same for you. Can you post a screen shot of the issue you're having?
 
Here's an interesting way to look at the irregular (cyan and magenta) candles. This script plots arrows on the upper chart as buy and sell signals for the irregular candles. It also has an option to do higher timeframe candles in two ways - using standard higher timeframe aggregation (with all the downsides like repainting that come with that), but also using a rolling period to construct aggregate candles of a user configurable period, in a way that will not repaint.

Code:
# VPA IRREGULAR ARROWS WITH ALTERNATE TIMEFRAME OPTIONS
# VERSION 1.0
# by bigboss
#
# Modified from https://usethinkscript.com/threads/anna-coulling-volume-price-analysis-for-thinkorswim.8882/post-86921
# This plots the irregular buy and sell volume candles as arrows
#
# Added an option to do multi timeframe analysis in two ways
# 1. The first way is simply using a higher timeframe aggregation.
#    This can be useful if you want to see the 5 min irregular candles
#    on a 1 min chart, for instance. It repaints, and will flicker on
#    and off until the 5 minute period so be aware.
#
# 2. The second way is a little more novel, and much more interesting.
#    It constructs a higher timeframe candle by looking at the open, high,
#    low, close, and volume of the previous X bars. On a 1 minute chart with
#    a rolling length of 5, it will take the last 5 bars and merge them together
#    as if they were one 5 minute candle, then evaluates the aggregate candle for irregular
#    body shape, and volume against the prior rollingLength period.


input volavgtype = averagetype.exponential;
input volavglength = 12;
input AggregationMode = {none, period, default rolling};
input period = aggregationPeriod.FIVE_MIN;
input rollingLength = 5;

def v;
def o;
def h;
def l;
def c;
def vaLength;
def vOffset;

switch(AggregationMode){
    case none:
        v = volume;
        o = open;
        h = high;
        l = low;
        c = close;
        vaLength = volAvglength;
        vOffset = 1;
    case period:
        v = volume(period=period);
        o = open(period=period);
        h = high(period=period);
        l = low(period=period);
        c = close(period=period);
        vaLength = volAvglength;
        vOffset = 1;
    case rolling:
        v = sum(volume,rollingLength);
        o = open[rollingLength-1];
        h = highest(high,rollingLength);
        l = lowest(low,rollingLength);
        c = close;
        vaLength = volAvgLength * rollingLength;
        vOffset = rollingLength;
}

def VolAvg = movingAverage(volAvgType,v,vaLength);
def buying = Round(v * (c - l) / (h - l), 0);
def selling = Round(v * (h - c) / (h - l), 0);


def BODY_RANGE = max(o,c) - min(o,c);
def IR_BODY = if (BODY_RANGE < BODY_RANGE[vOffset]) and (v > v[vOffset]) then 1 else 0 ;
def IR_BODYG  = if IR_BODY and buying > selling then 1 else 0;
def IR_BODYR  = if IR_BODY and buying < selling then 1 else 0;

def up3 = if IR_BODYG and (v > VolAvg) then 1 else 0;
def down3 = if IR_BODYR and (v > VolAvg) then 1 else 0;

plot buyarrow = up3;
buyarrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
buyarrow.setdefaultColor(color.cyan);
plot sellarrow = down3;
sellarrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
sellarrow.setdefaultColor(color.magenta);
 
Here's an interesting way to look at the irregular (cyan and magenta) candles. This script plots arrows on the upper chart as buy and sell signals for the irregular candles. It also has an option to do higher timeframe candles in two ways - using standard higher timeframe aggregation (with all the downsides like repainting that come with that), but also using a rolling period to construct aggregate candles of a user configurable period, in a way that will not repaint.

Code:
# VPA IRREGULAR ARROWS WITH ALTERNATE TIMEFRAME OPTIONS
# VERSION 1.0
# by bigboss
#
# Modified from https://usethinkscript.com/threads/anna-coulling-volume-price-analysis-for-thinkorswim.8882/post-86921
# This plots the irregular buy and sell volume candles as arrows
#
# Added an option to do multi timeframe analysis in two ways
# 1. The first way is simply using a higher timeframe aggregation.
#    This can be useful if you want to see the 5 min irregular candles
#    on a 1 min chart, for instance. It repaints, and will flicker on
#    and off until the 5 minute period so be aware.
#
# 2. The second way is a little more novel, and much more interesting.
#    It constructs a higher timeframe candle by looking at the open, high,
#    low, close, and volume of the previous X bars. On a 1 minute chart with
#    a rolling length of 5, it will take the last 5 bars and merge them together
#    as if they were one 5 minute candle, then evaluates the aggregate candle for irregular
#    body shape, and volume against the prior rollingLength period.


input volavgtype = averagetype.exponential;
input volavglength = 12;
input AggregationMode = {none, period, default rolling};
input period = aggregationPeriod.FIVE_MIN;
input rollingLength = 5;

def v;
def o;
def h;
def l;
def c;
def vaLength;
def vOffset;

switch(AggregationMode){
    case none:
        v = volume;
        o = open;
        h = high;
        l = low;
        c = close;
        vaLength = volAvglength;
        vOffset = 1;
    case period:
        v = volume(period=period);
        o = open(period=period);
        h = high(period=period);
        l = low(period=period);
        c = close(period=period);
        vaLength = volAvglength;
        vOffset = 1;
    case rolling:
        v = sum(volume,rollingLength);
        o = open[rollingLength-1];
        h = highest(high,rollingLength);
        l = lowest(low,rollingLength);
        c = close;
        vaLength = volAvgLength * rollingLength;
        vOffset = rollingLength;
}

def VolAvg = movingAverage(volAvgType,v,vaLength);
def buying = Round(v * (c - l) / (h - l), 0);
def selling = Round(v * (h - c) / (h - l), 0);


def BODY_RANGE = max(o,c) - min(o,c);
def IR_BODY = if (BODY_RANGE < BODY_RANGE[vOffset]) and (v > v[vOffset]) then 1 else 0 ;
def IR_BODYG  = if IR_BODY and buying > selling then 1 else 0;
def IR_BODYR  = if IR_BODY and buying < selling then 1 else 0;

def up3 = if IR_BODYG and (v > VolAvg) then 1 else 0;
def down3 = if IR_BODYR and (v > VolAvg) then 1 else 0;

plot buyarrow = up3;
buyarrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
buyarrow.setdefaultColor(color.cyan);
plot sellarrow = down3;
sellarrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
sellarrow.setdefaultColor(color.magenta);


Somtheing like this might help with the excess candles printing:
Code:
plot buyarrow = if !up3[1] then up3 else double.nan;

plot sellarrow = if !down3[1] then down3 else double.nan;
 
Hey Tidan, Any way you can just copy and past the correct version? If not, no worries as I appreciate you trying to help.
 
Last edited by a moderator:
Hey Tidan, Any way you can just copy and past the correct version? If not, no worries as I appreciate you trying to help.
I'm not in front of my computer.
The process is as simple as pressing the "#" sign one time on your keyboard, there's nothing more to it. That is the ONLY edit you need to make to get it working as you wish. Please reference the above post again.

For your convenience here it is again.
Add a pound sign to the beginning of this line:

AddLabel(showLabels, "Day_volume: " + volume (period = "DAY" ), Color.LIGHT_GRAY);

So it looks like this:

#AddLabel(showLabels, "Day_volume: " + volume (period = "DAY" ), Color.LIGHT_GRAY);

If that is too difficult then simply delete the entire line.
 
Last edited:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
353 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top