Relative Volume Standard Deviation for ThinkorSwim

XeoNoX

Well-known member
VIP
This is the built in code of TOS for RelativeVolumeStDev

i however when its charted on a chart i just want to hide (not show) the bars that are under 2.0 times the relative volume.
example pic of what im trying to hide attached

Code:
#
# TD Ameritrade IP Company, Inc. (c) 2014-2019
#

declare lower;
declare zerobase;

input length = 60;
input numDev = 2.0;
input allowNegativeValues = no;

def rawRelVol = (volume - Average(volume, length)) / StDev(volume, length);
plot RelVol = if allowNegativeValues then rawRelVol else Max(0, rawRelVol);
plot StDevLevel = numDev;

RelVol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
RelVol.SetLineWeight(3);
RelVol.DefineColor("Above", GetColor(0));
RelVol.DefineColor("Below", GetColor(2));
RelVol.AssignValueColor(if RelVol >= numDev then RelVol.Color("Above") else RelVol.Color("Below"));
StDevLevel.SetDefaultColor(GetColor(7));
StDevLevel.SetStyle(Curve.SHORT_DASH);

nnwid8K.png
 

tomsk

Well-known member
VIP
@XeoNoX Per your request I have modified your study so that it only displays bars ABOVE the dotted line.
Here is the code, I tested against your 1 min chart of AMD

Code:
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:

MrDrB

New member
Can someone please help me add dashed vertical lines to the canned TOS RelativeVolumeStDev indicator? I would like them on the price chart where standard deviation is greater than 2
 

ronl1975

New member
Hi everybody. I am brand new here. I like using the TOS built in study RelativeVolumeStDev. However I would like to set an alert if the numDev were to hit 4.0 or higher during intraday and PM/AH. Could somebody kindly help me out. I've tried using some alert code but no luck; I have no clue what I'm doing. Please help!

Code:
#
# TD Ameritrade IP Company, Inc. (c) 2014-2021
#

declare lower;
declare zerobase;

input length = 60;
input numDev = 2.0;
input allowNegativeValues = no;

def rawRelVol = (volume - Average(volume, length)) / StDev(volume, length);
plot RelVol = if allowNegativeValues then rawRelVol else Max(0, rawRelVol);
plot StDevLevel = numDev;

RelVol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
RelVol.SetLineWeight(3);
RelVol.DefineColor("Above", GetColor(0));
RelVol.DefineColor("Below", GetColor(2));
RelVol.AssignValueColor(if RelVol >= numDev then RelVol.Color("Above") else RelVol.Color("Below"));
StDevLevel.SetDefaultColor(GetColor(7));
StDevLevel.SetStyle(Curve.SHORT_DASH);
 

mc01439

Well-known member
2019 Donor
VIP
Try the following - I also added a label for you. If you do not want the label just pick "no" under input.

http://tos.mx/k9BGx4i


Code:
#Alert
def alerttrigger1 = volume crosses above numDev;

input alerttext = "!!!!! Volume crosses Number Deviation  !!!!!";

input UseAlerts = {false, default true};

input AlertType = {default "BAR", "ONCE", "TICK"};

def at = AlertType;

input AlertSound = {"Chimes", "Ring", default "Bell", "NoSound", "Ding"};

Alert (alerttrigger1 and UseAlerts, alerttext, if at == 1 then Alert.ONCE else if at == 2 then Alert.TICK else Alert.BAR, AlertSound);

#Label
input label = yes;

def nDev = alerttrigger1;

AddLabel(label and nDev, " Deviation > Input ", color.PLUM);
 

ronl1975

New member
Try the following - I also added a label for you. If you do not want the label just pick "no" under input.

http://tos.mx/k9BGx4i


Code:
#Alert
def alerttrigger1 = volume crosses above numDev;

input alerttext = "!!!!! Volume crosses Number Deviation  !!!!!";

input UseAlerts = {false, default true};

input AlertType = {default "BAR", "ONCE", "TICK"};

def at = AlertType;

