In his book, The Volatility Edge in Options Trading, Jeff Augen describes a method for recasting absolute price changes in terms of recent volatility using the standard deviation. In this representation of price action, the last bar’s price change is represented as its ratio to the standard deviation of the price action over a recent period. *** Please see Tom’s N-1 weighted version in the comments! ***
# AUGENSTDDEVPLOT
# (c) 2009 http://www.thinkscripter.com
# thinkscripter@gmail.com
# Last Update 19 MAR 2009
declare lower;
input price = close;
input length = 20;
def oneSD = stdev (price,length);
plot StdDevPlot = (price-price[1])/oneSD;
StdDevPlot.setPaintingStrategy(paintingStrategy.HISTOGRAM);
StdDevPlot.setLineWeight(2);
StdDevPlot.assignValueColor(if StdDevPlot > 0 then color.green else color.red);
plot zero = 0;
zero.setDefaultColor(color.white);





That doesn’t take into effect N-1 weighting. Check out my version:
# Tom Utley 3-17-2009
# Thanks to Jeff Augen
# Price Spikes in Standard Deviations
declare lower;
input length = 20;
def closeLog = Log(close[1] / close[2]);
def SDev = stdev(closeLog, length)* Sqrt(length / (length – 1));
def m= SDev * close[1];
plot spike = (close[0] – close[1]) / m;
spike.setPaintingStrategy(PaintingStrategy.HISTOGRAM);
spike.AssignValueColor(if close > close[1] then Color.UPTICK else if close < close[1] then Color.DOWNTICK else GetColor(1));
Can you help me with your code.
I have been trying to convert this the tradestations easy language
would you have any idea on how to write that code.
thanks
Joe,
Unfortunately I don’t program TradeStation.
Eric
HI, just found this site. Be happy to pay, but also wanting to know if there are any indicators with sounds that trigger and not have to be reset like their alert system?
Is there any way to screen for stocks that have spiked in price more than a certain number of standard deviations (say 3) that particular day?
Pat,
Unfortunately, the TOS screening tools do not allow you to use custom studies in the screen process.
Eric
I typed in the code verbatum and the line: def SDev = stdev(closeLog, length)* Sqrt(length / (length – 1)); is invalid in TOS. I did not copy and paste. Why is TOs not recognizing this
thank you
Ok there was an extra parenthesis, TOS now has no invalid entries. When i go to add the study to a chart it does not plot. i can’t figure that out. the first indicator listed in this post works well it plots just fine , but the one that factors in the N-1 weighting does not plot. This is after I typed in the code exactly.
thank you
So is this correct for a 5 day price spike for 60 days?
declare lower;
input length = 60;
def closeLog = Log(close[1] /close[5]);
def astd = stdev(closeLog, length) * Sqrt(length / (5));
def m = astd * close [1];
plot spike = (close[0]- close [5]) / m;
spike.setPaintingStrategy(paintingStrategy.HISTOGRAM);
spike. AssignValueColor(if close > close[5] then Color.UPTICK else if close < close[5] then Color.DOWNTICK else GetColor(1));
plot zero = 0;
zero.setDefaultColor(color.black);
plot one = 1;
one.setDefaultColor(color.red);
plot two = -1;
two.setDefaultColor(color.red);
plot three = 0.5;
three.setDefaultColor(color.blue);
plot four = -0.5;
four.setDefaultColor(color.blue);
Many Thanks
D
Please could anyone help? Is this correct for a 5 day price spike for 60 days?
declare lower;
input length = 60;
def closeLog = Log(close[1] /close[5]);
def astd = stdev(closeLog, length) * Sqrt(length / (5));
def m = astd * close [1];
plot spike = (close[0]- close [5]) / m;
spike.setPaintingStrategy(paintingStrategy.HISTOGRAM);
spike. AssignValueColor(if close > close[5] then Color.UPTICK else if close < close[5] then Color.DOWNTICK else GetColor(1));
plot zero = 0;
zero.setDefaultColor(color.black);
plot one = 1;
one.setDefaultColor(color.red);
plot two = -1;
two.setDefaultColor(color.red);
plot three = 0.5;
three.setDefaultColor(color.blue);
plot four = -0.5;
four.setDefaultColor(color.blue);
Many Thanks
Dz
I’m not sure what you mean by 5 day spike? You will get a better response if you post questions in the forum rather than here in the comments.
-Eric
Excellent addition Tom. Thank you.
-Eric
Susan,
Currently there is no functionality in thinkScript to trigger audio
alerts. Believe me, we are ALL waiting for this. Please send
ThinkOrSwim an email to that effect. If enough of us complain, they
will add it to the software.
Eric
Tom
I am unable to get your study to be recognized
I get invalid statement which leads to no such variable.
and at least one plot needs to be defined.
Can you clarify
The text editor in TOS sometimes has problems pasting in text from a web browser. If this happens, you’ll need to go in to the code and remove some hidden carriage returns around the semicolons. These hidden characters will manifest themselves as all kinds of script errors having nothing to do with the real syntax of the script.
-Eric
That fixed it thanks.
The Running Tom’s AugenIndicator with the N-1 weighting makes a massive difference if you are looking for moves outside of 2 standard deviations.
Much better accuracy. Thanks Eric and Tom!