| Adaptive
MA, Price Finder (RE) - CCI,MACD, Yesterday Bars on today, DYO CPU Burden |
February 23 , 2005
16:33 @Ensign_H: Welcome to today's class with the Ensign developers.
16:33 @Ensign_H: My, how rapidly things change from week to week. I thought last week had exciting news about the new Candle types, and now that starts to seem less significant when compared with the new innovation of the past week. So, we are glad you are here for another Wednesday class with us.

16:34 @Ensign_H: Let me begin with a discussion of Adaptive Average
16:35 @Ensign_H: I know there are many different ways to do an Adaptive Average and they go by different names. Now what I show is not one of the existing adaptive averages, but it is a teaching example of how you might try to create an adaptive average.
16:36 @Ensign_H: In this picture I am showing three averages, and the lines in blue and red are the standard Smoothed average formulas using parameters of 5 for the Red and 20 for the Blue line.
16:37 @Ensign_H: The bigger the parameter the smoother the average line will be, but also the greater the 'lag' time.
16:37 @Ensign_H: likewise, the smaller the parameter the quicker the average responds, but possibly at a detriment of being too close to the market in choppy action.
6:38 @Ensign_H: So an adaptive average is one in principle that adapts to the market conditions. One such attempt by me to create such an adapting average is shown with the pink line on the chart.
16:39 @Ensign_H: When the market start to move quickly, I wanted the average to adapt to have the 'quick' characteristic of a small parameter and when the market is moving sideways, I wanted the average to adapt to have the greater lag time of a bigger parameter.
16:40 @Ensign_H: The DYO feature in Ensign is a great way to prototype ideas like this.
6:41 @Ensign_H: I thought that a momentum of 5 bars would be a pretty good foot pedal to control the adapting parameter. When the market is sideways, then momentum is around zero. When market is trending up strongly, then momentum is a steep positive number, such as 6. When the market is trending strongly down, as in the chart after the 9:30 time stamp on the 17th, then momentum will be like a -6.
16:43 @Ensign_H: I used the DYO to convert the Momentum value in a range of -6 to +6 through a little formula so the resulting calculated parameter to use for the moving average is between 0 and 30.
16:43 @Ensign_H: Let me show the DYO form that does this.

