Tools, Techniques, and Training for Nirvana Platforms 
OmniTrader, VisualTrader, OmniFunds & OmniVest 
 
 


1 Timothy 6:910 (NIV) … People who want to get rich fall into temptation and a trap and into many foolish and harmful desires that plunge men into ruin and destruction. For the love of money is a root of all kinds of evil. Some people, eager for money, have wandered from the faith and pierced themselves with many griefs. 
Evaluating PriceWiggles (Volatility)  

JimDean 
 
Owner/Admin Posts: 3922 Location: USA: GA, Lawrenceville  Volatility certainly is an important concept in trading. Some trading methods are driven as much or more by volatilityanalysis than by pricemomentum, etc ... options in particular (historical vs implied volatility ... click here for an indic that deals with those). This thread is not intended for discussion about options considerations, since their timevalue and multiple contracts set a different kind of playingfield than we deal with when trading stocks. I've been spending a lot of time, off and on in the past few years or so studying different ways of measuring how "wiggly" a stock's price is. There are hundreds of different uses for this information ... yet often I think we take a "kneejerk" approach to it ... sometimes we "automatically" gravitate to "interbar" measurements like Std Dev or Variance ... other times we "automatically" choose "intrabar" measurements like HL Range or TrueRange. Most times, we just use what "everyone else uses" ... but if five million Martians call a cow's tail a "leg", a cow still actually has only four legs ... that is, the fact that a lot of people (ET's?) believe something to be true doesn't necessarily make it true. In order to study this, we need to look closely at every aspect of the calculations of each "traditional" calculation, and think about reasons why some other alternative might be better ... not just toss every alternative in a pot, but have a rationale for each, so we can meaningfully test it. Then somehow we need to build some kind of evaluation tool to compare alternatives.  
JimDean 
 
Owner/Admin Posts: 3922 Location: USA: GA, Lawrenceville  Two things have intrigued me recently ... 1. what is the "best" averaging method to use for TrueRange (TR)? 2. how do True Range and Std Deviation (SD) relate to one another? To evaluate this, I've created a simple Indicator that plots *normalized* SD (red) and TR (green) on the same scale, their average (gold), as well as the SD/TR ratio (blue). Also, the Indic allows for TR to be averaged in one of seven methods (calc's are slow/inefficient but easy to code up for testing): 1=SMA, 3=WMA, 5=EMA, 7=Wilder's ... where 2,4,6, are averages of the two adjoining methods. In addition to the plotting, the indic provides a Return value that looks back over the entire history and reports the (simple) Average, Max, or Std Dev of the SD/TR ratio ... this is used to create a Focus List column so that the "scope" of the ratio can be evaluated across many stocks. The final input param controls this. Finally, I added a "Cap" input (which probably doesn't matter too much), so that the "outlier" cases of the ratio could be capped off before the Avg & SD are affected by them ... if the cap ends up being less that some SD excursion, the plot shows maroon histo's coming down from the top, to show how much higher the SD actually was. This makes the chart somewhat more readable. If Cap is set to zero, it's turned off. The snapshots below show what the code looks like (registered Participants can download the TXT file), and a sample chart. Don't read a lot into the choices of periods or avg'g methods in the snapshot ... this is a testing tool. (aJDndSDvsTR FL&chartsnap.png) (aJDndSDvsTR codesnap.png) Attachments aJDndSDvsTR FL&chartsnap.png (78KB  0 downloads)aJDndSDvsTR codesnap.png (89KB  0 downloads) aJDndSDvsTR.txt (1KB  8 downloads)  
JimDean 
 
