Build DYOs with Howard - Avg 2 studies - Compare current bar with last N Bars

14:29 lat: Hi Howard, I am trying to use dyo to make a simple indicator which is the avg of two studies, I cannot seem to figure out how to tell the DYO to do that on third line, any suggestions? thx

14:30 Ensign Howard: lat, show me your DYO properties and I can help you finish your DYO

14:31 Ensign Howard: on Line A change Write GV to a 1

14:32 Ensign Howard: on Line B change the Write GV to 2

14:33 Ensign Howard: New Line C would be Function | Ave[#] #=2 and Read GV would be 1 check the Show, Marker is the curve line, and pick a color

14:33 lat: ah, ok, will try that, thx

14:33 Ensign Howard: welcome

14:34 Ensign Howard: Do you understand what I just did for the DYO

14:34 Ensign Howard: We stored 2 values in adjacent GVs. Then used a function to average the GVs. Number field is the size of the set of 2 members and the Read GV is the place where the set begins

14:35 lat: it knows which 2 to avg?

14:35 Ensign Howard: we told it the first member of the set was GB [1] and the set size is 2, so it expects the members to be [`1] and [2]. If # = 3 then the members would be [1], [2], and [3] to average

14:36 lat: k,

14:38 lat: it worked, not sure if it is of much value, thanks a lot

14:38 Ensign Howard: welcome lat


14:36 cajun: Howard - is there a central location that describes/illustrates all the operators and their usage , such as the Function Ave[2] u just used ?

14:36 Ensign Howard: yes, and no, cajun..... I suggest you start with this web page

14:37 Ensign Howard: Then there is a page about Global Variables, then there is a great page of Examples. These links are found on the Help page for the Design Your Own section and there are a couple of in detail videos to watch and hear the step by step logic of what I am doing in the examples. These are on the Video page. collectively, you get a good idea of the style used in the DYO

14:40 Ensign Howard: type in the number, press enter

14:41 cajun: ok Howard , but for example if I wanted to find the method for determining the low of the last N bars and then comparing the close of current bar to the close of that low bar.. where best does one begin to find the operators? just search by keyword?

14:41 Ensign Howard: cajun, the Low of the last N bars is finding something about the chart.

14:42 Ensign Howard: So begin looking in the Chart Value category, and on the drop down list of selections you will see Min Low [#]. Enter the N value as the Number field for the size of the set of lows to find the minimum in.

14:43 cajun: ok - I guess I need a better understanding of the category tree and where to start the look

14:43 Ensign Howard: So the DYO selection would be Chart Value | Min Low[#] and this result can be saved in a GV using Write GV[6] for example.

14:44 Ensign Howard: cajun, the better understanding would come by watching the 50 minute video DYO: Categories and GVs

14:44 cajun: ah ok - will do that

14:44 Ensign Howard: 2nd line of your DYO would be getting a Bar Value or Close and store it in a different GV

14:45 Ensign Howard: 3rd line would be your test to compare the 2 GVs, and that would be GLOBAL FLAG and a selection like Value > Next where Value is the Read GV reference

14:46 Ensign Howard: and Next would be the adjacent GV index.... so if Read is from [6] then Next would reference GV[7]

14:46 Ensign Howard: let me show example

14:46 cajun: ok

14:49 Ensign Howard: In this example Line A finds the lowest low of last 5 bars, which includes current bar.

14:49 Ensign Howard: Line B finds current bar's close

14:49 Ensign Howard: Line C compares these 2 saved values for being equal and when the test is True a marker is put on the chart

14:50 Ensign Howard: The marker chosen was the zone background color for the bar being changed to sky blue. This condition happened once in the chart view, ie the bar closed on the low of the last 5 bars.

14:51 Ensign Howard: line C compares Value from GV[6] with a number and the number field has [7] which says to read the contents of GV[7] to get the number for the test. Without the [ ] an entry of 7 would have been the value 7

14:51 Ensign Howard: [7] changes this to be look up the contents of GV [7]

14:52 Ensign Howard: so contents of [6] (Value) is tested against contents of [7] and line A and B put some values in those 2 global variables so they could be tested by the selection on line C

14:52 cajun: ic, and if I wanted to compare to the close of the bar that contained the minimum low? ie higher than the close of the min bar. That's where I start going in circles with the terminology.

14:55 Ensign Howard: Then you would have had to have additional tests to see if this bar's low equaled the min low, and when that test is true then store this bar's close in a GV for later testing with other bar closes

14:55 Ensign Howard: If you have time I will show you this last example too

14:55 cajun: sure :)

14:55 Ensign Howard: ok 1 moment

14:59 Ensign Howard: ok let me walk you through the visual and the DYO

15:00 Ensign Howard: When the bar is setting the low of the last 5 bars, I will highlight in sky blue

15:00 Ensign Howard: This is lines A, B and C to accomplish this test and we store the test flag in GV [1] on line C for use by Line D

15:01 Ensign Howard: Line D will test this situation of this bar setting new low, and when the test is TRUE, the Global Action will return the contents of the Number field and when the test is False, it will return the contents of the Value field.

15:02 Ensign Howard: So the expression of IF( has 3 parameter, with the 1st parameter being the Test which is the flag in GV[1]. The 2nd parameter is what is returned on a True flag and the 3rd parameter is what is returned on a False flag

15:03 Ensign Howard: When the test is True, return the [$C] contents which is a look up for the bar's Close value

15:03 Ensign Howard: A table of these look up tags is found in the web page for DYO Property Form. [$C] gets the close price and stores this is GV[8]

15:04 Ensign Howard: When it is false it reads GV[8] and turns right around and rewrites the same value in GV[8]

15:04 Ensign Howard: So the net effect of this statement is to update GV[8] with a new close value when we set a new low

15:05 Ensign Howard: To see the effect of this value occasionally changing when the background is blue, I chose to plot a red line through the value being returned. So you see the red line is flat in a rising market, and then jumps to the close of the bar when it sets a low for the last 5 bars.

15:06 Ensign Howard: So far it looks good, we have the right close value to work with.

15:06 Ensign Howard: Now we are ready to test a bar's close against this remembered close.

15:06 Ensign Howard: Line E gets current bar close and saves in [9]

15:07 Ensign Howard: Line F tests if our current close is below the close of the low bar in [8] and when it is, pop on a red zone stripe and this case happened as shown on the chart

15:07 cajun: eureka lol

15:08 Ensign Howard: Now if you wanted to include the close of the bar that sets the low you could change the test to <=

15:11 cajun: Except I think we had a misunderstanding somewhere

15:12 Ensign Howard: ok. You can learn from the example and possibly adapt it to be what you seek

15:13 cajun: What I wanted was an indication of the close of current bar above the close of the bar with the min low.

15:13 Ensign Howard: ok change the Line F test to be >

15:13 cajun: I think just change the < to > Thanks a lot Howard this will help me a great deal :)

15:14 Ensign Howard: Now you have lots of red stripes

15:15 cajun: Yes but only interested in first occurrence - so I will work on that

15:16 Ensign Howard: ok, way to do that would be when test is True to reset the contents of [8] to a very high number so it does not repeat red stripe until new low resets [8] to new [$C]

15:16 Ensign Howard: 1 moment I will show that effect.

15:18 Ensign Howard: Line G has been added to reset [8] to a high number after the red zone stripe is shown and the final visual will be to remove the blue zone coloring by unchecking Line C Show box.

15:19 cajun: then once u get a new min low deal the whole thing resets

15:19 cajun: yeah that's getting there :) Neat Howard

15:20 Ensign Howard: You can see the Red line stair stepping lower with new lows around 11:30 and shows where the trigger level will be for the Red Stripe test

15:20 Ensign Howard: ok, this has been a fun process to build up the idea in small steps and check each step along the way with excess visual indicators. Then we trimmed back on the visual for the final effect.

15:20 cajun: yes .. now I need to save all this lol

15:21 Ensign Howard: ok, have a good day, bye. Go watch the video on Categories and Global Variables.

15:21 cajun: will do !