16:44 @Ensign_H: Scroll this image downward to see the DYO form below the chart.
16:44 @Ensign_H: Line A gets the Bar Values into the array used by Line A.
16:44 @Ensign_H: Line B then calculates a 5 bar momentum of the data in Line A. The distance of 5 comes from the Number field. Momentum here is simply the difference in the Close price from 5 bars ahead of the current bar. This price difference on the ES chart typically runs between + and - 6 points. For some other symbol, the price delta will be in a different range, but you understand the principle.
6:47 @Ensign_H: Line C takes the momentum stored in GV[1] by Line B and converts it to an absolute value (ie a positive number).
16:47 @Ensign_H: Now I have a 6 for a strong downtrend move instead of a -6.
16:48 @Ensign_H: I use Line D, and E to create a parameter that can be as high as 30 when the momentum is zero, and then moves towards zero, (could possibly even go to a negative number).
16:49 @Ensign_H: The Line E value will be the parameter for my moving average function.
16:49 @Ensign_H: I do not have to worry that the parameter might be zero or negative, because internally Ensign has some error checking on the parameters used for averages, and I know any value less than 1 will become a parameter of 1 for the average calculation. If I did not know that was how we do things internally, then I would have to have additional logic to prevent a parameter less than 1.
16:50 @Ensign_H: Now the final part of the this idea, is to use an average function on the data still in Line A.
16:51 @Ensign_H: The average needs a parameter passed in the Number field, and the notation [2] tells the program to go look up the value in
16:51 @Ensign_H: Global Variable 2, which is where we parked the calculation result from Line E.
6:52 @Ensign_H: So A gets the bar closes, B finds a momentum value, C-D-E create a parameter, and F does the averaging with the parameter.
16:53 @Ensign_H: The parameter value in [2] is fluctuating as the momentum changes, and the plotted effect of this adapting average is the Pink line on the chart.
6:53 @Ensign_H: When the market did its 9:30 plunge on the 17th, you can see the average zoomed in tight by having a very small average parameter and then as the market moves sideways, the average lagged underneath or above the bars instead of through the middle of them.
16:54 @Ensign_H: I quite like the visual of this adaptive average in this example.
6:54 @Ensign_H: Any questions about this example, concept or principles of implementation?
16:55 @Ensign_H: There is no limit to the possibilities in the various way the parameter could have been calculated.
16:55 hobo3: could it be made to change for rising and falling?
16:55 @Ensign_H: do you mean use different colors for the line if it is rising or falling?
16:56 hobo3: yes
6:56 @Ensign_H: yes, you can do that to.... you would add a test for the Line F value for being Rising or Falling and
16:57 @Ensign_H: then use Do Next If type of statement to either plot in color 1 or go to a different line which would plot in color 2.
16:57 hobo3: ty
6:58 @Ensign_H: Or, another way is to add a moving average that uses DYO line F as the data point and use the Rising Falling selection on that form to plot the line.
16:58 @Ensign_H: This DYO can do the calc as shown through Line F, but not do the plotting you see on line F.
16:59 @Ensign_H: You could have an Average study added after the DYO that references the LIne F for plotting.
16:59 @Ensign_H: any more questions?
17:00 @Ensign_H: ok, will move on to 2nd topic
17:00 @Ensign_H: The 02-23 Beta which was posted for download about an hour ago introduces another power innovation which we will call PriceFinder.
17:01 @Ensign_H: PriceFinder is innovation that can be used to determine the price the chart must go to to cause certain effects in studies, bars, and alerts. I have had lots of fun over the past few days experimenting with the possibilities, and the results are exciting.
7:02 @Ensign_H: let me post a few examples,

7:03 @Ensign_H: This picture also has a DYO form below the chart, showing the implementation. There is one other study on the chart and that is an RSI with a 7,3 parameter setting so my chart objects list would show 2 entries, RSI and DYO (and the notes).
17:04 @Ensign_H: Line A is the RSI study flag for testing if RSI is above or below 70. This boolean flag is stored in GV[1]
17:05 @Ensign_H: the PriceFinder selection on Line B will evaluate the boolean flag found in GV[1] and return a price that would cause the flag to change from False to True or from True to False.
17:06 @Ensign_H: So this one clever selection will auto detect if the RSI is already above 70, and in that case will find the lower price that will bring RSI back down to 70. Or, if RSI is currently below 70, it will find the higher price that will bring RSI up to 70.
17:07 @Ensign_H: These PriceFinder values are being plotted by the marker on line B which is the thick curve line using the Red color.
17:08 @Ensign_H: So the basic principle with PriceFinder is this..... You tell it which boolean flag to watch in the GVs, and it will figure out the price needed to cause that bar flag, study flag, or GV flag to change states.
17:09 @Ensign_H: Pricefinder has two other selections that are similar, such as just do the IS TRUE part or do just the IS FALSE part instead of both part and some later examples will make these other choices for PriceFinder more understandable.
17:10 @Ensign_H: The concepts of Line A and B were repeated for RSI to find the similar information for RSI at the 30 level.
17:10 @Ensign_H: This is plotted by Line E in Blue.
17:10 @Ensign_H: Line B and E values were stored in [3] and [4] so that Line G could average them and show a mid channel line in purples.
7:11 @Ensign_H: So this is a novel new way to look at an RSI study. I do not even have the RSI plotting on the chart. But I have instead a channel in red and blue that indicates when RSI is in overbought or oversold territories of >70 and <30.
17:12 @Ensign_H: This is shown on the chart as the channel lines.... when RSI is high the price bars will be Above the upper channel band...and when RSI is low, it will be below the low channel band...and when RSI is in the middle, it will be near the purple line.
17:13 @Ensign_H: Yesterday was a pretty strong down day, and you can see how the RSI channels look on the chart.
17:14 @Ensign_H: Any questions about this PriceFinder example for the RSI study.
17:14 @TraderBambu: thxs Howard, this was fast! :-)