input AlertSound = {"Chimes", "Ring", default "Bell", "NoSound", "Ding"};

Alert (alerttrigger1 and UseAlerts, alerttext, if at == 1 then Alert.ONCE else if at == 2 then Alert.TICK else Alert.BAR, AlertSound);

#Label
input label = yes;

def nDev = alerttrigger1;

AddLabel(label and nDev, " Deviation > Input ", color.PLUM);
Thank you. I will check it out on Monday!
 

ronl1975

New member
Try the following - I also added a label for you. If you do not want the label just pick "no" under input.

http://tos.mx/k9BGx4i


Code:
#Alert
def alerttrigger1 = volume crosses above numDev;

input alerttext = "!!!!! Volume crosses Number Deviation  !!!!!";

input UseAlerts = {false, default true};

input AlertType = {default "BAR", "ONCE", "TICK"};

def at = AlertType;

input AlertSound = {"Chimes", "Ring", default "Bell", "NoSound", "Ding"};

Alert (alerttrigger1 and UseAlerts, alerttext, if at == 1 then Alert.ONCE else if at == 2 then Alert.TICK else Alert.BAR, AlertSound);

#Label
input label = yes;

def nDev = alerttrigger1;

AddLabel(label and nDev, " Deviation > Input ", color.PLUM);

@mc01439

Thanks again. I've tested this with /NQ tonight and it isn't working :( . I've switch the code around and tried other code after reading the "Thinkscript Learning Center" with no luck. I've been trying to get this one thing right for a month and figured I'd find a group and ask folks that know more than me -because I'm obviously not a coder. I am pleased that I've found somebody that could offer some help as I posted the same question 6 hours ago and didn't get an answer - Thus the reason why I posted again. I'm not trying to get on here to mooch off others. I'm not trying to have poor forum etiquette. I just figured that maybe this could be easy for somebody that could help. Therefore, I thank you for your time and effort in attempting to get this 1 alert right for me. I'll keep searching. (Sorry for the bold font, I do not know why it won't "unbold", sorry for the repost and sorry for the stupid questions)​

 

rad14733

Well-known member
VIP
@ronl1975 Simply because nobody answered your question as fast as you wanted doesn't make reposting right... That IS poor forum etiquette whether you see it as such or not... If someone has the time to read your post, and has an answer, they will respond... It may be minutes, hours, days, months, or never, but that doesn't mean just keep posting until someone answers... These are very busy forums, believe it or not, and not everyone is well versed in every aspect of trading or Thinkscript... Those who are here, on and off, throughout the day generally read EVERY post so nothing goes un-noticed... Maybe you're new to the forum culture and maybe you aren't but I've been running or helping maintain forums since the inception of the internet, and BBS's before that, so I know what is and isn't proper... Making sure members follow proper etiquette helps keep forums orderly and reduces the amount of administrative time and effort it takes to correct what has been messed up... If you had as much experience doing such maintenance as I do you would understand why members are steered in the right direction...

Nuff Said... Trade on...
 

mc01439

Well-known member
2019 Donor
VIP

@mc01439

Thanks again. I've tested this with /NQ tonight and it isn't working :( . I've switch the code around and tried other code after reading the "Thinkscript Learning Center" with no luck. I've been trying to get this one thing right for a month and figured I'd find a group and ask folks that know more than me -because I'm obviously not a coder. I am pleased that I've found somebody that could offer some help as I posted the same question 6 hours ago and didn't get an answer - Thus the reason why I posted again. I'm not trying to get on here to mooch off others. I'm not trying to have poor forum etiquette. I just figured that maybe this could be easy for somebody that could help. Therefore, I thank you for your time and effort in attempting to get this 1 alert right for me. I'll keep searching. (Sorry for the bold font, I do not know why it won't "unbold", sorry for the repost and sorry for the stupid questions)​

Sorry my mistake. I tested with the corrections I made, it works now. Just change the "input numDev" to the number you want.

http://tos.mx/jDKQojo
 

Similar threads

Top