Owner/Admin Posts: 3922 Location: USA: GA, Lawrenceville  The snapshot shows the results from one set of param's ... I'm not going to the trouble of creating snaps for all the variations but you can download the code and try it yourself. The snap shows the Nas100, but I later decided to use the DNS1 for testing since it's a bit more representative of the "main" stocks ... DNS1 = Dow 15+20+30 + Nas100 + SP100 ... currently 217 symbols (some overlap of the lists of course). Note that I've normalized all the results so that they are comparable between stocks. The snap below shows the results of 72 test runs, across the spectrum of periods and MA calc types. All of them use the same list and number of bars and cap. The Max and Min columns are usually the average of the two top and bottom sorted symbols, unless their history was too short or the results were odd (uncommon). I'm using 10, 20 and 40 periods for the mostrepresentative TR avg'g method (4=WMA&EMA avg'd), then I standardize on 20 to compare the other avg'g methods (see chart). To help simplify things, I'm not playing with how StdDev is calc'd in these tests ... the canned OT function does it using the SMA as the centerline, focusing on the Closing price, without any correction for skew or kurtosis. The two tables below show different sorting methods of the same 72 tests ... the LHS table sorts by Periods then SWEL (calc method), and the RHS table sorts by SWEL then Pds. Each has two sets of three columns ... Max/Middle/Min values for the Average of the SD/TR values for the DNS1 list across 500 bars, and then the Max/Middle/Min values for the Std Deviation of those SD/TR values as a percentage of the Average SD/TR values ... that is, the percent that the Average ratio typically "swings" over time and various symbols. There are a number of interesting observations from this: 1. the LHS table "Mid SMA" column is very consistent for a given Pds, regardless of calc method 2. the SD/TR ratio increases about 42% when periods double ... .79*1.42~1.14 & 1.14*1.42~1.61 3. the median StdDev of SD/TR is fairly constant at about 40% (more pds = a bit less StdDev) 4. the max&min StdDev's of SD/TR follow a similar pattern, but varying between ~25% to ~75% 5. the RHS table shows StdDev of SD/TR is a bit lower for StoW methods than for EtoL methods Conclusions from those observations: a. There is a fairly consistent pattern in the variation of SD vs TR, from a medianratio point of view ... a very approx formula can be derived to express that ratio as a function of the periods, relatively independent of the calcmethod: SD/TR ratio = Pds/33 +0.44 ... this produces answers that are well within the 40% SD range. b. Since there is consistently somewhat less StdDev swing using StoW (SMAWMA) methods than using EtoL (EMAWilder) methods, *and* since EtoW calc's require significant extra warmup (38x) vs SW, it would seem advisable from a calcefficiency and accuracy and stability standpoint to use SW averaging rather than the "classic" Wilder ATR, or even an EMA of TR. So, instead of ATR, we can use WMA(TR,pds) or SMA(TR,pds), where TR = math.max(C[1],H)math.min(C[1],L) ... that is: WMA(math.max(C[1],H)math.min(C[1],L),Pds) or SMA(math.max(C[1],H)math.min(C[1],L),Pds) c. It makes sense that SD would flip from being less than TR to greater than TR as periods increase, since the price has more time with longer periods to demonstrate a "swing" from a moredistant centerline ... and that swing will be wider, since a longperiod SMA is often pretty frar from the price itself. OTOH, the True Range is just looking at one bar plus the close of the prior one, so the individual diff's aren't dependent on the time window at all. d. Looking at a bunch of charts (not discussed above but easy when you plot the indicator I provided), we can see that SD has moreextreme excursions than TR, and that sometimes the slope of the SD is going the opposite direction of the slope of the TR. The average of the two is more useful than either of them, as a possible indicator that says to consider entering a trade, in the direction of the general trend, when the gold line has reversed upwards (ie increasing volatility), and has moved some minimumamount of yaxis points. So, the code could be developed into an entry system. e. When the gold line slope starts falling off significantly, and has dropped some minamt of yaxis points, that seems to indicate a significant period of consolidation, or an incipient reversal ... this might be developed into a useful exit rule. Overall: I'm going to start including an option in my custom routines to use either TR or SD or the average of the two, and use either SMA or WMA or the average of the two for smoothing, in place of where I used to just use "kneejerk" ATR. Your comments are welcome. (aJDndSDvsTR testresults.png) Attachments aJDndSDvsTR testresults.png (35KB  0 downloads)  
RossKovacs 
 
Veteran Posts: 131 Location: USA: GA, Snellville  A third option may be Larry Williams' VIX Fix (see the article in the url below) or some variation of it. In the article, Williams claims that "it is easy to duplicate the VIX for any market — Treasury bonds, gold, silver, soybeans, even individual stocks — with a simple formula." The formula and examples are given in the article. https://www.ireallytrade.com/newsletters/VIXFix.pdf FYI: ireallytrade.com is Larry Williams' web site; he has other free articles and videos available. Thanks, Ross ... I'll take a look at it!  
JimDean 
 
Owner/Admin Posts: 3922 Location: USA: GA, Lawrenceville  I've spent a lot of time today horsing around with this ... I'm planning to develop an indicator that provides efficient and highly flexible calculations related to this, that y'all can use like you use the ATR() or STD() functions now, but with a lot more power. It will include expert evaluations of the slopes and distancestravelledsincelastextreme as options. I'll have to come back to this later, but here is a snapshot of the initial commentspec's and paramlist. You'll see some really special new things here ... the "PreSetToUse" and "MsgBoxNoneErrNfo" controls ... I intend to include them with all significant new tools. But more on that, later ;~) (aJDndRngDev commentssnap.png) Attachments aJDndRngDev commentssnap.png (85KB  1 downloads)  
MelDickover 
 
