Bubbling Up Parameters

Bubbling up parameters refers to the practice of passing data or values from one level of a function to another, when you have a hierarchy of function calls. The term "bubbling up" is used to describe the process of passing these parameters up through the call stack, so that data or values from a lower-level function are made available to higher-level functions. In this example we will show how this can be done for a conditional relationship between 3 moving averages.

First lets click the EasyScan menu button and select New Condition

Then click Add Condition(s) and select Write Formula

Next we will add a new function by clicking on the hamburger button and selecting Add New Function

For more about the items in this menu please see this article

We will name the function ShortAvg, create a parameter called #X and use it to define the period of the average using the formula AVGC#X, then click OK to bring that function in to our main formula editor.

For more on functions please see this article. For more on Parameters please see this article

We will then follow the same steps to add two more functions called #MidAvg and #LongAvg

Once all three functions have been created we will call them into our formula and set up the relationship we want, in this case the relationship will be that they are stacked with longest at the bottom and shortest at the top.

Currently the functions are using their default period values that we assigned (10,20,and 30) but we can see each of them have a parameter #X that can be changed, they "Bubble Up" to this formula.

Lets add three new parameters to the formula; #Sht, #Med, and #Lng with values of 20, 40 and 50 then pass them into those functions

Note that we have been adding descriptions to each of our parameters along the way. You will see why this is good practice in a later step. For more information on descriptions and comments please see this article

Lets click the show formula button to check that these new values are passing through

This type of moving average relationship is sometimes referred to as a moving average cloud, lets name this formula MACloud and save it so it can be re-used as a function by clicking on the hamburger button and selecting Save Formula.

Once that formula is saved close the editor window then open a new one by clicking the EasyScan menu button and selecting New condition

Then, like before, click Add Condition(s) and select Write Formula

Now lets bring in the MACloud formula that we saved as a function by clicking on the hamburger button and selecting Add Function from Library...

Begin typing MACloud into the search field and select it from the results

This will open that formula in the add function window, select OK to bring it into the main formula window

We now have that #MACloud function available to use in our new formula, as you can see the #Sht, #Med, and #Lng parameters are all available. Lets call it into our formula and add a criteria for 90 bar average volume to be greater than 500,000.

Now lets pass new period values into our #MACloud function, we will pass values of 100, 200, and 300

Notice as you are passing in those values that the code complete tooltip shows the default values for each of those parameters as well as the description for whatever parameter you are currently entering (in this case it is the #Lng parameter). This is why adding parameter descriptions is a good practice

Now lets click on the show formula button to see how those values are passing through

As you can see those "Bubbled Up" parameters allow us to pass values all the way down to the lowest level functions, this visual should help to cement this concept.