17:16 @Ensign_H: This example adds to the last example by adding a PriceFinder line for the CCI study that was added to the chart.
17:16 @Ensign_H: The Pink line is showing the Price that would cause the CCI line to be zero.
17:17 @Ensign_H: So when CCI is below the zero line, the PriceFinder value will be a higher price to pull CCI back up to zero.
7:17 @Ensign_H: When CCI is above zero, the PriceFinder value will be a lower price that would pull CCI back down to zero.
17:18 @Ensign_H: I do find it of interest, perhaps just coincidence, that the CCI line is so similar in its position to the RSI mid channel line.l
17:18 @Ensign_H: so the price behavior that would make RSI go to 50 is so very similar to the prices that would make CCI go to zero.
17:19 @Ensign_H: I guess I should not be surprised at that neutral position for both of these studies.

7:19 @Ensign_H: This example shows a CCI band created by the PriceFinder.
17:20 @Ensign_H: Upper band is showing values for the close needed to move CCI to the 133 level.
17:20 @Ensign_H: and lower band is showing the values for close that would cause CCI to move to the -133 level.
17:21 @Ensign_H: around 11:30 you see the price bars are below the band, and that corresponds to the CCI line in the sub-window being below the -133 grid line.
7:22 @Ensign_H: When CCI is near the zero line, as is the case around 12:30.... then the two bands narrow, quite like a Bollinger Band
17:22 @Ensign_H: anyway, I find the above type of information about a study like CCI and RSI informative and of great interest in how I might be able to use it in trading setups.
17:22 @Buffy2: the CCI study had to be added to the chart correct?
7:23 @Ensign_H: yes buffy, I added CCI and put on the objects list ahead of the DYO so that it could be reference by the DYO.
17:23 @Ensign_H: The DYO will only show on its study selection lists the other objects that precede it on the objects list.
7:24 @Buffy2: Just like the old alerts
17:24 @Ensign_H: this is the same principle as has been in place for the Alert Objects being able to reference study values from other objects.
17:24 @Buffy2: new users are not familiar so wanted to clarify ty

17:25 @Ensign_H: This example pulls into one view some of the new PriceFinder bands for CCI, and the Degrees information for the EMA study on the chart and throw in the auto Trends option on the CCI form.
17:26 @Ensign_H: This chart may look simple, but the complexity of the math behind the lines is pretty impressive.
17:27 @Ensign_H: All of this to the end user is hopefully as simple as using the DYO form drop down boxes to pick and choose what effect you want and that is also the purpose of these classes and the examples I post on my web site and also is posted on the dacharts site. Often a good example teaches others how to put the building blocks together to accomplish some desired effect.
17:28 @Ensign_H: any questions about these CCI examples?