Veteran Posts: 155 Location: USA: FL, Bradenton  I am going to make a couple of posts about volatility. The first is based on the idea that the price time series is not a Gaussian (Bell Curve) distribution, even though lots of indicators (like Bollinger Bands) calculate things like it is. There is a transform that converts almost any probability distribution into a Guassian one. It is called the Fisher Transform, and it is calculated like the arctanh(). I am attaching a module that allows you to play with converting various things with the Fisher Transform. The result is much more valid Standard Deviation Bands, and clearer indications of price turns. The Inverse Fisher Transform converts almost any probability distribution into a square wave  is used to sharpen unclear oscillator lines and other data. I am not including it here since it does not normally apply to volatility. Just know it is very different. The plot compares price with 20, 2 BBs and the fisher transform with 20,2 bands. Note the price is normalized around zero. The line color changes from black to white or red depending on positive or negative divergence with a linreg(5) of price. A digression: Ehlers suggests traders not use the WMA at all. He states it was designed by a trader lacking a firm grasp of filter theory in hopes of reducing lag. It has more lag than an equivalent EMA and even poorer attenuation than the equivalent SMA. In short, nothing to recommend it over other moving averages. Mel (Fisher.png) Attachments Fisher.png (42KB  1 downloads)EhlersFisherTransform.txt (3KB  8 downloads) eSSFfast.txt (0KB  5 downloads)  
MelDickover 
 
Veteran Posts: 155 Location: USA: FL, Bradenton  eSSFfast I added it to the orig post ... am cleaning things up Attachments eSSFfast.txt (0KB  7 downloads)  
MelDickover 
 
Veteran Posts: 155 Location: USA: FL, Bradenton  Here are some interesting volatility calculations, useful for options especially. HistoricalVolatilityCalc replicates the one in Omnitrader. HistoricalVolatilityIntraday computes the historical Open to Close volatility HistoricalVolatilityOvernight computes the Open to Close[1] volatility. Counting intraday spikes can find good day trading candidates, those with big moves during regular trading hours. Those with overnight volatilty are gap plays. CheapOrExpensive computes whether an option is cheap or expensive by which of 5 bins in the lookback range IV is. IV is mean reverting, so if it is relatively high, you expect it to drop, and vice versa. A good measure of cheap or expensive is where it is in its range cycle. Here I use five bins. Another measure, less important(IMHO) but still interesting, is whether IV is higher or lower than fair IV. The spikes plotted turn yellow if there is a conflict Attachments HistoricalVolatilityCalc.txt (0KB  8 downloads)HistoricalVolatilityIntraday.txt (0KB  7 downloads) HistoricalVolatilityOvernight.txt (0KB  7 downloads) CheapOrExpensive.txt (1KB  8 downloads)  
MelDickover 
 
Veteran Posts: 155 Location: USA: FL, Bradenton  More volatility stuff in the form of spike charts RelativeSpread finds big HL spikes in standard deviations RelativeTrueRange finds big ATR changes in standard deviations SpikeChart finds a variety of significant changes 'CCoCOoOCoVLoPV = 0, C[1] to C, equivalent to daily change using EOD data 'CCoCOoOCoVLoPV = 1, C[1] to O, equivalent to Opening Gap using EOD data 'CCoCOoOCoVLoPV = 2, O to C, equivalent to the body of a candle 'CCoCOoOCoVLoPV = 3, V[1] to V, Volume bartobar SpikeVIXStretch finds possible reversals on you current chart based on VIX spikes Mel (Spike charts.png) Attachments Spike charts.png (42KB  2 downloads)RelativeSpread.txt (0KB  10 downloads) RelativeTrueRange.txt (0KB  8 downloads) SpikeChart.txt (3KB  8 downloads) SpikeVIXstretch.txt (1KB  9 downloads)  

Owner of site: Jim Dean  Forum content is confidential, and may not be distributed without written permission.  