| Average Volume, Smallest Volume per X Bars, Plotting Average Volume, Using Globals On Other Charts, Global Value, Adjusting Scaling, Using Alerts writing Globals, Gotchas - Sequence of Processing, Gotchas - ZList, Using Line to Count Bars, 30 Bar ATR to Low of each bar and plotted, Slope, IB Back data |
December 2, 2004
16:36 @Ensign_H: Welcome to today's class, which will be a continuation of the training given for using Alert Objects.
16:36 @Ensign_H: Over the past 2-3 weeks, the Alert Objects have undergone a fairly major enhancement while maintaining backward compatibility.
16:37 @Ensign_H: 7 new categories have been added, which provide for more ease in doing math operations, sharing signals between charts, and obtaining quote and study values for use in alerts.
Average Volume
http://www.ensignsoftware.com/tips/tradingtips59.htm
16:39 @Ensign_H: scroll to the bottom of the newsletter for the example of Average Volume that I want to start with today.
16:39 @Ensign_H: The idea is to mark or signal when the bar's volume is exceeding 1.5 times the average volume.
16:40 @Ensign_H: Panel B is using one of the new categories, Chart Value, and the Ave Volume[#] function. The number parameter for the function is the number of bar volumes to average. The parameter is entered on the Number field, and in the example is 50. Thus panel B is returning the 50 period simple average of the bar volumes from the chart.
16:41 @Ensign_H: Panel A is going to be used to return the current bar's volume.
6:42 @Ensign_H: Since we need to scale the volume value before the comparison, we use the Trade Value category which allows us to multiply Volume by a value.
16:42 @Ensign_H: the expression we are thinking of implementing is:
If Volume > 1.5 * AveVol then do something.
16:43 @Ensign_H: since we can multiply the left side but not the right side in our alert parameters, lets rearrange the expression algebraically.
16:43 @Ensign_H: the equivalent expression is: If Volume * 0.6667 > AveVol then do something.
16:44 @Ensign_H: All we did here was to divide both sides of the expression by 1.5 so the multiplier for the left side is 1/1.5 or 0.6667. That is why the Number in panel A is 0.6667.
16:45 @Ensign_H: So, if the resized volume for today is above the AveVol, then we have the signal and the signal is going to color a zone at the bar position the color light red.
16:46 @Ensign_H: This effect has been shown in the chart example that accompanies the article.
16:46 @Ensign_H: Are there any questions about this example using a single Alert to test Average Volume?
16:49 er2: don't understand why divide both sides by 1.5
16:49 @Ensign_H: ar2, we have AveVol computed in panel B, but no way to also multiply it by 1.5
16:49 er2: it's only times 0.6667 of left side isn't it?
16:49 @Ensign_H: however, we can retrieve Volume in panel A and have ability to multiply it.
16:50 @Ensign_H: So lets do multiply in A instead of in B
16:51 @Ensign_H: Vol > 1.5 AveVol is the same expression as Vol / 1.5 > AveVol which is the same as Vol * 0.6667 > AveVol
16:51 @Ensign_H: it is all just algebra
Smallest Volume per X Bars
16:47 Moe Mentum: related: can you obtain the smallest vol per X bars?
16:52 @Ensign_H: Moe, the answer is yes, easy to find smallest volume per X bars, using the Chart Values category. Let me show the selection choices.

16:54 @Ensign_H: In the Chart Value category are several functions, one of which is MIN
16:54 @Ensign_H: This is listed for different fields of the bar data, one of which is Min Volume[#]
(Please underline highlight or something the following line - tks)
16:54 @Ensign_H: the [#] notation is our way of indicating that the Number field will be used as the period parameter.
16:55 @Ensign_H: So if you wanted the smallest volume in the last 5 bars, select Chart Value | Min Volume[#] | Number = 5 and the panel will produce that value for use in your testing.
16:55 Moe Mentum: condition "if A then do B" ?
16:56 @Ensign_H: the IF A then do B is a powerful way to conditionally have the action in B performed. Typically you would use GLobal Action as the category in panel B. This action might be to put a zero in some global variable.
16:57 @Ensign_H: another clever use of the conditional was to test bar time in panel A, and when a certain time occurred, to load that bar's volume value into an array of global variables and then average the array values. The effect was to get an average volume for the 10:00 bar for the past 20 days and that was clever.
16:57 tradinoncoffee: @Ensign_H, what does "sum" mean?
6:58 @Ensign_H: SUM is a function to add values together.
16:58 @Ensign_H: So the Sum of the last 2 daily highs would be Sum = HighToday + HighYesterday. The number of values to add is the value in Number.
16:59 @Ensign_H: the Sum function has entries for which value is being summed.
16:59 @Ensign_H: when referring to a chart, it is using bar values for a set of size # that ends with the current bar. So a Sum High[2] sums 2 bar highs, yesterday and today.
Plotting Average Volume
17:00 @Ensign_H: ok, cmtrade asked to plot the AveVol.
17:01 @Ensign_H: this would be most easily done using the Moving Average study with Volume selected as the Data Point and the Volume sub-window as the location.
17:01 @Ensign_H: It could also be done using the Alert Object, which can compute the Average Volume.
17:02 @Ensign_H: We would then select the Volume panel as the sub window, and 'B' Value as the position, and use the Curve marker selection.

17:04 @Ensign_H: Ok, in this example the alert is using panel A to compute Average Volume for 5 periods, and plotting a green line in the volume window for the 'A' Values
17:05 @Ensign_H: as a side note, the blue line on the chart is the Pesavento Map I was following today and it did a good job of timing the highs at the end of the day and I was not surprised at the sell-off either.
Using Globals On Other Charts
17:06 Kato: is it possible to replicate that moving average onto another chart with a different time frame?
17:07 @Ensign_H: over the holiday, I wrote some documentation about Global Variables, and we can cover that material now.
17:07 @Ensign_H: kato, the answer is yes, using alerts, but with a gotcha.
17:08 @Ensign_H: lets cover that gotcha and the full answer to kato's question as we cover global variables.
www.ensignsoftware.com/help/globalvariables.htm
7:08 @Ensign_H: you can read through the global variable material.
17:08 @Ensign_H: GV will be my shorthand for global variable and [value] will refer to a particular GV where value is the index or reference.
17:09 @Ensign_H: there are 100 global variables, from [0] through [99]
17:10 @Ensign_H: studies can easily put the study line value in a GV by using the spinner on the study property form.
17:10 @Ensign_H: in the first image of the Bollinger band form, the Upper Band value is written to [1]
17:10 @Ensign_H: and the middle line value is written to [2]
17:11 @Ensign_H: [0] is a valid GV, but since all studies kind of default to [0], lets consider [0] as the throw away slop bucket.
17:11 @Ensign_H: when I see a spinner for Global on 0, I will consider it as not assigning a GV
17:12 @Ensign_H: you can put middle line in 1 if you want, but my example picture of the Bollinger property form has the middle (Average) line going to [2]
17:12 @Ensign_H: and the lower band value into [3]
17:12 @Ensign_H: you can do this kind of assignment from any study property form.
17:13 @Ensign_H: any questions about GVs and pushing study data into these global variables?
17:13 @Ensign_H: GVs are just a public mailbox or bulletin board. Anyone can put data in the GVs and anyone can also read the values that are posted.
17:14 @Ensign_H: it is very public, or very global
17:14 @Ensign_H: the 5min chart might put its moving average values in the GVs and then the 1 min chart could read those values because it is in a public or global place.
17:15 @Ensign_H: the GVs are owned by the Ensign program, not by any chart. They can be written to or read by any chart or alert object.
17:16 @Ensign_H: now that the program has a set of 100 global variables, we added some new categories to the alert object.
Global Value
17:17 @Ensign_H: the first new category is the Global Value, which you see next in the documentation.
17:17 @Ensign_H: look in the documentation at the picture of some of the Global Value selections
17:18 @Ensign_H: the 1st selection of Value would read the value in a global variable, and which global variable to read is the selection of the Global Variable spinner in the alert object panel.

17:20 @Ensign_H: in this picture, the Global Variable [1] is being read, and the frame shows the value it obtained which is the 1192.21 in the corner. Showing the value the panel is returning or computing helps you know if you are getting what you expected.
17:21 @Ensign_H: in my example, I am reading the upper Bollinger band value that was stored in [1] and now I can use this value in my alert object tests.
17:22 @Ensign_H: now we could have used Study Value to get the bollinger upper band directly and skipped all this global variable stuff but this is an example that the GV might have been written by a different chart and the Study Value could not have read any study on another chart.
http://www.ensignsoftware.com/help/globalvariables.htm
17:23 @Ensign_H: scroll back to the list of Global Value selections.
17:23 @Ensign_H: the 2nd line is the Sum[#]
17:23 @Ensign_H: this will sum a series of global variables. The size of the set to sum is the Number field.
17:24 @Ensign_H: The starting position in the array of global variables is the Global Variable value. [#] will often refer to a set of values, and the # parameter comes from the Number fields.
17:25 @Ensign_H: example, if Sto put its value in [1] and RSI puts its value in [2] and SMI put its value in [3] one could find the smallest value of the tree using Min[#] selection with Number = 3 and GV = 1 in the panel.
17:26 @Ensign_H: Min would test 3 adjacent GVs, starting with [1]
17:26 @Ensign_H: I hope you get the idea and vision of the power built into some of these selections.
17:26 @Ensign_H: the Value + # will add the Number field to the GV value
17:27 @Ensign_H: the GV read is the selection of the Global Variable spinner.
17:27 @Ensign_H: you see there is built in math to multiply and add and subtract and divide
17:28 @Ensign_H: some may think we needed Value - # too, but not really, because you can add a negative number to accomplish the subtraction.
17:28 @Ensign_H: the same applies to dividing by a number.... multiplying by the number inverse is equivalent.
17:30 @Ensign_H: we had an example of multiplying to accomplish a division earlier in our discussion
17:30 @Ensign_H: we wanted Volume / 1.5 so we did a Volume * 0.6667 because 0.6667 is the inverse of 1.5, ie 1/1.5
17:31 @Ensign_H: if we wanted to subtract 1.00 from the value we would put -1.0 in the Number field and use Value + #
Adjusting Scaling
17:31 @Ensign_H: a couple of useful entries are at the bottom of the Global Value list
17:32 @Ensign_H: namely: Value * # + Scale Low
17:32 @Ensign_H: this is a handy function to be convert a value for plotting purposes.
17:32 @Ensign_H: this type of scaling formula was used in the Historical Volatility example in the Nov Trading Tips issue.
17:33 @Ensign_H: we had a historical volatility value like 12.50 that we wanted to plot on an IBM chart.
17:33 @Ensign_H: perhaps the chart range was 7 points, and had a scale low of 90.
17:34 @Ensign_H: well we can make the 12.50 into a plottable value by scaling it for size with a multiplier from the Number field, such as 0.5 and then add on the scale low..... in such an example the panel computation would be 12.5 * 0.5 + 90 = 96.25.........and we can then use the plot position of 'B' Value and plot using the Curve marker selection.
17:35 @Ensign_H: any questions at this point?
17:36 SpinHalfEnM: related: Will GV info be available in ESPL (e.g. as flags and study values)?
17:36 @Ensign_H: eventually spin, however ESPL has less need for GV access since ESPL can create its own variables and formulas and look ups. However, ESPL will be enhanced as time permits to be able to read and write GVs
17:37 SpinHalfEnM: Super -- Thanks
Using Alerts writing Globals
17:37 @Ensign_H: Ok, lets move on to the next section of the Global Variable documentation.
17:38 ce10: Howard, would the scale opt help compare charts with different ranges, for example YN vs ER2?
17:38 @Ensign_H: yes ce10....On the alert form
17:38 @Ensign_H: We showed how studies could write values to GVs, well so can alerts.
17:38 @Ensign_H: On the alert form is a Write Variable spinner on the right side of the Marker frame.
17:39 @Ensign_H: This is where you can tell the Alert to save its A/B calculation.
17:39 @Ensign_H: the first several Conditions are Boolean, and when one of these conditions is selected, the A/B result will be Boolean.
17:40 @Ensign_H: This Boolean flag result can be stored in a global variable.
17:41 @Ensign_H: we had examples in the Study Consensus where different studies wrote Boolean values to GVs, and then used the nifty Count True selection to see of all of the studies were in agreement by having all of them voting True simultaneously.
17:41 @Ensign_H: If the Condition is A only, then the result from panel A is written to the GV selected in Write Variable.
17:42 @Ensign_H: The panel A value might be a quote value, a study value or flag, a bar value or flag, a global variable expression etc.
17:42 @Ensign_H: while I was designing this I thought, though panel A is calculating and writing the variable and the condition is A only,
17:43 @Ensign_H: we can make good use of doing something like a global action in panel B
17:43 @Ensign_H: panel B is not involved in the condition, but it can be an addition calculation or action performed after panel A
17:44 @Ensign_H: so this is the sequence, panel A evaluates, when Condition is A Only, panel A writes to GV, now panel B executes.
17:45 @Ensign_H: Panel B could be a global action that read a GV (even the one just written by A) and perhaps does some math on it.
17:45 @Ensign_H: let me show an example from our Historical Volatility example.
http://www.ensignsoftware.com/tips/tradingtips59.htm#Volatility
17:46 @Ensign_H: scroll down to the alert below the chart.
17:46 @Ensign_H: panel A does a big calculation of returning Historical Volatility for 30 bars and it writes this HV answer in global variable 1
17:47 @Ensign_H: now panel B reads [1] because its Global Variable spinner is set to 1
17:47 @Ensign_H: the action is to read the GV, multiply it by 4, and add the scale low.
17:47 @Ensign_H: this is wonderful, we have use one alert to rescale the HV values to plot on a chart. The marker uses the 'B' value for plotting
17:48 @Ensign_H: panel A computed it, and panel B rescaled it for plotting purposes
17:49 @Ensign_H: the example write A to [1] because Write Variable was set to 1, but any of the 99 numbers would have been used. If we had used [57] then the same 57 would be set on the GB panel B to get B to read [57]
17:50 @Ensign_H: now as a side note, why did A only act as a True when the panel A was a value instead of a Boolean.
17:50 @Ensign_H: The answer is in the evaluation any non zero number is treated as TRUE. For a false, the value must be zero.
17:51 @Ensign_H: since the values in panel A were all chart values, A only always acted as being true, so it always plotted the marker at every bar position.
17:52 ce10: I think I understand .. but what is the num "4" on the B panel for?
17:53 @Ensign_H: ce10, the number 4 on the panel B was just a resizing factor. The values returned were too small to see much wiggle and giggle. So we make the values 4 times bigger and then plotted them offset from the chart scale low
17:54 ce10: cool... other shoe just dropped.
17:52 @Buffy2: the last part really helped
17:52 @Ensign_H: well, you can read the rest of the Global Variable material
Gotchas - Sequence of Processing
17:53 @Ensign_H: the one thing yet to discuss was the gotcha, which is the last section of the GV material.
17:53 dblue2: review of that would be great Howard - the gotcha
www.ensignsoftware.com/help/globalvariables.htm
17:54 @Ensign_H: back to the earlier question about plotting a study value from another chart.
17:54 @Ensign_H: the other chart would push the study line value to a GV such as [10] and then an alert or study on this chart can plot the value it reads from [10]
17:55 @Ensign_H: the problem is one of sequence.
17:55 @Ensign_H: when the charts are updating tick by tick in real time, everything is fine. One chart is pushing new values, and the other chart is reading them and plotting them.
7:56 @Ensign_H: the 'gotcha' is we cannot sequence these charts for mutual calculation and value sharing when the charts redraw or open.
17:56 @Ensign_H: for example, Chart A opens and calculates. perhaps it is the study value pusher to GV. It did all of its pushing, but Chart B was not yet running to read any of the values pushed.
17:57 @Ensign_H: Or vice versa, chart B opens and calculates across all bars, reading [10], but it finds that [10] value is a constant. While chart B is calculating, chart A is not calculating, and so the value in [10] is constant.
17:58 @Ensign_H: the net result is the idea works great in real time, but we cannot plot the history of the study across the back data part of the chart.
17:58 @Buffy2: passing data between charts needs to be tested RT or with PB - don't assume it doesn't work
17:58 @Ensign_H: good point buffy, it won't look right when you open the charts, but they can work right in real time.
17:59 @Buffy2: exactly - that was another gotcha for me and has been for others :-)
17:59 @Ensign_H: yes, and it was a big concern about even introducing global variables. Discussed it at length with Kimball and decided the advantages outweighed the disadvantages and we would just have to work at educating users about the sequence challenge
18:01 @Ensign_H: I made the calculations internal to a chart all work in sequence, ie bar by bar every study updates for that bar because some might be GV writers and others might be GV readers.
18:01 @Ensign_H: But I do not have any solution between chart windows. No way to sync update calculate chart A with chart B when they open or when they repaint.
Gotchas - ZList
18:01 dblue2: what about the Z order list?
18:02 @Ensign_H: that is another gotcha, but a bit minor in compared to the gotcha just discussed.
18:03 @Ensign_H: the Z-order gotcha is at times Chart A may calculate before Chart B, and perhaps that is the desired sequence but if you give B the focus it moves above A in the sequence for updating. and now A is writing data after B already read it...but B would get the value on the next tick read.
18:04 @Ensign_H: so at times A writes and B reads, and other times B reads and then A writes.
18:03 ce10: would you also have problems if you applied a template that used GV's to multiple charts? Wouldn't the studies in each chart write over each other?
18:04 @Ensign_H: yes ce10, common templates would have studies overwriting the same GVs.
18:06 ce10: ok.. so the consensus alert example works fine for multiple charts, for example
18:07 @Ensign_H: ce10, consensus works just fine on multiple charts because all values used were calculated by that chart and read by the same chart.
18:04 dblue2: so as long as A is in focus... you would be ok, if that was the way originally designed?
18:04 @Ensign_H: however, if the data is strictly internal to the chart and not intended for another chart to use, no problem.
18:05 @Ensign_H: the data is written by studies higher on the Chart Objects list and then read by studies/alerts lower on the list.
18:05 @Ensign_H: now the GV value can be discarded as it is not needed any longer.
18:05 @Ensign_H: again, this all depends on what you are trying to accomplish with GV data sharing/exchange.
18:06 @Ensign_H: each chart does a full calculate across all bars when it opens.
18:07 @Ensign_H: a 5 min chart with 1000 bars may have written to the same GV 1000 times but no one was there to read each value before the next bar calculated if the value was intended for another chart.
Using Line to Count Bars
18:11 SpinHalfEnM: As an unrelated minor suggestion, could a future version of EW offer "Bar Number" as an optional info parameter in the on-chart Data Panel (info in top left portion of chart)? It would allow tick-chart users to easily find the number of bars between two points on chart (subtract the two bar numbers).
18:18 @Ensign_H: spin, you can use Bar as the marker for a draw line or a cycle. You can drag the draw line across the bar span you want to count, and the Bar marker on the end of the line will show the number of bars in the span between the two construction points of the draw line.


18:29 @Ensign_H: one line will count a span of bars. You can reuse the one line by repositioning it and dragging either end to create a new span, and the change will change BAR count shown
18:30 SpinHalfEnM: that number is the span, not the bar number of one of the ends
18:30 @Ensign_H: correct, it is the count between the two ends
18:30 SpinHalfEnM: Thanks Howard
30 Bar ATR to Low of each bar and plotted
18:14 Rice: So what would be the simplest way to add a gv to a bar value and plot the sum?
18:20 @Ensign_H: rice, I have not understood your question - ask again with more detail and I can try to help - you want to plot bar close plus some value from a GV?
18:24 Rice: suppose I want to add the 30 bar ATR to the low of each bar and plot the result. I can do that by taking a 1 bar simple average and storing that in 1 gv, the atr in an adjacent one, summing them and using a marker to plot. Wondered if there's an easier approach.
18:24 @Ensign_H: rice, you could use Bar Value or Trade Value to read the bar value and write it to a GV
18:25 @Ensign_H: use the GV that is adjacent to the GV you want to add to the bar value
18:25 @Ensign_H: then use Global Value and Sum the two adjacent GVs and plot that panel
18:25 @Ensign_H: so one alert object could do this
18:26 Rice: and on the B panel?
18:26 @Ensign_H: let me show form, 1 moment

18:27 @Ensign_H: this alert assumes your ATR value is parked in [16]
18:27 @Ensign_H: we panel a reads bar value | close and pushes it to [15]
18:28 @Ensign_H: then panel B reads the sum of [15]+[16] and plots the result
18:30 @Ensign_H: is the example sufficient Rice for your question?
18:33 Rice: ok, I think this gets me over the hump. Thanks.
18:34 @Ensign_H: ok, it has been another great class, good questions, etc.
18:34 @Buffy2: yes it has
18:34 @Ensign_H: thanks for attending and enjoy your trading
18:34 @Buffy2: tied some things together I was missing
Slope
18:36 ce10: Howard, .. I have a question on slope of an ema
18:36 @Ensign_H: ok ask - the slope is returning value-previous value
18:36 ce10: that's what I thought ...
18:36 @Ensign_H: so it is the delta change between study calculations
18:37 @Ensign_H: if MA value is 20.4 and prior value was 20.3 then the slope is 0.1
18:38 ce10: I'm trying to detect a 'flat' ema and one that moves from flat to trending. Problem with using 'slope' in the alert, is that each underlying has a different scale, so a move of '2' in the YM is lows for a .02 move in ER2. Looking for some way to just use a common 'slope' amount. Trying to solve the scaling.
http://www.ensignsoftware.com/tips/tradingtips15.htm
18:43 SpinHalfEnM: Thanks again ce10
18:43 SpinHalfEnM: I'll read it now
18:43 @Ensign_H: spin, slope is change in Y divided by change in X, but in our slope reply the X delta is a 1 - so it is just change in Y from one point to the next.
18:44 SpinHalfEnM: ok, thanks Howard
GV should be consecutive
18:40 Rice: can you add or multiply GVs in non adjacent addresses? eg 10 and 15 in prior example
18:44 @Ensign_H: no rice, the GV math will between adjacent items, and Next refers to the right side companion to Value...so if value is [22] then Next will be [23]
18:45 @Ensign_H: do not have enough fields to specify two global variable references
18:45 @Ensign_H: so the companion reference has to be implied based on the Value reference
18:46 @Ensign_H: there is one command to read a GV from the number index and write the GV at the Global Variable index, but that is the only such command
18:46 @Ensign_H: and it is listed as Value = Value at number
IB Back data
18:44 Randy: I need to back fill about a weeks worth of continuous constant tick data (vacation) as an IB user was is the best way to do this?
18:47 @Ensign_H: randy, the 100,000 back fill is the best you can do and doubt it will be sufficient to regain a week's worth of fill
18:50 @Ensign_H: the emini is the only possibility if you have the playback files for the dates missed
18:51 @Ensign_H: you could do the playback which makes the DEMO file for that time frame
18:51 @Ensign_H: then use File | FIle Manger | Merge 2 Files feature to put Demo chart bars into the ES files
18:52 @Ensign_H: you can speed up playback by entering an end of day time stamp
18:52 Randy: or we could increase the 100K to say 1 M
18:52 @Ensign_H: so it computes chart for 2 days instantly instead of playing it back tick by tick
18:52 @Ensign_H: sorry, DTN Market Access will not permit me to request more than Today or 100K which ever is greater.
18:53 Randy: thx
18:53 @Ensign_H: or randy you can pay more money and subscribe to esignal and refresh 6 days back for ticks.
18:53 SpinHalfEnM: Is there an effective maximum number of bars a chart can have at once? I have mine set at 12,000 bars and am wondering if I could do more without causing problems
18:54 @Ensign_H: the physical maximum is 65535. However, 12000 is a lot and the more you have the longer it takes to load, save, and calculate.
18:55 SpinHalfEnM: does EW calculate all bars at every new bar formation?
18:55 @Ensign_H: no spin, just a calc for the new bar. All studies are in a state to make another calculation. .. many of them do tick by tick recalculation
18:56 SpinHalfEnM: ok - so a large total number of bars would just cause a delay in new studies, refresh times, and open - that sort of thing?
18:56 @Ensign_H: correct, and have not affect on chart once it is calculated and updating with new ticks
18:57 SpinHalfEnM: wow - that sounds great - the issue for me is backtesting, and I need as much data as possible for that -
18:57 @Ensign_H: the Pesavento map study needs lots of data for crunching too
19:02 SpinHalfEnM: is it a wild goose chase though, mechanical methods? (I'm sure this an old question -- sorry to bother you with it)
19:02 @Ensign_H: many pitfalls and challenges, spin. Seems like I wrote an article on the subject of holy grail chasers in a newsletter. Let me see if I can find it for you to read
www.ensignsoftware.com/tips/tradingtips42.htm#In
19:04 @Ensign_H: there, the 42 one is the one I was thinking of