17:29 @Ensign_H: ok, moving on to the Bollinger Band example.
17:29 @Ensign_H: the PriceFInder put on the Blue and the Pink lines, which show where price would have to go to to cause the bar to reach the upper or the lower bollinger band.
17:30 @Ensign_H: now, the first impulse is to think you just need to go to the green bollinger band......but not so.
17:30 @Ensign_H: for example at the last bar on the chart, price is now at 1184.50 and the bollinger upper band is around 1189.50 but if the price moves to the 1189.50, the BB upper band will have also moved higher.
17:31 @Ensign_H: The Blue line shows that both the band and the price bar would meet at around 1190, which is a bit higher than where the band is now.
17:32 @Ensign_H: That is all part of the clever innovation of the PriceFinder...... it also considers the impact on the Study that a different price will make.
17:32 @Ensign_H: you can see that when price is already near a BB band, then the PriceFinder value is also very close or on top of the band.
17:33 @Ensign_H: now this example also shows a broken Pink line. This is because I was testing one of the other PriceFinder selections on the DYO.
17:34 @Ensign_H: Using the Value Changes selection will resolve to a price regardless of whether price is above or below a band. The IS False selection will show what price needs to be only when the current bars are above the lower band. In this case the bars are not below the band, so the PriceFinder figures out what it takes to get the bars to the lower band.
17:36 @Ensign_H: In the areas where prices are already below the band, this selection for the PriceFinder says there is nothing to do.
17:37 @Ensign_H: on the very left of the chart at the top, you will see a few gaps in the BLue line too, where once above the upper line, PriceFInder was told to not do anything, we are already above the target BB band line.
17:38 @Ensign_H: If I had tried to resolve for being on both sides of a band, then you get some really odd looking zooms of the pink line to really high values, and what that amounts to when you think about it, is it takes some really high bar highs to change the volatility of the BB calculations to cause the BB bands to expand outward.
7:39 @Ensign_H: we cannot undo a Bar low that is existing, so the only way to get bar and band to meet when the bar is below a band is to increase the BB volatility so the band moves to the bar.
7:40 @Ensign_H: That is a very interesting characteristic about using PriceFinder with the Bollinger Bands.
7:40 @Ensign_H: Anyway, I dare speculate that this kind of chart that I am showing has not been viewed before by John Bollinger, and possibly he would be interested in seeing some of these new tools at work.
7:41 @Ensign_H: This is cutting edge technology and innovation that kind of came as early morning inspiration.

7:42 @Ensign_H: this little addition to the example had a 34 EMA average line added in gray and used Price Finder to show what change in the close would be needed to have the close cross the average line.
17:43 @Ensign_H: when prices are above the gray average line, see 10:00 am, then the PriceFinder line in red is below the average line.
17:43 @Ensign_H: and when prices are below the average, as expected the forecast price is then above the average line.
7:44 @Ensign_H: and it is not on top of the average line for the same explanation as I gave about the BB bands.
17:44 @Ensign_H: If price moves higher to get to the average line, the average line will also move higher and the will meet at the PriceFinder line as shown.
17:44 @Ensign_H: any question about this example?
17:45 @TraderBambu: I do not usually post here and this time all I want to say is: thank you, Howard! PriceFinder is HUGE! Thxs again! :-)
17:46 @Ensign_H: welcome TB.... yes it is huge and I am glad you are perceiving its potential.
17:46 @Ensign_H: I have more to show... so lets continue.

