1 Sigma

You first should clear why "352", must be a typo; it surely was supposed to mean 252.

And: you should know what you are calculating :)
Do you want to calc
1) the possible 1SD price range (ie. for -1SD and for +1SD), or
2) the theoretical price of the Call or Put option?
B/c if your current stock price is 201.48 and you calculate something like 4.95, 4.78, 5.70, 5.48 etc, then this never can be the result for #1, it rather must be the theoretical option price (#2). But for that you are not using the correct formula: for it Black-Scholes must be used.
IMO, you have totally messed up, man :)
My advice: use a real programming language, not such a spreadsheet "language" like Excel or such crap :)

Yeah changed that...don't know why I keep typing 352...anyway if I messed up then so did tos and I think they know how to calculate SD. :)

I have dabbled in php but not anything else. Are you api the data for the script or have to manually add it in?

the DBL_EPSILON stuff means just to make it slightly > 0, ie. to avoid <= 0 (b/c otherwise NaN or DivByZero can happen)

on google sheets you just need iferror( :)
 
...anyway if I messed up then so did tos and I think they know how to calculate SD. :)
Can you just tell which input parameters they use to calc it?

Ah, I finally figured out what you are attempting to do: Converting IV down for DTE and then calc SD of stock for DTE...
Here's the solution using the Linux "bc" calculator:
s=201.48 ; iv=20.99 ; dte=5 ; z=1 ; pp = iv * z * sqrt(dte / 365) ; sd = s * pp / 100 ; sd
4.9497
Ie. just set s, iv, dte, and keep the rest

Here's a slightly extended version by also varying z: for z it prints the SD and the Sx:
Code:
s=201.48 ; iv=20.99 ; dte=5 ; z=-1 ; pp = iv * z * sqrt(dte / 365) ; sd = s * pp / 100 ; sd ; s + sd
-4.94974642575233342445
196.53025357424766657555

s=201.48 ; iv=20.99 ; dte=5 ; z=1 ; pp = iv * z * sqrt(dte / 365) ; sd = s * pp / 100 ; sd ; s + sd
4.94974642575233342445
206.42974642575233342445


I just use stock price * volatility * square root of days to expiration/365 (or 252)
and I get: $4.95

TOS has: $4.78

However if I take the actual data over the past 30 days and adjust the SD for the trend then I get:
$5.70/$5.48 which are probably the more realistic targets imo. I prefer this method because then I don't need to keep adding in IV manually...but as Desteiro pointed out this will skew if there are high volatility events. The maximum daily range over the last 365 days was $9.70 on Oct13 2022 so there is less than a 1% of that occurring...and about a 36% chance that the daily range will be wider than the current atr ($3.69) based on the last 365 days.
You can do whatever you like :)
 
Last edited:
I have dabbled in php but not anything else. Are you api the data for the script or have to manually add it in?
Oh boy, I'm afraid this C/C++ code is too complicated for you, since you never ever have compiled a program before (FYI: a C/C++ program must be "compiled" to an executable binary (exe), this is much different from interpreted (scripting) languages where no such compilation is necessary).
The code was intended that you just read it and convert it to your own language of choice.

the DBL_EPSILON stuff means just to make it slightly > 0, ie. to avoid <= 0 (b/c otherwise NaN or DivByZero can happen)

on google sheets you just need iferror( :)
But that's a very bad programming practice and slows down the program. Better is to avoid the error case in the first place, as done in my code.
 
Last edited:
Here's the solution using the Linux "bc" calculator:
s=201.48 ; iv=20.99 ; dte=5 ; z=1 ; pp = iv * z * sqrt(dte / 365) ; sd = s * pp / 100 ; sd
4.9497
Ie. just set s, iv, dte, and keep the rest

Here's a slightly extended version by also varying z: for z it prints the SD and the Sx:
Code:
s=201.48 ; iv=20.99 ; dte=5 ; z=-1 ; pp = iv * z * sqrt(dte / 365) ; sd = s * pp / 100 ; sd ; s + sd
-4.94974642575233342445
196.53025357424766657555

s=201.48 ; iv=20.99 ; dte=5 ; z=1 ; pp = iv * z * sqrt(dte / 365) ; sd = s * pp / 100 ; sd ; s + sd
4.94974642575233342445
206.42974642575233342445
C++ code for ExpectedMove (EM): this is practically the same as the above "bc"-code
z means xSD, ie. -1 or +1 for -1SD or +1SD; one can of course use also other values for z.
What's missing in this solution is rPct and qPct (this is left for you as an exercise :)) --> see the above calc_Sx for their meaning.
And: this version uses NormalDistribution around S, but it rather should use LognormalDistribution (ie. that would make it an Advanced Solution, a more exact solution).
Code:
double ExpectedMove(const double S, const double AnnVolaPct, const double nDays, const double z, double& PeriodPct, double& Sx)
  {
    PeriodPct = AnnVolaPct * z * sqrt(nDays / 365.0);
    const double SD = S * PeriodPct / 100.0;
    Sx = S + SD;
    return SD;
  }

Example output when called from a wrapper program:
Code:
ExpectedMove for S=201.4800 Vola=20.9900 nDays=5.00 z=-1.00: -4.949746(-2.4567% --> Sx=196.530254)
ExpectedMove for S=201.4800 Vola=20.9900 nDays=5.00 z=+1.00: +4.949746(+2.4567% --> Sx=206.429746)
 
Last edited:
I’ll give you a shortcut, but you need to google how to find EM (expected move) for 30 days:

SD=EM/0.8 (approx)

What the rule of 16? Already have it.


Oh boy, I'm afraid this C/C++ code is too complicated for you, since you never ever have compiled a program before (FYI: a C/C++ program must be "compiled" to an executable binary (exe), this is much different from interpreted (scripting) languages where no such compilation is necessary).
The code was intended that you just read it and convert it to your own language of choice.


But that's a very bad programming practice and slows down the program. Better is to avoid the error case in the first place, as done in my code.

if(A3=0,""
 
Example output when called from a wrapper program:
Code:
ExpectedMove for S=201.4800 Vola=20.9900 nDays=5.00 z=-1.00: -4.949746(-2.4567% --> Sx=196.530254)
ExpectedMove for S=201.4800 Vola=20.9900 nDays=5.00 z=+1.00: +4.949746(+2.4567% --> Sx=206.429746)

So all that to come to the same result as my spreadsheet, but without P/L ladder and color coded SD levels, or the cool P/L graph. :)

rp.jpg
 
So all that to come to the same result as my spreadsheet, but without P/L ladder and color coded SD levels, or the cool P/L graph. :)
Yeah, cool! Enjoy! :-)
Mine is low-level library code (it can be put into an own DLL etc. and then used from other programs).
It's no problem to build GUI wrapper programs that use the library.
 
Yeah, cool! Enjoy! :)
Mine is low-level library code (it can be put into an own DLL etc. and then used from other programs).
It's no problem to build GUI wrapper programs that use the library.

Anyway BS is all skewed wrong imo...the trend weighted sigma is more likely the actual statistical range, which comes to a 1SD range for IWM DEC29 of:
$198.39/$206.34
 
Last edited:
Back
Top