17:46 @Ensign_H: VH, explained what he was trying to do, so I helped him with this example this morning.
7:47 @Ensign_H: I have a note on the chart of the idea wanted.
17:51 @Ensign_H: for this example VH wanted to know in advance what price action would cause the oscillator to reach a recent previous peak high (HH) or peak low (LL) - so the DYO shown does all that.
17:52 @Ensign_H: LIne A gets the Macd data and stores current value in [3]
17:52 @Ensign_H: Line B examines that CCI data set on Line A for the HH value in the last 140 bars, and store peak value in [1]. It also plots a horizontal red line from this peak level, which you see changing as old peaks move out of the 140 bar data set and new peaks create new extremes.
17:54 @Ensign_H: Line C does the determination of the Lowest Low for the MACD low peaks in 140 bar sets, and plots another horz red line. This makes for a nice view in the CCI study window.
17:54 @Ensign_H: Now VH wanted to bail out of a trade when the CCI peaks approach 90% of the prior peaks
17:55 @Ensign_H: So Lines D and E calculate trigger levels for later use to be 90% of the HH and LL peaks.
7:56 @Ensign_H: Lines F and G set up boolean signals that will be used by the PriceFinder on Lines H and I.
7:57 @Ensign_H: Line F says to get the MACD price from [3], and compare it to a value in the number field, which the [1] is a GV lookup to get the HH*.90 value from Line D.
17:58 @Ensign_H: Line H will read the boolean from Line F and figure out prices needed that will cause CCI to change the boolean.
17:59 @Ensign_H: Line I does the same type of thing for the price that would cause MACD to change the state of the 90%LL boolean for the low swings of MACD
17:59 @Ensign_H: these PriceFinder values are plotted using brown curve lines on the chart.
18:00 @Ensign_H: and proof is in the pudding at 11:30 when a new MACD LL Peak goes down to the green line = 90% of LL and sure enough, our PriceFInder channel line is right there at that point on the price chart.
8:02 @Ensign_H: So the 11:30 point on Feb 22nd shows the PriceFInder is working beautifully as expected.
8:02 @Ensign_H: and the 9:00 on the 22nd shows the MACD peak are going above prior HH peak and sure enough, the price bars are breaking above our channel line.
18:02 @Ensign_H: Love it.
18:03 Trade888: How do you know where the marker plots? Line B to E plot in the window but H and I plot on chart?
18:03 @Ensign_H: this is a super example of some very powerful innovation using the DYO form to do it all in one place.
18:03 @Ensign_H: you get the award today trade888 for being an astute observer.
8:04 @Ensign_H: I implemented a little override for the PriceFInder lines......
18:04 @Ensign_H: during development I really wanted to have the peak lines and the 90% lines shown in the MACD sub-window.
18:05 @Ensign_H: yet the PriceFInder returns prices to plot, and I did not want to have to use a 2nd DYO just for the sake of being able to
18:05 @Ensign_H: select the plot location being the chart and the scale being the chart scale.
18:05 @Ensign_H: So, I treated myself to an override for just the PriceFinder....... it will always plot on the chart in spite of the Location and Scale selections. I did not think that you would mind.... just trying to implement what you would want to have happen.
8:07 @Ensign_H: this little exception permitted me to finish the example with the PriceFinder plots on the same DYO form as the MACD peak plots.
18:08 @Ensign_H: so, thank you for observing that so I could explain what I did.
18:08 @Ensign_H: for all of the other examples shown today, the Study Location and the Study Scale selections were to use the Chart and the Chart Scale - so my little override made no difference.
18:09 @Ensign_H: now have one more clever trick to share, via this example.

8:10 @Ensign_H: one of amg's charts today had a beautiful overlay is subtle colors so it was seen yet not distractive. She had TICK plotted as an overlay on a VOLD chart and that sparked an idea.... I told Kimball lots of you want yesterday's values such as open, high, and low to show on today's charts as horizontal lines with labels and values.
18:11 @Ensign_H: The spark was why not just reshow Yesterdays' chart as a subtle overlay like amg's beautiful chart...so this is what I did.
18:12 @Ensign_H: A couple months ago I showed an example of Average Candles, where we really did some averaging to invent highs and lows. The clever part of that example was to use the Spread of High to Low and Spread of Open to Close to simulate a candle.
18:13 @Ensign_H: So I did the same thing here, but with averaging set to 1, so actual highs, lows, opens and closes are being plotted as candles. I use subtle colors as shown.
18:14 @Ensign_H: Now the last trick was to offset the plot position of the information RIGHTWARD by using a positive parameter for the Shift L/R box on the study property forms.
18:15 @Ensign_H: Let me post the two study property forms that created this visual effect.
18:15 @Ensign_H: One study does the vertical line from High to Low in a gray color.
18:15 @Ensign_H: The other study does the candle body with a fatter spread marker to color the open to close in green or red.
18:16 @Ensign_H: so the entire visual is done by two average objects.

18:16 @Ensign_H: Note the Ave1 and Ave2 parameters are both set to 1, so actual price is used, not an average.
18:17 @Ensign_H: First data point is High and 2nd average data point is Low.
18:17 @Ensign_H: the Shift L/R is 81 bars into the future, that way yesterday shows in today's position.
18:18 @Ensign_H: The shift distance is 81 for this chart because it is a 5 minute chart for Day Session only ES.
18:18 @Ensign_H: The shift distance is 81 for this chart because it is a 5 minute chart for Day Session only ES.
18:18 @Ensign_H: and this day session hour range is 6 hours and 45 minutes = 6.75 * 12 = 81 5-min bars...works really slick.

18:19 @Ensign_H: This is the 2nd MA property form, note the parameters of 1,1, shift 81, data points Open and Close.
18:20 @Ensign_H: the Study Mode of Above | Below is used so we can have different colors for the candle bodies of faint green or faint red.
18:20 @Ensign_H: also note the spread markers are a fatter spread (histogram) style.
18:21 @Ensign_H: that's it.... enjoy the ideas explored and illustrated today..... hope some are of use to you and help you be more profitable.
8:21 @Buffy2: excellent Howard - mmaker: THANKS Howard!!!!!!!!!!!!!!
18:21 James_AZ: H. thank you - dwas: tks - christophe: thank you Howard!
18:22 XRay: :-) - VH: thanks Howard - LB: Many thanks Howard
18:24 amg: Thanks, Howard, for your energy and efforts, it is catching!
18:24 dblue2: amen - hobo3: ty, this is great. - dblue2: thx
18:27 XRay: Howard this is outstanding stuff !
8:29 @Ensign_H: dblue, think the only one not shown was the bollinger.
:33 mmaker: why do the CCI reverse engineering only go back so far on the chart?

18:35 mmaker: when I double click on the chart it disappeared - oh ok
18:34 @Ensign_H: good question that needs an answer mmaker.
18:34 @Ensign_H: the PriceFInder is more CPU intensive that any of the other studies I have in the program. Therefore, I am trying to cut the burden down if at all possible. One corner cut was to do the calculation ONLY for the visible bars on the chart. Some of you have 65000 bars or 20000 bars, and the calc on all of that which you are not looking at is a HUGE CPU burden.
18:36 @Ensign_H: now as you scroll back or tighten the bar spacing to see more bars, you can get the PriceFinder (PF) information by causing the DYO to recalculate. Do that by opening DYO form, check and uncheck any checkbox and close form - the recalc will be done for new visible bars, and the image will show what you did not see before

18:37 mmaker: and they come back!
18:37 @Ensign_H: cool mmaker - looks good
18:38 @Ensign_H: To wrap up today's topics about the PriceFinder let me address the CPU burden issue.
18:40 @Ensign_H: Here are a couple things that you all can do that will help.
18:41 @Ensign_H: Please consider exactly the studies, alerts or other DYOs that are needed for analysis and have these at the TOP of your chart objects list, and have the DYO with the PriceFinder as HIGH ON THE objects list as possible. Those objects that follow the PriceFinder do not need to be considered in the calculation process. That REALLY really helps reduce theCPU burden, if you can let the DYO know via order of items on the chart objects list which ones are needed for the PF and which ones are not needed. So please be careful with it, use it sparingly

18:40 mmaker: otherwise...
18:43 @Ensign_H: so in your post mmaker, you probably just added a DYO to your chart and started using PriceFinder (PF).
18:43 @Ensign_H: you might have 60 objects ahead of this DYO.
18:44 @Ensign_H: do yourself and me a favor by moving this DYO ahead of every object not needed for analysis by the DYO - if the DYO is referencing a single study like MACD, the optimum would be to have MACD as first study and the DYO with PF as the 2nd study on the list and the other 58 objects following.
18:46 @Ensign_H: ok, that's all folks..... been typing for 2 1/2 hours and need a break, so class I over now.... bye
18:46 TOC: TY Howard